Skip to content

Commit

Permalink
added themepicker for accents, needs loading saving
Browse files Browse the repository at this point in the history
  • Loading branch information
dreanor committed May 5, 2017
1 parent aca1b21 commit fa06664
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 45 deletions.
10 changes: 1 addition & 9 deletions src/PlaylistManager/Logic/PlaylistViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public PlaylistViewModel(string header, string infotext)
Header = header;
InfoText = infotext;
playlistPath = $"{PlaylistPaths.MainFolder}\\{Header}{PlaylistPaths.PlaylistEnding}";
PlaylistEntries = new ObservableCollection<PlaylistItem>();
PlaylistEntries = new ObservableCollection<PlaylistItem>(LoadPlaylist());
PlaylistEntries.CollectionChanged += PlaylistEntries_CollectionChanged;
}

Expand All @@ -37,14 +37,6 @@ public PlaylistViewModel(string header, string infotext)

public ObservableCollection<PlaylistItem> PlaylistEntries { get; private set; }

public void OnLoad()
{
foreach (var item in LoadPlaylist())
{
PlaylistEntries.Add(item);
}
}

public void DoubleClick(object sender, MouseButtonEventArgs e)
{
if (sender is PlaylistItem item)
Expand Down
14 changes: 14 additions & 0 deletions src/PlaylistManager/Logic/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ public class ViewModel : INotifyPropertyChanged
public event MessageBoxRaiseHandler OnMessageBoxRaise;

private bool areInformationsVisible;
private bool isStylePickerVisible;
private int selectedContainer;

public ViewModel(List<TabContainer> containers)
{
Containers = new ObservableCollection<TabContainer>(containers);
OpenWikiLinkCmd = new ActionCommand(x => Process.Start("https://wiki.guildwars2.com/wiki/Customized_soundtrack"));
ShowMoreInformationsCmd = new ActionCommand(x => AreInformationsVisible = true);
ShowStyleChangeCmd = new ActionCommand(x => IsStylePickerVisible = true);
Directory.CreateDirectory(PlaylistPaths.MainFolder);

foreach (var container in containers)
Expand All @@ -35,6 +37,8 @@ public ViewModel(List<TabContainer> containers)

public ICommand ShowMoreInformationsCmd { get; set; }

public ICommand ShowStyleChangeCmd { get; set; }

public ObservableCollection<TabContainer> Containers { get; private set; }

public int SelectedContainer
Expand All @@ -57,6 +61,16 @@ public bool AreInformationsVisible
}
}

public bool IsStylePickerVisible
{
get { return isStylePickerVisible; }
set
{
isStylePickerVisible = value;
NotifyPropertyChanged(nameof(IsStylePickerVisible));
}
}

protected void NotifyPropertyChanged(string prop)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(prop));
Expand Down
9 changes: 6 additions & 3 deletions src/PlaylistManager/PlaylistManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Ressources\02.ico</ApplicationIcon>
<ApplicationIcon>Resources\02.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="MahApps.Metro, Version=1.4.1.0, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL">
Expand Down Expand Up @@ -127,10 +127,13 @@
<Resource Include="FodyWeavers.xml" />
</ItemGroup>
<ItemGroup>
<Resource Include="Ressources\02.ico" />
<Resource Include="Resources\02.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Ressources\icon.png" />
<Resource Include="Resources\icon.png" />
</ItemGroup>
<ItemGroup>
<Folder Include="Translation\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Fody.1.29.4\build\dotnet\Fody.targets" Condition="Exists('..\packages\Fody.1.29.4\build\dotnet\Fody.targets')" />
Expand Down
4 changes: 2 additions & 2 deletions src/PlaylistManager/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
[assembly: AssemblyCopyright("Copyright © Dreanor 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("1.2.1")]
[assembly: AssemblyFileVersion("1.2.1")]
[assembly: AssemblyVersion("1.2.2")]
[assembly: AssemblyFileVersion("1.2.2")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
Expand Down
11 changes: 10 additions & 1 deletion src/PlaylistManager/UI/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Startup="Application_Startup">
<Application.Resources>

<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Orange.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedTabControl.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
14 changes: 1 addition & 13 deletions src/PlaylistManager/UI/PlaylistView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
Loaded="UserControl_Loaded"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Orange.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedTabControl.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>

<GroupBox Grid.RowSpan="2">
<GroupBox.Header>
<TextBlock HorizontalAlignment="Center"
Expand Down
5 changes: 0 additions & 5 deletions src/PlaylistManager/UI/PlaylistView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,5 @@ private void DataGrid_MouseDoubleClick(object sender, System.Windows.Input.Mouse
{
viewModel.DoubleClick(datagrid.SelectedItem, e);
}

private void UserControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
viewModel.OnLoad();
}
}
}
39 changes: 28 additions & 11 deletions src/PlaylistManager/UI/View.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:metro="clr-namespace:MahApps.Metro;assembly=MahApps.Metro"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
Expand All @@ -13,27 +14,43 @@
Width="800"
MinWidth="800"
MinHeight="600">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Orange.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />

</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Controls:MetroWindow.RightWindowCommands>
<Controls:WindowCommands>
<Button Content="Change Style"
Command="{Binding Path=ShowStyleChangeCmd}"/>
<Button Content="Informations"
ToolTip="Show more Informations about playlists"
Command="{Binding Path=ShowMoreInformationsCmd}"/>
</Controls:WindowCommands>
</Controls:MetroWindow.RightWindowCommands>
<Controls:MetroWindow.Flyouts>
<Controls:FlyoutsControl>
<Controls:Flyout Header="Style Picker" Position="Right" Width="270" IsOpen="{Binding Path=IsStylePickerVisible, UpdateSourceTrigger=PropertyChanged}">
<Grid Margin="6">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>

<TextBlock Text="Accents" Margin="0 0 2 0" VerticalAlignment="Center" />

<ComboBox x:Name="AccentSelector"
Grid.Row="1"
Margin="0 0 2 0"
VerticalAlignment="Center"
SelectionChanged="AccentSelectionChanged"
ItemsSource="{x:Static metro:ThemeManager.Accents}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
</Controls:Flyout>
<Controls:Flyout Header="Informations" Position="Right" Width="400" IsOpen="{Binding Path=AreInformationsVisible, UpdateSourceTrigger=PropertyChanged}">
<TextBlock TextWrapping="Wrap" Margin="6">
<TextBlock FontWeight="Bold">Supported media</TextBlock><LineBreak/>
Expand Down
32 changes: 31 additions & 1 deletion src/PlaylistManager/UI/View.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
using MahApps.Metro.Controls;
using MahApps.Metro;
using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;
using PlaylistManager.Logic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace PlaylistManager.UI
{
Expand All @@ -18,11 +25,34 @@ public View(ViewModel viewModel)

var version = Assembly.GetExecutingAssembly().GetName().Version;
Title += $" - {version.Major}.{version.Minor}.{version.Build}";

LoadThemeIfSet();
}

private async void ViewModel_OnMessageBoxRaiseAsync(object sender, MessageBoxRaiseEvent e)
{
await this.ShowMessageAsync(e.Title, e.Message, e.DialogStyle);
}

#region ThemePicker
private void AccentSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (AccentSelector.SelectedItem is Accent)
{
Accent selectedAccent = (Accent)AccentSelector.SelectedItem;
if (selectedAccent != null)
{
var theme = ThemeManager.DetectAppStyle(Application.Current);
ThemeManager.ChangeAppStyle(Application.Current, selectedAccent, theme.Item1);
Application.Current.MainWindow.Activate();
}
}
}

private void LoadThemeIfSet()
{
//todo
}
#endregion
}
}

0 comments on commit fa06664

Please sign in to comment.