-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ee58e2
commit a65f375
Showing
29 changed files
with
499 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<UserControl x:Class="Daybreak.Controls.DropDownButton" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:Daybreak.Controls" | ||
xmlns:buttons="clr-namespace:Daybreak.Controls.Buttons" | ||
xmlns:glyphs="clr-namespace:Daybreak.Controls.Glyphs" | ||
xmlns:converters="clr-namespace:Daybreak.Converters" | ||
mc:Ignorable="d" | ||
x:Name="_this" | ||
Tag="{Binding RelativeSource={RelativeSource Self}}" | ||
MouseRightButtonDown="IgnoreRightMouseButton" | ||
MouseRightButtonUp="IgnoreRightMouseButton" | ||
d:DesignHeight="450" d:DesignWidth="800"> | ||
<UserControl.Resources> | ||
<converters:BooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter" TriggerValue="True"/> | ||
</UserControl.Resources> | ||
<UserControl.ContextMenu> | ||
<ContextMenu Placement="Bottom"> | ||
<ContextMenu.Template> | ||
<ControlTemplate> | ||
<local:DropDownButtonContextMenu | ||
Items="{Binding PlacementTarget.Tag.Items, RelativeSource={RelativeSource AncestorType=ContextMenu}}" | ||
ItemTemplate="{Binding PlacementTarget.Tag.ItemTemplate, RelativeSource={RelativeSource AncestorType=ContextMenu}}" | ||
Background="{Binding PlacementTarget.Tag.Background, RelativeSource={RelativeSource AncestorType=ContextMenu}}" | ||
Width="{Binding PlacementTarget.Tag.ActualWidth, RelativeSource={RelativeSource AncestorType=ContextMenu}}" | ||
ItemClicked="DropDownButtonContextMenu_ItemClicked"/> | ||
</ControlTemplate> | ||
</ContextMenu.Template> | ||
</ContextMenu> | ||
</UserControl.ContextMenu> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*"/> | ||
<ColumnDefinition Width="auto"/> | ||
</Grid.ColumnDefinitions> | ||
<buttons:HighlightButton Grid.Column="0" | ||
Foreground="{DynamicResource MahApps.Brushes.ThemeForeground}" | ||
HighlightColor="{DynamicResource MahApps.Brushes.Accent}" | ||
VerticalAlignment="Stretch" | ||
HorizontalAlignment="Stretch" | ||
VerticalContentAlignment="Center" | ||
HorizontalContentAlignment="Center" | ||
Clicked="MainButton_Clicked"> | ||
<buttons:HighlightButton.ButtonContent> | ||
<ContentControl ContentTemplate="{Binding ItemTemplate, RelativeSource={RelativeSource AncestorType={x:Type local:DropDownButton}}}" | ||
Content="{Binding SelectedItem, RelativeSource={RelativeSource AncestorType={x:Type local:DropDownButton}}}" /> | ||
</buttons:HighlightButton.ButtonContent> | ||
</buttons:HighlightButton> | ||
<buttons:HighlightButton Grid.Column="1" | ||
Foreground="{DynamicResource MahApps.Brushes.ThemeForeground}" | ||
HighlightColor="{DynamicResource MahApps.Brushes.Accent}" | ||
VerticalAlignment="Stretch" | ||
HorizontalAlignment="Stretch" | ||
Clicked="ArrowButton_Clicked"> | ||
<buttons:HighlightButton.ButtonContent> | ||
<glyphs:ArrowGlyph Foreground="{DynamicResource MahApps.Brushes.ThemeForeground}" | ||
Height="30" | ||
Width="30" | ||
VerticalAlignment="Center" | ||
HorizontalAlignment="Center" | ||
RenderTransformOrigin="0.5 0.5"> | ||
<glyphs:ArrowGlyph.RenderTransform> | ||
<RotateTransform Angle="270"/> | ||
</glyphs:ArrowGlyph.RenderTransform> | ||
</glyphs:ArrowGlyph> | ||
</buttons:HighlightButton.ButtonContent> | ||
</buttons:HighlightButton> | ||
<Rectangle Opacity="0.2" | ||
Fill="Black" | ||
VerticalAlignment="Stretch" | ||
HorizontalAlignment="Stretch" | ||
Visibility="{Binding ElementName=_this, Path=ClickEnabled, Mode=OneWay, Converter={StaticResource InverseBooleanToVisibilityConverter}}"/> | ||
</Grid> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Extensions; | ||
using System.Windows.Input; | ||
|
||
namespace Daybreak.Controls; | ||
/// <summary> | ||
/// Interaction logic for DropdownButton.xaml | ||
/// </summary> | ||
public partial class DropDownButton : UserControl | ||
{ | ||
[GenerateDependencyProperty] | ||
private DataTemplate itemTemplate = default!; | ||
|
||
[GenerateDependencyProperty] | ||
private object selectedItem = default!; | ||
|
||
[GenerateDependencyProperty] | ||
private IEnumerable items = default!; | ||
|
||
[GenerateDependencyProperty(InitialValue = true)] | ||
private bool clickEnabled = true; | ||
|
||
public event EventHandler<object> Clicked = default!; | ||
public event EventHandler<object> SelectionChanged = default!; | ||
|
||
public DropDownButton() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
private void MainButton_Clicked(object sender, EventArgs e) | ||
{ | ||
this.Clicked?.Invoke(this, this.SelectedItem); | ||
} | ||
|
||
private void ArrowButton_Clicked(object sender, EventArgs e) | ||
{ | ||
var contextMenu = this.ContextMenu; | ||
contextMenu.PlacementTarget = this; | ||
contextMenu.IsOpen = true; | ||
} | ||
|
||
private void DropDownButtonContextMenu_ItemClicked(object _, object e) | ||
{ | ||
this.SelectedItem = e; | ||
this.ContextMenu.IsOpen = false; | ||
this.SelectionChanged?.Invoke(this, e); | ||
} | ||
|
||
private void IgnoreRightMouseButton(object sender, MouseButtonEventArgs e) | ||
{ | ||
if (e.ChangedButton is MouseButton.Right) | ||
{ | ||
e.Handled = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<UserControl x:Class="Daybreak.Controls.DropDownButtonContextMenu" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:Daybreak.Controls" | ||
xmlns:buttons="clr-namespace:Daybreak.Controls.Buttons" | ||
mc:Ignorable="d" | ||
x:Name="_this" | ||
d:DesignHeight="450" d:DesignWidth="800"> | ||
<Grid> | ||
<ItemsControl ItemsSource="{Binding ElementName=_this, Path=Items, Mode=OneWay}"> | ||
<ItemsControl.ItemTemplate> | ||
<DataTemplate> | ||
<buttons:HighlightButton HighlightColor="{DynamicResource MahApps.Brushes.Accent}" | ||
VerticalAlignment="Stretch" | ||
HorizontalAlignment="Stretch" | ||
Tag="{Binding Mode=OneWay}" | ||
Clicked="HighlightButton_Clicked"> | ||
<buttons:HighlightButton.ButtonContent> | ||
<ContentControl DataContext="{Binding DataContext, RelativeSource={RelativeSource AncestorType={x:Type buttons:HighlightButton}}}" | ||
ContentTemplate="{Binding ItemTemplate, RelativeSource={RelativeSource AncestorType={x:Type local:DropDownButtonContextMenu}}}"/> | ||
</buttons:HighlightButton.ButtonContent> | ||
</buttons:HighlightButton> | ||
</DataTemplate> | ||
</ItemsControl.ItemTemplate> | ||
</ItemsControl> | ||
</Grid> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Daybreak.Controls.Buttons; | ||
using System; | ||
using System.Collections; | ||
using System.Extensions; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Extensions; | ||
|
||
namespace Daybreak.Controls; | ||
/// <summary> | ||
/// Interaction logic for DropDownButtonContextMenu.xaml | ||
/// </summary> | ||
public partial class DropDownButtonContextMenu : UserControl | ||
{ | ||
[GenerateDependencyProperty] | ||
private DataTemplate itemTemplate = default!; | ||
|
||
[GenerateDependencyProperty] | ||
private IEnumerable items = default!; | ||
|
||
public event EventHandler<object> ItemClicked = default!; | ||
|
||
public DropDownButtonContextMenu() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
private void HighlightButton_Clicked(object sender, EventArgs e) | ||
{ | ||
this.ItemClicked?.Invoke(this, sender.Cast<HighlightButton>().DataContext); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<UserControl x:Class="Daybreak.Controls.Glyphs.ArrowGlyph" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:Daybreak.Controls.Glyphs" | ||
mc:Ignorable="d" | ||
d:DesignHeight="450" d:DesignWidth="800"> | ||
<Viewbox> | ||
<Grid Width="30" Height="30" Margin="-2, 0, 0 ,0"> | ||
<Path Fill="{DynamicResource MahApps.Brushes.ThemeForeground}" VerticalAlignment="Top" HorizontalAlignment="Left" | ||
Data="m18.87,9.41l-5.58,5.59l5.58,5.59a1,1 0 0 1 0,1.41l0,0a1,1 0 0 1 -1.41,0l-6.36,-6.36a0.91,0.91 0 0 1 0,-1.28l6.36,-6.36a1,1 0 0 1 1.41,0l0,0a1,1 0 0 1 0,1.41z"></Path> | ||
</Grid> | ||
</Viewbox> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Windows.Controls; | ||
|
||
namespace Daybreak.Controls.Glyphs; | ||
/// <summary> | ||
/// Interaction logic for ArrowGlyph.xaml | ||
/// </summary> | ||
public partial class ArrowGlyph : UserControl | ||
{ | ||
public ArrowGlyph() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.