Skip to content

Commit

Permalink
(GH-3839) Update documentation, reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Jun 18, 2020
1 parent f6804d1 commit 633b3e0
Show file tree
Hide file tree
Showing 8 changed files with 464 additions and 275 deletions.
Expand Up @@ -162,7 +162,7 @@
<!-- Items -->
<Controls:HamburgerMenu.ItemsSource>
<Controls:HamburgerMenuItemCollection>
<Controls:HamburgerMenuHeaderItem Label="Pictures" AutomationProperties.Name="The Pictures Header" />
<Controls:HamburgerMenuHeaderItem AutomationProperties.Name="The Pictures Header" Label="Pictures" />
<Controls:HamburgerMenuGlyphItem Glyph="/Assets/Photos/BigFourSummerHeat.png" Label="Big four summer heat" />
<Controls:HamburgerMenuGlyphItem Glyph="/Assets/Photos/BisonBadlandsChillin.png" Label="Bison badlands Chillin" />
<Controls:HamburgerMenuSeparatorItem />
Expand Down
Expand Up @@ -3,7 +3,7 @@
namespace MahApps.Metro.Controls
{
/// <summary>
/// EventArgs used for the <see cref="HamburgerMenu"/> ItemClick and OptionsItemClick event.
/// EventArgs used for the <see cref="HamburgerMenu.ItemClick"/> and <see cref="HamburgerMenu.OptionsItemClick"/> events.
/// </summary>
public class ItemClickEventArgs : RoutedEventArgs
{
Expand All @@ -25,18 +25,18 @@ public ItemClickEventArgs(RoutedEvent routedEvent, object source)
}

/// <summary>
/// Gets the clicked item
/// Gets the clicked item (options item).
/// </summary>
public object ClickedItem { get; internal set; }
}

/// <summary>
/// RoutedEventHandler used for the <see cref="HamburgerMenu"/> ItemClick and OptionsItemClick event.
/// RoutedEventHandler used for the <see cref="HamburgerMenu.ItemClick"/> and <see cref="HamburgerMenu.OptionsItemClick"/> events.
/// </summary>
public delegate void ItemClickRoutedEventHandler(object sender, ItemClickEventArgs args);

/// <summary>
/// EventArgs used for the <see cref="HamburgerMenu"/> ItemInvoked event.
/// EventArgs used for the <see cref="HamburgerMenu.ItemInvoked"/> event.
/// </summary>
public class HamburgerMenuItemInvokedEventArgs : RoutedEventArgs
{
Expand All @@ -58,7 +58,7 @@ public HamburgerMenuItemInvokedEventArgs(RoutedEvent routedEvent, object source)
}

/// <summary>
/// Gets the invoked item
/// Gets the invoked item.
/// </summary>
public object InvokedItem { get; internal set; }

Expand All @@ -69,7 +69,7 @@ public HamburgerMenuItemInvokedEventArgs(RoutedEvent routedEvent, object source)
}

/// <summary>
/// RoutedEventHandler used for the <see cref="HamburgerMenu"/> ItemInvoked event.
/// RoutedEventHandler used for the <see cref="HamburgerMenu.ItemInvoked"/> event.
/// </summary>
public delegate void HamburgerMenuItemInvokedRoutedEventHandler(object sender, HamburgerMenuItemInvokedEventArgs args);
}
30 changes: 22 additions & 8 deletions src/MahApps.Metro/Controls/HamburgerMenu/HamburgerMenu.Events.cs
Expand Up @@ -6,7 +6,11 @@ namespace MahApps.Metro.Controls
public partial class HamburgerMenu
{
/// <summary>Identifies the <see cref="ItemClick"/> routed event.</summary>
public static readonly RoutedEvent ItemClickEvent = EventManager.RegisterRoutedEvent("ItemClick", RoutingStrategy.Direct, typeof(ItemClickRoutedEventHandler), typeof(HamburgerMenu));
public static readonly RoutedEvent ItemClickEvent
= EventManager.RegisterRoutedEvent(nameof(ItemClick),
RoutingStrategy.Direct,
typeof(ItemClickRoutedEventHandler),
typeof(HamburgerMenu));

/// <summary>
/// Event raised when an item is clicked
Expand All @@ -18,7 +22,11 @@ public partial class HamburgerMenu
}

/// <summary>Identifies the <see cref="OptionsItemClick"/> routed event.</summary>
public static readonly RoutedEvent OptionsItemClickEvent = EventManager.RegisterRoutedEvent("OptionsItemClick", RoutingStrategy.Direct, typeof(ItemClickRoutedEventHandler), typeof(HamburgerMenu));
public static readonly RoutedEvent OptionsItemClickEvent
= EventManager.RegisterRoutedEvent(nameof(OptionsItemClick),
RoutingStrategy.Direct,
typeof(ItemClickRoutedEventHandler),
typeof(HamburgerMenu));

/// <summary>
/// Event raised when an options' item is clicked
Expand All @@ -30,7 +38,11 @@ public partial class HamburgerMenu
}

/// <summary>Identifies the <see cref="ItemInvoked"/> routed event.</summary>
public static readonly RoutedEvent ItemInvokedEvent = EventManager.RegisterRoutedEvent("ItemInvoked", RoutingStrategy.Direct, typeof(HamburgerMenuItemInvokedRoutedEventHandler), typeof(HamburgerMenu));
public static readonly RoutedEvent ItemInvokedEvent
= EventManager.RegisterRoutedEvent(nameof(ItemInvoked),
RoutingStrategy.Direct,
typeof(HamburgerMenuItemInvokedRoutedEventHandler),
typeof(HamburgerMenu));

/// <summary>
/// Event raised when an item is invoked
Expand All @@ -42,7 +54,11 @@ public partial class HamburgerMenu
}

/// <summary>Identifies the <see cref="HamburgerButtonClick"/> routed event.</summary>
public static readonly RoutedEvent HamburgerButtonClickEvent = EventManager.RegisterRoutedEvent("HamburgerButtonClick", RoutingStrategy.Direct, typeof(RoutedEventHandler), typeof(HamburgerMenu));
public static readonly RoutedEvent HamburgerButtonClickEvent
= EventManager.RegisterRoutedEvent(nameof(HamburgerButtonClick),
RoutingStrategy.Direct,
typeof(RoutedEventHandler),
typeof(HamburgerMenu));

/// <summary>
/// Event raised when the hamburger button is clicked
Expand Down Expand Up @@ -185,8 +201,7 @@ private bool RaiseOptionsItemEvents(object selectedItem)

private void ButtonsListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var listBox = sender as ListBox;
if (listBox == null)
if (!(sender is ListBox listBox))
{
return;
}
Expand Down Expand Up @@ -216,8 +231,7 @@ private void ButtonsListView_SelectionChanged(object sender, SelectionChangedEve

private void OptionsListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var listBox = sender as ListBox;
if (listBox == null)
if (!(sender is ListBox listBox))
{
return;
}
Expand Down
Expand Up @@ -8,55 +8,119 @@ namespace MahApps.Metro.Controls
public partial class HamburgerMenu
{
/// <summary>Identifies the <see cref="HamburgerWidth"/> dependency property.</summary>
public static readonly DependencyProperty HamburgerWidthProperty = DependencyProperty.Register(nameof(HamburgerWidth), typeof(double), typeof(HamburgerMenu), new PropertyMetadata(48.0));
public static readonly DependencyProperty HamburgerWidthProperty
= DependencyProperty.Register(nameof(HamburgerWidth),
typeof(double),
typeof(HamburgerMenu),
new PropertyMetadata(48.0));

/// <summary>
/// Gets or sets HamburgerMenu button's <see cref="FrameworkElement.Width"/>.
/// </summary>
public double HamburgerWidth
{
get => (double)this.GetValue(HamburgerWidthProperty);
set => this.SetValue(HamburgerWidthProperty, value);
}

/// <summary>Identifies the <see cref="HamburgerHeight"/> dependency property.</summary>
public static readonly DependencyProperty HamburgerHeightProperty = DependencyProperty.Register(nameof(HamburgerHeight), typeof(double), typeof(HamburgerMenu), new PropertyMetadata(48.0));
public static readonly DependencyProperty HamburgerHeightProperty
= DependencyProperty.Register(nameof(HamburgerHeight),
typeof(double),
typeof(HamburgerMenu),
new PropertyMetadata(48.0));

/// <summary>
/// Gets or sets the <see cref="FrameworkElement.Height"/> for the HamburgerMenu button.
/// </summary>
public double HamburgerHeight
{
get => (double)this.GetValue(HamburgerHeightProperty);
set => this.SetValue(HamburgerHeightProperty, value);
}

/// <summary>Identifies the <see cref="HamburgerMargin"/> dependency property.</summary>
public static readonly DependencyProperty HamburgerMarginProperty = DependencyProperty.Register(nameof(HamburgerMargin), typeof(Thickness), typeof(HamburgerMenu), new PropertyMetadata(null));
public static readonly DependencyProperty HamburgerMarginProperty
= DependencyProperty.Register(nameof(HamburgerMargin),
typeof(Thickness),
typeof(HamburgerMenu),
new PropertyMetadata(new Thickness()));

/// <summary>
/// Gets or sets the margin for the HamburgerMenu button.
/// </summary>
public Thickness HamburgerMargin
{
get => (Thickness)this.GetValue(HamburgerMarginProperty);
set => this.SetValue(HamburgerMarginProperty, value);
}

/// <summary>Identifies the <see cref="HamburgerVisibility"/> dependency property.</summary>
public static readonly DependencyProperty HamburgerVisibilityProperty = DependencyProperty.Register(nameof(HamburgerVisibility), typeof(Visibility), typeof(HamburgerMenu), new PropertyMetadata(Visibility.Visible));
public static readonly DependencyProperty HamburgerVisibilityProperty
= DependencyProperty.Register(nameof(HamburgerVisibility),
typeof(Visibility),
typeof(HamburgerMenu),
new PropertyMetadata(Visibility.Visible));

/// <summary>Identifies the <see cref="HamburgerButtonStyle"/> dependency property.</summary>
public static readonly DependencyProperty HamburgerButtonStyleProperty = DependencyProperty.Register(nameof(HamburgerButtonStyle), typeof(Style), typeof(HamburgerMenu), new PropertyMetadata(null));
/// <summary>
/// Gets or sets the <see cref="UIElement.Visibility"/> for the HamburgerMenu button.
/// </summary>
public Visibility HamburgerVisibility
{
get => (Visibility)this.GetValue(HamburgerVisibilityProperty);
set => this.SetValue(HamburgerVisibilityProperty, value);
}

/// <summary>Identifies the <see cref="HamburgerButtonTemplate"/> dependency property.</summary>
public static readonly DependencyProperty HamburgerButtonTemplateProperty = DependencyProperty.Register(nameof(HamburgerButtonTemplate), typeof(DataTemplate), typeof(HamburgerMenu), new PropertyMetadata(null));
/// <summary>Identifies the <see cref="HamburgerButtonStyle"/> dependency property.</summary>
public static readonly DependencyProperty HamburgerButtonStyleProperty
= DependencyProperty.Register(nameof(HamburgerButtonStyle),
typeof(Style),
typeof(HamburgerMenu),
new PropertyMetadata(null));

/// <summary>
/// Gets or sets the Style used for the hamburger button.
/// Gets or sets the <see cref="FrameworkElement.Style"/> for the HamburgerMenu button.
/// </summary>
public Style HamburgerButtonStyle
{
get => (Style)this.GetValue(HamburgerButtonStyleProperty);
set => this.SetValue(HamburgerButtonStyleProperty, value);
}

/// <summary>Identifies the <see cref="HamburgerButtonTemplate"/> dependency property.</summary>
public static readonly DependencyProperty HamburgerButtonTemplateProperty
= DependencyProperty.Register(nameof(HamburgerButtonTemplate),
typeof(DataTemplate),
typeof(HamburgerMenu),
new PropertyMetadata(null));

/// <summary>
/// Gets or sets a template for the hamburger button.
/// Gets or sets the <see cref="ContentControl.ContentTemplate"/> for the HamburgerMenu button.
/// </summary>
public DataTemplate HamburgerButtonTemplate
{
get => (DataTemplate)this.GetValue(HamburgerButtonTemplateProperty);
set => this.SetValue(HamburgerButtonTemplateProperty, value);
}

/// <summary>Identifies the <see cref="HamburgerButtonName"/> dependency property.</summary>
public static readonly DependencyProperty HamburgerButtonNameProperty
= DependencyProperty.Register(nameof(HamburgerButtonName),
typeof(string),
typeof(HamburgerMenu),
new UIPropertyMetadata(string.Empty),
new ValidateValueCallback(IsNotNull));

/// Gets or sets the <see cref="AutomationProperties.NameProperty"/> for the HamburgerMenu button.
/// <summary>
/// Gets or sets the<see cref= "AutomationProperties.NameProperty" /> for the HamburgerMenu button.
/// </summary>
public string HamburgerButtonName
{
get => (string)this.GetValue(HamburgerButtonNameProperty);
set => this.SetValue(HamburgerButtonNameProperty, value);
}

/// <summary>Identifies the <see cref="HamburgerButtonHelpText"/> dependency property.</summary>
public static readonly DependencyProperty HamburgerButtonHelpTextProperty
= DependencyProperty.Register(nameof(HamburgerButtonHelpText),
typeof(string),
Expand All @@ -74,53 +138,21 @@ public string HamburgerButtonHelpText
}

/// <summary>Identifies the <see cref="HamburgerMenuHeaderTemplate"/> dependency property.</summary>
public static readonly DependencyProperty HamburgerMenuHeaderTemplateProperty = DependencyProperty.Register(nameof(HamburgerMenuHeaderTemplate), typeof(DataTemplate), typeof(HamburgerMenu), new PropertyMetadata(null));
public static readonly DependencyProperty HamburgerMenuHeaderTemplateProperty
= DependencyProperty.Register(nameof(HamburgerMenuHeaderTemplate),
typeof(DataTemplate),
typeof(HamburgerMenu),
new PropertyMetadata(null));

/// <summary>
/// Gets or sets a template for the hamburger pane header.
/// Gets or sets the <see cref="ContentControl.ContentTemplate"/> for the HamburgerMenu pane header.
/// </summary>
public DataTemplate HamburgerMenuHeaderTemplate
{
get => (DataTemplate)this.GetValue(HamburgerMenuHeaderTemplateProperty);
set => this.SetValue(HamburgerMenuHeaderTemplateProperty, value);
}

/// <summary>
/// Gets or sets main button's width.
/// </summary>
public double HamburgerWidth
{
get => (double)this.GetValue(HamburgerWidthProperty);
set => this.SetValue(HamburgerWidthProperty, value);
}

/// <summary>
/// Gets or sets main button's height.
/// </summary>
public double HamburgerHeight
{
get => (double)this.GetValue(HamburgerHeightProperty);
set => this.SetValue(HamburgerHeightProperty, value);
}

/// <summary>
/// Gets or sets main button's margin.
/// </summary>
public Thickness HamburgerMargin
{
get => (Thickness)this.GetValue(HamburgerMarginProperty);
set => this.SetValue(HamburgerMarginProperty, value);
}

/// <summary>
/// Gets or sets main button's visibility.
/// </summary>
public Visibility HamburgerVisibility
{
get => (Visibility)this.GetValue(HamburgerVisibilityProperty);
set => this.SetValue(HamburgerVisibilityProperty, value);
}

private static bool IsNotNull(object value)
{
return value != null;
Expand Down

0 comments on commit 633b3e0

Please sign in to comment.