Mercurial > silverbladetech
changeset 16:2395908fa45b
Getting there... 1.20am at BKK airport.
MainWindow and Menu now have VMs, Login form is displayed first
author | stevenh7776 stevenhollidge@hotmail.com |
---|---|
date | Wed, 14 Mar 2012 01:23:18 +0700 |
parents | 060f02cd4591 |
children | 7721a1270363 |
files | MetroWpf/MetroWpf.Services/Messaging/MessengerConfiguration.cs MetroWpf/MetroWpf.Services/Messaging/NavigationMessage.cs MetroWpf/MetroWpf.Services/MetroWpf.Services.csproj MetroWpf/MetroWpf.Services/Navigation/MenuOptions.cs MetroWpf/MetroWpf.Xaml/MetroWpf.Xaml.csproj MetroWpf/MetroWpf/App.xaml MetroWpf/MetroWpf/App.xaml.cs MetroWpf/MetroWpf/IoCConfiguration.cs MetroWpf/MetroWpf/Locator.cs MetroWpf/MetroWpf/MetroWpf.csproj MetroWpf/MetroWpf/Presentation/About/AboutView.xaml MetroWpf/MetroWpf/Presentation/About/AboutView.xaml.cs MetroWpf/MetroWpf/Presentation/About/AboutViewModel.cs MetroWpf/MetroWpf/Presentation/Login/Login.xaml MetroWpf/MetroWpf/Presentation/Login/Login.xaml.cs MetroWpf/MetroWpf/Presentation/Login/LoginViewModel.cs MetroWpf/MetroWpf/Presentation/Login/UserLogin.cs MetroWpf/MetroWpf/Presentation/MDI/MDIView.xaml MetroWpf/MetroWpf/Presentation/MDI/MDIView.xaml.cs MetroWpf/MetroWpf/Presentation/MDI/MDIViewModel.cs MetroWpf/MetroWpf/Presentation/MDI/TabMenu.xaml MetroWpf/MetroWpf/Presentation/MDI/TabMenu.xaml.cs MetroWpf/MetroWpf/Presentation/Settings/SettingsWindow.xaml MetroWpf/MetroWpf/Presentation/Settings/SettingsWindow.xaml.cs MetroWpf/MetroWpf/Presentation/Settings/SettingsWindowViewModel.cs MetroWpf/MetroWpf/Presentation/Shell/MainWindow.xaml MetroWpf/MetroWpf/Presentation/Shell/MainWindow.xaml.cs MetroWpf/MetroWpf/Presentation/Shell/MainWindowViewModel.cs |
diffstat | 28 files changed, 319 insertions(+), 623 deletions(-) [+] |
line wrap: on
line diff
--- a/MetroWpf/MetroWpf.Services/Messaging/MessengerConfiguration.cs Mon Mar 12 23:05:21 2012 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ - -using MetroWpf.Services.Interfaces; -namespace MetroWpf.Services.Messaging -{ - public class MessengerConfiguration : IInitialize - { - //private ApplicationStyleHelper _applicationStyleHelper; - - //public MessengerModule(ApplicationStyleHelper applicationStyleHelper) - //{ - // _applicationStyleHelper = applicationStyleHelper; - //} - public void Initialize() - { - //Messenger.Default.Register<ApplicationStyleChangeMessage>( - // this, message => _applicationStyleHelper.Update(message.ApplicationStyle)); - } - } -}
--- a/MetroWpf/MetroWpf.Services/Messaging/NavigationMessage.cs Mon Mar 12 23:05:21 2012 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -using GalaSoft.MvvmLight.Messaging; -using MetroWpf.Services.Navigation; - -namespace MetroWpf.Services.Messaging -{ - public class NavigationMessage : MessageBase - { - public MenuOption MenuOption { get; set; } - } -}
--- a/MetroWpf/MetroWpf.Services/MetroWpf.Services.csproj Mon Mar 12 23:05:21 2012 +0800 +++ b/MetroWpf/MetroWpf.Services/MetroWpf.Services.csproj Wed Mar 14 01:23:18 2012 +0700 @@ -37,6 +37,7 @@ <Reference Include="GalaSoft.MvvmLight.WPF4"> <HintPath>..\Libs\MvvmLight.4.0.0\GalaSoft.MvvmLight.WPF4.dll</HintPath> </Reference> + <Reference Include="PresentationFramework" /> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> @@ -49,9 +50,6 @@ <Compile Include="Interfaces\ButtonExtras.cs" /> <Compile Include="Interfaces\IDialogService.cs" /> <Compile Include="Interfaces\IInitialize.cs" /> - <Compile Include="Messaging\MessengerConfiguration.cs" /> - <Compile Include="Messaging\NavigationMessage.cs" /> - <Compile Include="Navigation\MenuOptions.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Windows\IWindowManager.cs" /> <Compile Include="Windows\WindowManager.cs" />
--- a/MetroWpf/MetroWpf.Services/Navigation/MenuOptions.cs Mon Mar 12 23:05:21 2012 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ - -namespace MetroWpf.Services.Navigation -{ - public enum MenuOption - { - NotSet = 0, - Home, - StockMarket, - FxRates, - Settings - } -}
--- a/MetroWpf/MetroWpf.Xaml/MetroWpf.Xaml.csproj Mon Mar 12 23:05:21 2012 +0800 +++ b/MetroWpf/MetroWpf.Xaml/MetroWpf.Xaml.csproj Wed Mar 14 01:23:18 2012 +0700 @@ -35,6 +35,10 @@ <Reference Include="PresentationFramework" /> <Reference Include="System" /> <Reference Include="System.Core" /> + <Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\Libs\System.Windows.Interactivity\System.Windows.Interactivity.dll</HintPath> + </Reference> <Reference Include="System.Xaml" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> @@ -59,6 +63,7 @@ <Compile Include="Converters\DoubleToGridLengthConverter.cs" /> <Compile Include="Converters\DoubleToThicknessConverter.cs" /> <Compile Include="Converters\EnumBooleanConverter.cs" /> + <Compile Include="Converters\EnumToIntConverter.cs" /> <Compile Include="Converters\GridLengthToDoubleConverter.cs" /> <Compile Include="Converters\IsStringNullOrWhitespaceConverter.cs" /> <Compile Include="Converters\NotConverter.cs" /> @@ -68,6 +73,7 @@ <Compile Include="Converters\RotationAngleToSimplePositiveAngleConverter.cs" /> <Compile Include="Converters\ThicknessPositiveToNegativeConverter.cs" /> <Compile Include="Converters\ThicknessToDoubleConverter.cs" /> + <Compile Include="Events\WeakPropertyChangeNotifier.cs" /> <Compile Include="Extensions\AdornerExtensions.cs" /> <Compile Include="Extensions\DependencyObject.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
--- a/MetroWpf/MetroWpf/App.xaml Mon Mar 12 23:05:21 2012 +0800 +++ b/MetroWpf/MetroWpf/App.xaml Wed Mar 14 01:23:18 2012 +0700 @@ -6,7 +6,6 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" StartupUri="Presentation/Shell/MainWindow.xaml"> - <!--StartupUri="Presentation/Shell/ShellView.xaml">--> <Application.Resources> <ResourceDictionary> <!--Global IoC Locator-->
--- a/MetroWpf/MetroWpf/App.xaml.cs Mon Mar 12 23:05:21 2012 +0800 +++ b/MetroWpf/MetroWpf/App.xaml.cs Wed Mar 14 01:23:18 2012 +0700 @@ -3,7 +3,6 @@ using System.Windows; using GalaSoft.MvvmLight.Ioc; using MetroWpf.Framework.Interfaces; -using MetroWpf.Services.Messaging; using MetroWpf.Xaml.Binding; namespace MetroWpf @@ -21,7 +20,6 @@ protected override void OnStartup(StartupEventArgs e) { InitializeIoC(); - InitializeMessaging(); base.OnStartup(e); InitializeWpfApplication(); InitializeBindingErrorTrace(); @@ -50,12 +48,5 @@ { IoCConfiguration.RegisterRuntimeServices(); } - - private void InitializeMessaging() - { - // setup notifications - var messenger = SimpleIoc.Default.GetInstance<MessengerConfiguration>(); - messenger.Initialize(); - } } }
--- a/MetroWpf/MetroWpf/IoCConfiguration.cs Mon Mar 12 23:05:21 2012 +0800 +++ b/MetroWpf/MetroWpf/IoCConfiguration.cs Wed Mar 14 01:23:18 2012 +0700 @@ -3,7 +3,11 @@ using MetroWpf.Framework; using MetroWpf.Framework.Interfaces; using MetroWpf.Presentation.Settings; -using MetroWpf.Services.Messaging; +using MetroWpf.Presentation.Login; +using MetroWpf.Presentation.About; +using MetroWpf.Presentation.UserProfile; +using MetroWpf.Presentation.Menu; +using MetroWpf.Presentation.Shell; namespace MetroWpf { @@ -12,9 +16,13 @@ private static void RegisterCoreServices() { SimpleIoc.Default.Register<IMessenger, Messenger>(); - SimpleIoc.Default.Register<MessengerConfiguration>(); SimpleIoc.Default.Register<IWpfApplication, WpfApplication>(); - SimpleIoc.Default.Register<SettingsWindowViewModel>(); + SimpleIoc.Default.Register<MainWindowViewModel>(); + SimpleIoc.Default.Register<MenuViewModel>(); + SimpleIoc.Default.Register<LoginViewModel>(); + SimpleIoc.Default.Register<UserProfileViewModel>(); + SimpleIoc.Default.Register<SettingsViewModel>(); + SimpleIoc.Default.Register<AboutViewModel>(); } public static void RegisterDesignTimeServices()
--- a/MetroWpf/MetroWpf/Locator.cs Mon Mar 12 23:05:21 2012 +0800 +++ b/MetroWpf/MetroWpf/Locator.cs Wed Mar 14 01:23:18 2012 +0700 @@ -2,6 +2,10 @@ using GalaSoft.MvvmLight.Ioc; using MetroWpf.Presentation.Shell; using MetroWpf.Presentation.Settings; +using MetroWpf.Presentation.Login; +using MetroWpf.Presentation.UserProfile; +using MetroWpf.Presentation.About; +using MetroWpf.Presentation.Menu; namespace MetroWpf { @@ -20,9 +24,34 @@ } } - public SettingsWindowViewModel SettingsWindowViewModel + public MainWindowViewModel MainWindowViewModel + { + get { return SimpleIoc.Default.GetInstance<MainWindowViewModel>(); } + } + + public MenuViewModel MenuViewModel + { + get { return SimpleIoc.Default.GetInstance<MenuViewModel>(); } + } + + public LoginViewModel LoginViewModel { - get { return SimpleIoc.Default.GetInstance<SettingsWindowViewModel>(); } + get { return SimpleIoc.Default.GetInstance<LoginViewModel>(); } + } + + public UserProfileViewModel UserProfileViewModel + { + get { return SimpleIoc.Default.GetInstance<UserProfileViewModel>(); } + } + + public SettingsViewModel SettingsViewModel + { + get { return SimpleIoc.Default.GetInstance<SettingsViewModel>(); } + } + + public AboutViewModel AboutViewModel + { + get { return SimpleIoc.Default.GetInstance<AboutViewModel>(); } } } } \ No newline at end of file
--- a/MetroWpf/MetroWpf/MetroWpf.csproj Mon Mar 12 23:05:21 2012 +0800 +++ b/MetroWpf/MetroWpf/MetroWpf.csproj Wed Mar 14 01:23:18 2012 +0700 @@ -79,37 +79,42 @@ <DependentUpon>App.xaml</DependentUpon> <SubType>Code</SubType> </Compile> - <Compile Include="Presentation\Settings\SettingsWindow.xaml.cs"> - <DependentUpon>SettingsWindow.xaml</DependentUpon> + <Compile Include="Messages\NavigationMessage.cs" /> + <Compile Include="Services\Interfaces\INavigationService.cs" /> + <Compile Include="Services\NavigationService.cs" /> + <Compile Include="Presentation\About\AboutView.xaml.cs"> + <DependentUpon>AboutView.xaml</DependentUpon> + </Compile> + <Compile Include="Presentation\Login\LoginView.xaml.cs"> + <DependentUpon>LoginView.xaml</DependentUpon> </Compile> + <Compile Include="Presentation\Menu\MenuViewModel.cs" /> + <Compile Include="Presentation\Screen.cs" /> + <Compile Include="Presentation\Settings\SettingsView.xaml.cs"> + <DependentUpon>SettingsView.xaml</DependentUpon> + </Compile> + <Compile Include="Presentation\UserProfile\UserProfileView.xaml.cs"> + <DependentUpon>UserProfileView.xaml</DependentUpon> + </Compile> + <Compile Include="Presentation\UserProfile\UserProfileViewModel.cs" /> <Compile Include="Styles\ApplicationStyle.cs" /> - <Compile Include="Presentation\Settings\SettingsWindowViewModel.cs" /> + <Compile Include="Presentation\Settings\SettingsViewModel.cs" /> <Compile Include="Messages\ApplicationStyleChangeMessage.cs" /> - <Compile Include="Presentation\MDI\TabMenu.xaml.cs"> - <DependentUpon>TabMenu.xaml</DependentUpon> + <Compile Include="Presentation\Menu\MenuView.xaml.cs"> + <DependentUpon>MenuView.xaml</DependentUpon> </Compile> <Compile Include="Presentation\Shell\MainWindow.xaml.cs"> <DependentUpon>MainWindow.xaml</DependentUpon> </Compile> <Compile Include="Presentation\Shell\MainWindowViewModel.cs" /> - <None Include="Presentation\MDI\MDIView.xaml.cs"> - <DependentUpon>MDIView.xaml</DependentUpon> - </None> - <None Include="Presentation\MDI\MDIViewModel.cs" /> - <Compile Include="Presentation\About\AboutView.xaml.cs"> - <DependentUpon>AboutView.xaml</DependentUpon> - </Compile> <Compile Include="Presentation\Exceptions\ExceptionDialog.xaml.cs"> <DependentUpon>ExceptionDialog.xaml</DependentUpon> </Compile> <Compile Include="IoCConfiguration.cs" /> <Compile Include="Locator.cs" /> <Compile Include="Presentation\About\AboutViewModel.cs" /> - <None Include="Presentation\Login\Login.xaml.cs"> - <DependentUpon>Login.xaml</DependentUpon> - </None> - <None Include="Presentation\Login\LoginViewModel.cs" /> - <None Include="Presentation\Login\UserLogin.cs" /> + <Compile Include="Presentation\Login\LoginViewModel.cs" /> + <Compile Include="Presentation\Login\UserLogin.cs" /> </ItemGroup> <ItemGroup> <Compile Include="Properties\AssemblyInfo.cs"> @@ -137,14 +142,6 @@ <AppDesigner Include="Properties\" /> </ItemGroup> <ItemGroup> - <None Include="Presentation\Login\Login.xaml"> - <Generator>MSBuild:Compile</Generator> - <SubType>Designer</SubType> - </None> - <None Include="Presentation\MDI\MDIView.xaml"> - <Generator>MSBuild:Compile</Generator> - <SubType>Designer</SubType> - </None> <Page Include="Presentation\About\AboutView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -153,11 +150,15 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> - <Page Include="Presentation\MDI\TabMenu.xaml"> + <Page Include="Presentation\Login\LoginView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="Presentation\Settings\SettingsWindow.xaml"> + <Page Include="Presentation\Menu\MenuView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + <Page Include="Presentation\Settings\SettingsView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> @@ -165,6 +166,10 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> + <Page Include="Presentation\UserProfile\UserProfileView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Styles\MetroWpf.Accents.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType>
--- a/MetroWpf/MetroWpf/Presentation/About/AboutView.xaml Mon Mar 12 23:05:21 2012 +0800 +++ b/MetroWpf/MetroWpf/Presentation/About/AboutView.xaml Wed Mar 14 01:23:18 2012 +0700 @@ -1,57 +1,23 @@ -<Window x:Class="MetroWpf.Presentation.About.AboutView" - xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" - xmlns:Behaviours="clr-namespace:MahApps.Metro.Behaviours;assembly=MahApps.Metro" - xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:About="clr-namespace:MetroWpf.Presentation.About" - mc:Ignorable="d" - ResizeMode="NoResize" - MouseLeftButtonDown="DragMoveWindow" - ShowInTaskbar="False" - Title="AboutView" Height="575" Width="450" WindowStartupLocation="CenterOwner" - d:DataContext="{d:DesignInstance About:AboutViewModel}"> +<UserControl + x:Class="MetroWpf.Presentation.About.AboutView" + 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" + mc:Ignorable="d" + DataContext="{Binding AboutViewModel, Source={StaticResource Locator}}"> - <Window.Resources> - <ResourceDictionary> - <ResourceDictionary.MergedDictionaries> - <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.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/BaseLight.xaml" /> - <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedSingleRowTabControl.xaml" /> - <ResourceDictionary Source="pack://application:,,,/MetroWpf;component/Xaml/Styles/MetroWpf.Accents.xaml" /> - </ResourceDictionary.MergedDictionaries> - </ResourceDictionary> - </Window.Resources> - <i:Interaction.Behaviors> - <Behaviours:BorderlessWindowBehavior ResizeWithGrip="False" /> - </i:Interaction.Behaviors> - - <Window.Background> - <LinearGradientBrush MappingMode="Absolute" StartPoint="0,0" EndPoint="0,180"> - <GradientStop Color="#FFDEDEDE" /> - <GradientStop Color="White" Offset="1" /> - </LinearGradientBrush> - </Window.Background> - - <Grid> - <Button x:Name="TryClose" Style="{DynamicResource ChromelessButtonStyle}" Content="r" - HorizontalAlignment="Right" - FontFamily="Marlett" - IsCancel="True" - Margin="0,8,8,0" Height="14" VerticalAlignment="Top" /> - <StackPanel Margin="60,10,60,0"> - <Image Margin="0" Source="{Binding ApplicationIcon, Mode=OneTime}" Height="150" Width="150" HorizontalAlignment="Center"/> - <TextBlock TextWrapping="Wrap" FontWeight="Bold" FontSize="69.333" HorizontalAlignment="Left" Margin="-4,0,0,0"><Run Text="{Binding ApplicationTitle, Mode=OneTime}"/></TextBlock> - <TextBlock Margin="0,-18,0,0" TextWrapping="Wrap" FontWeight="Bold" HorizontalAlignment="Left" Height="20.83"><Run Text="version "/><Run Text=" "/><Run Text="{Binding Version, Mode=OneTime}" /><Run Text=" "/><Run Text="{Binding Configuration, Mode=OneTime}" /></TextBlock> - <TextBlock TextWrapping="Wrap" Foreground="#FF41B1E1" Margin="0,-7,-0.001,0" VerticalAlignment="Bottom" HorizontalAlignment="Left" FontFamily="Segoe UI Light" FontSize="18.667"><Run Text="a silverblade technology project"/></TextBlock> - <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Margin="0,8,0,0" FontFamily="Segoe UI Light" FontSize="32" Text="by" /> - <TextBlock Text="{Binding Authors}" TextWrapping="Wrap" Margin="0,4,0,0" /> - <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Margin="0,10,0,0" FontFamily="Segoe UI Light" FontSize="32" ><Run Text="MetroWpf uses"/></TextBlock> - <TextBlock Text="{Binding Components}" TextWrapping="Wrap" Margin="0,4,0,0" /> - <Button x:Name="Visit" Content="Visit MetroWpf Website" HorizontalAlignment="Center" Margin="0,25,0,0" Style="{DynamicResource SquareButtonStyle}" Width="145"/> - </StackPanel> - </Grid> -</Window> + <Grid> + <StackPanel Margin="60,10,60,0"> + <Image Margin="0" Source="{Binding ApplicationIcon, Mode=OneTime}" Height="150" Width="150" HorizontalAlignment="Center"/> + <TextBlock TextWrapping="Wrap" FontWeight="Bold" FontSize="69.333" HorizontalAlignment="Left" Margin="-4,0,0,0"><Run Text="{Binding ApplicationTitle, Mode=OneTime}"/></TextBlock> + <TextBlock Margin="0,-18,0,0" TextWrapping="Wrap" FontWeight="Bold" HorizontalAlignment="Left" Height="20.83"><Run Text="version "/><Run Text=" "/><Run Text="{Binding Version, Mode=OneTime}" /><Run Text=" "/><Run Text="{Binding Configuration, Mode=OneTime}" /></TextBlock> + <TextBlock TextWrapping="Wrap" Foreground="#FF41B1E1" Margin="0,-7,-0.001,0" VerticalAlignment="Bottom" HorizontalAlignment="Left" FontFamily="Segoe UI Light" FontSize="18.667"><Run Text="a silverblade technology project"/></TextBlock> + <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Margin="0,8,0,0" FontFamily="Segoe UI Light" FontSize="32" Text="by" /> + <TextBlock Text="{Binding Authors}" TextWrapping="Wrap" Margin="0,4,0,0" /> + <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Margin="0,10,0,0" FontFamily="Segoe UI Light" FontSize="32" ><Run Text="MetroWpf uses"/></TextBlock> + <TextBlock Text="{Binding Components}" TextWrapping="Wrap" Margin="0,4,0,0" /> + <Button x:Name="Visit" Content="StevenHollidge.com" HorizontalAlignment="Center" Margin="0,25,0,0" Style="{DynamicResource SquareButtonStyle}" Width="145"/> + </StackPanel> + </Grid> +</UserControl> \ No newline at end of file
--- a/MetroWpf/MetroWpf/Presentation/About/AboutView.xaml.cs Mon Mar 12 23:05:21 2012 +0800 +++ b/MetroWpf/MetroWpf/Presentation/About/AboutView.xaml.cs Wed Mar 14 01:23:18 2012 +0700 @@ -1,20 +1,27 @@ -using System.Windows; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; namespace MetroWpf.Presentation.About { - public partial class AboutView : Window + /// <summary> + /// Interaction logic for AboutView.xaml + /// </summary> + public partial class AboutView : UserControl { public AboutView() { InitializeComponent(); } - - private void DragMoveWindow(object sender, MouseButtonEventArgs e) - { - if (e.RightButton != MouseButtonState.Pressed - && e.MiddleButton != MouseButtonState.Pressed) - DragMove(); - } } }
--- a/MetroWpf/MetroWpf/Presentation/About/AboutViewModel.cs Mon Mar 12 23:05:21 2012 +0800 +++ b/MetroWpf/MetroWpf/Presentation/About/AboutViewModel.cs Wed Mar 14 01:23:18 2012 +0700 @@ -55,9 +55,7 @@ { "MahApps.Metro", "Markdown", - "MVVM Light", - "Ninject", - "Ookii Dialogs" + "MVVM Light" }; public string Components {
--- a/MetroWpf/MetroWpf/Presentation/Login/Login.xaml Mon Mar 12 23:05:21 2012 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,125 +0,0 @@ -<chronos:WindowElement x:Class="Chronos.Views.Login" - xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" - xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" - xmlns:nRoute="http://nRoute/schemas/2010/xaml" - xmlns:chronos="http://chronos/schemas/2010/xaml" - Style="{StaticResource DefaultDialogWindowStyle}" - Background="{StaticResource GradientBackgroundBrush}" - StartupLocation="CenterParent" - Title="IDENTIFICATION" - ShowCloseButton="False"> - - <Grid x:Name="VisualRoot"> - <Grid.InputBindings> - <KeyBinding Gesture="CTRL+Enter" Command="{Binding InquiryCommand}" /> - </Grid.InputBindings> - - <Grid.RowDefinitions> - <RowDefinition Height="Auto" /> - <RowDefinition Height="10" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="90" /> - <RowDefinition Height="Auto" /> - </Grid.RowDefinitions> - - <Grid Grid.Row="0"> - <Border Grid.RowSpan="4" Grid.ColumnSpan="3" - BorderBrush="{StaticResource WindowBorderBrush}" - BorderThickness="1" - Background="{StaticResource GradientBackgroundBrush}" - Padding="3.5"> - <Grid VerticalAlignment="Top"> - <Grid.RowDefinitions> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - </Grid.RowDefinitions> - <Grid.ColumnDefinitions> - <ColumnDefinition Width="*" /> - <ColumnDefinition Width="*" /> - <ColumnDefinition Width="85" /> - </Grid.ColumnDefinitions> - - <TextBox Grid.Column="0" Grid.Row="0" - Text="{Binding UserId, Mode=TwoWay, ValidatesOnDataErrors=True}" - FontWeight="Bold" - IsEnabled="{Binding Path=PropertyStates[UserId].IsEditable}" - HorizontalAlignment="Left" VerticalAlignment="Center" - Width="220" MaxLength="50" Margin="3.5"> - <i:Interaction.Behaviors> - <chronos:TextBoxWatermarkBehavior Label="USERNAME" LabelStyle="{StaticResource WatermarkTextBlockStyle}" /> - </i:Interaction.Behaviors> - </TextBox> - - <PasswordBox Grid.Column="0" Grid.Row="1" - chronos:PasswordBoxHelper.BoundPassword="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=Default, ValidatesOnDataErrors=True}" - FontWeight="Bold" - IsEnabled="{Binding Path=PropertyStates[Password].IsEditable}" - HorizontalAlignment="Left" VerticalAlignment="Center" - Width="220" MaxLength="50" Margin="3.5"> - <i:Interaction.Behaviors> - <chronos:PasswordBoxWatermarkBehavior Label="PASSWORD" LabelStyle="{StaticResource WatermarkTextBlockStyle}" /> - </i:Interaction.Behaviors> - </PasswordBox> - - <Button Grid.Column="1" Grid.Row="1" - Style="{StaticResource HyperlinkButtonStyle}" - Margin="3.5" - Content="SIGN IN" - FontWeight="Bold" FontSize="10" - HorizontalAlignment="Left" - VerticalAlignment="Center" - Command="{Binding InquiryCommand}" - IsDefault="True"> - </Button> - - <CheckBox Grid.Column="0" Grid.Row="2" - FontSize="{StaticResource ControlContentFontSize}" - Content="Remember my password" - Margin="3.5" VerticalAlignment="Center" - Opacity="0.6" /> - <CheckBox Grid.Column="0" Grid.Row="3" - FontSize="{StaticResource ControlContentFontSize}" - Content="Remember me" - Margin="3.5" VerticalAlignment="Center" - Opacity="0.6" /> - <CheckBox Grid.Column="1" Grid.Row="3" - FontSize="{StaticResource ControlContentFontSize}" - Content="Sign me in automatically" - Margin="3.5" VerticalAlignment="Center" - Opacity="0.6" /> - </Grid> - </Border> - </Grid> - - <Button Grid.Row="2" - Style="{StaticResource MetroButtonStyle}" - FontWeight="Normal" FontSize="16" - Content="create new account" - HorizontalAlignment="Left" - VerticalAlignment="Bottom"> - </Button> - - <Button Grid.Row="3" - Style="{StaticResource MetroButtonStyle}" - FontWeight="Normal" FontSize="16" - Content="forgot your password" - HorizontalAlignment="Left" - VerticalAlignment="Top"> - </Button> - - <Button Grid.Row="5" - Style="{StaticResource HyperlinkButtonStyle}" - Margin="3.5" - FontWeight="Bold" - Content="CANCEL" - Command="{Binding CloseCommand}" - HorizontalAlignment="Right" VerticalAlignment="Center" - IsCancel="True"> - </Button> - </Grid> -</chronos:WindowElement>
--- a/MetroWpf/MetroWpf/Presentation/Login/Login.xaml.cs Mon Mar 12 23:05:21 2012 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -using Chronos.Modules.Navigation; -using Chronos.Presentation.Windows.Controls; -using Chronos.ViewModel; -using nRoute.Components.Composition; -using nRoute.Navigation.Mapping; -using nRoute.ViewModels; - -namespace Chronos.Views -{ - /// <summary> - /// Interaction logic for LoginView.xaml - /// </summary> - [MapNavigationContent(NavigationRoutes.Login)] - [DefineViewViewModel(typeof(Login), typeof(LoginViewModel))] - public partial class Login : WindowElement - { - #region · Constructors · - - [ResolveConstructor] - public Login([ResolveViewModel(typeof(Login))]LoginViewModel viewModel) - { - InitializeComponent(); - - this.DataContext = viewModel; - } - - #endregion - } -}
--- a/MetroWpf/MetroWpf/Presentation/Login/LoginViewModel.cs Mon Mar 12 23:05:21 2012 +0800 +++ b/MetroWpf/MetroWpf/Presentation/Login/LoginViewModel.cs Wed Mar 14 01:23:18 2012 +0700 @@ -1,31 +1,51 @@ using System; using System.Windows; using System.ComponentModel; +using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Command; namespace MetroWpf.Presentation.Login { /// <summary> /// Login view view model class /// </summary> - public sealed class LoginViewModel - : INotifyPropertyChanged + public sealed class LoginViewModel : + ViewModelBase { #region · Data Properties · /// <summary> + /// Gets or sets whether the form is busy + /// </summary> + private bool isBusy; + public bool IsBusy + { + get { return isBusy; } + set + { + if (this.isBusy != value) + { + this.isBusy = value; + RaisePropertyChanged("IsBusy"); + //relay requery? + } + } + } + + /// <summary> /// Gets or sets the user name /// </summary> + private string userId; public string UserId { - get { return this.Entity.UserId; } + get { return this.userId; } set { - if (this.Entity.UserId != value) + if (this.userId != value) { - this.Entity.UserId = value; - this.NotifyPropertyChanged(() => UserId); - - this.InquiryCommand.RequeryCanExecute(); + this.userId = value; + RaisePropertyChanged("UserId"); + //relay requery? } } } @@ -33,17 +53,17 @@ /// <summary> /// Gets or sets the password /// </summary> + private string password; public string Password { - get { return this.Entity.Password; } + get { return this.password; } set { - if (this.Entity.Password != value) + if (this.password != value) { - this.Entity.Password = value; - this.NotifyPropertyChanged(() => Password); - - this.InquiryCommand.RequeryCanExecute(); + this.password = value; + RaisePropertyChanged("Password"); + //relay requery? } } } @@ -58,77 +78,75 @@ public LoginViewModel() : base() { - } - - #endregion - - #region · Overriden Methods · - - public override bool CanClose() - { - return (this.ViewMode != ViewModeType.Busy); - } - - public override void Close() - { - this.GetService<IVirtualDesktopManager>().CloseDialog(); - Application.Current.Shutdown(); - } - - protected override void InitializePropertyStates() - { - this.PropertyStates.Add(e => e.UserId); - this.PropertyStates.Add(e => e.Password); - } - - protected override void OnViewModeChanged() - { - base.OnViewModeChanged(); - - if (this.PropertyStates.Count > 0) - { - this.PropertyStates[x => x.UserId].IsEditable = (this.ViewMode != ViewModeType.Busy); - this.PropertyStates[x => x.Password].IsEditable = (this.ViewMode != ViewModeType.Busy); - } + LoginCommand = new RelayCommand(LoginCommandExecute, CanLoginCommandExecute); + CloseCommand = new RelayCommand(CloseCommandExecute); } #endregion #region · Command Actions · - protected override bool CanInquiryData() + #region LoginCommand + + public RelayCommand LoginCommand { get; set; } + + private void LoginCommandExecute() { - return (!String.IsNullOrEmpty(this.UserId) && - !String.IsNullOrEmpty(this.Password) && - this.ViewMode != ViewModeType.Busy); } - protected override void OnInquiryAction(InquiryActionResult<UserLogin> result) + private bool CanLoginCommandExecute() { - result.Data = this.Entity; - result.Result = InquiryActionResultType.DataFetched; + if (string.IsNullOrEmpty(UserId) || + string.IsNullOrEmpty(Password)) + return false; + + return true; } - protected override void OnInquiryActionComplete(InquiryActionResult<UserLogin> result) + #endregion + + #region CloseCommand + public RelayCommand CloseCommand { get; set; } + + private void CloseCommandExecute() { - if (result.Result == InquiryActionResultType.DataFetched) - { - Channel<AuthenticationInfo>.Public.OnNext( - new AuthenticationInfo - { - Action = AuthenticationAction.LoggedIn, - UserId = this.UserId - }, true); + } + #endregion + // should fields be disabled when busy? + + //protected override bool CanInquiryData() + //{ + // return (!String.IsNullOrEmpty(this.UserId) && + // !String.IsNullOrEmpty(this.Password) && + // this.ViewMode != ViewModeType.Busy); + //} + + //protected override void OnInquiryAction(InquiryActionResult<UserLogin> result) + //{ + // result.Data = this.Entity; + // result.Result = InquiryActionResultType.DataFetched; + //} - ServiceLocator.GetService<IVirtualDesktopManager>().CloseDialog(); - } - else if (result.Result == InquiryActionResultType.DataNotFound) - { - this.NotificationMessage = "Username and password do not match."; + //protected override void OnInquiryActionComplete(InquiryActionResult<UserLogin> result) + //{ + // if (result.Result == InquiryActionResultType.DataFetched) + // { + // Channel<AuthenticationInfo>.Public.OnNext( + // new AuthenticationInfo + // { + // Action = AuthenticationAction.LoggedIn, + // UserId = this.UserId + // }, true); - this.ViewMode = ViewModeType.Default; - } - } + // ServiceLocator.GetService<IVirtualDesktopManager>().CloseDialog(); + // } + // else if (result.Result == InquiryActionResultType.DataNotFound) + // { + // this.NotificationMessage = "Username and password do not match."; + + // this.ViewMode = ViewModeType.Default; + // } + //} #endregion }
--- a/MetroWpf/MetroWpf/Presentation/Login/UserLogin.cs Mon Mar 12 23:05:21 2012 +0800 +++ b/MetroWpf/MetroWpf/Presentation/Login/UserLogin.cs Wed Mar 14 01:23:18 2012 +0700 @@ -4,8 +4,9 @@ namespace MetroWpf.Presentation.Login { - public sealed class UserLogin - : ObservableObject, IDataErrorInfo + public sealed class UserLogin : + ObservableObject, + IDataErrorInfo { #region · Fields · @@ -32,7 +33,6 @@ public string UserId { get; set; } public string Password { get; set; } - public int WorkYear { get; set; } #endregion
--- a/MetroWpf/MetroWpf/Presentation/MDI/MDIView.xaml Mon Mar 12 23:05:21 2012 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -<UserControl - x:Class="MarkPad.MDI.MDIView" - 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:cal="http://www.caliburnproject.org" mc:Ignorable="d" - d:DesignHeight="300" d:DesignWidth="300" -> - <UserControl.Resources> - <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" /> - </UserControl.Resources> - <TabControl x:Name="Items"> - <TabControl.ItemTemplate> - <DataTemplate> - <StackPanel Orientation="Horizontal"> - <TextBlock Text="{Binding DisplayName}" TextTrimming="CharacterEllipsis" MaxWidth="400"> - <TextBlock.ToolTip> - <ToolTip Content="{Binding DisplayName}" /> - </TextBlock.ToolTip> - </TextBlock> - <TextBlock Text="i" FontFamily="Marlett" Visibility="{Binding HasChanges, Converter={StaticResource BooleanToVisibilityConverter}}" /> - <Button - Style="{DynamicResource ChromelessButtonStyle}" - Margin="5,0,15,0" - FontFamily="Marlett" - FontSize="12" - Content="r" - cal:Message.Attach="DeactivateItem($dataContext, true)" - /> - </StackPanel> - </DataTemplate> - </TabControl.ItemTemplate> - </TabControl> -</UserControl>
--- a/MetroWpf/MetroWpf/Presentation/MDI/MDIView.xaml.cs Mon Mar 12 23:05:21 2012 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -using System.Windows.Controls; - -namespace MarkPad.MDI -{ - /// <summary> - /// Interaction logic for MDIView.xaml - /// </summary> - public partial class MDIView : UserControl - { - public MDIView() - { - InitializeComponent(); - } - } -}
--- a/MetroWpf/MetroWpf/Presentation/MDI/MDIViewModel.cs Mon Mar 12 23:05:21 2012 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -using Caliburn.Micro; - -namespace MarkPad.MDI -{ - public class MDIViewModel : Conductor<IScreen>.Collection.OneActive - { - public void Open(IScreen screen) - { - this.ActivateItem(screen); - } - } -}
--- a/MetroWpf/MetroWpf/Presentation/MDI/TabMenu.xaml Mon Mar 12 23:05:21 2012 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -<UserControl x:Class="MetroWpf.Presentation.MDI.TabMenu" - 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" - mc:Ignorable="d" - d:DesignHeight="300" d:DesignWidth="300"> - <Grid> - <TabControl> - <TabItem Header="_Home"> - <StackPanel Margin="25,10"> - - </StackPanel> - </TabItem> - - <TabItem Header="_Stocks"> - <StackPanel Margin="25,10"> - - </StackPanel> - </TabItem> - - <TabItem Header="_Rates"> - <StackPanel Margin="25,10"> - - </StackPanel> - </TabItem> - - <TabItem Header="_Sport"> - <StackPanel Margin="25,10"> - - </StackPanel> - </TabItem> - - <!-- Start of hidden tabs--> - <TabItem Name="tabItemUserProfile" Visibility="Collapsed" Header=""> - <StackPanel Margin="25,10"> - - </StackPanel> - </TabItem> - - <TabItem Name="tabItemSettings" Visibility="Collapsed" Header=""> - <StackPanel Margin="25,10"> - - </StackPanel> - </TabItem> - - <TabItem Name="tabItemAbout" Visibility="Collapsed" Header=""> - <StackPanel Margin="25,10"> - - </StackPanel> - </TabItem> - - <!-- End of hidden tabs--> - </TabControl> - </Grid> -</UserControl> \ No newline at end of file
--- a/MetroWpf/MetroWpf/Presentation/MDI/TabMenu.xaml.cs Mon Mar 12 23:05:21 2012 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -using System.Windows.Controls; - -namespace MetroWpf.Presentation.MDI -{ - /// <summary> - /// Interaction logic for TabMenu.xaml - /// </summary> - public partial class TabMenu : UserControl - { - public TabMenu() - { - InitializeComponent(); - } - } -}
--- a/MetroWpf/MetroWpf/Presentation/Settings/SettingsWindow.xaml Mon Mar 12 23:05:21 2012 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -<UserControl x:Class="MetroWpf.Presentation.Settings.SettingsWindow" - 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:MetroWpf.Presentation.Settings" - xmlns:s="clr-namespace:MetroWpf.Styles" - xmlns:System="clr-namespace:System;assembly=mscorlib" - mc:Ignorable="d" - d:DesignHeight="50" d:DesignWidth="350" - DataContext="{Binding SettingsWindowViewModel, Source={StaticResource Locator}}"> - <UserControl.Resources> - <ObjectDataProvider x:Key="ApplicationStyleEnum" - MethodName="GetValues" - ObjectType="{x:Type System:Enum}"> - <ObjectDataProvider.MethodParameters> - <x:Type TypeName="s:ApplicationStyle"/> - </ObjectDataProvider.MethodParameters> - </ObjectDataProvider> - </UserControl.Resources> - <Grid> - <StackPanel Orientation="Horizontal" VerticalAlignment="Top"> - <Label Width="50">Style:</Label> - <ComboBox Width="300" - ItemsSource="{Binding Source={StaticResource ApplicationStyleEnum}}" - SelectedItem="{Binding Path=SelectedApplicationStyle, Mode=TwoWay}"/> - </StackPanel> - </Grid> -</UserControl>
--- a/MetroWpf/MetroWpf/Presentation/Settings/SettingsWindow.xaml.cs Mon Mar 12 23:05:21 2012 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace MetroWpf.Presentation.Settings -{ - /// <summary> - /// Interaction logic for UserControl1.xaml - /// </summary> - public partial class SettingsWindow : UserControl - { - public SettingsWindow() - { - InitializeComponent(); - } - } -}
--- a/MetroWpf/MetroWpf/Presentation/Settings/SettingsWindowViewModel.cs Mon Mar 12 23:05:21 2012 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -using GalaSoft.MvvmLight; -using GalaSoft.MvvmLight.Messaging; -using MetroWpf.Messages; -using MetroWpf.Styles; - -namespace MetroWpf.Presentation.Settings -{ - public class SettingsWindowViewModel : ViewModelBase - { - ApplicationStyle _selectedApplicationStyle; - - public SettingsWindowViewModel() - { - _selectedApplicationStyle = ApplicationStyle.BlueLight; - } - - public ApplicationStyle SelectedApplicationStyle - { - get { return _selectedApplicationStyle; } - set - { - _selectedApplicationStyle = value; - RaisePropertyChanged("SelectedApplicationStyle"); - - Messenger.Default.Send( - new ApplicationStyleChangeMessage() - { ApplicationStyle = _selectedApplicationStyle }); - } - } - } -}
--- a/MetroWpf/MetroWpf/Presentation/Shell/MainWindow.xaml Mon Mar 12 23:05:21 2012 +0800 +++ b/MetroWpf/MetroWpf/Presentation/Shell/MainWindow.xaml Wed Mar 14 01:23:18 2012 +0700 @@ -6,13 +6,17 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" - xmlns:mdi="clr-namespace:MetroWpf.Presentation.MDI" + xmlns:presentation="clr-namespace:MetroWpf.Presentation" + xmlns:menu="clr-namespace:MetroWpf.Presentation.Menu" + xmlns:converters="clr-namespace:MetroWpf.Xaml.Converters;assembly=MetroWpf.Xaml" Title="Metro WPF Demo" Height="490" Width="660" Icon="../logo.ico" ShowIconOnTitleBar="true" - ShowTitleBar="true"> + ShowTitleBar="true" + WindowState="Maximized" + DataContext="{Binding MainWindowViewModel, Source={StaticResource Locator}}"> <Window.Resources> <ResourceDictionary> @@ -24,7 +28,6 @@ <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Icons/MergedResources.xaml" /> <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:,,,/MetroWpf.Xaml;component/Styles/MetroWpf.Accents.xaml" />--> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Window.Resources> @@ -32,12 +35,42 @@ <Controls:MetroContentControl> <Grid> - <mdi:TabMenu /> + <menu:MenuView /> - <StackPanel x:Name="TopRightOptions" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,4,0,0" Orientation="Horizontal"> - <Button x:Name="UserLogOnInfo" Content="stevenh" Style="{DynamicResource ChromelessButtonStyle}" FontSize="10.667" Margin="15,0,0,0" /> - <Button x:Name="ShowSettings" Content="settings" Style="{DynamicResource ChromelessButtonStyle}" FontSize="10.667" Margin="15,0,0,0" /> - <Button x:Name="ShowAbout" Content="about" Style="{DynamicResource ChromelessButtonStyle}" FontSize="10.667" Margin="15,0,20,0" /> + <StackPanel x:Name="TopRightOptions" + HorizontalAlignment="Right" + VerticalAlignment="Top" + Margin="0,4,0,0" + Orientation="Horizontal" + Visibility="{Binding ShowTopRightOptions, Converter={converters:BoolVisibilityConverter}}"> + <Button x:Name="UserLogOnInfo" + Content="stevenh" + Style="{DynamicResource ChromelessButtonStyle}" + FontSize="10.667" + Margin="15,0,0,0" + Command="{Binding Path=MenuCommand}" + CommandParameter="{x:Static presentation:Screen.UserProfile}" /> + <Button x:Name="ShowSettings" + Content="settings" + Style="{DynamicResource ChromelessButtonStyle}" + FontSize="10.667" + Margin="15,0,0,0" + Command="{Binding Path=MenuCommand}" + CommandParameter="{x:Static presentation:Screen.Settings}" /> + <Button x:Name="ShowAbout" + Content="about" + Style="{DynamicResource ChromelessButtonStyle}" + FontSize="10.667" + Margin="15,0,0,0" + Command="{Binding Path=MenuCommand}" + CommandParameter="{x:Static presentation:Screen.About}" /> + <Button x:Name="ShowHelp" + Content="help" + Style="{DynamicResource ChromelessButtonStyle}" + FontSize="10.667" + Margin="15,0,20,0" + Command="{Binding Path=MenuCommand}" + CommandParameter="{x:Static presentation:Screen.Help}" /> </StackPanel> </Grid> </Controls:MetroContentControl>
--- a/MetroWpf/MetroWpf/Presentation/Shell/MainWindow.xaml.cs Mon Mar 12 23:05:21 2012 +0800 +++ b/MetroWpf/MetroWpf/Presentation/Shell/MainWindow.xaml.cs Wed Mar 14 01:23:18 2012 +0700 @@ -1,9 +1,9 @@ using System.Windows.Input; using GalaSoft.MvvmLight.Messaging; -//using StockMarket.GUI.Assets; -//using StockMarket.GUI.Helpers; -//using StockMarket.GUI.Messages; -//using StockMarket.GUI.ViewModels; +using MetroWpf.Messages; +using MetroWpf.Styles; +using MahApps.Metro; +using System.Linq; namespace MetroWpf.Presentation.Shell { @@ -15,13 +15,39 @@ InitializeComponent(); // setup notifications - //Messenger.Default.Register<ApplicationStyleChangeMessage>( - // this, message => ChangeTheme(message.ApplicationStyle)); + Messenger.Default.Register<ApplicationStyleChangeMessage>( + this, message => ChangeTheme(message.ApplicationStyle)); } - //private void ChangeTheme(ApplicationStyle applicationStyle) - //{ - // new ApplicationStyleHelper().ChangeStyle(this, applicationStyle); - //} + private void ChangeTheme(ApplicationStyle applicationStyle) + { + switch (applicationStyle) + { + case ApplicationStyle.BlueLight: + ThemeManager.ChangeTheme(this, ThemeManager.DefaultAccents.First(a => a.Name == "Blue"), Theme.Light); + break; + case ApplicationStyle.BlueDark: + ThemeManager.ChangeTheme(this, ThemeManager.DefaultAccents.First(a => a.Name == "Blue"), Theme.Dark); + break; + case ApplicationStyle.GreenLight: + ThemeManager.ChangeTheme(this, ThemeManager.DefaultAccents.First(a => a.Name == "Green"), Theme.Light); + break; + case ApplicationStyle.GreenDark: + ThemeManager.ChangeTheme(this, ThemeManager.DefaultAccents.First(a => a.Name == "Green"), Theme.Dark); + break; + case ApplicationStyle.RedLight: + ThemeManager.ChangeTheme(this, ThemeManager.DefaultAccents.First(a => a.Name == "Red"), Theme.Light); + break; + case ApplicationStyle.RedDark: + ThemeManager.ChangeTheme(this, ThemeManager.DefaultAccents.First(a => a.Name == "Red"), Theme.Dark); + break; + case ApplicationStyle.PurpleLight: + ThemeManager.ChangeTheme(this, ThemeManager.DefaultAccents.First(a => a.Name == "Purple"), Theme.Light); + break; + case ApplicationStyle.PurpleDark: + ThemeManager.ChangeTheme(this, ThemeManager.DefaultAccents.First(a => a.Name == "Purple"), Theme.Dark); + break; + } + } } }
--- a/MetroWpf/MetroWpf/Presentation/Shell/MainWindowViewModel.cs Mon Mar 12 23:05:21 2012 +0800 +++ b/MetroWpf/MetroWpf/Presentation/Shell/MainWindowViewModel.cs Wed Mar 14 01:23:18 2012 +0700 @@ -1,14 +1,41 @@ using System.Windows.Threading; +using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Command; +using GalaSoft.MvvmLight.Messaging; +using MetroWpf.Messages; namespace MetroWpf.Presentation.Shell { - public class MainWindowViewModel + public class MainWindowViewModel : ViewModelBase { - private readonly Dispatcher _dispatcher; + private bool showTopRightOptions; + public bool ShowTopRightOptions + { + get { return showTopRightOptions; } + set + { + if (showTopRightOptions == value) + return; - public MainWindowViewModel(Dispatcher dispatcher) + showTopRightOptions = value; + RaisePropertyChanged("ShowTopRightOptions"); + } + } + + public RelayCommand<Screen> MenuCommand { get; set; } + + public MainWindowViewModel() { - _dispatcher = dispatcher; + MenuCommand = new RelayCommand<Screen>(MenuCommandExecute); + } + + private void MenuCommandExecute(Screen screen) + { + Messenger.Default.Send( + new NavigationMessage() + { + DisplayScreen = screen + }); } } } \ No newline at end of file