Commit 59a7e1f

mo <email@solidware.ca>
2011-03-26 22:00:31
add icons to menu items and dialogs.
1 parent 6e5a8df
product/desktop.ui/bootstrappers/ComposeShell.cs
@@ -1,6 +1,8 @@
 using System.Windows;
+using gorilla.infrastructure.container;
 using solidware.financials.windows.ui.presenters;
 using solidware.financials.windows.ui.views;
+using solidware.financials.windows.ui.views.icons;
 
 namespace solidware.financials.windows.ui.bootstrappers
 {
@@ -23,15 +25,13 @@ namespace solidware.financials.windows.ui.bootstrappers
 
             region_manager.region<MainMenu>(x =>
             {
-                x.add("_Family")
-                    .add("_Add Member", launch<AddFamilyMemberPresenter, AddFamilyMemberDialog>);
-                x.add("_Income")
-                    .add("_Add Income", launch<AddNewIncomeViewModel, AddNewIncomeDialog>);
+                x.add("_Application").add("E_xit", () => Resolve.the<Shell>().Close());
+                x.add("_Family").add("_Add Member", launch<AddFamilyMemberPresenter, AddFamilyMemberDialog>).apply_icon(UIIcon.Plus).parent();
+                x.add("_Income").add("_Add Income", launch<AddNewIncomeViewModel, AddNewIncomeDialog>).apply_icon(UIIcon.Plus);
                 //x.add("_Deductions").add("_Add RRSP", () => { }) ;
                 //x.add("_Credits").add("_Add Credit", () => { }) ;
                 //x.add("_Benefits").add("_Add Benefit", () => { }) ;
-                x.add("_Help")
-                    .add("_Taxes", launch<DisplayCanadianTaxInformationViewModel, DisplayCanadianTaxInformationDialog>);
+                x.add("_Help").add("_Taxes", launch<DisplayCanadianTaxInformationViewModel, DisplayCanadianTaxInformationDialog>).apply_icon(UIIcon.Help);
             });
 
             controller.load_region<StatusBarPresenter, StatusBarRegion>();
product/desktop.ui/views/icons/category.png
Binary file
product/desktop.ui/views/icons/comment.png
Binary file
product/desktop.ui/views/icons/delete.png
Binary file
product/desktop.ui/views/icons/edit.png
Binary file
product/desktop.ui/views/icons/help.ico
Binary file
product/desktop.ui/views/icons/IconMarker.cs
@@ -0,0 +1,15 @@
+using System.IO;
+using System.Reflection;
+
+namespace solidware.financials.windows.ui.views.icons
+{
+    public class IconMarker
+    {
+        private static readonly Assembly _assembly = Assembly.GetExecutingAssembly();
+
+        public static Stream GetImage(string path)
+        {
+            return _assembly.GetManifestResourceStream(typeof (IconMarker), path);
+        }
+    }
+}
\ No newline at end of file
product/desktop.ui/views/icons/plus.png
Binary file
product/desktop.ui/views/icons/refresh.png
Binary file
product/desktop.ui/views/icons/running.gif
Binary file
product/desktop.ui/views/icons/success.png
Binary file
product/desktop.ui/views/icons/UIIcon.cs
@@ -0,0 +1,40 @@
+using System.IO;
+using System.Windows.Media;
+
+namespace solidware.financials.windows.ui.views.icons
+{
+    public class UIIcon
+    {
+        static public readonly UIIcon Category = new UIIcon("category.png");
+        static public readonly UIIcon Comment = new UIIcon("comment.png");
+        static public readonly UIIcon Delete = new UIIcon("delete.png");
+        static public readonly UIIcon Edit = new UIIcon("edit.png");
+        static public readonly UIIcon Help = new UIIcon("help.ico");
+        static public readonly UIIcon Plus = new UIIcon("plus.png");
+        static public readonly UIIcon Refresh = new UIIcon("refresh.png");
+        static public readonly UIIcon Running = new UIIcon("running.gif");
+        static public readonly UIIcon Success = new UIIcon("success.png");
+
+        UIIcon(string path)
+        {
+            this.path = path;
+        }
+
+        public Stream ImageStream()
+        {
+            return IconMarker.GetImage(path);
+        }
+
+        public ImageSource BitmapFrame()
+        {
+            return System.Windows.Media.Imaging.BitmapFrame.Create(ImageStream());
+        }
+
+        public override string ToString()
+        {
+            return string.Format("Path: {0}", path);
+        }
+
+        string path;
+    }
+}
\ No newline at end of file
product/desktop.ui/views/AddFamilyMemberDialog.xaml.cs
@@ -1,3 +1,5 @@
+using solidware.financials.windows.ui.views.icons;
+
 namespace solidware.financials.windows.ui.views
 {
     public partial class AddFamilyMemberDialog
@@ -5,6 +7,7 @@ namespace solidware.financials.windows.ui.views
         public AddFamilyMemberDialog()
         {
             InitializeComponent();
+            Icon = UIIcon.Plus.BitmapFrame();
         }
     }
 }
\ No newline at end of file
product/desktop.ui/views/AddNewIncomeDialog.xaml.cs
@@ -5,6 +5,7 @@
         public AddNewIncomeDialog()
         {
             InitializeComponent();
+            Icon =  icons.UIIcon.Plus.BitmapFrame();
         }
     }
 }
\ No newline at end of file
product/desktop.ui/views/DisplayCanadianTaxInformationDialog.xaml.cs
@@ -1,4 +1,5 @@
 using System;
+using solidware.financials.windows.ui.views.icons;
 
 namespace solidware.financials.windows.ui.views
 {
@@ -7,8 +8,8 @@ namespace solidware.financials.windows.ui.views
         public DisplayCanadianTaxInformationDialog()
         {
             InitializeComponent();
+            Icon = UIIcon.Help.BitmapFrame();
             browser.Navigate(new Uri("http://www.cra-arc.gc.ca/tx/ndvdls/fq/txrts-eng.html"));
         }
-
     }
 }
\ No newline at end of file
product/desktop.ui/views/MenuItemExtensions.cs
@@ -1,5 +1,8 @@
 using System;
 using System.Windows.Controls;
+using System.Windows.Media.Imaging;
+using gorilla.utility;
+using solidware.financials.windows.ui.views.icons;
 
 namespace solidware.financials.windows.ui.views
 {
@@ -11,5 +14,31 @@ namespace solidware.financials.windows.ui.views
             item.Items.Add(menu_item);
             return menu_item;
         }
+
+        static public MenuItem parent(this MenuItem item)
+        {
+            return item.Parent.downcast_to<MenuItem>();
+        }
+
+        static public MenuItem apply_icon(this MenuItem item, UIIcon icon)
+        {
+            var image = new Image();
+            image.Width = 16;
+            image.Height = 16;
+            image.apply_icon(icon);
+            item.Icon = image;
+            return item;
+        }
+
+        static public void apply_icon(this Image image, UIIcon icon)
+        {
+            image.Tag = icon;
+
+            var source = new BitmapImage();
+            source.BeginInit();
+            source.StreamSource = icon.ImageStream();
+            source.EndInit();
+            image.Source = source;
+        }
     }
 }
\ No newline at end of file
product/desktop.ui/views/Shell.xaml
@@ -16,9 +16,17 @@
           <ad:DockablePane ad:ResizingPanel.ResizeWidth="150">
             <ad:DockableContent x:Name="classesContent" Title="Classes">
               <TreeView>
-                <TreeViewItem Header="Class1"/>
-                <TreeViewItem Header="Class2"/>
-              </TreeView>
+                <TreeViewItem Header="2011">
+                    <TreeViewItem Header="January"></TreeViewItem>
+                    <TreeViewItem Header="February"></TreeViewItem>
+                    <TreeViewItem Header="March"></TreeViewItem>
+                </TreeViewItem>
+                <TreeViewItem Header="2010">
+                    <TreeViewItem Header="January"></TreeViewItem>
+                    <TreeViewItem Header="February"></TreeViewItem>
+                    <TreeViewItem Header="March"></TreeViewItem>
+                </TreeViewItem>
+            </TreeView>
             </ad:DockableContent>
             <ad:DockableContent x:Name="toolsContent" Title="Tools">
               <ListBox>
product/desktop.ui/solidware.financials.csproj
@@ -90,7 +90,6 @@
     <Reference Include="System" />
     <Reference Include="System.Data" />
     <Reference Include="System.Drawing" />
-    <Reference Include="System.Windows.Forms" />
     <Reference Include="System.Xml" />
     <Reference Include="Microsoft.CSharp" />
     <Reference Include="System.Core" />
@@ -159,6 +158,8 @@
     <Compile Include="views\ErrorWindow.xaml.cs">
       <DependentUpon>ErrorWindow.xaml</DependentUpon>
     </Compile>
+    <Compile Include="views\icons\UIIcon.cs" />
+    <Compile Include="views\icons\IconMarker.cs" />
     <Compile Include="views\ImageButton.cs" />
     <Compile Include="views\MainMenu.cs" />
     <Compile Include="views\MenuItemExtensions.cs" />
@@ -292,6 +293,36 @@
       <Install>true</Install>
     </BootstrapperPackage>
   </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="views\icons\help.ico" />
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="resources\" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="views\icons\plus.png" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="views\icons\comment.png" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="views\icons\category.png" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="views\icons\delete.png" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="views\icons\edit.png" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="views\icons\refresh.png" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="views\icons\running.gif" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="views\icons\success.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/desktop.ui/WPFApplicationController.cs
@@ -26,7 +26,7 @@ namespace solidware.financials.windows.ui
             configure_region<DocumentPane>(x => x.Items.Add(new DocumentContent
             {
                 Title = presenter.Header,
-                Content = new View {DataContext = presenter}
+                Content = new View {DataContext = presenter},
             }));
         }