# HG changeset patch
# User adminsh@apollo
# Date 1332274715 0
# Node ID a8b50a0875444edc1315a63885b800c11a892fee
# Parent 399398841fd06e46f58aad4ca05d00440b842821
Stocks and FxRates working, new menu introduced. Working nicely so far
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.Common/Ccy.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.Common/Ccy.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,16 @@
+namespace FxRates.Common
+{
+ public enum Ccy
+ {
+ EURtoUSD,
+ USDtoJPY,
+ GBPtoUSD,
+ EURtoGBP,
+ USDtoCHF,
+ EURtoJPY,
+ EURtoCHF,
+ USDtoCAD,
+ AUDtoUSD,
+ GBPtoJPY
+ }
+}
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.Common/FxRate.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.Common/FxRate.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,39 @@
+using System;
+
+namespace FxRates.Common
+{
+ public class FxRate : IFxRate
+ {
+ private FxRate(Ccy ccy, decimal bid, decimal offer, DateTime timestamp)
+ {
+ Ccy = ccy;
+ Bid = bid;
+ PreviousOffer = offer;
+ Offer = offer;
+ Timestamp = timestamp;
+ }
+
+ #region IFxRate Members
+
+ public decimal Bid { get; private set; }
+ public Ccy Ccy { get; private set; }
+ public decimal Offer { get; private set; }
+ public decimal PreviousOffer { get; private set; }
+ public DateTime Timestamp { get; private set; }
+
+ #endregion
+
+ public static FxRate Create(Ccy ccy, decimal bid, decimal offer, DateTime timestamp)
+ {
+ return new FxRate(ccy, bid, offer, timestamp);
+ }
+
+ public void UpdatePrice(decimal bid, decimal offer, DateTime timestamp)
+ {
+ Bid = bid;
+ PreviousOffer = Offer;
+ Offer = offer;
+ Timestamp = timestamp;
+ }
+ }
+}
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.Common/FxRates.Common.csproj
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.Common/FxRates.Common.csproj Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,53 @@
+
+
+
+ Debug
+ AnyCPU
+ 8.0.30703
+ 2.0
+ {789B8256-13E5-41B0-84B5-29A98A3F6E74}
+ Library
+ Properties
+ FxRates.Common
+ FxRates.Common
+ v4.0
+ 512
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.Common/IFxRate.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.Common/IFxRate.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,13 @@
+using System;
+
+namespace FxRates.Common
+{
+ public interface IFxRate
+ {
+ decimal Bid { get; }
+ Ccy Ccy { get; }
+ decimal Offer { get; }
+ decimal PreviousOffer { get; }
+ DateTime Timestamp { get; }
+ }
+}
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.Common/IPricingService.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.Common/IPricingService.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+namespace FxRates.Common
+{
+ public interface IPricingService
+ {
+ bool IsRunning { get; }
+ List GetFullCurrentPrices();
+ void Start();
+ void Stop();
+ event EventHandler PriceUpdate;
+ }
+}
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.Common/PriceUpdateEventArgs.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.Common/PriceUpdateEventArgs.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,9 @@
+using System;
+
+namespace FxRates.Common
+{
+ public class PriceUpdateEventArgs : EventArgs
+ {
+ public FxRate LatestPrice { get; set; }
+ }
+}
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.Common/Properties/AssemblyInfo.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.Common/Properties/AssemblyInfo.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,39 @@
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+
+[assembly: AssemblyTitle("FxRates.Common")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("FxRates.Common")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 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.
+
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+
+[assembly: Guid("bd6efb1c-907d-4a6f-9599-42e64a863603")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.Service/FxRates.Service.csproj
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.Service/FxRates.Service.csproj Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,56 @@
+
+
+
+ Debug
+ AnyCPU
+ 8.0.30703
+ 2.0
+ {0AFFFD20-14C7-44A9-B27E-93165001241C}
+ Library
+ Properties
+ FxRates.Service
+ FxRates.Service
+ v4.0
+ 512
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+ {789B8256-13E5-41B0-84B5-29A98A3F6E74}
+ FxRates.Common
+
+
+
+
+
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.Service/PriceFactory.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.Service/PriceFactory.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using FxRates.Common;
+
+namespace FxRates.Service
+{
+ class PriceFactory
+ {
+ private int _numberOfCcys;
+
+ public PriceFactory()
+ {
+ _numberOfCcys = (int) Enum.GetValues(typeof(Ccy)).Cast().Max() + 1;
+ }
+
+ public readonly List CurrentPrices = new List
+ {
+ FxRate.Create(Ccy.AUDtoUSD, (decimal) 1.0724, (decimal) 1.0731, DateTime.Now),
+ FxRate.Create(Ccy.EURtoCHF, (decimal) 1.2075, (decimal) 1.2094, DateTime.Now),
+ FxRate.Create(Ccy.EURtoGBP, (decimal) 0.8375, (decimal) 0.8401, DateTime.Now),
+ FxRate.Create(Ccy.EURtoJPY, (decimal) 103.2930, (decimal) 103.3180, DateTime.Now),
+ FxRate.Create(Ccy.EURtoUSD, (decimal) 1.3154, (decimal) 1.3276, DateTime.Now),
+ FxRate.Create(Ccy.GBPtoJPY, (decimal) 123.3250, (decimal) 123.3350, DateTime.Now),
+ FxRate.Create(Ccy.GBPtoUSD, (decimal) 1.5707, (decimal) 1.5723, DateTime.Now),
+ FxRate.Create(Ccy.USDtoCAD, (decimal) 0.9974, (decimal) 0.9999, DateTime.Now),
+ FxRate.Create(Ccy.USDtoCHF, (decimal) 0.9179, (decimal) 0.9191, DateTime.Now),
+ FxRate.Create(Ccy.USDtoJPY, (decimal) 78.5090, (decimal) 78.5187, DateTime.Now)
+ };
+
+ public FxRate GetNextPrice()
+ {
+ Random random = new Random();
+
+ var ccyIndex = random.Next(0, _numberOfCcys);
+ var rate = CurrentPrices[ccyIndex];
+
+ int randomSpread = random.Next(-100, 100);
+ decimal deltaPercentage = (decimal) randomSpread / 10000;
+ if (deltaPercentage != 0)
+ {
+ var bid = Math.Round(rate.Bid * (1 + deltaPercentage), 4);
+ var offer = Math.Round(rate.Offer * (1 + deltaPercentage), 4);
+ rate.UpdatePrice(bid, offer, DateTime.Now);
+ }
+ return rate;
+ }
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.Service/PricingService.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.Service/PricingService.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,47 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using FxRates.Common;
+using System.Collections.Generic;
+
+namespace FxRates.Service
+{
+ public class PricingService : IPricingService
+ {
+ PriceFactory factory;
+ bool _isRunning = false;
+ public bool IsRunning { get { return _isRunning; } }
+
+ public PricingService()
+ {
+ factory = new PriceFactory();
+ }
+
+ public void Start()
+ {
+ Task.Factory.StartNew(() =>
+ {
+ _isRunning = true;
+ while (_isRunning)
+ {
+ Thread.Sleep(10);
+ if (PriceUpdate == null) continue;
+ var latestPrice = factory.GetNextPrice();
+ PriceUpdate(null, new PriceUpdateEventArgs { LatestPrice = latestPrice });
+ }
+ });
+ }
+
+ public void Stop()
+ {
+ _isRunning = false;
+ }
+
+ public List GetFullCurrentPrices()
+ {
+ return factory.CurrentPrices;
+ }
+
+ public event EventHandler PriceUpdate;
+ }
+}
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.Service/Properties/AssemblyInfo.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.Service/Properties/AssemblyInfo.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("FxRates.Service")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("FxRates.Service")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 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.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("9a0b61cc-fb8c-4208-8248-90665e07b757")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Controls/TimerTextBlock.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.UI/Controls/TimerTextBlock.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,187 @@
+using System;
+using System.Threading;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+
+namespace FxRates.UI.Controls
+{
+ public delegate void Invoker();
+
+ public class TimerTextBlock : TextBlock
+ {
+ //private static Timer _UpdateTimer = new Timer(UpdateTimer, null, 1000, 1000);
+
+ public static readonly DependencyProperty TimeSpanProperty =
+ DependencyProperty.Register("TimeSpan", typeof (TimeSpan), typeof (TimerTextBlock),
+ new UIPropertyMetadata(TimeSpan.Zero));
+
+ public static readonly DependencyProperty IsStartedProperty =
+ DependencyProperty.Register("IsStarted", typeof (bool), typeof (TimerTextBlock),
+ new UIPropertyMetadata(false));
+
+ public static readonly DependencyProperty TimeFormatProperty =
+ DependencyProperty.Register("TimeFormat", typeof (string), typeof (TimerTextBlock),
+ new UIPropertyMetadata(null));
+
+ public static readonly DependencyProperty IsCountDownProperty =
+ DependencyProperty.Register("IsCountDown", typeof (bool), typeof (TimerTextBlock),
+ new UIPropertyMetadata(false));
+
+ private Invoker _UpdateTimeInvoker;
+
+ public TimerTextBlock()
+ {
+ Init();
+ }
+
+ public TimerTextBlock(Inline inline) : base(inline)
+ {
+ Init();
+ }
+
+ ///
+ /// Represents the time remaining for the count down to complete if
+ /// the control is initialized as a count down timer otherwise, it
+ /// represents the time elapsed since the timer has started.
+ ///
+ ///
+ ///
+ public TimeSpan TimeSpan
+ {
+ get { return (TimeSpan) GetValue(TimeSpanProperty); }
+ set
+ {
+ if (value < TimeSpan.Zero)
+ throw new ArgumentException();
+
+ SetValue(TimeSpanProperty, value);
+ }
+ }
+
+ // Using a DependencyProperty as the backing store for TimeSpan. This enables animation, styling, binding, etc...
+
+ public bool IsStarted
+ {
+ get { return (bool) GetValue(IsStartedProperty); }
+ set { SetValue(IsStartedProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for IsStarted. This enables animation, styling, binding, etc...
+
+ ///
+ /// Format string for displaying the time span value.
+ ///
+ public string TimeFormat
+ {
+ get { return (string) GetValue(TimeFormatProperty); }
+ set { SetValue(TimeFormatProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for TimeFormat. This enables animation, styling, binding, etc...
+
+ ///
+ /// Represents whether the control is a CountDown or regular timer.
+ ///
+ public bool IsCountDown
+ {
+ get { return (bool) GetValue(IsCountDownProperty); }
+ set { SetValue(IsCountDownProperty, value); }
+ }
+
+ public event EventHandler OnCountDownComplete;
+
+ private static event EventHandler OnTick;
+
+ private void Init()
+ {
+ Loaded += TimerTextBlock_Loaded;
+ Unloaded += TimerTextBlock_Unloaded;
+ }
+
+ ~TimerTextBlock()
+ {
+ Dispose();
+ }
+
+ public void Dispose()
+ {
+ OnTick -= TimerTextBlock_OnTick;
+ }
+
+ // Using a DependencyProperty as the backing store for IsCountDown. This enables animation, styling, binding, etc...
+
+ ///
+ /// Sets the time span to zero and stops the timer.
+ ///
+ public void Reset()
+ {
+ IsStarted = false;
+ TimeSpan = TimeSpan.Zero;
+ }
+
+ private static void UpdateTimer(object state)
+ {
+ EventHandler onTick = OnTick;
+ if (onTick != null)
+ onTick(null, EventArgs.Empty);
+ }
+
+ private void TimerTextBlock_Loaded(object sender, RoutedEventArgs e)
+ {
+ var binding = new Binding("TimeSpan");
+ binding.Source = this;
+ binding.Mode = BindingMode.OneWay;
+ binding.StringFormat = TimeFormat;
+
+ SetBinding(TextProperty, binding);
+
+ _UpdateTimeInvoker = UpdateTime;
+
+ OnTick += TimerTextBlock_OnTick;
+ }
+
+ private void TimerTextBlock_Unloaded(object sender, RoutedEventArgs e)
+ {
+ OnTick -= TimerTextBlock_OnTick;
+ }
+
+ private void TimerTextBlock_OnTick(object sender, EventArgs e)
+ {
+ Dispatcher.Invoke(_UpdateTimeInvoker);
+ }
+
+ private void UpdateTime()
+ {
+ if (IsStarted)
+ {
+ TimeSpan step = TimeSpan.FromSeconds(1);
+ if (IsCountDown)
+ {
+ if (TimeSpan >= TimeSpan.FromSeconds(1))
+ {
+ TimeSpan -= step;
+ if (TimeSpan.TotalSeconds <= 0)
+ {
+ TimeSpan = TimeSpan.Zero;
+ IsStarted = false;
+ NotifyCountDownComplete();
+ }
+ }
+ }
+ else
+ {
+ TimeSpan += step;
+ }
+ }
+ }
+
+ private void NotifyCountDownComplete()
+ {
+ EventHandler handler = OnCountDownComplete;
+ if (handler != null)
+ handler(this, EventArgs.Empty);
+ }
+ }
+}
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Converters/AbsoluteNumberConverter.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.UI/Converters/AbsoluteNumberConverter.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,22 @@
+using System;
+using System.Windows.Data;
+
+namespace FxRates.UI.Converters
+{
+ public class AbsoluteNumberConverter : IValueConverter
+ {
+ #region IValueConverter Members
+
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ return Math.Abs((decimal) value);
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Converters/BoolToServiceRunningTextConverter.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.UI/Converters/BoolToServiceRunningTextConverter.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,22 @@
+using System;
+using System.Windows.Data;
+
+namespace FxRates.UI.Converters
+{
+ public class BoolToServiceRunningTextConverter : IValueConverter
+ {
+ #region IValueConverter Members
+
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ return (bool) value ? "Service Running" : "Service Stopped";
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Converters/BoolToSubscribedTextConverter.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.UI/Converters/BoolToSubscribedTextConverter.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,22 @@
+using System;
+using System.Windows.Data;
+
+namespace FxRates.UI.Converters
+{
+ public class BoolToSubscribedTextConverter : IValueConverter
+ {
+ #region IValueConverter Members
+
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ return (bool) value ? "Subscribed" : "Unsubscribed";
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Converters/CcyFromIconConverter.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.UI/Converters/CcyFromIconConverter.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,23 @@
+using System;
+using System.Windows.Data;
+using FxRates.UI.Helpers;
+
+namespace FxRates.UI.Converters
+{
+ public class CcyFromIconConverter : IValueConverter
+ {
+ #region IValueConverter Members
+
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ return IconHelper.GetCcyIcon(value.ToString().Substring(0,3));
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Converters/CcyToDisplayNameConverter.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.UI/Converters/CcyToDisplayNameConverter.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,78 @@
+using System;
+using System.Windows.Data;
+using FxRates.Common;
+
+namespace FxRates.UI.Converters
+{
+ public class CcyToDisplayNameConverter : IValueConverter
+ {
+ #region IValueConverter Members
+
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ string result;
+ try
+ {
+ switch ((Ccy)value)
+ {
+ case Ccy.AUDtoUSD:
+ result = "AUD to USD";
+ break;
+
+ case Ccy.EURtoCHF:
+ result = "EUR to CHF";
+ break;
+
+ case Ccy.EURtoGBP:
+ result = "EUR to GBP";
+ break;
+
+ case Ccy.EURtoJPY:
+ result = "EUR to JPY";
+ break;
+
+ case Ccy.EURtoUSD:
+ result = "EUR to USD";
+ break;
+
+ case Ccy.GBPtoJPY:
+ result = "GBP to JPY";
+ break;
+
+ case Ccy.GBPtoUSD:
+ result = "GBP to USD";
+ break;
+
+ case Ccy.USDtoCAD:
+ result = "USD to CAD";
+ break;
+
+ case Ccy.USDtoCHF:
+ result = "USD to CHF";
+ break;
+
+ case Ccy.USDtoJPY:
+ result = "USD to JPY";
+ break;
+
+ default:
+ result = "Unknown";
+ break;
+ }
+ }
+ catch
+ {
+ result = "Unknown";
+ }
+
+ return result;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Converters/CcyToIconConverter.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.UI/Converters/CcyToIconConverter.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,23 @@
+using System;
+using System.Windows.Data;
+using FxRates.UI.Helpers;
+
+namespace FxRates.UI.Converters
+{
+ public class CcyToIconConverter : IValueConverter
+ {
+ #region IValueConverter Members
+
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ return IconHelper.GetCcyIcon(value.ToString().Substring(5, 3));
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Converters/DateTimeToTimeConverter.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.UI/Converters/DateTimeToTimeConverter.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,24 @@
+using System;
+using System.Windows.Data;
+
+namespace FxRates.UI.Converters
+{
+ public class DateTimeToTimeConverter : IValueConverter
+ {
+ #region IValueConverter Members
+
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ string dateTimeString = ((DateTime) value).ToString("HH:mm:ss.ffff");
+
+ return dateTimeString;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Converters/DeltaToIconConverter.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.UI/Converters/DeltaToIconConverter.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,46 @@
+using System;
+using System.Windows.Data;
+using System.Windows.Media.Imaging;
+
+namespace FxRates.UI.Converters
+{
+ public class DeltaToIconConverter : IValueConverter
+ {
+ #region IValueConverter Members
+
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ string uri;
+ BitmapImage image;
+ decimal delta;
+ string file = "UNK";
+
+ try
+ {
+ delta = (decimal) value;
+ {
+ if (delta > 0)
+ file = "UP";
+ else if (delta < 0)
+ file = "DOWN";
+ else
+ file = "LEVEL";
+ }
+ }
+ finally
+ {
+ uri = string.Format("../Images/{0}.png", file);
+ image = new BitmapImage(new Uri(uri, UriKind.Relative));
+ }
+
+ return image;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/FxRates.UI.csproj
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.UI/FxRates.UI.csproj Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,113 @@
+
+
+
+ Debug
+ AnyCPU
+ 8.0.30703
+ 2.0
+ {4BD124E6-F437-47F4-93C9-E09170EB06A2}
+ Library
+ Properties
+ FxRates.UI
+ FxRates.UI
+ v4.0
+ 512
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ ..\Libs\MvvmLight.4.0.0\GalaSoft.MvvmLight.WPF4.dll
+
+
+
+
+
+
+ ..\Libs\Rx-Main.1.0.11226\lib\Net4\System.Reactive.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ FxRatesView.xaml
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {789B8256-13E5-41B0-84B5-29A98A3F6E74}
+ FxRates.Common
+
+
+
+
+
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Helpers/IconHelper.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.UI/Helpers/IconHelper.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,26 @@
+using System;
+using System.Windows.Media.Imaging;
+
+namespace FxRates.UI.Helpers
+{
+ class IconHelper
+ {
+ public static BitmapImage GetCcyIcon(string isocode)
+ {
+ string uri;
+ BitmapImage image;
+ try
+ {
+ uri = string.Format("../Images/{0}.png", isocode);
+ image = new BitmapImage(new Uri(uri, UriKind.Relative));
+ }
+ catch
+ {
+ uri = string.Format("../Images/{0}.png", "UNK");
+ image = new BitmapImage(new Uri(uri, UriKind.Relative));
+ }
+
+ return image;
+ }
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Helpers/XamlHelper.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.UI/Helpers/XamlHelper.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,22 @@
+using System.Windows;
+using System.Windows.Media;
+
+namespace FxRates.UI.Helpers
+{
+ public static class XamlHelper
+ {
+ ///
+ /// Finds a parent of a given control/item on the visual tree.
+ ///
+ /// Type of Parent
+ /// Child whose parent is queried
+ /// Returns the first parent item that matched the type (T), if no match found then it will return null
+ public static T TryFindParent(this DependencyObject child) where T : DependencyObject
+ {
+ var parentObject = VisualTreeHelper.GetParent(child);
+ if (parentObject == null) return null;
+ var parent = parentObject as T;
+ return parent ?? TryFindParent(parentObject);
+ }
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Images/AUD.png
Binary file MetroWpf/FxRates.UI/Images/AUD.png has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Images/BRL.png
Binary file MetroWpf/FxRates.UI/Images/BRL.png has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Images/CAD.png
Binary file MetroWpf/FxRates.UI/Images/CAD.png has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Images/CHF.png
Binary file MetroWpf/FxRates.UI/Images/CHF.png has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Images/CNY.png
Binary file MetroWpf/FxRates.UI/Images/CNY.png has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Images/DOWN.png
Binary file MetroWpf/FxRates.UI/Images/DOWN.png has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Images/EUR.png
Binary file MetroWpf/FxRates.UI/Images/EUR.png has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Images/GBP.png
Binary file MetroWpf/FxRates.UI/Images/GBP.png has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Images/INR.png
Binary file MetroWpf/FxRates.UI/Images/INR.png has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Images/JPY.png
Binary file MetroWpf/FxRates.UI/Images/JPY.png has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Images/LEVEL.png
Binary file MetroWpf/FxRates.UI/Images/LEVEL.png has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Images/NZD.png
Binary file MetroWpf/FxRates.UI/Images/NZD.png has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Images/RUB.png
Binary file MetroWpf/FxRates.UI/Images/RUB.png has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Images/THB.png
Binary file MetroWpf/FxRates.UI/Images/THB.png has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Images/UNK.png
Binary file MetroWpf/FxRates.UI/Images/UNK.png has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Images/UP.png
Binary file MetroWpf/FxRates.UI/Images/UP.png has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Images/USD.png
Binary file MetroWpf/FxRates.UI/Images/USD.png has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Images/ZAR.png
Binary file MetroWpf/FxRates.UI/Images/ZAR.png has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Images/help.png
Binary file MetroWpf/FxRates.UI/Images/help.png has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Models/DisplayFxRate.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.UI/Models/DisplayFxRate.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,138 @@
+using System;
+using FxRates.Common;
+using GalaSoft.MvvmLight;
+
+namespace FxRates.UI.Models
+{
+ public class DisplayFxRate : ObservableObject, IFxRate
+ {
+ private DisplayFxRate() { }
+
+ public static DisplayFxRate Create(FxRate rate)
+ {
+ var display = new DisplayFxRate()
+ {
+ Ccy = rate.Ccy,
+ Bid = rate.Bid,
+ Offer = rate.Offer,
+ PreviousOffer = rate.PreviousOffer,
+ Timestamp = rate.Timestamp,
+ Spread = getSpread(rate),
+ Delta = getDelta(rate)
+ };
+
+ return display;
+ }
+
+ public void Update(FxRate rate)
+ {
+ this.Bid = rate.Bid;
+ this.Offer = rate.Offer;
+ this.PreviousOffer = rate.PreviousOffer;
+ this.Timestamp = rate.Timestamp;
+ this.Spread = getSpread(rate);
+ this.Delta = getDelta(rate);
+ }
+
+ private static decimal getSpread(IFxRate rate)
+ {
+ return Math.Round(rate.Offer - rate.Bid, 4);
+ }
+
+ private static decimal getDelta(IFxRate rate)
+ {
+ return Math.Round(rate.Offer - rate.PreviousOffer, 4);
+ }
+
+ public const string CcyPropertyName = "Ccy";
+ private Ccy _ccy;
+ public Ccy Ccy
+ {
+ get { return _ccy; }
+ private set
+ {
+ if (_ccy == value) return;
+ _ccy = value;
+ RaisePropertyChanged(CcyPropertyName);
+ }
+ }
+
+ public const string BidPropertyName = "Bid";
+ private decimal _bid = 0;
+ public decimal Bid
+ {
+ get { return _bid; }
+ private set
+ {
+ if (_bid == value) return;
+ _bid = value;
+ RaisePropertyChanged(BidPropertyName);
+ }
+ }
+
+ public const string OfferPropertyName = "Offer";
+ private decimal _offer = 0;
+ public decimal Offer
+ {
+ get { return _offer; }
+ private set
+ {
+ if (_offer == value) return;
+ _offer = value;
+ RaisePropertyChanged(OfferPropertyName);
+ }
+ }
+
+ public const string PreviousOfferPropertyName = "PreviousOffer";
+ private decimal _previousOffer = 0;
+ public decimal PreviousOffer
+ {
+ get { return _previousOffer; }
+ private set
+ {
+ if (_previousOffer == value) return;
+ _previousOffer = value;
+ RaisePropertyChanged(PreviousOfferPropertyName);
+ }
+ }
+
+ public const string DeltaPropertyName = "Delta";
+ private decimal _delta = 0;
+ public decimal Delta
+ {
+ get { return _delta; }
+ private set
+ {
+ if (_delta == value) return;
+ _delta = value;
+ RaisePropertyChanged(DeltaPropertyName);
+ }
+ }
+
+ public const string SpreadPropertyName = "Spread";
+ private decimal _spread = 0;
+ public decimal Spread
+ {
+ get { return _spread; }
+ private set
+ {
+ if (_spread == value) return;
+ _spread = value;
+ RaisePropertyChanged(SpreadPropertyName);
+ }
+ }
+
+ public const string TimestampPropertyName = "Timestamp";
+ private DateTime _timestamp = DateTime.MinValue;
+ public DateTime Timestamp
+ {
+ get { return _timestamp;}
+ private set
+ {
+ if (_timestamp == value) return;
+ _timestamp = value;
+ RaisePropertyChanged(TimestampPropertyName);
+ }
+ }
+ }
+}
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Properties/AssemblyInfo.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.UI/Properties/AssemblyInfo.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("FxRates.UI")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("FxRates.UI")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 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.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("d7408b4d-c599-40a9-88be-099fc8f6c3ed")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/ViewModels/FxRatesViewModel.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.UI/ViewModels/FxRatesViewModel.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,109 @@
+using System;
+using System.ComponentModel;
+using System.Linq;
+using System.Reactive;
+using System.Reactive.Linq;
+using System.Windows.Input;
+using FxRates.Common;
+using FxRates.UI.Models;
+using GalaSoft.MvvmLight;
+using GalaSoft.MvvmLight.Command;
+
+namespace FxRates.UI.ViewModels
+{
+ public class FxRatesViewModel : ViewModelBase
+ {
+ private IPricingService pricingService;
+
+ public BindingList DisplayFxRates { get; set; }
+ public ICommand ServiceRunningCommand { get; set; }
+ public ICommand SubscriptionCommand { get; set; }
+
+ public FxRatesViewModel(IPricingService service)
+ {
+ pricingService = service;
+ GetLatestPrices();
+
+ SubscriptionCommand = new RelayCommand(SubscriptionCommand_Execute);
+ ServiceRunningCommand = new RelayCommand(ServiceRunningCommand_Execute);
+
+ var priceUpdates = Observable.FromEventPattern(
+ pricingService, "PriceUpdate");
+
+ priceUpdates.Where(e => (Subscribed)
+ // && (e.EventArgs.LatestPrice.Ccy == Ccy.EURtoGBP) example of filter
+ )
+ //.Throttle(TimeSpan.FromSeconds(1)) example of throttling
+ .Subscribe(PriceUpdate);
+ }
+
+ public void PriceUpdate(EventPattern e)
+ {
+ var displayRate = DisplayFxRates.First(rate => rate.Ccy == e.EventArgs.LatestPrice.Ccy);
+
+ if (displayRate != null)
+ displayRate.Update(e.EventArgs.LatestPrice);
+ }
+
+
+ private void GetLatestPrices()
+ {
+ DisplayFxRates = new BindingList();
+ var currentRates = pricingService.GetFullCurrentPrices();
+ foreach (var latestRate in currentRates)
+ {
+ var displayRate = DisplayFxRate.Create(latestRate);
+ DisplayFxRates.Add(displayRate);
+ }
+ }
+
+ private const string SubscribedPropertyName = "Subscribed";
+ private bool _subscribed = false;
+ public bool Subscribed
+ {
+ get { return _subscribed; }
+ set
+ {
+ if (_subscribed == value) return;
+ _subscribed = value;
+ RaisePropertyChanged(SubscribedPropertyName);
+ }
+ }
+
+ private const string ServiceRunningPropertyName = "ServiceRunning";
+ private bool _serviceRunning;
+ public bool ServiceRunning
+ {
+ get
+ {
+ return _serviceRunning;
+ }
+ set
+ {
+ if (_serviceRunning == value) return;
+ _serviceRunning = value;
+ RaisePropertyChanged(ServiceRunningPropertyName);
+ }
+ }
+
+ void ServiceRunningCommand_Execute()
+ {
+ if (pricingService.IsRunning)
+ {
+ pricingService.Stop();
+ ServiceRunning = false;
+ }
+ else
+ {
+ pricingService.Start();
+ ServiceRunning = true;
+ }
+ }
+
+ void SubscriptionCommand_Execute()
+ {
+ //toggle subscribed
+ Subscribed = !Subscribed;
+ }
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Views/FxRatesView.xaml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.UI/Views/FxRatesView.xaml Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,98 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/FxRates.UI/Views/FxRatesView.xaml.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/FxRates.UI/Views/FxRatesView.xaml.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,15 @@
+using System.Windows.Controls;
+
+namespace FxRates.UI.Views
+{
+ ///
+ /// Interaction logic for FxRatesView.xaml
+ ///
+ public partial class FxRatesView
+ {
+ public FxRatesView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf.Framework/MetroWpf.Framework.csproj
--- a/MetroWpf/MetroWpf.Framework/MetroWpf.Framework.csproj Tue Mar 20 16:53:29 2012 +0000
+++ b/MetroWpf/MetroWpf.Framework/MetroWpf.Framework.csproj Tue Mar 20 20:18:35 2012 +0000
@@ -37,9 +37,6 @@
-
-
-
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf.Services/Interfaces/IInitialize.cs
--- a/MetroWpf/MetroWpf.Services/Interfaces/IInitialize.cs Tue Mar 20 16:53:29 2012 +0000
+++ b/MetroWpf/MetroWpf.Services/Interfaces/IInitialize.cs Tue Mar 20 20:18:35 2012 +0000
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Text;
namespace MetroWpf.Services.Interfaces
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf.Services/MetroWpf.Services.csproj
--- a/MetroWpf/MetroWpf.Services/MetroWpf.Services.csproj Tue Mar 20 16:53:29 2012 +0000
+++ b/MetroWpf/MetroWpf.Services/MetroWpf.Services.csproj Tue Mar 20 20:18:35 2012 +0000
@@ -31,20 +31,8 @@
4
-
- ..\Libs\MvvmLight.Extras.4.0.0\GalaSoft.MvvmLight.Extras.WPF4.dll
-
-
- ..\Libs\MvvmLight.4.0.0\GalaSoft.MvvmLight.WPF4.dll
-
-
-
-
-
-
-
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf.Services/Windows/WindowManager.cs
--- a/MetroWpf/MetroWpf.Services/Windows/WindowManager.cs Tue Mar 20 16:53:29 2012 +0000
+++ b/MetroWpf/MetroWpf.Services/Windows/WindowManager.cs Tue Mar 20 20:18:35 2012 +0000
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Text;
namespace MetroWpf.Services.Windows
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf.Xaml/Extensions/AdornerExtensions.cs
--- a/MetroWpf/MetroWpf.Xaml/Extensions/AdornerExtensions.cs Tue Mar 20 16:53:29 2012 +0000
+++ b/MetroWpf/MetroWpf.Xaml/Extensions/AdornerExtensions.cs Tue Mar 20 20:18:35 2012 +0000
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Text;
using System.Windows.Documents;
using System.Windows;
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf.Xaml/MetroWpf.Xaml.csproj
--- a/MetroWpf/MetroWpf.Xaml/MetroWpf.Xaml.csproj Tue Mar 20 16:53:29 2012 +0000
+++ b/MetroWpf/MetroWpf.Xaml/MetroWpf.Xaml.csproj Tue Mar 20 20:18:35 2012 +0000
@@ -35,15 +35,7 @@
-
- False
- ..\Libs\System.Windows.Interactivity\System.Windows.Interactivity.dll
-
-
-
-
-
@@ -77,6 +69,12 @@
+
+
+
+
+
+
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf.Xaml/Styles/Colors.cs
--- a/MetroWpf/MetroWpf.Xaml/Styles/Colors.cs Tue Mar 20 16:53:29 2012 +0000
+++ b/MetroWpf/MetroWpf.Xaml/Styles/Colors.cs Tue Mar 20 20:18:35 2012 +0000
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Text;
using System.Windows.Media;
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf.Xaml/Transitions/Fade.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf.Xaml/Transitions/Fade.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,39 @@
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media.Animation;
+
+namespace MetroWpf.Xaml.Transitions
+{
+ // Simple transition that fades out the old content
+ public class FadeTransition : Transition
+ {
+ static FadeTransition()
+ {
+ IsNewContentTopmostProperty.OverrideMetadata(typeof(FadeTransition), new FrameworkPropertyMetadata(false));
+ }
+
+ public Duration Duration
+ {
+ get { return (Duration)GetValue(DurationProperty); }
+ set { SetValue(DurationProperty, value); }
+ }
+
+ public static readonly DependencyProperty DurationProperty =
+ DependencyProperty.Register("Duration", typeof(Duration), typeof(FadeTransition), new UIPropertyMetadata(Duration.Automatic));
+
+ protected internal override void BeginTransition(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent)
+ {
+ DoubleAnimation da = new DoubleAnimation(0, Duration);
+ da.Completed += delegate
+ {
+ EndTransition(transitionElement, oldContent, newContent);
+ };
+ oldContent.BeginAnimation(UIElement.OpacityProperty, da);
+ }
+
+ protected override void OnTransitionEnded(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent)
+ {
+ oldContent.BeginAnimation(UIElement.OpacityProperty, null);
+ }
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf.Xaml/Transitions/StoryboardTransition.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf.Xaml/Transitions/StoryboardTransition.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,118 @@
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media.Animation;
+
+namespace MetroWpf.Xaml.Transitions
+{
+ // Transition with storyboards for the old and new content presenters
+ [StyleTypedProperty(Property = "OldContentStyle", StyleTargetType = typeof(ContentPresenter))]
+ [StyleTypedProperty(Property = "NewContentStyle", StyleTargetType = typeof(ContentPresenter))]
+ public class StoryboardTransition : Transition
+ {
+ public Style OldContentStyle
+ {
+ get { return (Style)GetValue(OldContentStyleProperty); }
+ set { SetValue(OldContentStyleProperty, value); }
+ }
+
+ public static readonly DependencyProperty OldContentStyleProperty =
+ DependencyProperty.Register("OldContentStyle",
+ typeof(Style),
+ typeof(StoryboardTransition),
+ new UIPropertyMetadata(null));
+
+ public Storyboard OldContentStoryboard
+ {
+ get { return (Storyboard)GetValue(OldContentStoryboardProperty); }
+ set { SetValue(OldContentStoryboardProperty, value); }
+ }
+
+ public static readonly DependencyProperty OldContentStoryboardProperty =
+ DependencyProperty.Register("OldContentStoryboard",
+ typeof(Storyboard),
+ typeof(StoryboardTransition),
+ new UIPropertyMetadata(null));
+
+ public Style NewContentStyle
+ {
+ get { return (Style)GetValue(NewContentStyleProperty); }
+ set { SetValue(NewContentStyleProperty, value); }
+ }
+
+ public static readonly DependencyProperty NewContentStyleProperty =
+ DependencyProperty.Register("NewContentStyle",
+ typeof(Style),
+ typeof(StoryboardTransition),
+ new UIPropertyMetadata(null));
+
+ public Storyboard NewContentStoryboard
+ {
+ get { return (Storyboard)GetValue(NewContentStoryboardProperty); }
+ set { SetValue(NewContentStoryboardProperty, value); }
+ }
+
+ public static readonly DependencyProperty NewContentStoryboardProperty =
+ DependencyProperty.Register("NewContentStoryboard",
+ typeof(Storyboard),
+ typeof(StoryboardTransition),
+ new UIPropertyMetadata(null));
+
+ protected internal override void BeginTransition(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent)
+ {
+ Storyboard oldStoryboard = OldContentStoryboard;
+ Storyboard newStoryboard = NewContentStoryboard;
+
+ if (oldStoryboard != null || newStoryboard != null)
+ {
+ oldContent.Style = OldContentStyle;
+ newContent.Style = NewContentStyle;
+
+ // Flag to determine when both storyboards are done
+ bool done = oldStoryboard == null || newStoryboard == null;
+
+ if (oldStoryboard != null)
+ {
+ oldStoryboard = oldStoryboard.Clone();
+ oldContent.SetValue(OldContentStoryboardProperty, oldStoryboard);
+ oldStoryboard.Completed += delegate
+ {
+ if (done)
+ EndTransition(transitionElement, oldContent, newContent);
+ done = true;
+ };
+ oldStoryboard.Begin(oldContent, true);
+ }
+
+ if (newStoryboard != null)
+ {
+ newStoryboard = newStoryboard.Clone();
+ newContent.SetValue(NewContentStoryboardProperty, newStoryboard);
+ newStoryboard.Completed += delegate
+ {
+ if (done)
+ EndTransition(transitionElement, oldContent, newContent);
+ done = true;
+ };
+ newStoryboard.Begin(newContent, true);
+ }
+ }
+ else
+ {
+ EndTransition(transitionElement, oldContent, newContent);
+ }
+ }
+
+ protected override void OnTransitionEnded(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent)
+ {
+ Storyboard oldStoryboard = (Storyboard)oldContent.GetValue(OldContentStoryboardProperty);
+ if (oldStoryboard != null)
+ oldStoryboard.Stop(oldContent);
+ oldContent.ClearValue(ContentPresenter.StyleProperty);
+
+ Storyboard newStoryboard = (Storyboard)newContent.GetValue(NewContentStoryboardProperty);
+ if (newStoryboard != null)
+ newStoryboard.Stop(newContent);
+ newContent.ClearValue(ContentPresenter.StyleProperty);
+ }
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf.Xaml/Transitions/Transition.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf.Xaml/Transitions/Transition.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,65 @@
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+
+namespace MetroWpf.Xaml.Transitions
+{
+ // Base class for all transitions.
+ public class Transition : DependencyObject
+ {
+ public bool ClipToBounds
+ {
+ get { return (bool)GetValue(ClipToBoundsProperty); }
+ set { SetValue(ClipToBoundsProperty, value); }
+ }
+
+ public static readonly DependencyProperty ClipToBoundsProperty =
+ DependencyProperty.Register("ClipToBounds",
+ typeof(bool),
+ typeof(Transition),
+ new UIPropertyMetadata(false));
+
+ public bool IsNewContentTopmost
+ {
+ get { return (bool)GetValue(IsNewContentTopmostProperty); }
+ set { SetValue(IsNewContentTopmostProperty, value); }
+ }
+
+ public static readonly DependencyProperty IsNewContentTopmostProperty =
+ DependencyProperty.Register("IsNewContentTopmost",
+ typeof(bool),
+ typeof(Transition),
+ new UIPropertyMetadata(true));
+
+ // Called when an element is Removed from the TransitionPresenter's visual tree
+ protected internal virtual void BeginTransition(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent)
+ {
+ EndTransition(transitionElement, oldContent, newContent);
+ }
+
+ //Transitions should call this method when they are done
+ protected void EndTransition(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent)
+ {
+ OnTransitionEnded(transitionElement, oldContent, newContent);
+
+ transitionElement.OnTransitionCompleted();
+ }
+
+ //Transitions can override this to perform cleanup at the end of the transition
+ protected virtual void OnTransitionEnded(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent)
+ {
+ }
+
+ // Returns a clone of the element and hides it in the main tree
+ protected static Brush CreateBrush(ContentPresenter content)
+ {
+ ((Decorator)content.Parent).Visibility = Visibility.Hidden;
+
+ VisualBrush brush = new VisualBrush(content);
+ brush.ViewportUnits = BrushMappingMode.Absolute;
+ RenderOptions.SetCachingHint(brush, CachingHint.Cache);
+ RenderOptions.SetCacheInvalidationThresholdMinimum(brush, 40);
+ return brush;
+ }
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf.Xaml/Transitions/TransitionPresenter.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf.Xaml/Transitions/TransitionPresenter.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,249 @@
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Media;
+
+namespace MetroWpf.Xaml.Transitions
+{
+ [System.Windows.Markup.ContentProperty("Content")]
+ public class TransitionPresenter : FrameworkElement
+ {
+ static TransitionPresenter()
+ {
+ ClipToBoundsProperty.OverrideMetadata(typeof(TransitionPresenter), new FrameworkPropertyMetadata(null, CoerceClipToBounds));
+ }
+
+ // Force clip to be true if the active Transition requires it
+ private static object CoerceClipToBounds(object element, object value)
+ {
+ TransitionPresenter transitionElement = (TransitionPresenter)element;
+ bool clip = (bool)value;
+ if (!clip && transitionElement.IsTransitioning)
+ {
+ Transition transition = transitionElement.Transition;
+ if (transition.ClipToBounds)
+ return true;
+ }
+ return value;
+ }
+
+ public object Content
+ {
+ get { return (object)GetValue(ContentProperty); }
+ set { SetValue(ContentProperty, value); }
+ }
+
+ public static readonly DependencyProperty ContentProperty =
+ DependencyProperty.Register("Content",
+ typeof(object),
+ typeof(TransitionPresenter),
+ new UIPropertyMetadata(null, OnContentChanged, CoerceContent));
+
+ // Don't update content until done transitioning
+ private static object CoerceContent(object element, object value)
+ {
+ TransitionPresenter te = (TransitionPresenter)element;
+ if (te.IsTransitioning)
+ return te.CurrentContentPresenter.Content;
+ return value;
+ }
+
+ private static void OnContentChanged(object element, DependencyPropertyChangedEventArgs e)
+ {
+ TransitionPresenter te = (TransitionPresenter)element;
+ te.BeginTransition();
+ }
+
+ public DataTemplate ContentTemplate
+ {
+ get { return (DataTemplate)GetValue(ContentTemplateProperty); }
+ set { SetValue(ContentTemplateProperty, value); }
+ }
+
+ public static readonly DependencyProperty ContentTemplateProperty =
+ DependencyProperty.Register("ContentTemplate",
+ typeof(DataTemplate),
+ typeof(TransitionPresenter),
+ new UIPropertyMetadata(null, OnContentTemplateChanged));
+
+ private static void OnContentTemplateChanged(object element, DependencyPropertyChangedEventArgs e)
+ {
+ TransitionPresenter te = (TransitionPresenter)element;
+ te.CurrentContentPresenter.ContentTemplate = (DataTemplate)e.NewValue;
+ }
+
+ public DataTemplateSelector ContentTemplateSelector
+ {
+ get { return (DataTemplateSelector)GetValue(ContentTemplateSelectorProperty); }
+ set { SetValue(ContentTemplateSelectorProperty, value); }
+ }
+
+ public static readonly DependencyProperty ContentTemplateSelectorProperty =
+ DependencyProperty.Register("ContentTemplateSelector",
+ typeof(DataTemplateSelector),
+ typeof(TransitionPresenter),
+ new UIPropertyMetadata(null, OnContentTemplateSelectorChanged));
+
+ private static void OnContentTemplateSelectorChanged(object element, DependencyPropertyChangedEventArgs e)
+ {
+ TransitionPresenter te = (TransitionPresenter)element;
+ te.CurrentContentPresenter.ContentTemplateSelector = (DataTemplateSelector)e.NewValue;
+ }
+
+ public bool IsTransitioning
+ {
+ get { return (bool)GetValue(IsTransitioningProperty); }
+ private set { SetValue(IsTransitioningPropertyKey, value); }
+ }
+
+ private static readonly DependencyPropertyKey IsTransitioningPropertyKey =
+ DependencyProperty.RegisterReadOnly("IsTransitioning",
+ typeof(bool),
+ typeof(TransitionPresenter),
+ new UIPropertyMetadata(false));
+
+ public static readonly DependencyProperty IsTransitioningProperty =
+ IsTransitioningPropertyKey.DependencyProperty;
+
+ public Transition Transition
+ {
+ get { return (Transition)GetValue(TransitionProperty); }
+ set { SetValue(TransitionProperty, value); }
+ }
+
+ public static readonly DependencyProperty TransitionProperty =
+ DependencyProperty.Register("Transition", typeof(Transition), typeof(TransitionPresenter), new UIPropertyMetadata(null, null, CoerceTransition));
+
+ private static object CoerceTransition(object element, object value)
+ {
+ TransitionPresenter te = (TransitionPresenter)element;
+ if (te.IsTransitioning) return te._activeTransition;
+ return value;
+ }
+
+ public TransitionSelector TransitionSelector
+ {
+ get { return (TransitionSelector)GetValue(TransitionSelectorProperty); }
+ set { SetValue(TransitionSelectorProperty, value); }
+ }
+
+ public static readonly DependencyProperty TransitionSelectorProperty =
+ DependencyProperty.Register("TransitionSelector", typeof(TransitionSelector), typeof(TransitionPresenter), new UIPropertyMetadata(null));
+
+ public TransitionPresenter()
+ {
+ _children = new UIElementCollection(this, null);
+ ContentPresenter currentContent = new ContentPresenter();
+ _currentHost = new AdornerDecorator();
+ _currentHost.Child = currentContent;
+ _children.Add(_currentHost);
+
+ ContentPresenter previousContent = new ContentPresenter();
+ _previousHost = new AdornerDecorator();
+ _previousHost.Child = previousContent;
+ }
+
+ private void BeginTransition()
+ {
+ TransitionSelector selector = TransitionSelector;
+
+ Transition transition = selector != null ?
+ selector.SelectTransition(CurrentContentPresenter.Content, Content) :
+ Transition;
+
+ if (transition != null)
+ {
+ // Swap content presenters
+ AdornerDecorator temp = _previousHost;
+ _previousHost = _currentHost;
+ _currentHost = temp;
+ }
+
+ ContentPresenter currentContent = CurrentContentPresenter;
+ // Set the current content
+ currentContent.Content = Content;
+ currentContent.ContentTemplate = ContentTemplate;
+ currentContent.ContentTemplateSelector = ContentTemplateSelector;
+
+ if (transition != null)
+ {
+ ContentPresenter previousContent = PreviousContentPresenter;
+
+ if (transition.IsNewContentTopmost)
+ Children.Add(_currentHost);
+ else
+ Children.Insert(0, _currentHost);
+
+ IsTransitioning = true;
+ _activeTransition = transition;
+ CoerceValue(TransitionProperty);
+ CoerceValue(ClipToBoundsProperty);
+ transition.BeginTransition(this, previousContent, currentContent);
+ }
+ }
+
+ // Clean up after the transition is complete
+ internal void OnTransitionCompleted()
+ {
+ _children.Clear();
+ _children.Add(_currentHost);
+ _currentHost.Visibility = Visibility.Visible;
+ _previousHost.Visibility = Visibility.Visible;
+ ((ContentPresenter)_previousHost.Child).Content = null;
+
+ IsTransitioning = false;
+ _activeTransition = null;
+ CoerceValue(TransitionProperty);
+ CoerceValue(ClipToBoundsProperty);
+ CoerceValue(ContentProperty);
+ }
+
+ protected override Size MeasureOverride(Size availableSize)
+ {
+ _currentHost.Measure(availableSize);
+ return _currentHost.DesiredSize;
+ }
+
+ protected override Size ArrangeOverride(Size finalSize)
+ {
+ foreach (UIElement uie in _children)
+ uie.Arrange(new Rect(finalSize));
+ return finalSize;
+ }
+
+ protected override int VisualChildrenCount
+ {
+ get { return _children.Count; }
+ }
+
+ protected override Visual GetVisualChild(int index)
+ {
+ if (index < 0 || index >= _children.Count)
+ throw new ArgumentOutOfRangeException("index");
+ return _children[index];
+ }
+
+ internal UIElementCollection Children
+ {
+ get { return _children; }
+ }
+
+ private ContentPresenter PreviousContentPresenter
+ {
+ get { return ((ContentPresenter)_previousHost.Child); }
+ }
+
+ private ContentPresenter CurrentContentPresenter
+ {
+ get { return ((ContentPresenter)_currentHost.Child); }
+ }
+
+ private UIElementCollection _children;
+
+ private AdornerDecorator _currentHost;
+ private AdornerDecorator _previousHost;
+
+ private Transition _activeTransition;
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf.Xaml/Transitions/TransitionSelector.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf.Xaml/Transitions/TransitionSelector.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,14 @@
+using System.Windows;
+
+namespace MetroWpf.Xaml.Transitions
+{
+ // Allows different transitions to run based on the old and new contents
+ // Override the SelectTransition method to return the transition to apply
+ public class TransitionSelector : DependencyObject
+ {
+ public virtual Transition SelectTransition(object oldContent, object newContent)
+ {
+ return null;
+ }
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf.Xaml/Transitions/TranslateTransition.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf.Xaml/Transitions/TranslateTransition.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,71 @@
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+
+namespace MetroWpf.Xaml.Transitions
+{
+ // Applies a Translation to the content. You can specify the starting point of the new
+ // content or the ending point of the old content using relative coordinates.
+ // Set start point to (-1,0) to have the content slide from the left
+ public class TranslateTransition : Transition
+ {
+ static TranslateTransition()
+ {
+ ClipToBoundsProperty.OverrideMetadata(typeof(TranslateTransition), new FrameworkPropertyMetadata(true));
+ }
+
+ public Duration Duration
+ {
+ get { return (Duration)GetValue(DurationProperty); }
+ set { SetValue(DurationProperty, value); }
+ }
+
+ public static readonly DependencyProperty DurationProperty =
+ DependencyProperty.Register("Duration", typeof(Duration), typeof(TranslateTransition), new UIPropertyMetadata(Duration.Automatic));
+
+ public Point StartPoint
+ {
+ get { return (Point)GetValue(StartPointProperty); }
+ set { SetValue(StartPointProperty, value); }
+ }
+
+ public static readonly DependencyProperty StartPointProperty =
+ DependencyProperty.Register("StartPoint", typeof(Point), typeof(TranslateTransition), new UIPropertyMetadata(new Point()));
+
+ public Point EndPoint
+ {
+ get { return (Point)GetValue(EndPointProperty); }
+ set { SetValue(EndPointProperty, value); }
+ }
+
+ public static readonly DependencyProperty EndPointProperty =
+ DependencyProperty.Register("EndPoint", typeof(Point), typeof(TranslateTransition), new UIPropertyMetadata(new Point()));
+
+ protected internal override void BeginTransition(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent)
+ {
+ TranslateTransform tt = new TranslateTransform(StartPoint.X * transitionElement.ActualWidth, StartPoint.Y * transitionElement.ActualHeight);
+
+ if (IsNewContentTopmost)
+ newContent.RenderTransform = tt;
+ else
+ oldContent.RenderTransform = tt;
+
+ DoubleAnimation da = new DoubleAnimation(EndPoint.X * transitionElement.ActualWidth, Duration);
+ tt.BeginAnimation(TranslateTransform.XProperty, da);
+
+ da.To = EndPoint.Y * transitionElement.ActualHeight;
+ da.Completed += delegate
+ {
+ EndTransition(transitionElement, oldContent, newContent);
+ };
+ tt.BeginAnimation(TranslateTransform.YProperty, da);
+ }
+
+ protected override void OnTransitionEnded(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent)
+ {
+ newContent.ClearValue(ContentPresenter.RenderTransformProperty);
+ oldContent.ClearValue(ContentPresenter.RenderTransformProperty);
+ }
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf.sln
--- a/MetroWpf/MetroWpf.sln Tue Mar 20 16:53:29 2012 +0000
+++ b/MetroWpf/MetroWpf.sln Tue Mar 20 20:18:35 2012 +0000
@@ -15,6 +15,12 @@
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stocks.UI", "Stocks.UI\Stocks.UI.csproj", "{BF20711D-4863-4FD3-9B6C-42D4E677D85C}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FxRates.UI", "FxRates.UI\FxRates.UI.csproj", "{4BD124E6-F437-47F4-93C9-E09170EB06A2}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FxRates.Common", "FxRates.Common\FxRates.Common.csproj", "{789B8256-13E5-41B0-84B5-29A98A3F6E74}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FxRates.Service", "FxRates.Service\FxRates.Service.csproj", "{0AFFFD20-14C7-44A9-B27E-93165001241C}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -95,6 +101,36 @@
{BF20711D-4863-4FD3-9B6C-42D4E677D85C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{BF20711D-4863-4FD3-9B6C-42D4E677D85C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{BF20711D-4863-4FD3-9B6C-42D4E677D85C}.Release|x86.ActiveCfg = Release|Any CPU
+ {4BD124E6-F437-47F4-93C9-E09170EB06A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4BD124E6-F437-47F4-93C9-E09170EB06A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4BD124E6-F437-47F4-93C9-E09170EB06A2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {4BD124E6-F437-47F4-93C9-E09170EB06A2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {4BD124E6-F437-47F4-93C9-E09170EB06A2}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {4BD124E6-F437-47F4-93C9-E09170EB06A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4BD124E6-F437-47F4-93C9-E09170EB06A2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4BD124E6-F437-47F4-93C9-E09170EB06A2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {4BD124E6-F437-47F4-93C9-E09170EB06A2}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {4BD124E6-F437-47F4-93C9-E09170EB06A2}.Release|x86.ActiveCfg = Release|Any CPU
+ {789B8256-13E5-41B0-84B5-29A98A3F6E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {789B8256-13E5-41B0-84B5-29A98A3F6E74}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {789B8256-13E5-41B0-84B5-29A98A3F6E74}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {789B8256-13E5-41B0-84B5-29A98A3F6E74}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {789B8256-13E5-41B0-84B5-29A98A3F6E74}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {789B8256-13E5-41B0-84B5-29A98A3F6E74}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {789B8256-13E5-41B0-84B5-29A98A3F6E74}.Release|Any CPU.Build.0 = Release|Any CPU
+ {789B8256-13E5-41B0-84B5-29A98A3F6E74}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {789B8256-13E5-41B0-84B5-29A98A3F6E74}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {789B8256-13E5-41B0-84B5-29A98A3F6E74}.Release|x86.ActiveCfg = Release|Any CPU
+ {0AFFFD20-14C7-44A9-B27E-93165001241C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0AFFFD20-14C7-44A9-B27E-93165001241C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0AFFFD20-14C7-44A9-B27E-93165001241C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {0AFFFD20-14C7-44A9-B27E-93165001241C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {0AFFFD20-14C7-44A9-B27E-93165001241C}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {0AFFFD20-14C7-44A9-B27E-93165001241C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0AFFFD20-14C7-44A9-B27E-93165001241C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {0AFFFD20-14C7-44A9-B27E-93165001241C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {0AFFFD20-14C7-44A9-B27E-93165001241C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {0AFFFD20-14C7-44A9-B27E-93165001241C}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/App.xaml
--- a/MetroWpf/MetroWpf/App.xaml Tue Mar 20 16:53:29 2012 +0000
+++ b/MetroWpf/MetroWpf/App.xaml Tue Mar 20 20:18:35 2012 +0000
@@ -4,13 +4,12 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:MetroWpf"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- mc:Ignorable="d"
- StartupUri="Presentation/Shell/MainWindow.xaml">
+ StartupUri="UI\Shell/ShellView.xaml"
+ mc:Ignorable="d">
-
-
+
+
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/App.xaml.cs
--- a/MetroWpf/MetroWpf/App.xaml.cs Tue Mar 20 16:53:29 2012 +0000
+++ b/MetroWpf/MetroWpf/App.xaml.cs Tue Mar 20 20:18:35 2012 +0000
@@ -1,7 +1,6 @@
using System.Diagnostics;
using System.Reflection;
using System.Windows;
-using GalaSoft.MvvmLight.Ioc;
using MetroWpf.Framework.Interfaces;
using MetroWpf.Xaml.Binding;
using Microsoft.Practices.ServiceLocation;
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/IoCModule.cs
--- a/MetroWpf/MetroWpf/IoCModule.cs Tue Mar 20 16:53:29 2012 +0000
+++ b/MetroWpf/MetroWpf/IoCModule.cs Tue Mar 20 20:18:35 2012 +0000
@@ -1,17 +1,20 @@
-
-using GalaSoft.MvvmLight.Messaging;
+using System.Threading.Tasks;
+using FxRates.Common;
+using FxRates.Service;
+using FxRates.UI.ViewModels;
+using FxRates.UI.Views;
using MetroWpf.Framework;
using MetroWpf.Framework.Interfaces;
-using MetroWpf.Presentation.About;
-using MetroWpf.Presentation.Login;
-using MetroWpf.Presentation.Menu;
-using MetroWpf.Presentation.Settings;
-using MetroWpf.Presentation.Shell;
using MetroWpf.Presentation.UserProfile;
+using MetroWpf.UI.About;
+using MetroWpf.UI.Login;
+using MetroWpf.UI.Settings;
+using MetroWpf.UI.Shell;
using Ninject.Modules;
using Stocks.Common;
using Stocks.Service;
using Stocks.UI.ViewModels;
+using Stocks.UI.Views;
namespace MetroWpf
{
@@ -19,20 +22,32 @@
{
public override void Load()
{
+ // start up
+ Bind().To();
+ Bind().ToSelf();
+ Bind().ToSelf();
+
+ Task.Factory.StartNew(AsyncOtherDependencies);
+ }
+
+ private void AsyncOtherDependencies()
+ {
+ // stocks
Bind()
.To()
.WithConstructorArgument("filename", "companyData.json");
Bind().To();
Bind().To();
-
- Bind().To();
- Bind().To();
+ Bind().ToSelf();
+ Bind().ToSelf();
- Bind().ToSelf();
- Bind().ToSelf();
- Bind().ToSelf();
- Bind().ToSelf();
+ // fx rates
+ Bind().To();
+ Bind().ToSelf();
+ Bind().ToSelf();
+
+ // other views
Bind().ToSelf();
Bind().ToSelf();
Bind().ToSelf();
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Locator.cs
--- a/MetroWpf/MetroWpf/Locator.cs Tue Mar 20 16:53:29 2012 +0000
+++ b/MetroWpf/MetroWpf/Locator.cs Tue Mar 20 20:18:35 2012 +0000
@@ -1,12 +1,10 @@
+using FxRates.UI.ViewModels;
using GalaSoft.MvvmLight;
-using MetroWpf.Framework;
-using MetroWpf.Framework.Interfaces;
-using MetroWpf.Presentation.Shell;
-using MetroWpf.Presentation.Settings;
-using MetroWpf.Presentation.Login;
using MetroWpf.Presentation.UserProfile;
-using MetroWpf.Presentation.About;
-using MetroWpf.Presentation.Menu;
+using MetroWpf.UI.About;
+using MetroWpf.UI.Login;
+using MetroWpf.UI.Settings;
+using MetroWpf.UI.Shell;
using Microsoft.Practices.ServiceLocation;
using Stocks.UI.ViewModels;
@@ -27,14 +25,9 @@
}
}
- public MainWindowViewModel MainWindowViewModel
+ public ShellViewModel ShellViewModel
{
- get { return ServiceLocator.Current.GetInstance(); }
- }
-
- public MenuViewModel MenuViewModel
- {
- get { return ServiceLocator.Current.GetInstance(); }
+ get { return ServiceLocator.Current.GetInstance(); }
}
public LoginViewModel LoginViewModel
@@ -62,9 +55,14 @@
get { return ServiceLocator.Current.GetInstance(); }
}
- public IWpfApplication WpfApplication
+ public FxRatesViewModel FxRatesViewModel
{
- get { return ServiceLocator.Current.GetInstance(); }
+ get { return ServiceLocator.Current.GetInstance(); }
}
+
+ //public IWpfApplication WpfApplication
+ //{
+ // get { return ServiceLocator.Current.GetInstance(); }
+ //}
}
}
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/MetroWpf.csproj
--- a/MetroWpf/MetroWpf/MetroWpf.csproj Tue Mar 20 16:53:29 2012 +0000
+++ b/MetroWpf/MetroWpf/MetroWpf.csproj Tue Mar 20 20:18:35 2012 +0000
@@ -36,10 +36,6 @@
4
-
- False
- ..\Libs\MvvmLight.Extras.4.0.0\GalaSoft.MvvmLight.Extras.WPF4.dll
-
False
..\Libs\MvvmLight.4.0.0\GalaSoft.MvvmLight.WPF4.dll
@@ -58,19 +54,11 @@
..\Libs\CommonServiceLocator.NinjectAdapter.1.0.0.0\lib\NinjectAdapter.dll
-
-
-
- ..\Libs\Rx-Main.1.0.11226\lib\Net4\System.Reactive.dll
-
..\packages\Caliburn.Micro.1.3.1\lib\net40\System.Windows.Interactivity.dll
-
-
-
4.0
@@ -98,38 +86,34 @@
-
+
AboutView.xaml
-
+
LoginView.xaml
-
-
-
+
+
SettingsView.xaml
-
+
UserProfileView.xaml
-
+
-
+
-
- MenuView.xaml
+
+ ShellView.xaml
-
- MainWindow.xaml
-
-
-
+
+
ExceptionDialog.xaml
-
-
-
+
+
+
@@ -156,31 +140,27 @@
-
- Designer
- MSBuild:Compile
-
-
- MSBuild:Compile
- Designer
-
-
+
Designer
MSBuild:Compile
-
+
+ MSBuild:Compile
+ Designer
+
+
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
-
+
MSBuild:Compile
Designer
-
+
Designer
MSBuild:Compile
@@ -190,18 +170,26 @@
-
-
+
+
+
+ {789B8256-13E5-41B0-84B5-29A98A3F6E74}
+ FxRates.Common
+
+
+ {0AFFFD20-14C7-44A9-B27E-93165001241C}
+ FxRates.Service
+
+
+ {4BD124E6-F437-47F4-93C9-E09170EB06A2}
+ FxRates.UI
+
{F0D99F7E-D4A6-4DBB-B492-D4BE9EA61EE2}
MetroWpf.Framework
-
- {E1B9AA29-C609-4CF1-87E9-7CE4D2EED8A4}
- MetroWpf.Services
-
{A5D99423-4BAE-4FC0-A0CB-F7238EC2C402}
MetroWpf.Xaml
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/About/AboutView.xaml
--- a/MetroWpf/MetroWpf/Presentation/About/AboutView.xaml Tue Mar 20 16:53:29 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/About/AboutView.xaml.cs
--- a/MetroWpf/MetroWpf/Presentation/About/AboutView.xaml.cs Tue Mar 20 16:53:29 2012 +0000
+++ /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.About
-{
- ///
- /// Interaction logic for AboutView.xaml
- ///
- public partial class AboutView : UserControl
- {
- public AboutView()
- {
- InitializeComponent();
- }
- }
-}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/About/AboutViewModel.cs
--- a/MetroWpf/MetroWpf/Presentation/About/AboutViewModel.cs Tue Mar 20 16:53:29 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using System.Windows.Media.Imaging;
-using GalaSoft.MvvmLight;
-using MetroWpf.Framework.Interfaces;
-
-namespace MetroWpf.Presentation.About
-{
- public class AboutViewModel : ViewModelBase
- {
- private readonly IWpfApplication wpfApplication;
-
- public AboutViewModel(IWpfApplication wpfApplication)
- {
- this.wpfApplication = wpfApplication;
- }
-
- public string ApplicationTitle { get { return wpfApplication.ApplicationTitle; } }
-
- public BitmapSource ApplicationIcon { get { return wpfApplication.ApplicationIcon; } }
-
- public string Version
- {
- get
- {
- return Assembly.GetExecutingAssembly().GetName().Version.ToString();
- }
- }
-
- public string Configuration
- {
- get
- {
- var attr = Assembly.GetExecutingAssembly()
- .GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false)
- .OfType()
- .FirstOrDefault() ?? new AssemblyConfigurationAttribute("");
-
- return attr.Configuration;
- }
- }
-
- // let's evolve the app as a fully loaded starting point for an app
- private readonly List authors = new List
- {
- "Steven Hollidge"
- };
- public string Authors
- {
- get { return string.Join(", ", authors); }
- }
-
- private readonly List components = new List
- {
- "MahApps.Metro",
- "Markdown",
- "MVVM Light"
- };
- public string Components
- {
- get { return string.Join(", ", components); }
- }
-
- public void Visit()
- {
- try
- {
- System.Diagnostics.Process.Start("http://stevenhollidge.com");
- }
- catch // browser exceptions
- {
-
- }
- }
- }
-}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/Exceptions/ExceptionDialog.xaml
--- a/MetroWpf/MetroWpf/Presentation/Exceptions/ExceptionDialog.xaml Tue Mar 20 16:53:29 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/Exceptions/ExceptionDialog.xaml.cs
--- a/MetroWpf/MetroWpf/Presentation/Exceptions/ExceptionDialog.xaml.cs Tue Mar 20 16:53:29 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.Threading;
-using System.Windows;
-using System.Windows.Input;
-
-namespace MetroWpf.Presentation.Exceptions
-{
- ///
- /// Interaction logic for ExceptionDialog.xaml
- ///
- public partial class ExceptionDialog : Window
- {
- private System.Exception exception;
- private string details;
- private string message;
-
- public ExceptionDialog()
- {
- InitializeComponent();
- }
-
- private void DragMoveWindow(object sender, MouseButtonEventArgs e)
- {
- if (e.RightButton != MouseButtonState.Pressed
- && e.MiddleButton != MouseButtonState.Pressed)
- DragMove();
- }
-
- public string Message
- {
- get { return message; }
- set
- {
- message = value;
-
- messageBox.Text = value;
- }
- }
-
- public string Details
- {
- get { return details; }
- set
- {
- details = value;
- detailsBox.Text = value;
- }
- }
-
- public System.Exception Exception
- {
- get { return exception; }
- set { exception = value; }
- }
-
- private void TryClose(object sender, RoutedEventArgs e)
- {
- this.Close();
- }
-
- private void CopyToClipboard(object sender, RoutedEventArgs e)
- {
- SetData(DataFormats.Text, this.Details);
- }
-
- // Implementation taken from the WinForms clipboard class.
- // Seriously, the clipboard can fail, so it retries 10 times.
- private void SetData(string format, object data)
- {
- if (!data.GetType().IsSerializable)
- {
- throw new NotSupportedException("An object being added to the clipboard must be serializable. Ensure that the entire object tree is serializable.");
- }
-
- bool succeeded = false;
- for (int i = 0; i < 10 && !succeeded; i++)
- {
- try
- {
- System.Windows.Clipboard.SetData(format, data);
- succeeded = true;
- }
- catch (Exception e)
- {
- Trace.WriteLine(e, "ERROR");
- }
- if (!succeeded)
- Thread.Sleep(100);
- }
- }
- }
-}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/Login/LoginView.xaml
--- a/MetroWpf/MetroWpf/Presentation/Login/LoginView.xaml Tue Mar 20 16:53:29 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,132 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- WELCOME TO OUR METRO WORLD
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/Login/LoginView.xaml.cs
--- a/MetroWpf/MetroWpf/Presentation/Login/LoginView.xaml.cs Tue Mar 20 16:53:29 2012 +0000
+++ /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.Login
-{
- ///
- /// Interaction logic for LoginView.xaml
- ///
- public partial class LoginView : UserControl
- {
- public LoginView()
- {
- InitializeComponent();
- }
- }
-}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/Login/LoginViewModel.cs
--- a/MetroWpf/MetroWpf/Presentation/Login/LoginViewModel.cs Tue Mar 20 16:53:29 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +0,0 @@
-using GalaSoft.MvvmLight;
-using GalaSoft.MvvmLight.Command;
-using GalaSoft.MvvmLight.Messaging;
-using MetroWpf.Messages;
-
-namespace MetroWpf.Presentation.Login
-{
- ///
- /// Login view view model class
- ///
- public sealed class LoginViewModel :
- ViewModelBase
- {
- #region · Data Properties ·
-
- ///
- /// Gets or sets whether the form is busy
- ///
- private bool isBusy;
- public bool IsBusy
- {
- get { return isBusy; }
- set
- {
- if (this.isBusy != value)
- {
- this.isBusy = value;
- RaisePropertyChanged("IsBusy");
- //relay requery?
- }
- }
- }
-
- ///
- /// Gets or sets the user name
- ///
- private string userId;
- public string UserId
- {
- get { return this.userId; }
- set
- {
- if (this.userId != value)
- {
- this.userId = value;
- RaisePropertyChanged("UserId");
- LoginCommand.RaiseCanExecuteChanged();
- }
- }
- }
-
- ///
- /// Gets or sets the password
- ///
- private string password;
- public string Password
- {
- get { return this.password; }
- set
- {
- if (this.password != value)
- {
- this.password = value;
- RaisePropertyChanged("Password");
- LoginCommand.RaiseCanExecuteChanged();
- }
- }
- }
-
- #endregion
-
- #region · Constructors ·
-
- ///
- /// Initializes a new instance of the class
- ///
- public LoginViewModel()
- : base()
- {
- LoginCommand = new RelayCommand(LoginCommandExecute, CanLoginCommandExecute);
- CloseCommand = new RelayCommand(CloseCommandExecute);
- }
-
- #endregion
-
- #region · Command Actions ·
-
- #region LoginCommand
-
- public RelayCommand LoginCommand { get; set; }
-
- private void LoginCommandExecute()
- {
- //successful login!
-
- Messenger.Default.Send(new UserAuthenticatedMessage() { UserId = userId });
- }
-
- private bool CanLoginCommandExecute()
- {
- if (string.IsNullOrEmpty(UserId) ||
- string.IsNullOrEmpty(Password))
- return false;
-
- return true;
- }
-
- #endregion
-
- #region CloseCommand
- public RelayCommand CloseCommand { get; set; }
-
- private void CloseCommandExecute()
- {
- }
- #endregion
-
- #endregion
- }
-}
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/Login/UserLogin.cs
--- a/MetroWpf/MetroWpf/Presentation/Login/UserLogin.cs Tue Mar 20 16:53:29 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-using System.Collections.Generic;
-using System.ComponentModel;
-using GalaSoft.MvvmLight;
-
-namespace MetroWpf.Presentation.Login
-{
- public sealed class UserLogin :
- ObservableObject,
- IDataErrorInfo
- {
- #region · Fields ·
-
- private Dictionary _errors
- = new Dictionary();
-
- #endregion
-
- #region · IDataErrorInfo Members ·
-
- public string Error
- {
- get { return null; }
- }
-
- public string this[string columnName]
- {
- get { return null; }
- }
-
- #endregion
-
- #region · Properties ·
-
- public string UserId { get; set; }
- public string Password { get; set; }
-
- #endregion
-
- #region · Constructors ·
-
- public UserLogin()
- {
- }
-
- #endregion
- }
-}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/Menu/MenuView.xaml
--- a/MetroWpf/MetroWpf/Presentation/Menu/MenuView.xaml Tue Mar 20 16:53:29 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/Menu/MenuView.xaml.cs
--- a/MetroWpf/MetroWpf/Presentation/Menu/MenuView.xaml.cs Tue Mar 20 16:53:29 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-using System.Windows.Controls;
-using GalaSoft.MvvmLight.Messaging;
-using MetroWpf.Messages;
-
-namespace MetroWpf.Presentation.Menu
-{
- ///
- /// Interaction logic for TabMenu.xaml
- ///
- public partial class MenuView : UserControl
- {
- public MenuView()
- {
- InitializeComponent();
- }
- }
-}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/Menu/MenuViewModel.cs
--- a/MetroWpf/MetroWpf/Presentation/Menu/MenuViewModel.cs Tue Mar 20 16:53:29 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,214 +0,0 @@
-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(
- this,
- message => ChangeDisplayScreen(message.DisplayScreen));
-
- Messenger.Default.Register(
- this,
- message => UserAuthenticated(message.UserId));
-
- ChangeDisplayScreen(Screen.Login);
- }
-
- private void UserAuthenticated(string userId)
- {
- Messenger.Default.Send(new NavigationMessage() { DisplayScreen= Screen.Stocks });
- }
-
- private void ChangeDisplayScreen(Screen screen)
- {
- switch (screen)
- {
- case Screen.Login:
- ShowLogin = true;
-
- ShowStocks = false;
- ShowFxRates = false;
- ShowUserProfile = false;
- ShowSettings = false;
- ShowAbout = false;
- ShowHelp = false;
- break;
- case Screen.Stocks:
- ShowStocks = true;
- ShowFxRates = true;
-
- ShowLogin = false;
- ShowUserProfile = false;
- ShowSettings = false;
- ShowAbout = false;
- ShowHelp = false;
- break;
- case Screen.UserProfile:
- ShowUserProfile = true;
-
- ShowStocks = false;
- ShowFxRates = false;
- ShowLogin = false;
- ShowSettings = false;
- ShowAbout = false;
- ShowHelp = false;
- break;
- case Screen.Settings:
- ShowSettings = true;
-
- ShowStocks = false;
- ShowFxRates = false;
- ShowLogin = false;
- ShowUserProfile = false;
- ShowAbout = false;
- ShowHelp = false;
- break;
- case Screen.About:
- ShowAbout = true;
-
- ShowStocks = false;
- ShowFxRates = false;
- ShowLogin = false;
- ShowUserProfile = false;
- ShowSettings = false;
- ShowHelp = false;
- break;
- case Screen.Help:
- ShowLogin = false;
- ShowUserProfile = false;
- ShowSettings = false;
- ShowAbout = false;
- ShowHelp = true;
- break;
- }
-
- SelectedTabIndex = screen;
- }
- }
-}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/Screen.cs
--- a/MetroWpf/MetroWpf/Presentation/Screen.cs Tue Mar 20 16:53:29 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-
-namespace MetroWpf.Presentation
-{
- public enum Screen
- {
- Stocks,
- FxRates,
- Login,
- UserProfile,
- Settings,
- About,
- Help
- }
-}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/Settings/SettingsView.xaml
--- a/MetroWpf/MetroWpf/Presentation/Settings/SettingsView.xaml Tue Mar 20 16:53:29 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/Settings/SettingsView.xaml.cs
--- a/MetroWpf/MetroWpf/Presentation/Settings/SettingsView.xaml.cs Tue Mar 20 16:53:29 2012 +0000
+++ /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
-{
- ///
- /// Interaction logic for SettingsView.xaml
- ///
- public partial class SettingsView : UserControl
- {
- public SettingsView()
- {
- InitializeComponent();
- }
- }
-}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/Settings/SettingsViewModel.cs
--- a/MetroWpf/MetroWpf/Presentation/Settings/SettingsViewModel.cs Tue Mar 20 16:53:29 2012 +0000
+++ /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 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 });
- }
- }
- }
-}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/Shell/MainWindow.xaml
--- a/MetroWpf/MetroWpf/Presentation/Shell/MainWindow.xaml Tue Mar 20 16:53:29 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/Shell/MainWindow.xaml.cs
--- a/MetroWpf/MetroWpf/Presentation/Shell/MainWindow.xaml.cs Tue Mar 20 16:53:29 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-using System.Windows.Input;
-using GalaSoft.MvvmLight.Messaging;
-using MetroWpf.Messages;
-using MetroWpf.Styles;
-using MahApps.Metro;
-using System.Linq;
-
-namespace MetroWpf.Presentation.Shell
-{
- public partial class MainWindow
- {
- public MainWindow()
- {
- //DataContext = new MainWindowViewModel(Dispatcher);
- InitializeComponent();
-
- // setup notifications
- Messenger.Default.Register(
- this, message => ChangeTheme(message.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;
- }
- }
- }
-}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/Shell/MainWindowViewModel.cs
--- a/MetroWpf/MetroWpf/Presentation/Shell/MainWindowViewModel.cs Tue Mar 20 16:53:29 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-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 : ViewModelBase
- {
- private bool showTopRightOptions;
- public bool ShowTopRightOptions
- {
- get { return showTopRightOptions; }
- set
- {
- if (showTopRightOptions == value)
- return;
-
- showTopRightOptions = value;
- RaisePropertyChanged("ShowTopRightOptions");
- }
- }
-
- public RelayCommand MenuCommand { get; set; }
-
- public MainWindowViewModel()
- {
- MenuCommand = new RelayCommand(MenuCommandExecute);
- }
-
- private void MenuCommandExecute(Screen screen)
- {
- Messenger.Default.Send(
- new NavigationMessage()
- {
- DisplayScreen = screen
- });
- }
- }
-}
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/Splash/splash.png
Binary file MetroWpf/MetroWpf/Presentation/Splash/splash.png has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/UserProfile/UserProfileView.xaml
--- a/MetroWpf/MetroWpf/Presentation/UserProfile/UserProfileView.xaml Tue Mar 20 16:53:29 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-
-
-
-
-
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/UserProfile/UserProfileView.xaml.cs
--- a/MetroWpf/MetroWpf/Presentation/UserProfile/UserProfileView.xaml.cs Tue Mar 20 16:53:29 2012 +0000
+++ /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.UserProfile
-{
- ///
- /// Interaction logic for UserProfileView.xaml
- ///
- public partial class UserProfileView : UserControl
- {
- public UserProfileView()
- {
- InitializeComponent();
- }
- }
-}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/UserProfile/UserProfileViewModel.cs
--- a/MetroWpf/MetroWpf/Presentation/UserProfile/UserProfileViewModel.cs Tue Mar 20 16:53:29 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace MetroWpf.Presentation.UserProfile
-{
- public class UserProfileViewModel
- {
- }
-}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/Presentation/logo.ico
Binary file MetroWpf/MetroWpf/Presentation/logo.ico has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/UI/About/AboutView.xaml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf/UI/About/AboutView.xaml Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/UI/About/AboutView.xaml.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf/UI/About/AboutView.xaml.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,15 @@
+using System.Windows.Controls;
+
+namespace MetroWpf.UI.About
+{
+ ///
+ /// Interaction logic for AboutView.xaml
+ ///
+ public partial class AboutView : UserControl
+ {
+ public AboutView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/UI/About/AboutViewModel.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf/UI/About/AboutViewModel.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,77 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Windows.Media.Imaging;
+using GalaSoft.MvvmLight;
+using MetroWpf.Framework.Interfaces;
+
+namespace MetroWpf.UI.About
+{
+ public class AboutViewModel : ViewModelBase
+ {
+ private readonly IWpfApplication wpfApplication;
+
+ public AboutViewModel(IWpfApplication wpfApplication)
+ {
+ this.wpfApplication = wpfApplication;
+ }
+
+ public string ApplicationTitle { get { return wpfApplication.ApplicationTitle; } }
+
+ public BitmapSource ApplicationIcon { get { return wpfApplication.ApplicationIcon; } }
+
+ public string Version
+ {
+ get
+ {
+ return Assembly.GetExecutingAssembly().GetName().Version.ToString();
+ }
+ }
+
+ public string Configuration
+ {
+ get
+ {
+ var attr = Assembly.GetExecutingAssembly()
+ .GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false)
+ .OfType()
+ .FirstOrDefault() ?? new AssemblyConfigurationAttribute("");
+
+ return attr.Configuration;
+ }
+ }
+
+ // let's evolve the app as a fully loaded starting point for an app
+ private readonly List authors = new List
+ {
+ "Steven Hollidge"
+ };
+ public string Authors
+ {
+ get { return string.Join(", ", authors); }
+ }
+
+ private readonly List components = new List
+ {
+ "MahApps.Metro",
+ "Markdown",
+ "MVVM Light"
+ };
+ public string Components
+ {
+ get { return string.Join(", ", components); }
+ }
+
+ public void Visit()
+ {
+ try
+ {
+ System.Diagnostics.Process.Start("http://stevenhollidge.com");
+ }
+ catch // browser exceptions
+ {
+
+ }
+ }
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/UI/Exceptions/ExceptionDialog.xaml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf/UI/Exceptions/ExceptionDialog.xaml Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,89 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/UI/Exceptions/ExceptionDialog.xaml.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf/UI/Exceptions/ExceptionDialog.xaml.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,93 @@
+using System;
+using System.Diagnostics;
+using System.Threading;
+using System.Windows;
+using System.Windows.Input;
+
+namespace MetroWpf.UI.Exceptions
+{
+ ///
+ /// Interaction logic for ExceptionDialog.xaml
+ ///
+ public partial class ExceptionDialog
+ {
+ private System.Exception exception;
+ private string details;
+ private string message;
+
+ public ExceptionDialog()
+ {
+ InitializeComponent();
+ }
+
+ private void DragMoveWindow(object sender, MouseButtonEventArgs e)
+ {
+ if (e.RightButton != MouseButtonState.Pressed
+ && e.MiddleButton != MouseButtonState.Pressed)
+ DragMove();
+ }
+
+ public string Message
+ {
+ get { return message; }
+ set
+ {
+ message = value;
+
+ messageBox.Text = value;
+ }
+ }
+
+ public string Details
+ {
+ get { return details; }
+ set
+ {
+ details = value;
+ detailsBox.Text = value;
+ }
+ }
+
+ public System.Exception Exception
+ {
+ get { return exception; }
+ set { exception = value; }
+ }
+
+ private void TryClose(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ }
+
+ private void CopyToClipboard(object sender, RoutedEventArgs e)
+ {
+ SetData(DataFormats.Text, this.Details);
+ }
+
+ // Implementation taken from the WinForms clipboard class.
+ // Seriously, the clipboard can fail, so it retries 10 times.
+ private void SetData(string format, object data)
+ {
+ if (!data.GetType().IsSerializable)
+ {
+ throw new NotSupportedException("An object being added to the clipboard must be serializable. Ensure that the entire object tree is serializable.");
+ }
+
+ bool succeeded = false;
+ for (int i = 0; i < 10 && !succeeded; i++)
+ {
+ try
+ {
+ System.Windows.Clipboard.SetData(format, data);
+ succeeded = true;
+ }
+ catch (Exception e)
+ {
+ Trace.WriteLine(e, "ERROR");
+ }
+ if (!succeeded)
+ Thread.Sleep(100);
+ }
+ }
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/UI/Login/LoginView.xaml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf/UI/Login/LoginView.xaml Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,132 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ WELCOME TO OUR METRO WORLD
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/UI/Login/LoginView.xaml.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf/UI/Login/LoginView.xaml.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,13 @@
+namespace MetroWpf.UI.Login
+{
+ ///
+ /// Interaction logic for LoginView.xaml
+ ///
+ public partial class LoginView
+ {
+ public LoginView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/UI/Login/LoginViewModel.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf/UI/Login/LoginViewModel.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,120 @@
+using GalaSoft.MvvmLight;
+using GalaSoft.MvvmLight.Command;
+using GalaSoft.MvvmLight.Messaging;
+using MetroWpf.Messages;
+
+namespace MetroWpf.UI.Login
+{
+ ///
+ /// Login view view model class
+ ///
+ public sealed class LoginViewModel :
+ ViewModelBase
+ {
+ #region · Data Properties ·
+
+ ///
+ /// Gets or sets whether the form is busy
+ ///
+ private bool isBusy;
+ public bool IsBusy
+ {
+ get { return isBusy; }
+ set
+ {
+ if (this.isBusy != value)
+ {
+ this.isBusy = value;
+ RaisePropertyChanged("IsBusy");
+ //relay requery?
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the user name
+ ///
+ private string userId;
+ public string UserId
+ {
+ get { return this.userId; }
+ set
+ {
+ if (this.userId != value)
+ {
+ this.userId = value;
+ RaisePropertyChanged("UserId");
+ LoginCommand.RaiseCanExecuteChanged();
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the password
+ ///
+ private string password;
+ public string Password
+ {
+ get { return this.password; }
+ set
+ {
+ if (this.password != value)
+ {
+ this.password = value;
+ RaisePropertyChanged("Password");
+ LoginCommand.RaiseCanExecuteChanged();
+ }
+ }
+ }
+
+ #endregion
+
+ #region · Constructors ·
+
+ ///
+ /// Initializes a new instance of the class
+ ///
+ public LoginViewModel()
+ : base()
+ {
+ LoginCommand = new RelayCommand(LoginCommandExecute, CanLoginCommandExecute);
+ CloseCommand = new RelayCommand(CloseCommandExecute);
+ }
+
+ #endregion
+
+ #region · Command Actions ·
+
+ #region LoginCommand
+
+ public RelayCommand LoginCommand { get; set; }
+
+ private void LoginCommandExecute()
+ {
+ //successful login!
+
+ Messenger.Default.Send(new UserAuthenticatedMessage() { UserId = userId });
+ }
+
+ private bool CanLoginCommandExecute()
+ {
+ if (string.IsNullOrEmpty(UserId) ||
+ string.IsNullOrEmpty(Password))
+ return false;
+
+ return true;
+ }
+
+ #endregion
+
+ #region CloseCommand
+ public RelayCommand CloseCommand { get; set; }
+
+ private void CloseCommandExecute()
+ {
+ }
+ #endregion
+
+ #endregion
+ }
+}
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/UI/Login/UserLogin.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf/UI/Login/UserLogin.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,47 @@
+using System.Collections.Generic;
+using System.ComponentModel;
+using GalaSoft.MvvmLight;
+
+namespace MetroWpf.UI.Login
+{
+ public sealed class UserLogin :
+ ObservableObject,
+ IDataErrorInfo
+ {
+ #region · Fields ·
+
+ private Dictionary _errors
+ = new Dictionary();
+
+ #endregion
+
+ #region · IDataErrorInfo Members ·
+
+ public string Error
+ {
+ get { return null; }
+ }
+
+ public string this[string columnName]
+ {
+ get { return null; }
+ }
+
+ #endregion
+
+ #region · Properties ·
+
+ public string UserId { get; set; }
+ public string Password { get; set; }
+
+ #endregion
+
+ #region · Constructors ·
+
+ public UserLogin()
+ {
+ }
+
+ #endregion
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/UI/Screen.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf/UI/Screen.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,14 @@
+
+namespace MetroWpf.Presentation
+{
+ public enum Screen
+ {
+ Stocks,
+ FxRates,
+ Login,
+ UserProfile,
+ Settings,
+ About,
+ Help
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/UI/Settings/SettingsView.xaml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf/UI/Settings/SettingsView.xaml Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/UI/Settings/SettingsView.xaml.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf/UI/Settings/SettingsView.xaml.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,15 @@
+using System.Windows.Controls;
+
+namespace MetroWpf.UI.Settings
+{
+ ///
+ /// Interaction logic for SettingsView.xaml
+ ///
+ public partial class SettingsView : UserControl
+ {
+ public SettingsView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/UI/Settings/SettingsViewModel.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf/UI/Settings/SettingsViewModel.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,31 @@
+using GalaSoft.MvvmLight;
+using GalaSoft.MvvmLight.Messaging;
+using MetroWpf.Messages;
+using MetroWpf.Styles;
+
+namespace MetroWpf.UI.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 });
+ }
+ }
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/UI/Shell/ShellView.xaml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf/UI/Shell/ShellView.xaml Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/UI/Shell/ShellView.xaml.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf/UI/Shell/ShellView.xaml.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,52 @@
+using GalaSoft.MvvmLight.Messaging;
+using MetroWpf.Messages;
+using MetroWpf.Styles;
+using MahApps.Metro;
+using System.Linq;
+
+namespace MetroWpf.UI.Shell
+{
+ public partial class ShellView
+ {
+ public ShellView()
+ {
+ //DataContext = new MainWindowViewModel(Dispatcher);
+ InitializeComponent();
+
+ // setup notifications
+ Messenger.Default.Register(
+ this, message => ChangeTheme(message.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;
+ }
+ }
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/UI/Shell/ShellViewModel.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf/UI/Shell/ShellViewModel.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,106 @@
+using FxRates.UI.ViewModels;
+using FxRates.UI.Views;
+using GalaSoft.MvvmLight;
+using GalaSoft.MvvmLight.Command;
+using GalaSoft.MvvmLight.Messaging;
+using MetroWpf.Messages;
+using MetroWpf.Presentation;
+using MetroWpf.UI.Login;
+using MetroWpf.UI.Settings;
+using Microsoft.Practices.ServiceLocation;
+using Stocks.UI.ViewModels;
+using Stocks.UI.Views;
+
+namespace MetroWpf.UI.Shell
+{
+ public class ShellViewModel : ViewModelBase
+ {
+ public RelayCommand MenuCommand { get; set; }
+
+ public ShellViewModel()
+ {
+ ShowMenuButtons = false;
+ MenuCommand = new RelayCommand(MenuCommandExecute);
+
+ Messenger.Default.Register(this, NavigationMessageReceived);
+ Messenger.Default.Register(this, UserAuthenticated);
+
+ Messenger.Default.Send(new NavigationMessage() { DisplayScreen = Screen.Login });
+ }
+
+ private void UserAuthenticated(UserAuthenticatedMessage message)
+ {
+ ShowMenuButtons = true;
+ Messenger.Default.Send(new NavigationMessage() { DisplayScreen = Screen.Stocks });
+ }
+
+ private object displayScreen;
+ public object DisplayScreen
+ {
+ get { return displayScreen; }
+ set
+ {
+ if (displayScreen == value) return;
+ displayScreen = value;
+ RaisePropertyChanged("DisplayScreen");
+ }
+ }
+
+ private bool _showMenuButtons;
+ public bool ShowMenuButtons
+ {
+ get { return _showMenuButtons; }
+ set
+ {
+ if (_showMenuButtons == value) return;
+ _showMenuButtons = value;
+ RaisePropertyChanged("ShowMenuButtons");
+ }
+ }
+
+ private void NavigationMessageReceived(NavigationMessage message)
+ {
+ switch (message.DisplayScreen)
+ {
+ case Screen.Login:
+ DisplayScreen = ServiceLocator.Current.GetInstance();
+ break;
+
+ case Screen.Stocks:
+ var stocksView = ServiceLocator.Current.GetInstance();
+ stocksView.DataContext = ServiceLocator.Current.GetInstance();
+ DisplayScreen = stocksView;
+ break;
+
+ case Screen.FxRates:
+ var fxRatesView = ServiceLocator.Current.GetInstance();
+ fxRatesView.DataContext = ServiceLocator.Current.GetInstance();
+ DisplayScreen = fxRatesView;
+ break;
+
+ case Screen.UserProfile:
+ break;
+
+ case Screen.Settings:
+ DisplayScreen = ServiceLocator.Current.GetInstance();
+ break;
+
+ case Screen.About:
+ break;
+
+ case Screen.Help:
+ break;
+ }
+
+ }
+
+ private void MenuCommandExecute(Screen screen)
+ {
+ Messenger.Default.Send(
+ new NavigationMessage()
+ {
+ DisplayScreen = screen
+ });
+ }
+ }
+}
\ No newline at end of file
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/UI/Splash/splash.png
Binary file MetroWpf/MetroWpf/UI/Splash/splash.png has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/UI/UserProfile/UserProfileView.xaml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf/UI/UserProfile/UserProfileView.xaml Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,11 @@
+
+
+
+
+
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/UI/UserProfile/UserProfileView.xaml.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf/UI/UserProfile/UserProfileView.xaml.cs Tue Mar 20 20:18:35 2012 +0000
@@ -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
+{
+ ///
+ /// Interaction logic for UserProfileView.xaml
+ ///
+ public partial class UserProfileView : UserControl
+ {
+ public UserProfileView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/UI/UserProfile/UserProfileViewModel.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf/UI/UserProfile/UserProfileViewModel.cs Tue Mar 20 20:18:35 2012 +0000
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace MetroWpf.Presentation.UserProfile
+{
+ public class UserProfileViewModel
+ {
+ }
+}
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/MetroWpf/UI/logo.ico
Binary file MetroWpf/MetroWpf/UI/logo.ico has changed
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/Stocks.Common/Exceptions/InvalidWebPriceData.cs
--- a/MetroWpf/Stocks.Common/Exceptions/InvalidWebPriceData.cs Tue Mar 20 16:53:29 2012 +0000
+++ b/MetroWpf/Stocks.Common/Exceptions/InvalidWebPriceData.cs Tue Mar 20 20:18:35 2012 +0000
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Text;
namespace Stocks.Common.Exceptions
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/Stocks.Common/Factory.cs
--- a/MetroWpf/Stocks.Common/Factory.cs Tue Mar 20 16:53:29 2012 +0000
+++ b/MetroWpf/Stocks.Common/Factory.cs Tue Mar 20 20:18:35 2012 +0000
@@ -1,5 +1,4 @@
-using NLog;
-using Stocks.Common.Core;
+using Stocks.Common.Core;
using Stocks.Common.Models;
using System;
using Stocks.Common.Exceptions;
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/Stocks.Common/Stocks.Common.csproj
--- a/MetroWpf/Stocks.Common/Stocks.Common.csproj Tue Mar 20 16:53:29 2012 +0000
+++ b/MetroWpf/Stocks.Common/Stocks.Common.csproj Tue Mar 20 20:18:35 2012 +0000
@@ -34,16 +34,8 @@
..\Libs\Newtonsoft.Json.4.0.8\lib\net40\Newtonsoft.Json.dll
-
- ..\Libs\NLog.2.0.0.2000\lib\net40\NLog.dll
-
-
-
-
-
-
diff -r 399398841fd0 -r a8b50a087544 MetroWpf/Stocks.Service/Stocks.Service.csproj
--- a/MetroWpf/Stocks.Service/Stocks.Service.csproj Tue Mar 20 16:53:29 2012 +0000
+++ b/MetroWpf/Stocks.Service/Stocks.Service.csproj Tue Mar 20 20:18:35 2012 +0000
@@ -36,11 +36,6 @@
-
-
-
-
-