Skip to content

Commit

Permalink
Added a more stylish darker look with MahApps.Metro
Browse files Browse the repository at this point in the history
and loading spinners for UX shenanigans
  • Loading branch information
microdee committed Jan 27, 2017
1 parent 74743da commit d1347b8
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/vpm/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ static void Main(string[] args)

var winapp = VpmConfig.Instance.WinApp = new Application();
var window = VpmConfig.Instance.AgreeWindow = new UserAgree();

winapp.Run(window);

if (VpmConfig.Instance.InstallationCancelled)
Expand Down
39 changes: 31 additions & 8 deletions src/vpm/UserAgree.xaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
<Window x:Class="vpm.UserAgree"
<Controls:MetroWindow x:Class="vpm.UserAgree"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
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:cefSharp="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
xmlns:local="clr-namespace:vpm"
mc:Ignorable="d" Height="567.869" Width="877.195"
Initialized="UserAgree_OnInitialized">
mc:Ignorable="d" Height="575" Width="1200"
BorderThickness="0"
GlowBrush="Black"
ResizeMode="CanResizeWithGrip"
Initialized="UserAgree_OnInitialized" Background="#FF2C2C2C" NonActiveWindowTitleBrush="#FF2C2C2C" OverrideDefaultWindowCommandsBrush="White" TitleForeground="White" WindowTitleBrush="#FF2C2C2C" Foreground="White">
<Controls:MetroWindow.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
<!-- Accent and AppTheme setting -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/FlatButton.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Controls:MetroWindow.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="155"/>
Expand All @@ -18,11 +36,16 @@
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<cefSharp:ChromiumWebBrowser x:Name="Browser" LoadingStateChanged="Browser_OnLoadingStateChanged" />
<CheckBox x:Name="AgreeAndInstall" FlowDirection="RightToLeft" Content="Agree and install" Margin="0,10,246,10" Grid.Row="1" Checked="AgreeAndInstall_OnChecked" HorizontalAlignment="Right" Width="109" RenderTransformOrigin="1.006,0.495"/>
<Button x:Name="NextPack" Content="Next &gt;" Grid.Row="1" HorizontalAlignment="Right" Width="75" IsDefault="True" Click="NextPack_OnClick" Margin="0,0,155,0"/>
<Button x:Name="ContinueInstall" Content="Continue" Height="40" VerticalAlignment="Bottom" Click="ContinueInstall_Click" IsEnabled="False" Grid.Row="1" HorizontalAlignment="Right" Width="155"/>
<Rectangle x:Name="LoadingCover" Fill="#FF2C2C2C"/>
<Controls:ProgressRing x:Name="LoadingRing" IsActive="True" Foreground="#FF898989" />
<Controls:ProgressRing x:Name="SmallLoadingRing" IsActive="False" Foreground="#FF898989" Margin="10,5,0,7" Grid.Row="1" HorizontalAlignment="Left" Width="36" ClipToBounds="True" />
<CheckBox x:Name="AgreeAndInstall" FlowDirection="RightToLeft" Content="Agree and install" Margin="266,10,246,10" Grid.Row="1" Checked="AgreeAndInstall_OnChecked" RenderTransformOrigin="1.006,0.495" Foreground="White" IsEnabledChanged="AgreeAndInstall_OnIsEnabledChanged"/>
<Button x:Name="NextPack" Content="Next &gt;" Grid.Row="1" HorizontalAlignment="Right" Width="75" IsDefault="True" Click="NextPack_OnClick" Margin="0,0,155,0" Background="#FF494949" Foreground="White">

</Button>
<Button x:Name="ContinueInstall" Content="Continue" Height="40" VerticalAlignment="Bottom" Click="ContinueInstall_Click" IsEnabled="False" Grid.Row="1" HorizontalAlignment="Right" Width="155" Background="#FF494949" Foreground="White" Opacity="0.5"/>
</Grid>
<ListBox x:Name="VPackList" SelectionChanged="VPackList_OnSelectionChanged" Margin="0,10,0,0" BorderBrush="{x:Null}"/>
<ListBox x:Name="VPackList" SelectionChanged="VPackList_OnSelectionChanged" BorderBrush="{x:Null}" Background="#FF2C2C2C" Foreground="White"/>

</Grid>
</Window>
</Controls:MetroWindow>
35 changes: 23 additions & 12 deletions src/vpm/UserAgree.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using MahApps.Metro.Controls;
using CefSharp;
using CefSharp.Wpf;

Expand All @@ -22,7 +23,7 @@ namespace vpm
/// <summary>
/// Interaction logic for UserAgree.xaml
/// </summary>
public partial class UserAgree : Window
public partial class UserAgree : MetroWindow
{
public JsVPackInterop InteropObj;
public ListBoxItem SelectedPack;
Expand Down Expand Up @@ -116,24 +117,35 @@ private void AgreeAndInstall_OnChecked(object sender, RoutedEventArgs e)
pack.Agreed = true;

ContinueInstall.IsEnabled = (from ListBoxItem item in VPackList.Items select (VPack) item.Content).Aggregate(true, (current, ipack) => current && ipack.Agreed);
if (ContinueInstall.IsEnabled) ContinueInstall.Opacity = 1;

}

private void Browser_OnLoadingStateChanged(object sender, LoadingStateChangedEventArgs e)
{
Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action( () =>
{
if (!PackChanged) return;
if (e.IsLoading)
if (PackChanged)
{
AgreeAndInstall.IsEnabled = false;
InteropObj.CurrentPack = (VPack)SelectedPack.Content;
if (e.IsLoading)
{
LoadingCover.Visibility = Visibility.Visible;
LoadingRing.IsActive = true;
AgreeAndInstall.IsEnabled = false;
InteropObj.CurrentPack = (VPack)SelectedPack.Content;
}
else
{
LoadingCover.Visibility = Visibility.Hidden;
LoadingRing.IsActive = false;
AgreeAndInstall.IsEnabled = true;
NextPack.IsEnabled = true;
PackChanged = false;
}
}
else
{
AgreeAndInstall.IsEnabled = true;
NextPack.IsEnabled = true;
PackChanged = false;
SmallLoadingRing.IsActive = e.IsLoading;
}
}));
}
Expand All @@ -142,12 +154,11 @@ private void NextPack_OnClick(object sender, RoutedEventArgs e)
{
VPackList.SelectedIndex = (VPackList.SelectedIndex + 1) % VPackList.Items.Count;
}
/*

private void AgreeAndInstall_OnIsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if(AgreeAndInstall.IsEnabled)
Console.WriteLine("Agree Enabled");
if ((bool)e.NewValue) AgreeAndInstall.Opacity = 1;
else AgreeAndInstall.Opacity = 0.5;
}
*/
}
}
1 change: 1 addition & 0 deletions src/vpm/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<package id="Fody" version="1.28.3" targetFramework="net461" developmentDependency="true" />
<package id="LibGit2Sharp" version="0.22.0" targetFramework="net461" />
<package id="LibGit2Sharp.NativeBinaries" version="1.0.129" targetFramework="net461" />
<package id="MahApps.Metro" version="1.4.1" targetFramework="net461" />
<package id="Microsoft.CodeAnalysis.Analyzers" version="1.1.0" targetFramework="net461" />
<package id="Microsoft.CodeAnalysis.Common" version="2.0.0-beta1" targetFramework="net461" />
<package id="Microsoft.CodeAnalysis.CSharp" version="2.0.0-beta1" targetFramework="net461" />
Expand Down
8 changes: 8 additions & 0 deletions src/vpm/vpm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@
<HintPath>packages\LibGit2Sharp.0.22.0\lib\net40\LibGit2Sharp.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MahApps.Metro, Version=1.4.1.0, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL">
<HintPath>packages\MahApps.Metro.1.4.1\lib\net45\MahApps.Metro.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.CodeAnalysis, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.CodeAnalysis.Common.2.0.0-beta1\lib\net45\Microsoft.CodeAnalysis.dll</HintPath>
<Private>True</Private>
Expand Down Expand Up @@ -174,6 +178,10 @@
<HintPath>packages\System.Reflection.Metadata.1.4.1\lib\portable-net45+win8\System.Reflection.Metadata.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\MahApps.Metro.1.4.1\lib\net45\System.Windows.Interactivity.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq">
<Private>False</Private>
Expand Down

0 comments on commit d1347b8

Please sign in to comment.