Skip to content

Commit

Permalink
#8 Basic UI and functionality implemented for accent picker
Browse files Browse the repository at this point in the history
Still need to add to all windows (currently only library until 100% flushed out). Fix conflicts with dark mode swap (causes accent to reset). And implement saving color after closing.
  • Loading branch information
dcgoings committed Feb 18, 2019
1 parent 29aba54 commit 54c65cc
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 3 deletions.
32 changes: 32 additions & 0 deletions WordByWord/WordByWord/Colors.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<mah:MetroWindow x:Class="WordByWord.Colors"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:local="clr-namespace:WordByWord"
xmlns:dialog="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
dialog:DialogParticipation.Register="{Binding}"
mc:Ignorable="d"
Title="Info" Height="200" Width="400">
<DockPanel>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<TextBlock Text="Accent color:" FontWeight="Bold" FontSize="30" VerticalAlignment="Center" Grid.Row="0" Margin="5"/>

<ComboBox x:Name="ColorsComboBox" FontWeight="Bold" FontSize="20" SelectionChanged="ColorsComboBox_SelectionChanged" Grid.Row="1" Margin="5" BorderBrush="Black" BorderThickness="2">
<ComboBoxItem>Blue</ComboBoxItem>
<ComboBoxItem>Red</ComboBoxItem>
<ComboBoxItem>Green</ComboBoxItem>
</ComboBox>

<Button x:Name="ColorsClose" IsCancel="True" Content="Close" Grid.Row="2" Height="30" Width="100" HorizontalAlignment="Right" Margin="0 0 5 0" BorderThickness="2" BorderBrush="Black"/>

</Grid>
</DockPanel>
</mah:MetroWindow>
30 changes: 30 additions & 0 deletions WordByWord/WordByWord/Colors.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using MahApps.Metro;
using MahApps.Metro.Controls;
using System;
using System.Drawing;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;

namespace WordByWord
{
/// <summary>
/// Interaction logic for Colors.xaml
/// </summary>
public partial class Colors : MetroWindow
{
public Colors()
{
InitializeComponent();
}

private void ColorsComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
Tuple<AppTheme, Accent> theme = ThemeManager.DetectAppStyle(Application.Current);
string selectedColor = (ColorsComboBox.SelectedItem as ComboBoxItem).Content.ToString();

if (Application.Current != null)
ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(selectedColor), theme.Item1);
}
}
}
16 changes: 13 additions & 3 deletions WordByWord/WordByWord/Library.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@

<mah:MetroWindow.RightWindowCommands>
<mah:WindowCommands>
<Button Command="{Binding OpenInfoCommand}">
<Button Command="{Binding OpenColorsCommand}">
<StackPanel Orientation="Horizontal">
<iconPacks:PackIconModern Kind="InformationCircle" Width="20" Height="20" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<iconPacks:PackIconModern Kind="DrawBrushReflection" Width="20" Height="20" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
</Button>
</Button>
<Button Command="{Binding SwapThemeCommand}">
<StackPanel Orientation="Horizontal">
<iconPacks:PackIconModern Kind="Contrast" Width="20" Height="20" HorizontalAlignment="Center" VerticalAlignment="Center"/>
Expand All @@ -105,4 +105,14 @@
</Button>
</mah:WindowCommands>
</mah:MetroWindow.RightWindowCommands>

<mah:MetroWindow.LeftWindowCommands>
<mah:WindowCommands>
<Button Command="{Binding OpenInfoCommand}">
<StackPanel Orientation="Horizontal">
<iconPacks:PackIconModern Kind="InformationCircle" Width="20" Height="20" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
</Button>
</mah:WindowCommands>
</mah:MetroWindow.LeftWindowCommands>
</mah:MetroWindow>
9 changes: 9 additions & 0 deletions WordByWord/WordByWord/Services/WindowService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class WindowService : IWindowService
private Reader _reader;
private InputText _inputText;
private Info _info;
private Colors _colors;

public void ShowWindow(string window, ViewModel.ViewModel viewModel)
{
Expand Down Expand Up @@ -42,6 +43,10 @@ public void ShowWindow(string window, ViewModel.ViewModel viewModel)
_info = new Info();
_info.ShowDialog();
break;
case "Colors":
_colors = new Colors();
_colors.ShowDialog();
break;
}
}

Expand All @@ -68,6 +73,10 @@ public void CloseWindow(string window)
_info?.Close();
_info = null;
break;
case "Colors":
_colors?.Close();
_colors = null;
break;
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions WordByWord/WordByWord/ViewModel/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public ViewModel(IDialogCoordinator dialogService, IWindowService windowService,
AddDocumentCommand = new RelayCommand(AddDocumentContext);
OpenEditorCommand = new RelayCommand(OpenEditorWindow, () => SelectedDocument != null && !SelectedDocument.IsBusy);
OpenInfoCommand = new RelayCommand(OpenInfoWindow);
OpenColorsCommand = new RelayCommand(OpenColorsWindow);
ConfirmEditCommand = new RelayCommand(ConfirmEdit);
ReadSelectedDocumentCommand = new RelayCommand(async () =>
{
Expand Down Expand Up @@ -168,6 +169,8 @@ public ViewModel(IDialogCoordinator dialogService, IWindowService windowService,

public RelayCommand OpenInfoCommand { get; }

public RelayCommand OpenColorsCommand { get; }

public RelayCommand AddDocumentCommand { get; }

public RelayCommand PauseReadingCommand { get; }
Expand Down Expand Up @@ -919,6 +922,11 @@ private void OpenInfoWindow()
_windowService.ShowWindow("Info", this);
}

private void OpenColorsWindow()
{
_windowService.ShowWindow("Colors", this);
}

private void AddDocumentContext()
{
_addDocumentContext.IsOpen = true;
Expand Down
7 changes: 7 additions & 0 deletions WordByWord/WordByWord/WordByWord.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Colors.xaml.cs">
<DependentUpon>Colors.xaml</DependentUpon>
</Compile>
<Compile Include="Converters\BoolToCollapsedConverter.cs" />
<Compile Include="Converters\InverseBoolConverter.cs" />
<Compile Include="Converters\InverseBoolVisibilityConverter.cs" />
Expand All @@ -237,6 +240,10 @@
<DependentUpon>Reader.xaml</DependentUpon>
</Compile>
<Compile Include="ViewModel\ViewModel.cs" />
<Page Include="Colors.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Editor.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down

0 comments on commit 54c65cc

Please sign in to comment.