Commit 4a4e250

mo <email@solidware.ca>
2011-04-05 03:51:02
add up,down icons. change timer interval to 20 seconds because larger values don't seem to work properly. main
1 parent 512d9d7
product/desktop.ui/handlers/PublishEventHandler.cs
@@ -1,11 +1,11 @@
-using gorilla.utility;
-using solidware.financials.infrastructure;
+using solidware.financials.infrastructure;
 using solidware.financials.infrastructure.eventing;
+using solidware.financials.messages;
 using solidware.financials.windows.ui.views;
 
 namespace solidware.financials.windows.ui.handlers
 {
-    public class PublishEventHandler<T> : Handles<T> where T : Event
+    public class PublishEventHandler<T> : Handles<T> where T : Announcement
     {
         EventAggregator event_aggregator;
         RegionManager region_manager;
@@ -21,7 +21,7 @@ namespace solidware.financials.windows.ui.handlers
             event_aggregator.publish(item);
             region_manager.region<TrayIcon>(x =>
             {
-                x.Say("{0}".format(item));
+                item.AnnounceUsing(x);
             });
         }
     }
product/desktop.ui/presenters/StockWatchPresenter.cs
@@ -29,14 +29,17 @@ namespace solidware.financials.windows.ui.presenters
 
         public void present()
         {
-            timer.start_notifying(this, new TimeSpan(0, 1, 0));
+            timer.start_notifying(this, new TimeSpan(0, 0, 20));
             AddSymbol = builder.build<AddSymbolCommand>(this);
             Refresh = builder.build<RefreshStockPricesCommand>(this);
         }
 
         public void notify()
         {
-            Refresh.Execute(this);
+            UIThread.Run(() =>
+            {
+                Refresh.Execute(this);
+            });
         }
 
         public void notify(CurrentStockPrice message)
product/desktop.ui/presenters/UIThread.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Windows;
+
+namespace solidware.financials.windows.ui.presenters
+{
+    static public class UIThread
+    {
+        static public void Run(Action action)
+        {
+            if (Application.Current != null)
+                Application.Current.Dispatcher.BeginInvoke(action);
+            else
+                action();
+        }
+    }
+}
\ No newline at end of file
product/desktop.ui/views/icons/down.png
Binary file
product/desktop.ui/views/icons/UIIcon.cs
@@ -19,6 +19,8 @@ namespace solidware.financials.windows.ui.views.icons
         static public readonly UIIcon Application = new UIIcon("mokhan.ico");
         static public readonly UIIcon Close = new UIIcon("close.png");
         static public readonly UIIcon Info = new UIIcon("info.png");
+        static public readonly UIIcon Up = new UIIcon("up.png");
+        static public readonly UIIcon Down = new UIIcon("down.png");
 
         UIIcon(string path)
         {
product/desktop.ui/views/icons/up.png
Binary file
product/desktop.ui/views/Shell.xaml
@@ -1,4 +1,4 @@
-<Window x:Class="solidware.financials.windows.ui.views.Shell" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock" xmlns:views="clr-namespace:solidware.financials.windows.ui.views" xmlns:controls="clr-namespace:solidware.financials.windows.ui.views.controls" Title="Family Finances - (ALPHA)" MinWidth="1024" MinHeight="768" WindowStartupLocation="CenterScreen" WindowState="Maximized">
+<Window x:Class="solidware.financials.windows.ui.views.Shell" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock" xmlns:views="clr-namespace:solidware.financials.windows.ui.views" xmlns:controls="clr-namespace:solidware.financials.windows.ui.views.controls" Title="Family Finances - (ALPHA)" MinWidth="1024" MinHeight="768" WindowStartupLocation="CenterScreen" WindowState="Maximized" ShowInTaskbar="False">
 	<Grid>
 		<Grid.RowDefinitions>
 			<RowDefinition Height="24" />
product/desktop.ui/views/Shell.xaml.cs
@@ -34,7 +34,6 @@ namespace solidware.financials.windows.ui.views
             Loaded += (o, e) =>
             {
                 TaskBarIcon.Icon = UIIcon.Application.AsIcon();
-                TaskBarIcon.Say("Welcome");
             };
         }
 
product/desktop.ui/views/TrayIcon.cs
@@ -1,10 +1,11 @@
 using System.Windows.Controls.Primitives;
 using Hardcodet.Wpf.TaskbarNotification;
+using solidware.financials.messages;
 using solidware.financials.windows.ui.presenters;
 
 namespace solidware.financials.windows.ui.views
 {
-    public class TrayIcon : TaskbarIcon
+    public class TrayIcon : TaskbarIcon, Announcer
     {
         public virtual void Say(string message)
         {
product/desktop.ui/solidware.financials.csproj
@@ -114,6 +114,7 @@
     <Compile Include="bootstrappers\ComposeShell.cs" />
     <Compile Include="bootstrappers\ConfigureMappings.cs" />
     <Compile Include="bootstrappers\DefaultMapper.cs" />
+    <Compile Include="presenters\UIThread.cs" />
     <Compile Include="presenters\validation\AnonymousRule.cs" />
     <Compile Include="presenters\validation\Error.cs" />
     <Compile Include="presenters\validation\INotification.cs" />
@@ -396,6 +397,10 @@
   <ItemGroup>
     <EmbeddedResource Include="views\icons\mokhan.ico" />
   </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="views\icons\down.png" />
+    <EmbeddedResource Include="views\icons\up.png" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
product/messages/AddedNewFamilyMember.cs
@@ -1,11 +1,11 @@
 using System;
 using gorilla.utility;
-using solidware.financials.infrastructure.eventing;
 
 namespace solidware.financials.messages
 {
-    public class AddedNewFamilyMember : Event
+    public class AddedNewFamilyMember : Announcement
     {
+        public AddedNewFamilyMember() {}
         public Guid id { get; set; }
         public string first_name { get; set; }
         public string last_name { get; set; }
@@ -14,5 +14,10 @@ namespace solidware.financials.messages
         {
             return "Welcome to the family {0} {1}".format(first_name, last_name);
         }
+
+        public void AnnounceUsing(Announcer announcer)
+        {
+            //announcer.Say(ToString());
+        }
     }
 }
\ No newline at end of file
product/messages/AddIncomeCommandMessage.cs
@@ -11,7 +11,7 @@ namespace solidware.financials.messages
         public DateTime Date { get; set; }
     }
 
-    public class IncomeMessage : ValueType<IncomeMessage>, Event
+    public class IncomeMessage : ValueType<IncomeMessage>, Announcement
     {
         public Guid PersonId { get; set; }
         public decimal Amount { get; set; }
@@ -21,5 +21,9 @@ namespace solidware.financials.messages
         {
             return "You got paid {0:C}!".format(Amount);
         }
+
+        public void AnnounceUsing(Announcer announcer)
+        {
+        }
     }
 }
\ No newline at end of file
product/messages/Announcement.cs
@@ -0,0 +1,14 @@
+using solidware.financials.infrastructure.eventing;
+
+namespace solidware.financials.messages
+{
+    public interface Announcement : Event
+    {
+        void AnnounceUsing(Announcer announcer);
+    }
+
+    public interface Announcer
+    {
+        void Say(string message);
+    }
+}
\ No newline at end of file
product/messages/CurrentStockPrice.cs
@@ -1,10 +1,9 @@
 using System.Text;
 using gorilla.utility;
-using solidware.financials.infrastructure.eventing;
 
 namespace solidware.financials.messages
 {
-    public class CurrentStockPrice : ValueType<CurrentStockPrice>, Event
+    public class CurrentStockPrice : ValueType<CurrentStockPrice>, Announcement
     {
         public string Symbol { get; set; }
         public decimal Price { get; set; }
@@ -23,5 +22,10 @@ namespace solidware.financials.messages
             //builder.AppendLine("O:{0:C} H:{1:C} L:{2:C}".format(Open, High, Low));
             return builder.ToString();
         }
+
+        public void AnnounceUsing(Announcer announcer)
+        {
+            announcer.Say(ToString());
+        }
     }
 }
\ No newline at end of file
product/messages/messages.csproj
@@ -46,6 +46,7 @@
   <ItemGroup>
     <Compile Include="AddedNewFamilyMember.cs" />
     <Compile Include="AddIncomeCommandMessage.cs" />
+    <Compile Include="Announcement.cs" />
     <Compile Include="CurrentStockPrice.cs" />
     <Compile Include="FamilyMemberToAdd.cs" />
     <Compile Include="FindAllFamily.cs" />
product/messages/StartWatchingSymbol.cs
@@ -1,9 +1,8 @@
 using gorilla.utility;
-using solidware.financials.infrastructure.eventing;
 
 namespace solidware.financials.messages
 {
-    public class StartWatchingSymbol : ValueType<StartWatchingSymbol>, Event
+    public class StartWatchingSymbol : ValueType<StartWatchingSymbol>, Announcement
     {
         public string Symbol { get; set; }
 
@@ -11,5 +10,10 @@ namespace solidware.financials.messages
         {
             return "I will start watching {0}".format(Symbol);
         }
+
+        public void AnnounceUsing(Announcer announcer)
+        {
+            announcer.Say(ToString());
+        }
     }
 }
\ No newline at end of file