From: Greg Burri Date: Sat, 20 Mar 2021 14:20:03 +0000 (+0100) Subject: To .NET 5 (lot of refactoring) X-Git-Tag: 1.0.13~8 X-Git-Url: http://git.euphorik.ch/?a=commitdiff_plain;h=95f9edf71456c8bf89a91850800f66efc2c9d4da;p=master-thesis.git To .NET 5 (lot of refactoring) --- diff --git a/Parasitemia/Logger/Logger.fs b/Parasitemia/Logger/Logger.fs index 4fc1736..7d54843 100644 --- a/Parasitemia/Logger/Logger.fs +++ b/Parasitemia/Logger/Logger.fs @@ -109,7 +109,7 @@ type Log () = let header = String.Format ( "{0:yyyy-MM-dd HH:mm:ss.fff} [{1}] {{{2}}} ({3})", - TimeZone.CurrentTimeZone.ToLocalTime DateTime.UtcNow, + DateTime.Now, string msg.Severity, msg.ModuleCaller, (if String.IsNullOrEmpty msg.ThreadName then string msg.ThreadId else sprintf "%s-%i" msg.ThreadName msg.ThreadId) diff --git a/Parasitemia/Logger/Logger.fsproj b/Parasitemia/Logger/Logger.fsproj index 1aed49f..618ff42 100644 --- a/Parasitemia/Logger/Logger.fsproj +++ b/Parasitemia/Logger/Logger.fsproj @@ -1,66 +1,17 @@ - - - + + - Debug - AnyCPU - 2.0 - a4f183ae-562a-4bad-88e6-658b4ce15dc3 Library - Logger - Logger - v4.8 - 4.4.3.0 - true - Logger - - - - true - full - false - false - bin\Debug\ - DEBUG;TRACE - 3 - bin\Debug\Logger.XML - AnyCPU - - - pdbonly - true - true - bin\Release\ - TRACE - 3 - bin\Release\Logger.XML - AnyCPU + net5.0 - - - - True - - - - - + - - 11 - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - - + + + + + \ No newline at end of file diff --git a/Parasitemia/Parasitemia.sln b/Parasitemia/Parasitemia.sln index 42e8f4e..15b5e71 100644 --- a/Parasitemia/Parasitemia.sln +++ b/Parasitemia/Parasitemia.sln @@ -1,24 +1,23 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26430.6 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30804.86 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "ParasitemiaUI", "ParasitemiaUI\ParasitemiaUI.fsproj", "{70838E65-F211-44FC-B28F-0ED1CA6E850F}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ParasitemiaUI", "ParasitemiaUI\ParasitemiaUI.fsproj", "{70838E65-F211-44FC-B28F-0ED1CA6E850F}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF", "WPF\WPF.csproj", "{314FD78E-870E-4794-BB16-EA4586F2ABDB}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Logger", "Logger\Logger.fsproj", "{A4F183AE-562A-4BAD-88E6-658B4CE15DC3}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Logger", "Logger\Logger.fsproj", "{A4F183AE-562A-4BAD-88E6-658B4CE15DC3}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "ParasitemiaCore", "ParasitemiaCore\ParasitemiaCore.fsproj", "{0F8A85F4-9328-40C3-B8FF-44FB39CEB01F}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ParasitemiaCore", "ParasitemiaCore\ParasitemiaCore.fsproj", "{0F8A85F4-9328-40C3-B8FF-44FB39CEB01F}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{1EC5C716-CA52-46FD-A76C-BEF9459E5561}" EndProject Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "ParasitemiaCore.Tests", "Tests\ParasitemiaCore.Tests\ParasitemiaCore.Tests.fsproj", "{2AB542E3-5F90-48CA-9442-32B2780B3E4A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ParasitemiaUIControls", "ParasitemiaUIControls\ParasitemiaUIControls.csproj", "{98E21672-B520-4CBA-86C7-6A0856367A10}" +EndProject Global - GlobalSection(Performance) = preSolution - HasPerformanceSessions = true - EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU DebugGUI|Any CPU = DebugGUI|Any CPU @@ -55,6 +54,12 @@ Global {2AB542E3-5F90-48CA-9442-32B2780B3E4A}.DebugGUI|Any CPU.Build.0 = Debug|Any CPU {2AB542E3-5F90-48CA-9442-32B2780B3E4A}.Release|Any CPU.ActiveCfg = Release|Any CPU {2AB542E3-5F90-48CA-9442-32B2780B3E4A}.Release|Any CPU.Build.0 = Release|Any CPU + {98E21672-B520-4CBA-86C7-6A0856367A10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {98E21672-B520-4CBA-86C7-6A0856367A10}.Debug|Any CPU.Build.0 = Debug|Any CPU + {98E21672-B520-4CBA-86C7-6A0856367A10}.DebugGUI|Any CPU.ActiveCfg = Debug|Any CPU + {98E21672-B520-4CBA-86C7-6A0856367A10}.DebugGUI|Any CPU.Build.0 = Debug|Any CPU + {98E21672-B520-4CBA-86C7-6A0856367A10}.Release|Any CPU.ActiveCfg = Release|Any CPU + {98E21672-B520-4CBA-86C7-6A0856367A10}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -62,6 +67,12 @@ Global GlobalSection(NestedProjects) = preSolution {2AB542E3-5F90-48CA-9442-32B2780B3E4A} = {1EC5C716-CA52-46FD-A76C-BEF9459E5561} EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EE42D93F-9364-4E6D-8D65-A065EEDB5733} + EndGlobalSection + GlobalSection(Performance) = preSolution + HasPerformanceSessions = true + EndGlobalSection GlobalSection(Performance) = preSolution HasPerformanceSessions = true EndGlobalSection diff --git a/Parasitemia/ParasitemiaCore/Analysis.fs b/Parasitemia/ParasitemiaCore/Analysis.fs index ed908e2..a4bb0ec 100644 --- a/Parasitemia/ParasitemiaCore/Analysis.fs +++ b/Parasitemia/ParasitemiaCore/Analysis.fs @@ -2,7 +2,6 @@ open System open System.Linq -open System.Drawing open FSharp.Collections.ParallelSeq @@ -178,7 +177,7 @@ let doAnalysis (img : Image) (name : string) (config : Config) (repor /// An optional function to report progress and/or cancel the process. /// The first call returning 'false' will cancel the analysis. /// The 'int' parameter correspond to the progression from 0 to 100 -/// 'None' if the process has been cancelled or the list of result as (name * cells), 'name' corresponds to the given name +/// 'None' if the process has been cancelled or the list of result as (name * cells), 'name' corresponds to the given name let doMultipleAnalysis (imgs : (string * Config * Image) list) (reportProgress : (int -> bool) option) : (string * AnalysisResult) list option = let report (percent : int) : bool = match reportProgress with diff --git a/Parasitemia/ParasitemiaCore/Classifier.fs b/Parasitemia/ParasitemiaCore/Classifier.fs index a2d9e4f..475e336 100644 --- a/Parasitemia/ParasitemiaCore/Classifier.fs +++ b/Parasitemia/ParasitemiaCore/Classifier.fs @@ -5,7 +5,6 @@ open System.Collections.Generic open System.Drawing open Emgu.CV -open Emgu.CV.Structure open Types open Utils diff --git a/Parasitemia/ParasitemiaCore/Ellipse.fs b/Parasitemia/ParasitemiaCore/Ellipse.fs index d0dea6e..65264ad 100644 --- a/Parasitemia/ParasitemiaCore/Ellipse.fs +++ b/Parasitemia/ParasitemiaCore/Ellipse.fs @@ -7,7 +7,6 @@ open System.Drawing open MathNet.Numerics.LinearAlgebra open Emgu.CV -open Emgu.CV.Structure open Utils open Config diff --git a/Parasitemia/ParasitemiaCore/Granulometry.fs b/Parasitemia/ParasitemiaCore/Granulometry.fs index 287cd3e..ea5ef67 100644 --- a/Parasitemia/ParasitemiaCore/Granulometry.fs +++ b/Parasitemia/ParasitemiaCore/Granulometry.fs @@ -1,7 +1,6 @@ module ParasitemiaCore.Granulometry open System -open System.IO open System.Drawing open Emgu.CV @@ -15,6 +14,7 @@ open Utils /// /// Minimum radius * maximum radius /// le 1.0, to speed up the process. +/// let findRadiusByClosing (img : Image) (range : int * int) (scale : float) (useOctagon : bool) : int = use scaledImg = if scale = 1. then img else img.Resize (scale, CvEnum.Inter.Area) diff --git a/Parasitemia/ParasitemiaCore/ImgTools/Drawing.fs b/Parasitemia/ParasitemiaCore/ImgTools/Drawing.fs index 2882f4b..51f3354 100644 --- a/Parasitemia/ParasitemiaCore/ImgTools/Drawing.fs +++ b/Parasitemia/ParasitemiaCore/ImgTools/Drawing.fs @@ -1,6 +1,5 @@ module ParasitemiaCore.Drawing -open System open System.Drawing open Emgu.CV diff --git a/Parasitemia/ParasitemiaCore/ImgTools/Edges.fs b/Parasitemia/ParasitemiaCore/ImgTools/Edges.fs index 7c3e6d3..b44c768 100644 --- a/Parasitemia/ParasitemiaCore/ImgTools/Edges.fs +++ b/Parasitemia/ParasitemiaCore/ImgTools/Edges.fs @@ -1,6 +1,5 @@ module ParasitemiaCore.Edges -open System open System.Drawing open System.Collections.Generic diff --git a/Parasitemia/ParasitemiaCore/ImgTools/IO.fs b/Parasitemia/ParasitemiaCore/ImgTools/IO.fs index 08adfb0..f052271 100644 --- a/Parasitemia/ParasitemiaCore/ImgTools/IO.fs +++ b/Parasitemia/ParasitemiaCore/ImgTools/IO.fs @@ -1,8 +1,5 @@ module ParasitemiaCore.IO -open System -open System.Drawing - open Emgu.CV open Emgu.CV.Structure diff --git a/Parasitemia/ParasitemiaCore/ImgTools/ImgTools.fs b/Parasitemia/ParasitemiaCore/ImgTools/ImgTools.fs index fc89047..991cb76 100644 --- a/Parasitemia/ParasitemiaCore/ImgTools/ImgTools.fs +++ b/Parasitemia/ParasitemiaCore/ImgTools/ImgTools.fs @@ -1,6 +1,5 @@ module ParasitemiaCore.ImgTools -open System open System.Drawing open Emgu.CV diff --git a/Parasitemia/ParasitemiaCore/KMeans.fs b/Parasitemia/ParasitemiaCore/KMeans.fs index c0276d9..9bb0691 100644 --- a/Parasitemia/ParasitemiaCore/KMeans.fs +++ b/Parasitemia/ParasitemiaCore/KMeans.fs @@ -1,6 +1,5 @@ module ParasitemiaCore.KMeans -open System.Collections.Generic open System.Drawing open Emgu.CV diff --git a/Parasitemia/ParasitemiaCore/MatchingEllipses.fs b/Parasitemia/ParasitemiaCore/MatchingEllipses.fs index 03a3869..67c2fb1 100644 --- a/Parasitemia/ParasitemiaCore/MatchingEllipses.fs +++ b/Parasitemia/ParasitemiaCore/MatchingEllipses.fs @@ -1,9 +1,6 @@ module ParasitemiaCore.MatchingEllipses -open System open System.Drawing -open System.Linq -open System.Collections open System.Collections.Generic open Types diff --git a/Parasitemia/ParasitemiaCore/ParasitemiaCore.fsproj b/Parasitemia/ParasitemiaCore/ParasitemiaCore.fsproj index 2642de5..4309643 100644 --- a/Parasitemia/ParasitemiaCore/ParasitemiaCore.fsproj +++ b/Parasitemia/ParasitemiaCore/ParasitemiaCore.fsproj @@ -1,52 +1,10 @@ - - - - + + - Debug - AnyCPU - 2.0 - 0f8a85f4-9328-40c3-b8ff-44fb39ceb01f Library - ParasitemiaCore - ParasitemiaCore - v4.8 - 4.4.1.0 - true - ParasitemiaCore - - - + net5.0 - - true - full - false - false - bin\Debug\ - DEBUG;TRACE - 3 - bin\Debug\ParasitemiaCore.XML - AnyCPU - - - pdbonly - true - true - bin\Release\ - TRACE - 3 - - - AnyCPU - - - 11 - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - + @@ -76,73 +34,18 @@ + + + + + + + - - ..\packages\EmguCV.3.1.0.1\lib\net30\Emgu.CV.UI.dll - - - ..\packages\EmguCV.3.1.0.1\lib\net30\Emgu.CV.UI.GL.dll - - - ..\packages\EmguCV.3.1.0.1\lib\net30\Emgu.CV.World.dll - - - ..\packages\FSharp.Collections.ParallelSeq.1.1.3\lib\net45\FSharp.Collections.ParallelSeq.dll - - - ..\packages\FSharp.Core.4.7.2\lib\net45\FSharp.Core.dll - - - ..\packages\MathNet.Numerics.4.11.0\lib\net461\MathNet.Numerics.dll - - - ..\packages\MathNet.Numerics.FSharp.4.11.0\lib\net45\MathNet.Numerics.FSharp.dll - - - - ..\packages\OpenTK.3.2\lib\net20\OpenTK.dll - - - ..\packages\OpenTK.GLControl.3.1.0\lib\net20\OpenTK.GLControl.dll - - - - - - - - True - - - - True - - - - - ..\packages\ZedGraph.5.1.7\lib\net35-Client\ZedGraph.dll - + + - - Logger - {a4f183ae-562a-4bad-88e6-658b4ce15dc3} - True - + - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - \ No newline at end of file diff --git a/Parasitemia/ParasitemiaCore/ParasitesMarker.fs b/Parasitemia/ParasitemiaCore/ParasitesMarker.fs index b89caa6..c815d86 100644 --- a/Parasitemia/ParasitemiaCore/ParasitesMarker.fs +++ b/Parasitemia/ParasitemiaCore/ParasitesMarker.fs @@ -10,7 +10,6 @@ open Utils open Histogram open Otsu open Morpho -open ImgTools type Result = { diff --git a/Parasitemia/ParasitemiaUI/About.fs b/Parasitemia/ParasitemiaUI/About.fs index 8c643b7..d421e22 100644 --- a/Parasitemia/ParasitemiaUI/About.fs +++ b/Parasitemia/ParasitemiaUI/About.fs @@ -1,12 +1,12 @@ module ParasitemiaUI.About -open System open System.Windows -open System.Windows.Controls open System.Diagnostics +open ParasitemiaUIControls + let showWindow (parent : Window) = - let win = Views.AboutWindow () + let win = AboutWindow () win.Owner <- parent win.Left <- (if parent.WindowState = WindowState.Maximized then 0. else parent.Left) + parent.ActualWidth / 2. - win.Width / 2. diff --git a/Parasitemia/ParasitemiaUI/Analysis.fs b/Parasitemia/ParasitemiaUI/Analysis.fs index 9a6047e..43987d1 100644 --- a/Parasitemia/ParasitemiaUI/Analysis.fs +++ b/Parasitemia/ParasitemiaUI/Analysis.fs @@ -1,25 +1,18 @@ module ParasitemiaUI.Analysis open System -open System.IO open System.Linq open System.Windows -open System.Windows.Media -open System.Windows.Markup -open System.Windows.Shapes open System.Windows.Controls -open System.Diagnostics -open Microsoft.Win32 // For the common dialogs. - -open Emgu.CV.WPF +open ParasitemiaUIControls open ParasitemiaCore.UnitsOfMeasure open ParasitemiaCore.Config open Types let showWindow (parent : Window) (state : State.State) : bool = - let win = Views.AnalysisWindow () + let win = AnalysisWindow () win.Owner <- parent win.Left <- (if parent.WindowState = WindowState.Maximized then 0. else parent.Left) + parent.ActualWidth / 2. - win.Width / 2. win.Top <- (if parent.WindowState = WindowState.Maximized then 0. else parent.Top) + parent.ActualHeight / 2. - win.Height / 2. @@ -54,7 +47,7 @@ let showWindow (parent : Window) (state : State.State) : bool = win.stackSourceImagesSelection.Children.Clear () let width = int win.stackSourceImagesSelection.ActualWidth for srcImg in state.SourceImages do - let imageSourceSelection = Views.ImageSourceSelection (Tag = srcImg, Margin = Thickness 3.) + let imageSourceSelection = ImageSourceSelection (Tag = srcImg, Margin = Thickness 3.) imageSourceSelection.Tag <- srcImg imageSourceSelection.txtImageNumber.Text <- string srcImg.RomanNum @@ -95,7 +88,7 @@ let showWindow (parent : Window) (state : State.State) : bool = // Get the new parameters for each image. If an error occurs then 'None' is returned and a message box is displayed. // The boolean is 'true' if the image is selected (checked). let getInputImagesParameters () : (SourceImage * bool * Parameters) list option = - let sourceImagesControls = win.stackSourceImagesSelection.Children |> Seq.cast + let sourceImagesControls = win.stackSourceImagesSelection.Children |> Seq.cast let parameters = seq { for srcImgCtrl in sourceImagesControls do diff --git a/Parasitemia/ParasitemiaUI/App.config b/Parasitemia/ParasitemiaUI/App.config deleted file mode 100644 index 5a363e0..0000000 --- a/Parasitemia/ParasitemiaUI/App.config +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Parasitemia/ParasitemiaUI/BitmapSourceConvert.fs b/Parasitemia/ParasitemiaUI/BitmapSourceConvert.fs new file mode 100644 index 0000000..ea41240 --- /dev/null +++ b/Parasitemia/ParasitemiaUI/BitmapSourceConvert.fs @@ -0,0 +1,30 @@ +namespace ParasitemiaUI + +open System +open System.Runtime.InteropServices +open System.Windows +open System.Windows.Media.Imaging + +open Emgu.CV + +module BitmapSourceConvert = + [] + extern int DeleteObject(IntPtr o); + + let ToBitmapSource (image : Image<'TColor, 'TDepth>) : BitmapSource = + use source = image.ToBitmap () + + let ptr : IntPtr = source.GetHbitmap () + + let bs : BitmapSource = + System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap + ( + ptr, + IntPtr.Zero, + Int32Rect.Empty, + (BitmapSizeOptions.FromEmptyOptions ()) + ) + + DeleteObject ptr |> ignore + + bs diff --git a/Parasitemia/ParasitemiaUI/CommandLineArguments.fs b/Parasitemia/ParasitemiaUI/CommandLineArguments.fs index 8025ebf..02d7979 100644 --- a/Parasitemia/ParasitemiaUI/CommandLineArguments.fs +++ b/Parasitemia/ParasitemiaUI/CommandLineArguments.fs @@ -1,12 +1,11 @@ module ParasitemiaUI.CommandLineArguments -open System open System.Windows -open System.Windows.Controls -open System.Diagnostics + +open ParasitemiaUIControls let showWindow (parent : Window) = - let win = Views.CommandLineArgumentsWindow () + let win = CommandLineArgumentsWindow () win.Owner <- parent win.Left <- (if parent.WindowState = WindowState.Maximized then 0. else parent.Left) + parent.ActualWidth / 2. - win.Width / 2. diff --git a/Parasitemia/ParasitemiaUI/DPICalculator.fs b/Parasitemia/ParasitemiaUI/DPICalculator.fs index 2cdc184..697bbef 100644 --- a/Parasitemia/ParasitemiaUI/DPICalculator.fs +++ b/Parasitemia/ParasitemiaUI/DPICalculator.fs @@ -2,19 +2,15 @@ open System open System.Windows -open System.Windows.Media -open System.Windows.Markup -open System.Windows.Shapes -open System.Windows.Controls -open System.Diagnostics +open ParasitemiaUIControls open ParasitemiaCore.Types open ParasitemiaCore.UnitsOfMeasure open Types let showWindow (parent : Window) : int option = - let win = Views.PPICalculatorWindow () + let win = PPICalculatorWindow () win.Owner <- parent win.Left <- parent.Left + parent.ActualWidth / 2. - win.Width / 2. win.Top <- parent.Top + parent.ActualHeight / 2. - win.Height / 2. @@ -30,7 +26,7 @@ let showWindow (parent : Window) : int option = let { w = w; h = h } = win.cmbSensorSize.SelectedValue :?> SensorSize let ratio = h / w - let parseDouble txt errorMess = match Double.TryParse (txt) with true, value -> Success value | _ -> Fail errorMess + let parseDouble (txt : string) (errorMess : string) = match Double.TryParse (txt) with true, value -> Success value | _ -> Fail errorMess match (result { diff --git a/Parasitemia/ParasitemiaUI/GUI.fs b/Parasitemia/ParasitemiaUI/GUI.fs index f305687..83e54c2 100644 --- a/Parasitemia/ParasitemiaUI/GUI.fs +++ b/Parasitemia/ParasitemiaUI/GUI.fs @@ -5,23 +5,19 @@ open System.IO open System.Linq open System.Windows open System.Windows.Media -open System.Windows.Markup -open System.Windows.Shapes open System.Windows.Controls -open System.Diagnostics open Microsoft.Win32 // For the common dialogs. -open Emgu.CV.WPF - open Logger +open ParasitemiaUIControls open ParasitemiaCore.Config open ParasitemiaCore.Utils open Types let run (defaultConfig : Config) (fileToOpen : string option) = let app = new Application () - let win = Views.MainWindow () + let win = MainWindow () let state = State.State defaultConfig let mutable currentScale = 1. @@ -47,7 +43,7 @@ let run (defaultConfig : Config) (fileToOpen : string option) = ) ) - let setRBCFrameStyle (srcImg : SourceImage) (rbc : RBC) (frame : Views.RBCFrame) = + let setRBCFrameStyle (srcImg : SourceImage) (rbc : RBC) (frame : RBCFrame) = frame.Opacity <- if displayHealthy || rbc.setManually || rbc.infected then 1. else 0. let color = if rbc.infected then srcImg.InfectedRBCColor else srcImg.HealthyRBCColor frame.manuallyAdded.Visibility <- if rbc.setManually then Visibility.Visible else Visibility.Hidden @@ -60,7 +56,7 @@ let run (defaultConfig : Config) (fileToOpen : string option) = let frameFontSize (averageRBCSize : float) = max 1. (averageRBCSize / 8.) - let RBCFrameFromExisting (srcImg : SourceImage) (rbc : RBC) (frame : Views.RBCFrame) (frameThickness : float) (fontSize : float) : Views.RBCFrame = + let createRBCFrameFromExisting (srcImg : SourceImage) (rbc : RBC) (frame : RBCFrame) (frameThickness : float) (fontSize : float) : RBCFrame = frame.Visibility <- Visibility.Visible frame.Width <- rbc.size.Width frame.Height <- rbc.size.Height @@ -84,7 +80,7 @@ let run (defaultConfig : Config) (fileToOpen : string option) = statusMessageTimer.Stop () statusMessageTimer.Start () - let highlightRBCFrame (frame : Views.RBCFrame) (highlight : bool) = + let highlightRBCFrame (frame : RBCFrame) (highlight : bool) = let rbc = frame.Tag :?> RBC if highlight then frame.border.StrokeThickness <- 3. * frame.border.StrokeThickness @@ -145,7 +141,7 @@ let run (defaultConfig : Config) (fileToOpen : string option) = ) let updateViewportPreview () = - for preview in win.stackPreviews.Children |> Seq.cast do + for preview in win.stackPreviews.Children |> Seq.cast do let srcImg = preview.Tag :?> SourceImage if Some srcImg = state.CurrentImage then preview.viewport.Visibility <- Visibility.Visible @@ -173,7 +169,7 @@ let run (defaultConfig : Config) (fileToOpen : string option) = let rec setAsInfected (srcImg : SourceImage) (rbc : RBC) (infected : bool) = state.SetAsInfected rbc infected win.canvasCurrentImage.Children - |> Seq.cast + |> Seq.cast |> Seq.iter ( fun frame -> if (frame.Tag :?> RBC) = rbc then @@ -183,8 +179,8 @@ let run (defaultConfig : Config) (fileToOpen : string option) = updateCurrentImageInformation () updateGlobalParasitemia () - and RBCFrame (srcImg : SourceImage) (rbc : RBC) (frameThickness : float) (fontSize : float) : Views.RBCFrame = - let frame = RBCFrameFromExisting srcImg rbc (Views.RBCFrame ()) frameThickness fontSize + and createRBCFrame (srcImg : SourceImage) (rbc : RBC) (frameThickness : float) (fontSize : float) : RBCFrame = + let frame = createRBCFrameFromExisting srcImg rbc (RBCFrame ()) frameThickness fontSize frame.SetValue (Panel.ZIndexProperty, Int32.MaxValue - rbc.num) // To be sure the frame.menuRBCSetAsHealthy.Click.AddHandler (fun obj args -> setAsInfected srcImg (frame.Tag :?> RBC) false) frame.menuRBCSetAsInfected.Click.AddHandler (fun obj args -> setAsInfected srcImg (frame.Tag :?> RBC) true) @@ -209,9 +205,9 @@ let run (defaultConfig : Config) (fileToOpen : string option) = for rbc in srcImg.RBCs |> List.filter (fun rbc -> displayHealthy || rbc.infected) do let previewInfected = if currentPreview < win.stackRBC.Children.Count then - RBCFrameFromExisting srcImg rbc (win.stackRBC.Children.[currentPreview] :?> Views.RBCFrame) 1. 12. + createRBCFrameFromExisting srcImg rbc (win.stackRBC.Children.[currentPreview] :?> RBCFrame) 1. 12. else - let f = RBCFrame srcImg rbc 1. 12. + let f = createRBCFrame srcImg rbc 1. 12. f.MouseLeftButtonUp.AddHandler (fun obj args -> zoomToRBC (f.Tag :?> RBC)) win.stackRBC.Children.Add f |> ignore f @@ -236,9 +232,9 @@ let run (defaultConfig : Config) (fileToOpen : string option) = for rbc in srcImg.RBCs do let frame = if currentCanvas < win.canvasCurrentImage.Children.Count then - RBCFrameFromExisting srcImg rbc (win.canvasCurrentImage.Children.[currentCanvas] :?> Views.RBCFrame) strokeThickness fontSize + createRBCFrameFromExisting srcImg rbc (win.canvasCurrentImage.Children.[currentCanvas] :?> RBCFrame) strokeThickness fontSize else - let f = RBCFrame srcImg rbc strokeThickness fontSize + let f = createRBCFrame srcImg rbc strokeThickness fontSize win.canvasCurrentImage.Children.Add f |> ignore f @@ -303,7 +299,7 @@ let run (defaultConfig : Config) (fileToOpen : string option) = // Highlight the preview. win.stackPreviews.Children - |> Seq.cast + |> Seq.cast |> Seq.iter (fun preview -> preview.border.BorderThickness <- Thickness (if preview.Tag = (srcImg :> Object) then 3. else 0.)) win.canvasCurrentImage.Height <- float srcImg.Img.Height @@ -328,7 +324,7 @@ let run (defaultConfig : Config) (fileToOpen : string option) = updateCurrentImage () let addPreview (srcImg : SourceImage) = - let imgCtrl = Views.ImageSourcePreview (Margin = Thickness 3.) + let imgCtrl = ImageSourcePreview (Margin = Thickness 3.) imgCtrl.menuRemoveImage.Click.AddHandler ( fun obj args -> @@ -342,7 +338,7 @@ let run (defaultConfig : Config) (fileToOpen : string option) = updateGlobalParasitemia () // Update image numbers. - win.stackPreviews.Children |> Seq.cast |> Seq.iter (fun imgPreview -> imgPreview.txtImageNumber.Text <- (imgPreview.Tag :?> SourceImage).RomanNum) + win.stackPreviews.Children |> Seq.cast |> Seq.iter (fun imgPreview -> imgPreview.txtImageNumber.Text <- (imgPreview.Tag :?> SourceImage).RomanNum) ) imgCtrl.Tag <- srcImg diff --git a/Parasitemia/ParasitemiaUI/ParasitemiaUI.fsproj b/Parasitemia/ParasitemiaUI/ParasitemiaUI.fsproj index 2ca9b50..3e7e22f 100644 --- a/Parasitemia/ParasitemiaUI/ParasitemiaUI.fsproj +++ b/Parasitemia/ParasitemiaUI/ParasitemiaUI.fsproj @@ -1,91 +1,13 @@ - - - - + + - Debug - AnyCPU - 2.0 - 70838e65-f211-44fc-b28f-0ed1ca6e850f WinExe - ParasitemiaUI - ParasitemiaUI - v4.8 - true - 4.4.1.0 - ParasitemiaUI - - - - resources.res + net5.0-windows + true - - true - full - false - false - bin\Debug\ - DEBUG;TRACE - 3 - AnyCPU - bin\Debug\ParasitemiaUI.XML - false - --folder "../../../Images/debug" --output "../../../Images/output" --debug - - - true - full - false - false - DEBUG;TRACE - 3 - AnyCPU - bin\Debug\ParasitemiaUI.XML - false - --output "../../../Images/output" --debug - bin\DebugGUI\ - - - pdbonly - true - true - bin\Release\ - TRACE - 1 - AnyCPU - - - false - --folder "../../../Images/release" --output "../../../Images/output" --debug - - - 11 - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - + - - - - - - - - - - - - - - - - - - - @@ -93,109 +15,34 @@ + - + - - ..\packages\EmguCV.3.1.0.1\lib\net30\Emgu.CV.UI.dll - - - ..\packages\EmguCV.3.1.0.1\lib\net30\Emgu.CV.UI.GL.dll - - - ..\packages\EmguCV.3.1.0.1\lib\net30\Emgu.CV.World.dll - - - ..\packages\FSharp.Core.4.7.2\lib\net45\FSharp.Core.dll - - - ..\packages\FSharp.ViewModule.Core.1.0.7.0\lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1\FSharp.ViewModule.dll - - - ..\packages\FsXaml.Wpf.3.1.6\lib\net45\FsXaml.Wpf.dll - - - ..\packages\FsXaml.Wpf.3.1.6\lib\net45\FsXaml.Wpf.TypeProvider.dll - - - - ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll - - - ..\packages\OpenTK.3.2\lib\net20\OpenTK.dll - - - ..\packages\OpenTK.GLControl.3.1.0\lib\net20\OpenTK.GLControl.dll - - - - - - - - - - - - - - True - - - - ..\packages\Expression.Blend.Sdk.1.0.2\lib\net45\System.Windows.Interactivity.dll - True - - - - - - - ..\packages\ZedGraph.5.1.7\lib\net35-Client\ZedGraph.dll - + + + + + + + - - Logger - {a4f183ae-562a-4bad-88e6-658b4ce15dc3} - True - - - ParasitemiaCore - {0f8a85f4-9328-40c3-b8ff-44fb39ceb01f} - True - - - WPF - {314fd78e-870e-4794-bb16-ea4586f2abdb} - True - + + + - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - + + + + + \ No newline at end of file diff --git a/Parasitemia/ParasitemiaUI/PiaZ.fs b/Parasitemia/ParasitemiaUI/PiaZ.fs index 2220953..18e9d6a 100644 --- a/Parasitemia/ParasitemiaUI/PiaZ.fs +++ b/Parasitemia/ParasitemiaUI/PiaZ.fs @@ -2,7 +2,6 @@ module ParasitemiaUI.PiaZ open System -open System.Windows open System.IO open System.IO.Compression @@ -10,7 +9,6 @@ open Emgu.CV open Emgu.CV.Structure open Newtonsoft.Json -open Newtonsoft.Json.Converters open Types @@ -100,7 +98,8 @@ let updateDocumentData (fromVersion : int) (toVersion : int) (data : DocumentDat /// /// Load document from a give file path. /// -/// +/// Path to the PiaZ file +/// /// If the file cannot be read let load (filePath : string) (defaultConfig : ParasitemiaCore.Config.Config) : DocumentData = use file = ZipFile.Open (filePath, ZipArchiveMode.Read) @@ -118,7 +117,7 @@ let load (filePath : string) (defaultConfig : ParasitemiaCore.Config.Config) : D for imgEntry in file.Entries do if imgEntry.Name.EndsWith (imageExtension) then use bitmap = new System.Drawing.Bitmap (imgEntry.Open (), false) - let img = new Image (bitmap) + let img = bitmap.ToImage () imgNum <- imgNum + 1 let imgJSONEntry = file.GetEntry (imgEntry.Name + ".json") use imgJSONFileReader = new StreamReader (imgJSONEntry.Open ()) diff --git a/Parasitemia/ParasitemiaUI/Resources/chuv_logo.png b/Parasitemia/ParasitemiaUI/Resources/chuv_logo.png deleted file mode 100644 index e062ad8..0000000 Binary files a/Parasitemia/ParasitemiaUI/Resources/chuv_logo.png and /dev/null differ diff --git a/Parasitemia/ParasitemiaUI/Resources/hes-so_logo.png b/Parasitemia/ParasitemiaUI/Resources/hes-so_logo.png deleted file mode 100644 index 7900495..0000000 Binary files a/Parasitemia/ParasitemiaUI/Resources/hes-so_logo.png and /dev/null differ diff --git a/Parasitemia/ParasitemiaUI/Resources/icon.ico b/Parasitemia/ParasitemiaUI/Resources/icon.ico deleted file mode 100644 index 147e3a8..0000000 Binary files a/Parasitemia/ParasitemiaUI/Resources/icon.ico and /dev/null differ diff --git a/Parasitemia/ParasitemiaUI/SourceImage.fs b/Parasitemia/ParasitemiaUI/SourceImage.fs index 7b3de18..7f5c245 100644 --- a/Parasitemia/ParasitemiaUI/SourceImage.fs +++ b/Parasitemia/ParasitemiaUI/SourceImage.fs @@ -1,7 +1,6 @@ namespace ParasitemiaUI open System -open System.Windows open System.Windows.Media open Emgu.CV diff --git a/Parasitemia/ParasitemiaUI/Types.fs b/Parasitemia/ParasitemiaUI/Types.fs index 3a3cf56..1da2dea 100644 --- a/Parasitemia/ParasitemiaUI/Types.fs +++ b/Parasitemia/ParasitemiaUI/Types.fs @@ -1,11 +1,6 @@ module ParasitemiaUI.Types -open System open System.Windows -open System.Windows.Media - -open Emgu.CV -open Emgu.CV.Structure open Newtonsoft.Json @@ -62,5 +57,3 @@ let defaultSensorSizes = { w = 8.8; h = 6.6; label = "2/3″" } { w = 13.2; h = 8.8; label = "1″" } ] - - diff --git a/Parasitemia/ParasitemiaUI/XAML/AboutWindow.xaml b/Parasitemia/ParasitemiaUI/XAML/AboutWindow.xaml deleted file mode 100644 index d08f4c4..0000000 --- a/Parasitemia/ParasitemiaUI/XAML/AboutWindow.xaml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - Parasitemia - - HES-SO / - CHUV - - Grégory Burri - - - +