From 0ffc31d85635d437e30fbdc8d3f0436e5ebb5155 Mon Sep 17 00:00:00 2001 From: Jan Karger Date: Thu, 7 Jul 2016 13:30:12 +0200 Subject: [PATCH 01/13] format suggestions --- MahApps.Metro/Controls/SplitButton.cs | 184 +++++++++++++------------- 1 file changed, 92 insertions(+), 92 deletions(-) diff --git a/MahApps.Metro/Controls/SplitButton.cs b/MahApps.Metro/Controls/SplitButton.cs index 9f81d42747..0162b549b3 100644 --- a/MahApps.Metro/Controls/SplitButton.cs +++ b/MahApps.Metro/Controls/SplitButton.cs @@ -11,50 +11,53 @@ namespace MahApps.Metro.Controls { [ContentProperty("ItemsSource")] [DefaultEvent("SelectionChanged"), - TemplatePart(Name = "PART_Container", Type = typeof(Grid)), - TemplatePart(Name = "PART_Button", Type = typeof(Button)), - TemplatePart(Name = "PART_ButtonContent", Type = typeof(ContentControl)), - TemplatePart(Name = "PART_Popup", Type = typeof(Popup)), - TemplatePart(Name = "PART_Expander", Type = typeof(Button)), - TemplatePart(Name = "PART_ListBox", Type = typeof(ListBox))] + TemplatePart(Name = "PART_Container", Type = typeof(Grid)), + TemplatePart(Name = "PART_Button", Type = typeof(Button)), + TemplatePart(Name = "PART_ButtonContent", Type = typeof(ContentControl)), + TemplatePart(Name = "PART_Popup", Type = typeof(Popup)), + TemplatePart(Name = "PART_Expander", Type = typeof(Button)), + TemplatePart(Name = "PART_ListBox", Type = typeof(ListBox))] public class SplitButton : ItemsControl { - - public static readonly RoutedEvent ClickEvent = - EventManager.RegisterRoutedEvent("Click", RoutingStrategy.Bubble, - typeof(RoutedEventHandler), typeof(SplitButton)); - - public static readonly RoutedEvent SelectionChangedEvent = - EventManager.RegisterRoutedEvent("SelectionChanged", RoutingStrategy.Bubble, - typeof(SelectionChangedEventHandler), typeof(SplitButton)); + public static readonly RoutedEvent ClickEvent + = EventManager.RegisterRoutedEvent("Click", + RoutingStrategy.Bubble, + typeof(RoutedEventHandler), + typeof(SplitButton)); + + public static readonly RoutedEvent SelectionChangedEvent + = EventManager.RegisterRoutedEvent("SelectionChanged", + RoutingStrategy.Bubble, + typeof(SelectionChangedEventHandler), + typeof(SplitButton)); public event SelectionChangedEventHandler SelectionChanged { - add { AddHandler(SelectionChangedEvent, value); } - remove { RemoveHandler(SelectionChangedEvent, value); } + add { this.AddHandler(SelectionChangedEvent, value); } + remove { this.RemoveHandler(SelectionChangedEvent, value); } } public event RoutedEventHandler Click { - add { AddHandler(ClickEvent, value); } - remove { RemoveHandler(ClickEvent, value); } + add { this.AddHandler(ClickEvent, value); } + remove { this.RemoveHandler(ClickEvent, value); } } public static readonly DependencyProperty IsExpandedProperty = DependencyProperty.Register("IsExpanded", typeof(bool), typeof(SplitButton)); - public static readonly DependencyProperty SelectedIndexProperty = DependencyProperty.Register("SelectedIndex", typeof(Int32), typeof(SplitButton), new FrameworkPropertyMetadata(-1, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); - public static readonly DependencyProperty SelectedItemProperty = DependencyProperty.Register("SelectedItem", typeof(Object), typeof(SplitButton), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); + public static readonly DependencyProperty SelectedIndexProperty = DependencyProperty.Register("SelectedIndex", typeof(int), typeof(SplitButton), new FrameworkPropertyMetadata(-1, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); + public static readonly DependencyProperty SelectedItemProperty = DependencyProperty.Register("SelectedItem", typeof(object), typeof(SplitButton), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); - public static readonly DependencyProperty ExtraTagProperty = DependencyProperty.Register("ExtraTag", typeof(Object), typeof(SplitButton)); + public static readonly DependencyProperty ExtraTagProperty = DependencyProperty.Register("ExtraTag", typeof(object), typeof(SplitButton)); public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register("Orientation", typeof(Orientation), typeof(SplitButton), new FrameworkPropertyMetadata(Orientation.Horizontal, FrameworkPropertyMetadataOptions.AffectsMeasure)); - public static readonly DependencyProperty IconProperty = DependencyProperty.Register("Icon", typeof(Object), typeof(SplitButton)); + public static readonly DependencyProperty IconProperty = DependencyProperty.Register("Icon", typeof(object), typeof(SplitButton)); public static readonly DependencyProperty IconTemplateProperty = DependencyProperty.Register("IconTemplate", typeof(DataTemplate), typeof(SplitButton)); public static readonly DependencyProperty CommandProperty = DependencyProperty.Register("Command", typeof(ICommand), typeof(SplitButton)); public static readonly DependencyProperty CommandTargetProperty = DependencyProperty.Register("CommandTarget", typeof(IInputElement), typeof(SplitButton)); - public static readonly DependencyProperty CommandParameterProperty = DependencyProperty.Register("CommandParameter", typeof(Object), typeof(SplitButton)); + public static readonly DependencyProperty CommandParameterProperty = DependencyProperty.Register("CommandParameter", typeof(object), typeof(SplitButton)); public static readonly DependencyProperty ButtonStyleProperty = DependencyProperty.Register("ButtonStyle", typeof(Style), typeof(SplitButton), new FrameworkPropertyMetadata(default(Style), FrameworkPropertyMetadataOptions.Inherits | FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure)); public static readonly DependencyProperty ButtonArrowStyleProperty = DependencyProperty.Register("ButtonArrowStyle", typeof(Style), typeof(SplitButton), new FrameworkPropertyMetadata(default(Style), FrameworkPropertyMetadataOptions.Inherits | FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure)); @@ -64,10 +67,10 @@ public event RoutedEventHandler Click /// /// Reflects the parameter to pass to the CommandProperty upon execution. /// - public Object CommandParameter + public object CommandParameter { - get { return (Object)GetValue(CommandParameterProperty); } - set { SetValue(CommandParameterProperty, value); } + get { return (object)this.GetValue(CommandParameterProperty); } + set { this.SetValue(CommandParameterProperty, value); } } /// @@ -75,8 +78,8 @@ public Object CommandParameter /// public IInputElement CommandTarget { - get { return (IInputElement)GetValue(CommandTargetProperty); } - set { SetValue(CommandTargetProperty, value); } + get { return (IInputElement)this.GetValue(CommandTargetProperty); } + set { this.SetValue(CommandTargetProperty, value); } } /// @@ -84,44 +87,44 @@ public IInputElement CommandTarget /// public ICommand Command { - get { return (ICommand)GetValue(CommandProperty); } - set { SetValue(CommandProperty, value); } + get { return (ICommand)this.GetValue(CommandProperty); } + set { this.SetValue(CommandProperty, value); } } /// /// The index of the first item in the current selection or -1 if the selection is empty. /// - public Int32 SelectedIndex + public int SelectedIndex { - get { return (Int32)GetValue(SelectedIndexProperty); } - set { SetValue(SelectedIndexProperty, value); } + get { return (int)this.GetValue(SelectedIndexProperty); } + set { this.SetValue(SelectedIndexProperty, value); } } /// /// The first item in the current selection, or null if the selection is empty. /// - public Object SelectedItem + public object SelectedItem { - get { return GetValue(SelectedItemProperty); } - set { SetValue(SelectedItemProperty, value); } + get { return this.GetValue(SelectedItemProperty); } + set { this.SetValue(SelectedItemProperty, value); } } /// /// Indicates whether the Popup is visible. /// - public Boolean IsExpanded + public bool IsExpanded { - get { return (bool)GetValue(IsExpandedProperty); } - set { SetValue(IsExpandedProperty, value); } + get { return (bool)this.GetValue(IsExpandedProperty); } + set { this.SetValue(IsExpandedProperty, value); } } /// /// Gets or sets an extra tag. /// - public Object ExtraTag + public object ExtraTag { - get { return GetValue(ExtraTagProperty); } - set { SetValue(ExtraTagProperty, value); } + get { return this.GetValue(ExtraTagProperty); } + set { this.SetValue(ExtraTagProperty, value); } } /// @@ -129,18 +132,18 @@ public Object ExtraTag /// public Orientation Orientation { - get { return (Orientation)GetValue(OrientationProperty); } - set { SetValue(OrientationProperty, value); } + get { return (Orientation)this.GetValue(OrientationProperty); } + set { this.SetValue(OrientationProperty, value); } } /// /// Gets or sets the Content used to generate the icon part. /// [Bindable(true)] - public Object Icon + public object Icon { - get { return GetValue(IconProperty); } - set { SetValue(IconProperty, value); } + get { return this.GetValue(IconProperty); } + set { this.SetValue(IconProperty, value); } } /// @@ -149,8 +152,8 @@ public Object Icon [Bindable(true)] public DataTemplate IconTemplate { - get { return (DataTemplate)GetValue(IconTemplateProperty); } - set { SetValue(IconTemplateProperty, value); } + get { return (DataTemplate)this.GetValue(IconTemplateProperty); } + set { this.SetValue(IconTemplateProperty, value); } } /// @@ -158,8 +161,8 @@ public DataTemplate IconTemplate /// public Style ButtonStyle { - get { return (Style)GetValue(ButtonStyleProperty); } - set { SetValue(ButtonStyleProperty, value); } + get { return (Style)this.GetValue(ButtonStyleProperty); } + set { this.SetValue(ButtonStyleProperty, value); } } /// @@ -167,8 +170,8 @@ public Style ButtonStyle /// public Style ButtonArrowStyle { - get { return (Style)GetValue(ButtonArrowStyleProperty); } - set { SetValue(ButtonArrowStyleProperty, value); } + get { return (Style)this.GetValue(ButtonArrowStyleProperty); } + set { this.SetValue(ButtonArrowStyleProperty, value); } } /// @@ -176,8 +179,8 @@ public Style ButtonArrowStyle /// public Style ListBoxStyle { - get { return (Style)GetValue(ListBoxStyleProperty); } - set { SetValue(ListBoxStyleProperty, value); } + get { return (Style)this.GetValue(ListBoxStyleProperty); } + set { this.SetValue(ListBoxStyleProperty, value); } } /// @@ -185,8 +188,8 @@ public Style ListBoxStyle /// public Brush ArrowBrush { - get { return (Brush)GetValue(ArrowBrushProperty); } - set { SetValue(ArrowBrushProperty, value); } + get { return (Brush)this.GetValue(ArrowBrushProperty); } + set { this.SetValue(ArrowBrushProperty, value); } } private Button _clickButton; @@ -202,58 +205,58 @@ static SplitButton() private void ButtonClick(object sender, RoutedEventArgs e) { e.RoutedEvent = ClickEvent; - RaiseEvent(e); + this.RaiseEvent(e); } private void ListBoxSelectionChanged(object sender, SelectionChangedEventArgs e) { e.RoutedEvent = SelectionChangedEvent; - RaiseEvent(e); + this.RaiseEvent(e); - IsExpanded = false; + this.IsExpanded = false; } private void ExpanderClick(object sender, RoutedEventArgs e) { - IsExpanded = !IsExpanded; + this.IsExpanded = !this.IsExpanded; } public override void OnApplyTemplate() { base.OnApplyTemplate(); - _clickButton = EnforceInstance - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + +