Commit 82d799d

mo <email@solidware.ca>
2011-03-18 04:43:00
refactor out a generic dialog.
1 parent ec400fa
product/desktop.ui/Properties/AssemblyInfo.cs
@@ -49,5 +49,5 @@ using System.Windows;
 // 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("2011.3.17.2218")]
-[assembly: AssemblyFileVersion("2011.3.17.2218")]
+[assembly: AssemblyVersion("2011.3.17.2242")]
+[assembly: AssemblyFileVersion("2011.3.17.2242")]
product/desktop.ui/views/AddFamilyMemberDialog.xaml
@@ -1,6 +1,8 @@
-<Window x:Class="solidware.financials.windows.ui.views.AddFamilyMemberDialog"
+<ui:WPFDialog x:Class="solidware.financials.windows.ui.views.AddFamilyMemberDialog"
+ xmlns:ui="clr-namespace:solidware.financials.windows.ui"              
+             x:TypeArguments="presenters:AddFamilyMemberPresenter"  
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Add A Family Member" ShowInTaskbar="False" WindowStartupLocation="CenterScreen" Width="400" Height="170">
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:presenters="clr-namespace:solidware.financials.windows.ui.presenters" Title="Add A Family Member" ShowInTaskbar="False" WindowStartupLocation="CenterScreen" Width="400" Height="170">
     <DockPanel>
         <StackPanel>
         <Label FontWeight="Bold">Add A Family Member</Label>
@@ -20,4 +22,4 @@
         </UniformGrid>
         </StackPanel>
     </DockPanel>
-</Window>
+</ui:WPFDialog>
product/desktop.ui/views/AddFamilyMemberDialog.xaml.cs
@@ -1,19 +1,10 @@
-using System.Windows;
-using solidware.financials.windows.ui.presenters;
-
 namespace solidware.financials.windows.ui.views
 {
-    public partial class AddFamilyMemberDialog : Dialog<AddFamilyMemberPresenter>
+    public partial class AddFamilyMemberDialog
     {
         public AddFamilyMemberDialog()
         {
             InitializeComponent();
         }
-
-        public void open()
-        {
-            Owner = Application.Current.MainWindow;
-            ShowDialog();
-        }
     }
 }
\ No newline at end of file
product/desktop.ui/views/AddNewIncomeDialog.xaml
@@ -1,7 +1,8 @@
-<Window x:Class="solidware.financials.windows.ui.views.AddNewIncomeDialog"
+<ui:WPFDialog  x:Class="solidware.financials.windows.ui.views.AddNewIncomeDialog"
+ xmlns:ui="clr-namespace:solidware.financials.windows.ui"              
+             x:TypeArguments="presenters:AddNewIncomeViewModel"  
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-        Title="Add Income" Width="400" Height="100"  WindowStartupLocation="CenterOwner">
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:presenters="clr-namespace:solidware.financials.windows.ui.presenters" Title="Add Income" Width="400" Height="100"  WindowStartupLocation="CenterOwner">
     <StackPanel>
         <DockPanel>
         <Label>Income Amount ($):</Label>
@@ -12,4 +13,4 @@
         <Button IsCancel="True" Command="{Binding Path=Cancel}">_Cancel</Button>
         </DockPanel>
     </StackPanel>
-</Window>
+</ui:WPFDialog >
product/desktop.ui/views/AddNewIncomeDialog.xaml.cs
@@ -1,19 +1,10 @@
-using System.Windows;
-using solidware.financials.windows.ui.presenters;
-
-namespace solidware.financials.windows.ui.views
+namespace solidware.financials.windows.ui.views
 {
-    public partial class AddNewIncomeDialog : Dialog<AddNewIncomeViewModel>
+    public partial class AddNewIncomeDialog
     {
         public AddNewIncomeDialog()
         {
             InitializeComponent();
         }
-
-        public void open()
-        {
-            Owner = Application.Current.MainWindow;
-            ShowDialog();
-        }
     }
 }
\ No newline at end of file
product/desktop.ui/views/DisplayCanadianTaxInformationDialog.xaml
@@ -1,8 +1,9 @@
-<Window x:Class="solidware.financials.windows.ui.views.DisplayCanadianTaxInformationDialog"
+<ui:WPFDialog  x:Class="solidware.financials.windows.ui.views.DisplayCanadianTaxInformationDialog"
+ xmlns:ui="clr-namespace:solidware.financials.windows.ui"              
+             x:TypeArguments="presenters:DisplayCanadianTaxInformationViewModel"  
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-        Title="DisplayCanadianTaxInformationDialog">
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:presenters="clr-namespace:solidware.financials.windows.ui.presenters" Title="DisplayCanadianTaxInformationDialog">
     <DockPanel>
         <WebBrowser x:Name="browser"></WebBrowser>
     </DockPanel>
-</Window>
+</ui:WPFDialog >
product/desktop.ui/views/DisplayCanadianTaxInformationDialog.xaml.cs
@@ -1,10 +1,8 @@
 using System;
-using System.Windows;
-using solidware.financials.windows.ui.presenters;
 
 namespace solidware.financials.windows.ui.views
 {
-    public partial class DisplayCanadianTaxInformationDialog : Dialog<DisplayCanadianTaxInformationViewModel>
+    public partial class DisplayCanadianTaxInformationDialog
     {
         public DisplayCanadianTaxInformationDialog()
         {
@@ -12,10 +10,5 @@ namespace solidware.financials.windows.ui.views
             browser.Navigate(new Uri("http://www.cra-arc.gc.ca/tx/ndvdls/fq/txrts-eng.html"));
         }
 
-        public void open()
-        {
-            Owner = Application.Current.MainWindow;
-            ShowDialog();
-        }
     }
 }
\ No newline at end of file
product/desktop.ui/Dialog.cs
@@ -1,8 +1,8 @@
 namespace solidware.financials.windows.ui
 {
-    public interface Dialog<TPresenter> : View<TPresenter> where TPresenter : DialogPresenter
+    public interface Dialog<Presenter> : View<Presenter> where Presenter : DialogPresenter
     {
-        void open();
+        void open(Presenter presenter);
         void Close();
     }
 }
\ No newline at end of file
product/desktop.ui/solidware.financials.csproj
@@ -150,6 +150,7 @@
     <Compile Include="views\TaxSummaryTab.xaml.cs">
       <DependentUpon>TaxSummaryTab.xaml</DependentUpon>
     </Compile>
+    <Compile Include="WPFDialog.cs" />
     <Compile Include="WPFApplication.cs" />
     <Compile Include="WPFApplicationController.cs" />
     <Compile Include="RegionManager.cs" />
product/desktop.ui/WPFApplicationController.cs
@@ -33,9 +33,8 @@ namespace solidware.financials.windows.ui
         {
             var presenter = factory.create<Presenter>();
             var dialog = new Dialog {DataContext = presenter};
-            presenter.close = () => dialog.Close();
             presenter.present();
-            dialog.open();
+            dialog.open(presenter);
         }
 
         public void load_region<TPresenter, Region>() where TPresenter : Presenter where Region : FrameworkElement, View<TPresenter>, new()
product/desktop.ui/WPFDialog.cs
@@ -0,0 +1,21 @@
+using System.Windows;
+
+namespace solidware.financials.windows.ui
+{
+    public class WPFDialog<TPresenter> : Window, Dialog<TPresenter> where TPresenter : DialogPresenter
+    {
+        public WPFDialog()
+        {
+            WindowStartupLocation = WindowStartupLocation.CenterOwner;
+            ShowInTaskbar = false;
+            WindowStyle = WindowStyle.SingleBorderWindow;
+        }
+
+        public void open(TPresenter presenter)
+        {
+            presenter.close = () => Close();
+            Owner = Application.Current.MainWindow;
+            ShowDialog();
+        }
+    }
+}
\ No newline at end of file