Add an about window.
authorGreg Burri <greg.burri@gmail.com>
Sun, 17 Jan 2016 18:39:37 +0000 (19:39 +0100)
committerGreg Burri <greg.burri@gmail.com>
Sun, 17 Jan 2016 18:39:37 +0000 (19:39 +0100)
Parasitemia/Parasitemia/AssemblyInfo.fs
Parasitemia/Parasitemia/GUI/About.fs [new file with mode: 0644]
Parasitemia/Parasitemia/GUI/AboutWindow.xaml [new file with mode: 0644]
Parasitemia/Parasitemia/GUI/AboutWindow.xaml.fs [new file with mode: 0644]
Parasitemia/Parasitemia/GUI/Analysis.fs
Parasitemia/Parasitemia/GUI/GUI.fs
Parasitemia/Parasitemia/GUI/MainWindow.xaml
Parasitemia/Parasitemia/Parasitemia.fsproj

index 269e427..1027e98 100644 (file)
@@ -4,20 +4,20 @@ open System.Reflection
 open System.Runtime.CompilerServices
 open System.Runtime.InteropServices
 
-// General Information about an assembly is controlled through the following 
+// 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("Parasitemia")>]
 [<assembly: AssemblyDescription("")>]
 [<assembly: AssemblyConfiguration("")>]
-[<assembly: AssemblyCompany("")>]
+[<assembly: AssemblyCompany("HES-SO / CHUV / Grégory Burri")>]
 [<assembly: AssemblyProduct("Parasitemia")>]
-[<assembly: AssemblyCopyright("Copyright ©  2015")>]
+[<assembly: AssemblyCopyright("Copyright © 2015-2016")>]
 [<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 
+// 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)>]
 
@@ -25,13 +25,13 @@ open System.Runtime.InteropServices
 [<assembly: Guid("70838e65-f211-44fc-b28f-0ed1ca6e850f")>]
 
 // Version information for an assembly consists of the following four values:
-// 
+//
 //       Major Version
-//       Minor Version 
+//       Minor Version
 //       Build Number
 //       Revision
-// 
-// You can specify all the values or you can default the Build and Revision Numbers 
+//
+// 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")>]
diff --git a/Parasitemia/Parasitemia/GUI/About.fs b/Parasitemia/Parasitemia/GUI/About.fs
new file mode 100644 (file)
index 0000000..bc8f3e5
--- /dev/null
@@ -0,0 +1,33 @@
+module Parasitemia.GUI.About
+
+open System
+open System.Windows
+open System.Windows.Media
+open System.Windows.Markup
+open System.Windows.Shapes
+open System.Windows.Controls
+open System.Diagnostics
+
+let showWindow (parent: Window) =
+    let window = Views.AboutWindow()
+    window.Root.Owner <- parent
+    window.Root.Left <- parent.Left + parent.ActualWidth / 2. - window.Root.Width / 2.
+    window.Root.Top <- parent.Top + parent.ActualHeight / 2. - window.Root.Height / 2.
+
+    let ctrl (name: string): 'a = window.Root.FindName(name) :?> 'a
+
+    let butClose: Button = ctrl "butClose"
+    let txtAbout: TextBlock = ctrl "txtAbout"
+
+    let version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version
+    let txtVersion = sprintf "%d.%d.%d" version.Major version.Minor version.Revision
+    txtAbout.Inlines.FirstInline.ElementEnd.InsertTextInRun(txtVersion)
+
+#if DEBUG
+    txtAbout.Inlines.FirstInline.ElementEnd.InsertTextInRun(" - DEBUG")
+#endif
+
+    butClose.Click.AddHandler(fun obj args -> window.Root.Close())
+
+    window.Root.ShowDialog() |> ignore
+
diff --git a/Parasitemia/Parasitemia/GUI/AboutWindow.xaml b/Parasitemia/Parasitemia/GUI/AboutWindow.xaml
new file mode 100644 (file)
index 0000000..3cb0de4
--- /dev/null
@@ -0,0 +1,24 @@
+<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        mc:Ignorable="d"
+        x:Name="AboutWindow" Height="200.969" Width="282.313" MinHeight="100" MinWidth="100" Title="About" Icon="pack://application:,,,/Resources/icon.ico">
+   <Grid>
+      <Grid.RowDefinitions>
+         <RowDefinition Height="Auto"/>
+         <RowDefinition Height="Auto"/>
+         <RowDefinition/>
+      </Grid.RowDefinitions>
+      <Image HorizontalAlignment="Left" Height="64" VerticalAlignment="Top" Width="64" Margin="6" Source="pack://application:,,,/Resources/icon.ico"/>
+      <TextBlock x:Name="txtAbout" HorizontalAlignment="Left" Margin="6" Grid.Row="1" TextWrapping="Wrap">
+         <Bold>Parasitemia </Bold>
+         <LineBreak />
+         <Hyperlink NavigateUri="http://www.hes-so.ch">HES-SO</Hyperlink> /
+         <Hyperlink NavigateUri="http://www.chuv.ch/">CHUV</Hyperlink>
+         <LineBreak />
+         Grégory Burri
+      </TextBlock>
+      <Button x:Name="butClose" Content="Close" HorizontalAlignment="Right" Margin="3" VerticalAlignment="Bottom" Width="75" Grid.Row="2" Height="20"/>
+   </Grid>
+</Window>
\ No newline at end of file
diff --git a/Parasitemia/Parasitemia/GUI/AboutWindow.xaml.fs b/Parasitemia/Parasitemia/GUI/AboutWindow.xaml.fs
new file mode 100644 (file)
index 0000000..5901226
--- /dev/null
@@ -0,0 +1,6 @@
+namespace Parasitemia.GUI.Views
+
+open FsXaml
+
+type AboutWindow = XAML<"GUI/AboutWindow.xaml">
+
index 0c79d79..7d72e72 100644 (file)
@@ -23,8 +23,7 @@ let showWindow (parent: Window) (state: State.State) : bool =
     window.Root.Left <- parent.Left + parent.ActualWidth / 2. - window.Root.Width / 2.
     window.Root.Top <- parent.Top + parent.ActualHeight / 2. - window.Root.Height / 2.
 
-    let ctrl (name: string): 'a =
-        window.Root.FindName(name) :?> 'a
+    let ctrl (name: string): 'a = window.Root.FindName(name) :?> 'a
 
     let butClose: Button = ctrl "butClose"
     let butStart: Button = ctrl "butStart"
index 8c57e20..950afc9 100644 (file)
@@ -19,8 +19,7 @@ open Types
 let run (defaultConfig: Config) (fileToOpen: string option) =
     let app = new Application()
     let mainWindow = Views.MainWindow()
-    let ctrl (name: string): 'a =
-        mainWindow.Root.FindName(name) :?> 'a
+    let ctrl (name: string): 'a = mainWindow.Root.FindName(name) :?> 'a
 
     let colorRBCHealthy = Brushes.YellowGreen
     let colorRBCInfected = Brushes.Red
@@ -38,6 +37,7 @@ let run (defaultConfig: Config) (fileToOpen: string option) =
     let menuStartAnalysis: MenuItem = ctrl "menuStartAnalysis"
     let menuView: MenuItem = ctrl "menuView"
     let menuHightlightRBC: MenuItem = ctrl "menuHightlightRBC"
+    let menuAbout: MenuItem = ctrl "menuAbout"
 
     let txtPatient: TextBox = ctrl "txtPatient"
     let txtGlobalParasitemia: TextBox = ctrl "txtGlobalParasitemia"
@@ -363,18 +363,22 @@ let run (defaultConfig: Config) (fileToOpen: string option) =
         updateGUI())
 
     menuAddSourceImage.Click.AddHandler(fun obj args ->
-        let dialog = OpenFileDialog(Filter = "Image Files|*.png;*.jpg;*.tif;*.tiff")
+        let dialog = OpenFileDialog(Filter = "Image Files|*.png;*.jpg;*.tif;*.tiff", Multiselect = true)
         let res = dialog.ShowDialog()
         if res.HasValue && res.Value
         then
-            let srcImg = state.AddSourceImage dialog.FileName defaultConfig
-            addPreview srcImg
+            let noSourceImage = state.SourceImages.Count() = 0
+
+            for filename in dialog.FileNames do
+                let srcImg = state.AddSourceImage filename defaultConfig
+                addPreview srcImg
+
             updateGlobalParasitemia ()
-            if state.SourceImages.Count() = 1
+
+            if noSourceImage
             then
                 updateCurrentImage ())
 
-
     menuAnalysis.SubmenuOpened.AddHandler(fun obj args -> menuStartAnalysis.IsEnabled <- state.SourceImages.Count() > 0)
 
     menuStartAnalysis.Click.AddHandler(fun obj args ->
@@ -388,6 +392,8 @@ let run (defaultConfig: Config) (fileToOpen: string option) =
         updateRBCFramesPreview ()
         updateRBCFramesCurrent ())
 
+    menuAbout.Click.AddHandler(fun obj args -> About.showWindow mainWindow.Root)
+
     // Zoom on the current image.
     let adjustCurrentImageBorders (deltaX: float) (deltaY: float) =
         borderCurrentImage.BorderThickness <-
index a2151d7..37ea0c0 100644 (file)
@@ -22,6 +22,9 @@
          <MenuItem x:Name="menuView" Header="_View">
             <MenuItem x:Name="menuHightlightRBC" Header="_Highlight healthy erytrocytes" IsCheckable="True" />
          </MenuItem>
+         <MenuItem x:Name="menuHelp" Header="_Help">
+            <MenuItem x:Name="menuAbout" Header="_About" />
+         </MenuItem>
       </Menu>
       <Grid x:Name="gridMain">
          <Grid.RowDefinitions>
index 610d802..e20ecb9 100644 (file)
     <Compile Include="GUI\RBCFrame.xaml.fs" />
     <Resource Include="GUI\AnalysisWindow.xaml" />
     <Compile Include="GUI\AnalysisWindow.xaml.fs" />
+    <Resource Include="GUI\AboutWindow.xaml" />
+    <Compile Include="GUI\AboutWindow.xaml.fs" />
     <Resource Include="GUI\MainWindow.xaml" />
     <Compile Include="GUI\MainWindow.xaml.fs" />
     <Compile Include="GUI\Types.fs" />
     <Compile Include="GUI\PiaZ.fs" />
     <Compile Include="GUI\State.fs" />
+    <Compile Include="GUI\About.fs" />
     <Compile Include="GUI\Analysis.fs" />
     <Compile Include="GUI\GUI.fs" />
     <Compile Include="Program.fs" />