Mercurial > silverbladetech
changeset 17:7721a1270363
New files added during dev
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MetroWpf/MetroWpf.Xaml/Converters/EnumToIntConverter.cs Wed Mar 14 01:23:57 2012 +0700 @@ -0,0 +1,34 @@ +using System; +using System.Windows; +using System.Windows.Data; +using System.Windows.Markup; + +namespace MetroWpf.Xaml.Converters +{ + public class EnumToIntConverter : MarkupExtension, IValueConverter + { + private static EnumToIntConverter _enumToIntConverter = null; + + public override object ProvideValue(IServiceProvider serviceProvider) + { + if (null == _enumToIntConverter) + _enumToIntConverter = new EnumToIntConverter(); + + return _enumToIntConverter; + } + + #region IValueConverter Members + + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + return (int) value; + } + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotImplementedException(); + } + + #endregion + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MetroWpf/MetroWpf.Xaml/Events/WeakPropertyChangeNotifier.cs Wed Mar 14 01:23:57 2012 +0700 @@ -0,0 +1,111 @@ +using System; +using System.ComponentModel; +using System.Windows; +using System.Windows.Data; + +namespace MetroWpf.Xaml.Events +{ + /// <summary> + /// http://agsmith.wordpress.com/2008/04/07/propertydescriptor-addvaluechanged-alternative/ + /// </summary> + public sealed class WeakPropertyChangeNotifier + : DependencyObject, IDisposable + { + #region Member Variables + private readonly WeakReference _propertySource; + #endregion // Member Variables + + #region Constructor + public WeakPropertyChangeNotifier(DependencyObject propertySource, string path) + : this(propertySource, new PropertyPath(path)) + { + } + public WeakPropertyChangeNotifier(DependencyObject propertySource, DependencyProperty property) + : this(propertySource, new PropertyPath(property)) + { + } + public WeakPropertyChangeNotifier(DependencyObject propertySource, PropertyPath property) + { + if (null == propertySource) + throw new ArgumentNullException("propertySource"); + if (null == property) + throw new ArgumentNullException("property"); + + this._propertySource = new WeakReference(propertySource); + + var binding = new System.Windows.Data.Binding(); + binding.Path = property; + binding.Mode = BindingMode.OneWay; + binding.Source = propertySource; + BindingOperations.SetBinding(this, ValueProperty, binding); + } + #endregion // Constructor + + #region PropertySource + public DependencyObject PropertySource + { + get + { + try + { + // note, it is possible that accessing the target property + // will result in an exception so i’ve wrapped this check + // in a try catch + return this._propertySource.IsAlive + ? this._propertySource.Target as DependencyObject + : null; + } + catch + { + return null; + } + } + } + #endregion // PropertySource + + #region Value + /// <summary> + /// Identifies the <see cref="Value"/> dependency property + /// </summary> + public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", + typeof(object), typeof(WeakPropertyChangeNotifier), new FrameworkPropertyMetadata(null, new PropertyChangedCallback(OnPropertyChanged))); + + private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + WeakPropertyChangeNotifier notifier = (WeakPropertyChangeNotifier)d; + if (null != notifier.ValueChanged) + notifier.ValueChanged(notifier, EventArgs.Empty); + } + + /// <summary> + /// Returns/sets the value of the property + /// </summary> + /// <seealso cref="ValueProperty"/> + [Description("Returns/sets the value of the property")] + [Category("Behavior")] + [Bindable(true)] + public object Value + { + get + { + return (object)this.GetValue(ValueProperty); + } + set + { + this.SetValue(ValueProperty, value); + } + } + #endregion //Value + + #region Events + public event EventHandler ValueChanged; + #endregion // Events + + #region IDisposable Members + public void Dispose() + { + BindingOperations.ClearBinding(this, ValueProperty); + } + #endregion + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MetroWpf/MetroWpf/Messages/NavigationMessage.cs Wed Mar 14 01:23:57 2012 +0700 @@ -0,0 +1,10 @@ +using GalaSoft.MvvmLight.Messaging; +using MetroWpf.Presentation; + +namespace MetroWpf.Messages +{ + public class NavigationMessage : MessageBase + { + public Screen DisplayScreen { get; set; } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MetroWpf/MetroWpf/Presentation/Login/LoginView.xaml Wed Mar 14 01:23:57 2012 +0700 @@ -0,0 +1,106 @@ +<UserControl + x:Class="MetroWpf.Presentation.Login.LoginView" + 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" + DataContext="{Binding LoginViewModel, Source={StaticResource Locator}}" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="292" d:DesignWidth="392"> + + <Grid x:Name="VisualRoot"> + <Grid.InputBindings> + <KeyBinding Gesture="Enter" Command="{Binding LoginCommand}" /> + </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" + BorderThickness="1" + 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" + HorizontalAlignment="Left" VerticalAlignment="Center" + Width="220" MaxLength="50" Margin="3.5"> + </TextBox> + + + <!--chronos:PasswordBoxHelper.BoundPassword="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=Default, ValidatesOnDataErrors=True}"--> + <PasswordBox + Grid.Column="0" Grid.Row="1" + FontWeight="Bold" + HorizontalAlignment="Left" VerticalAlignment="Center" + Width="220" MaxLength="50" Margin="3.5"> + </PasswordBox> + + <Button Grid.Column="1" Grid.Row="1" + Margin="3.5" + Content="SIGN IN" + FontWeight="Bold" FontSize="10" + HorizontalAlignment="Left" + VerticalAlignment="Center" + Command="{Binding LoginCommand}" + IsDefault="True"> + </Button> + + <CheckBox Grid.Column="0" Grid.Row="2" + Content="Remember my password" + Margin="3.5" VerticalAlignment="Center" + Opacity="0.6" /> + <CheckBox Grid.Column="0" Grid.Row="3" + Content="Remember me" + Margin="3.5" VerticalAlignment="Center" + Opacity="0.6" /> + <CheckBox Grid.Column="1" Grid.Row="3" + Content="Sign me in automatically" + Margin="3.5" VerticalAlignment="Center" + Opacity="0.6" /> + </Grid> + </Border> + </Grid> + + <Button Grid.Row="2" + FontWeight="Normal" FontSize="16" + Content="create new account" + HorizontalAlignment="Left" + VerticalAlignment="Bottom"> + </Button> + + <Button Grid.Row="3" + FontWeight="Normal" FontSize="16" + Content="forgot your password" + HorizontalAlignment="Left" + VerticalAlignment="Top"> + </Button> + + <Button Grid.Row="5" + Margin="3.5" + FontWeight="Bold" + Content="CANCEL" + Command="{Binding CloseCommand}" + HorizontalAlignment="Right" VerticalAlignment="Center" + IsCancel="True"> + </Button> + </Grid> +</UserControl>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MetroWpf/MetroWpf/Presentation/Login/LoginView.xaml.cs Wed Mar 14 01:23:57 2012 +0700 @@ -0,0 +1,27 @@ +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.Login +{ + /// <summary> + /// Interaction logic for LoginView.xaml + /// </summary> + public partial class LoginView : UserControl + { + public LoginView() + { + InitializeComponent(); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MetroWpf/MetroWpf/Presentation/Menu/MenuView.xaml Wed Mar 14 01:23:57 2012 +0700 @@ -0,0 +1,61 @@ +<UserControl x:Class="MetroWpf.Presentation.Menu.MenuView" + 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:login="clr-namespace:MetroWpf.Presentation.Login" + xmlns:userprofile="clr-namespace:MetroWpf.Presentation.UserProfile" + xmlns:settings="clr-namespace:MetroWpf.Presentation.Settings" + xmlns:about="clr-namespace:MetroWpf.Presentation.About" + xmlns:converters="clr-namespace:MetroWpf.Xaml.Converters;assembly=MetroWpf.Xaml" + mc:Ignorable="d" + DataContext="{Binding MenuViewModel, Source={StaticResource Locator}}"> + <Grid> + <TabControl x:Name="tabHost" SelectedIndex="{Binding SelectedTabIndex, Converter={converters:EnumToIntConverter}}"> + + <TabItem Header="_Stocks" Visibility="{Binding ShowStocks, Converter={converters:BoolVisibilityConverter}}"> + <StackPanel Margin="25,10"> + + </StackPanel> + </TabItem> + + <TabItem Header="_Rates" Visibility="{Binding ShowFxRates, Converter={converters:BoolVisibilityConverter}}"> + <StackPanel Margin="25,10"> + + </StackPanel> + </TabItem> + + <!-- Start of hidden tabs--> + <TabItem Name="tabItemLogin" Visibility="{Binding ShowLogin, Converter={converters:BoolVisibilityConverter}}"> + <StackPanel Margin="25,10"> + <login:LoginView/> + </StackPanel> + </TabItem> + + <TabItem Name="tabItemUserProfile" Visibility="{Binding ShowUserProfile, Converter={converters:BoolVisibilityConverter}}"> + <StackPanel Margin="25,10"> + <userprofile:UserProfileView /> + </StackPanel> + </TabItem> + + <TabItem Name="tabItemSettings" Visibility="{Binding ShowSettings, Converter={converters:BoolVisibilityConverter}}"> + <StackPanel Margin="25,10"> + <settings:SettingsView /> + </StackPanel> + </TabItem> + + <TabItem Name="tabItemAbout" Visibility="{Binding ShowAbout, Converter={converters:BoolVisibilityConverter}}"> + <StackPanel Margin="25,10"> + <about:AboutView /> + </StackPanel> + </TabItem> + + <TabItem Name="tabItemHelp" Visibility="{Binding ShowHelp, Converter={converters:BoolVisibilityConverter}}"> + <StackPanel Margin="25,10"> + <about:AboutView /> + </StackPanel> + </TabItem> + <!-- End of hidden tabs--> + </TabControl> + </Grid> +</UserControl> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MetroWpf/MetroWpf/Presentation/Menu/MenuView.xaml.cs Wed Mar 14 01:23:57 2012 +0700 @@ -0,0 +1,17 @@ +using System.Windows.Controls; +using GalaSoft.MvvmLight.Messaging; +using MetroWpf.Messages; + +namespace MetroWpf.Presentation.Menu +{ + /// <summary> + /// Interaction logic for TabMenu.xaml + /// </summary> + public partial class MenuView : UserControl + { + public MenuView() + { + InitializeComponent(); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MetroWpf/MetroWpf/Presentation/Menu/MenuViewModel.cs Wed Mar 14 01:23:57 2012 +0700 @@ -0,0 +1,185 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Messaging; +using MetroWpf.Messages; + +namespace MetroWpf.Presentation.Menu +{ + public class MenuViewModel : ViewModelBase + { + private Screen selectedTabIndex; + public Screen SelectedTabIndex + { + get { return selectedTabIndex; } + set + { + if (selectedTabIndex == value) + return; + + selectedTabIndex = value; + RaisePropertyChanged("SelectedTabIndex"); + } + } + + private bool showStocks; + public bool ShowStocks + { + get { return showStocks; } + set + { + if (showStocks == value) + return; + + showStocks = value; + RaisePropertyChanged("ShowStocks"); + } + } + + private bool showFxRates; + public bool ShowFxRates + { + get { return showFxRates; } + set + { + if (showFxRates == value) + return; + + showFxRates = value; + RaisePropertyChanged("ShowFxRates"); + } + } + + private bool showLogin; + public bool ShowLogin + { + get { return showLogin; } + set + { + if (showLogin == value) + return; + + showLogin = value; + RaisePropertyChanged("ShowLogin"); + } + } + + private bool showUserProfile; + public bool ShowUserProfile + { + get { return showUserProfile; } + set + { + if (showUserProfile == value) + return; + + showUserProfile = value; + RaisePropertyChanged("ShowUserProfile"); + } + } + + private bool showSettings; + public bool ShowSettings + { + get { return showSettings; } + set + { + if (showSettings == value) + return; + + showSettings = value; + RaisePropertyChanged("ShowSettings"); + } + } + + private bool showAbout; + public bool ShowAbout + { + get { return showAbout; } + set + { + if (showAbout == value) + return; + + showAbout = value; + RaisePropertyChanged("ShowAbout"); + } + } + + private bool showHelp; + public bool ShowHelp + { + get { return showHelp; } + set + { + if (showHelp == value) + return; + + showHelp = value; + RaisePropertyChanged("ShowHelp"); + } + } + + public MenuViewModel() + { + Init(); + } + + private void Init() + { + Messenger.Default.Register<NavigationMessage>( + this, + message => ChangeDisplayScreen(message.DisplayScreen)); + + ChangeDisplayScreen(Screen.Login); + } + + private void ChangeDisplayScreen(Screen screen) + { + switch (screen) + { + case Screen.Login: + ShowStocks = false; + ShowFxRates = false; + ShowLogin = true; + ShowUserProfile = false; + ShowSettings = false; + ShowAbout = false; + ShowHelp = false; + break; + case Screen.UserProfile: + ShowLogin = false; + ShowUserProfile = true; + ShowSettings = false; + ShowAbout = false; + ShowHelp = false; + break; + case Screen.Settings: + ShowLogin = false; + ShowUserProfile = false; + ShowSettings = true; + ShowAbout = false; + ShowHelp = false; + break; + case Screen.About: + ShowLogin = false; + ShowUserProfile = false; + ShowSettings = false; + ShowAbout = true; + ShowHelp = false; + break; + case Screen.Help: + ShowLogin = false; + ShowUserProfile = false; + ShowSettings = false; + ShowAbout = false; + ShowHelp = true; + break; + } + + SelectedTabIndex = screen; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MetroWpf/MetroWpf/Presentation/Screen.cs Wed Mar 14 01:23:57 2012 +0700 @@ -0,0 +1,14 @@ + +namespace MetroWpf.Presentation +{ + public enum Screen + { + Stocks, + FxRates, + Login, + UserProfile, + Settings, + About, + Help + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MetroWpf/MetroWpf/Presentation/Settings/SettingsView.xaml Wed Mar 14 01:23:57 2012 +0700 @@ -0,0 +1,29 @@ +<UserControl x:Class="MetroWpf.Presentation.Settings.SettingsView" + 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 SettingsViewModel, 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>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MetroWpf/MetroWpf/Presentation/Settings/SettingsView.xaml.cs Wed Mar 14 01:23:57 2012 +0700 @@ -0,0 +1,27 @@ +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 SettingsView.xaml + /// </summary> + public partial class SettingsView : UserControl + { + public SettingsView() + { + InitializeComponent(); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MetroWpf/MetroWpf/Presentation/Settings/SettingsViewModel.cs Wed Mar 14 01:23:57 2012 +0700 @@ -0,0 +1,31 @@ +using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Messaging; +using MetroWpf.Messages; +using MetroWpf.Styles; + +namespace MetroWpf.Presentation.Settings +{ + public class SettingsViewModel : ViewModelBase + { + ApplicationStyle _selectedApplicationStyle; + + public SettingsViewModel() + { + _selectedApplicationStyle = ApplicationStyle.BlueLight; + } + + public ApplicationStyle SelectedApplicationStyle + { + get { return _selectedApplicationStyle; } + set + { + _selectedApplicationStyle = value; + RaisePropertyChanged("SelectedApplicationStyle"); + + Messenger.Default.Send( + new ApplicationStyleChangeMessage() + { ApplicationStyle = _selectedApplicationStyle }); + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MetroWpf/MetroWpf/Presentation/UserProfile/UserProfileView.xaml Wed Mar 14 01:23:57 2012 +0700 @@ -0,0 +1,11 @@ +<UserControl x:Class="MetroWpf.Presentation.UserProfile.UserProfileView" + 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 UserProfileViewModel, Source={StaticResource Locator}}"> + <Grid> + + </Grid> +</UserControl>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MetroWpf/MetroWpf/Presentation/UserProfile/UserProfileView.xaml.cs Wed Mar 14 01:23:57 2012 +0700 @@ -0,0 +1,27 @@ +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.UserProfile +{ + /// <summary> + /// Interaction logic for UserProfileView.xaml + /// </summary> + public partial class UserProfileView : UserControl + { + public UserProfileView() + { + InitializeComponent(); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MetroWpf/MetroWpf/Presentation/UserProfile/UserProfileViewModel.cs Wed Mar 14 01:23:57 2012 +0700 @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace MetroWpf.Presentation.UserProfile +{ + public class UserProfileViewModel + { + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MetroWpf/MetroWpf/Services/Interfaces/INavigationService.cs Wed Mar 14 01:23:57 2012 +0700 @@ -0,0 +1,9 @@ +using MetroWpf.Presentation; + +namespace MetroWpf.Services.Interfaces +{ + public interface INavigationService + { + void NavigateTo(Screen displayScreen); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MetroWpf/MetroWpf/Services/NavigationService.cs Wed Mar 14 01:23:57 2012 +0700 @@ -0,0 +1,21 @@ +using System; +using System.Windows.Controls; +using MetroWpf.Services.Interfaces; +using MetroWpf.Presentation; +using GalaSoft.MvvmLight.Messaging; +using MetroWpf.Messages; + +namespace MetroWpf.Services +{ + public class NavigationService : INavigationService + { + public void NavigateTo(Screen displayScreen) + { + Messenger.Default.Send( + new NavigationMessage() + { + DisplayScreen = displayScreen + }); + } + } +} \ No newline at end of file