Skip to content

Commit

Permalink
* add GoldDiffCheckBox
Browse files Browse the repository at this point in the history
* add GoldDiffDialog
  • Loading branch information
Johannes-Schneider committed Oct 27, 2020
1 parent 80abcd7 commit 3fee0f6
Show file tree
Hide file tree
Showing 16 changed files with 348 additions and 20 deletions.
2 changes: 2 additions & 0 deletions GoldDiff.Playground/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<ResourceDictionary Source="pack://application:,,,/GoldDiff.Shared;component/View/Style/DefaultIconButtonStyle.xaml" />
<ResourceDictionary Source="pack://application:,,,/GoldDiff.Shared;component/View/Style/DefaultIconControlStyle.xaml" />
<ResourceDictionary Source="pack://application:,,,/GoldDiff.Shared;component/View/Style/DefaultProgressBarStyle.xaml" />
<ResourceDictionary Source="pack://application:,,,/GoldDiff.Shared;component/View/Style/DefaultGoldDiffCheckBoxStyle.xaml" />
<ResourceDictionary Source="pack://application:,,,/GoldDiff.Shared;component/View/Style/DefaultDialogStyle.xaml" />

<ResourceDictionary Source="pack://application:,,,/GoldDiff;component/View/Style/DefaultGoldDifferenceStyle.xaml" />
<ResourceDictionary Source="pack://application:,,,/GoldDiff;component/View/Style/DefaultLoLPositionStyle.xaml" />
Expand Down
16 changes: 16 additions & 0 deletions GoldDiff.Playground/Dialog.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<view:GoldDiffDialog x:Class="GoldDiff.Playground.Dialog"
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:GoldDiff.Playground"
xmlns:view="clr-namespace:GoldDiff.Shared.View;assembly=GoldDiff.Shared"
xmlns:controlElement="clr-namespace:GoldDiff.Shared.View.ControlElement;assembly=GoldDiff.Shared"
mc:Ignorable="d"

x:Name="This">

<Grid>
<controlElement:IconControl Source="{DynamicResource {x:Static view:GoldDiffSharedResourceKeys.IconSettings}}" />
</Grid>
</view:GoldDiffDialog>
12 changes: 12 additions & 0 deletions GoldDiff.Playground/Dialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using GoldDiff.Shared.View;

namespace GoldDiff.Playground
{
public partial class Dialog : GoldDiffDialog
{
public Dialog()
{
InitializeComponent();
}
}
}
4 changes: 4 additions & 0 deletions GoldDiff.Playground/GoldDiff.Playground.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="Dialog.xaml" />
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand All @@ -58,6 +59,9 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Dialog.xaml.cs">
<DependentUpon>Dialog.xaml</DependentUpon>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
Expand Down
38 changes: 24 additions & 14 deletions GoldDiff.Playground/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,31 @@
mc:Ignorable="d"

x:Name="This"

Style="{DynamicResource {x:Static view:GoldDiffSharedResourceKeys.DefaultWindowStyle}}"
WindowStyle="None"
ResizeMode="NoResize"

Title="MainWindow" Height="350" Width="525">
<StackPanel>

<controlElement:LoLPositionView Position="Top"></controlElement:LoLPositionView>
<controlElement:LoLPositionView Position="Jungle"></controlElement:LoLPositionView>
<controlElement:LoLPositionView Position="Middle"></controlElement:LoLPositionView>
<controlElement:LoLPositionView Position="Bottom"></controlElement:LoLPositionView>
<controlElement:LoLPositionView Position="Support"></controlElement:LoLPositionView>

<sharedControlElements:IconControl Source="{DynamicResource {x:Static view:GoldDiffSharedResourceKeys.IconLoLKills}}"></sharedControlElements:IconControl>
<sharedControlElements:IconControl Source="{DynamicResource {x:Static view:GoldDiffSharedResourceKeys.IconLoLDeaths}}"></sharedControlElements:IconControl>
<sharedControlElements:IconControl Source="{DynamicResource {x:Static view:GoldDiffSharedResourceKeys.IconLoLAssists}}"></sharedControlElements:IconControl>

</StackPanel>

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<sharedControlElements:WindowControlBar Grid.Row="0"
Margin="0, 0, 0, 12"
CanClose="True"
CanMaximize="True"
CanMinimize="True" />

<StackPanel Grid.Row="1">

<sharedControlElements:IconButton Icon="{DynamicResource {x:Static view:GoldDiffSharedResourceKeys.IconCoins}}"
Click="ButtonBase_OnClick" />

</StackPanel>
</Grid>


</Window>
19 changes: 18 additions & 1 deletion GoldDiff.Playground/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using GoldDiff.LeagueOfLegends.Game;
using System.Windows;
using System.Windows.Input;
using GoldDiff.LeagueOfLegends.Game;

namespace GoldDiff.Playground
{
Expand All @@ -11,5 +13,20 @@ public MainWindow()
{
InitializeComponent();
}

protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
base.OnMouseLeftButtonDown(e);
DragMove();
}

private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
var dialog = new Dialog()
{
Owner = this,
};
dialog.ShowDialog();
}
}
}
4 changes: 4 additions & 0 deletions GoldDiff.Shared/GoldDiff.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<Compile Include="Utility\MultiSet.cs" />
<Compile Include="View\Command\Commands.cs" />
<Compile Include="View\Command\GenericCommand.cs" />
<Compile Include="View\ControlElement\GoldDiffCheckBox.cs" />
<Compile Include="View\ControlElement\IconButton.cs" />
<Compile Include="View\ControlElement\IconControl.cs" />
<Compile Include="View\ControlElement\ProgressView.xaml.cs">
Expand All @@ -80,6 +81,7 @@
<Compile Include="View\Controller\ProgressViewController.cs" />
<Compile Include="View\Converter\BoolToVisibilityConverter.cs" />
<Compile Include="View\Converter\MultiplyDoubleConverter.cs" />
<Compile Include="View\GoldDiffDialog.cs" />
<Compile Include="View\GoldDiffSharedResourceKeys.cs" />
<Compile Include="View\Model\ProgressViewViewModel.cs" />
<Compile Include="View\Model\ViewModel.cs" />
Expand All @@ -91,6 +93,8 @@
</Page>
<Page Include="View\ControlElement\WindowControlBar.xaml" />
<Page Include="View\Resource\VectorIcons.xaml" />
<Page Include="View\Style\DefaultDialogStyle.xaml" />
<Page Include="View\Style\DefaultGoldDiffCheckBoxStyle.xaml" />
<Page Include="View\Style\DefaultIconButtonStyle.xaml" />
<Page Include="View\Style\DefaultIconControlStyle.xaml" />
<Page Include="View\Style\DefaultProgressBarStyle.xaml" />
Expand Down
72 changes: 72 additions & 0 deletions GoldDiff.Shared/View/ControlElement/GoldDiffCheckBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace GoldDiff.Shared.View.ControlElement
{
public class GoldDiffCheckBox : CheckBox
{
public static readonly DependencyProperty NotCheckedIconProperty = DependencyProperty.Register(nameof(NotCheckedIcon), typeof(Geometry), MethodBase.GetCurrentMethod().DeclaringType);
public static readonly DependencyProperty CheckedIconProperty = DependencyProperty.Register(nameof(CheckedIcon), typeof(Geometry), MethodBase.GetCurrentMethod().DeclaringType);
public static readonly DependencyProperty NotCheckedBackgroundProperty = DependencyProperty.Register(nameof(NotCheckedBackground), typeof(Brush), MethodBase.GetCurrentMethod().DeclaringType);
public static readonly DependencyProperty CheckedBackgroundProperty = DependencyProperty.Register(nameof(CheckedBackground), typeof(Brush), MethodBase.GetCurrentMethod().DeclaringType);
public static readonly DependencyProperty NotCheckedIconForegroundProperty = DependencyProperty.Register(nameof(NotCheckedIconForeground), typeof(Brush), MethodBase.GetCurrentMethod().DeclaringType);
public static readonly DependencyProperty CheckedIconForegroundProperty = DependencyProperty.Register(nameof(CheckedIconForeground), typeof(Brush), MethodBase.GetCurrentMethod().DeclaringType);
public static readonly DependencyProperty NotCheckedIconBackgroundProperty = DependencyProperty.Register(nameof(NotCheckedIconBackground), typeof(Brush), MethodBase.GetCurrentMethod().DeclaringType);
public static readonly DependencyProperty CheckedIconBackgroundProperty = DependencyProperty.Register(nameof(CheckedIconBackground), typeof(Brush), MethodBase.GetCurrentMethod().DeclaringType);

public Geometry? NotCheckedIcon
{
get => GetValue(NotCheckedIconProperty) as Geometry;
set => SetValue(NotCheckedIconProperty, value);
}

public Geometry? CheckedIcon
{
get => GetValue(CheckedIconProperty) as Geometry;
set => SetValue(CheckedIconProperty, value);
}

public Brush? NotCheckedBackground
{
get => GetValue(NotCheckedBackgroundProperty) as Brush;
set => SetValue(NotCheckedBackgroundProperty, value);
}

public Brush? CheckedBackground
{
get => GetValue(CheckedBackgroundProperty) as Brush;
set => SetValue(CheckedBackgroundProperty, value);
}

public Brush? NotCheckedIconForeground
{
get => GetValue(NotCheckedIconForegroundProperty) as Brush;
set => SetValue(NotCheckedIconForegroundProperty, value);
}

public Brush? CheckedIconForeground
{
get => GetValue(CheckedIconForegroundProperty) as Brush;
set => SetValue(CheckedIconForegroundProperty, value);
}

public Brush? NotCheckedIconBackground
{
get => GetValue(NotCheckedIconBackgroundProperty) as Brush;
set => SetValue(NotCheckedIconBackgroundProperty, value);
}

public Brush? CheckedIconBackground
{
get => GetValue(CheckedIconBackgroundProperty) as Brush;
set => SetValue(CheckedIconBackgroundProperty, value);
}

public GoldDiffCheckBox()
{
Style = Application.Current?.Resources[GoldDiffSharedResourceKeys.DefaultGoldDiffCheckBoxStyle] as Style;
}
}
}
2 changes: 1 addition & 1 deletion GoldDiff.Shared/View/ControlElement/IconButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public Brush? BorderBrushWhenDisabled

public IconButton()
{
Style = Application.Current?.Resources[GoldDiffSharedResourceKeys.DefaultIconButtonStyle] as Style ?? null;
Style = Application.Current?.Resources[GoldDiffSharedResourceKeys.DefaultIconButtonStyle] as Style;
}
}
}
2 changes: 1 addition & 1 deletion GoldDiff.Shared/View/ControlElement/IconControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public Geometry? Source

public IconControl()
{
Style = Application.Current?.Resources[GoldDiffSharedResourceKeys.DefaultIconControlStyle] as Style ?? null;
Style = Application.Current?.Resources[GoldDiffSharedResourceKeys.DefaultIconControlStyle] as Style;
}
}
}
2 changes: 1 addition & 1 deletion GoldDiff.Shared/View/ControlElement/WindowControlBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
Command="{x:Static command:Commands.ToggleMaximizeWindow}"
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" />

<controlElement:IconButton Icon="{DynamicResource {x:Static view:GoldDiffSharedResourceKeys.IconClose}}"
<controlElement:IconButton Icon="{DynamicResource {x:Static view:GoldDiffSharedResourceKeys.IconCross}}"
BackgroundWhenHovered="#e73c32"
BackgroundWhenPressed="#ad0009"
ForegroundWhenHovered="{DynamicResource {x:Static view:GoldDiffSharedResourceKeys.BackgroundRegular}}"
Expand Down
30 changes: 30 additions & 0 deletions GoldDiff.Shared/View/GoldDiffDialog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Windows;

namespace GoldDiff.Shared.View
{
public class GoldDiffDialog : Window
{
public GoldDiffDialog()
{
Style = Application.Current?.Resources[GoldDiffSharedResourceKeys.DefaultDialogStyle] as Style;
WindowState = WindowState.Minimized;
WindowStartupLocation = WindowStartupLocation.CenterOwner;

Loaded += OnLoaded;
}

private void OnLoaded(object sender, RoutedEventArgs e)
{
if (Owner == null)
{
return;
}

Width = Owner.Width;
Height = Owner.Height;
Top = Owner.Top;
Left = Owner.Left;
WindowState = WindowState.Normal;
}
}
}
5 changes: 4 additions & 1 deletion GoldDiff.Shared/View/GoldDiffSharedResourceKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public static class GoldDiffSharedResourceKeys

public const string ApplicationIcon = nameof(ApplicationIcon);

public const string IconClose = nameof(IconClose);
public const string IconCross = nameof(IconCross);
public const string IconCheck = nameof(IconCheck);
public const string IconMinimize = nameof(IconMinimize);
public const string IconMaximize = nameof(IconMaximize);
public const string IconSettings = nameof(IconSettings);
Expand Down Expand Up @@ -125,6 +126,8 @@ public static class GoldDiffSharedResourceKeys
public const string DefaultIconButtonStyle = nameof(DefaultIconButtonStyle);
public const string DefaultIconControlStyle = nameof(DefaultIconControlStyle);
public const string DefaultProgressBarStyle = nameof(DefaultProgressBarStyle);
public const string DefaultGoldDiffCheckBoxStyle = nameof(DefaultGoldDiffCheckBoxStyle);
public const string DefaultDialogStyle = nameof(DefaultDialogStyle);

#endregion
}
Expand Down
6 changes: 5 additions & 1 deletion GoldDiff.Shared/View/Resource/VectorIcons.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:view="clr-namespace:GoldDiff.Shared.View">

<StreamGeometry x:Key="{x:Static view:GoldDiffSharedResourceKeys.IconClose}">
<StreamGeometry x:Key="{x:Static view:GoldDiffSharedResourceKeys.IconCross}">
M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z
</StreamGeometry>

<StreamGeometry x:Key="{x:Static view:GoldDiffSharedResourceKeys.IconCheck}">
M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z
</StreamGeometry>

<RectangleGeometry x:Key="{x:Static view:GoldDiffSharedResourceKeys.IconMinimize}" Rect="3,12,18,2" />

Expand Down
57 changes: 57 additions & 0 deletions GoldDiff.Shared/View/Style/DefaultDialogStyle.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:view="clr-namespace:GoldDiff.Shared.View"
xmlns:controlElement="clr-namespace:GoldDiff.Shared.View.ControlElement">

<Style TargetType="{x:Type Window}" x:Key="{x:Static view:GoldDiffSharedResourceKeys.DefaultDialogStyle}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="FontFamily" Value="{DynamicResource {x:Static view:GoldDiffSharedResourceKeys.FontFamilyRegular}}" />
<Setter Property="FontSize" Value="{DynamicResource {x:Static view:GoldDiffSharedResourceKeys.FontSizeRegular}}" />
<Setter Property="Background" Value="{DynamicResource {x:Static view:GoldDiffSharedResourceKeys.BackgroundRegular}}" />
<Setter Property="Foreground" Value="{DynamicResource {x:Static view:GoldDiffSharedResourceKeys.ForegroundRegular}}" />
<Setter Property="Icon" Value="{DynamicResource {x:Static view:GoldDiffSharedResourceKeys.ApplicationIcon}}" />
<Setter Property="BorderThickness" Value="1" />

<Setter Property="ShowInTaskbar" Value="False" />
<Setter Property="AllowsTransparency" Value="True" />
<Setter Property="WindowStyle" Value="None" />
<Setter Property="ResizeMode" Value="NoResize" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Window}">
<Border x:Name="Background"
BorderThickness="0">
<Border.Background>
<SolidColorBrush Color="{DynamicResource {x:Static view:GoldDiffSharedResourceKeys.ForegroundDarkColor}}" Opacity="0.75" />
</Border.Background>

<Grid Margin="60"
Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}">

<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<controlElement:WindowControlBar Grid.Row="0"
CanClose="True"
CanMaximize="False"
CanMinimize="False" />


<ScrollViewer Grid.Row="1"
Margin="0, 12, 0, 0"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Auto">

<ContentPresenter Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}" />

</ScrollViewer>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

</ResourceDictionary>
Loading

0 comments on commit 3fee0f6

Please sign in to comment.