From: Greg Burri Date: Sun, 21 Mar 2021 21:25:54 +0000 (+0100) Subject: Put the RBC number text below border on the main image. X-Git-Tag: 1.0.13~5 X-Git-Url: http://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=e37e89a261df15d46d5128f18f9764d1cf81fd86;p=master-thesis.git Put the RBC number text below border on the main image. --- diff --git a/Parasitemia/Parasitemia.sln b/Parasitemia/Parasitemia.sln index 8102b58..0a0bad4 100644 --- a/Parasitemia/Parasitemia.sln +++ b/Parasitemia/Parasitemia.sln @@ -5,8 +5,6 @@ VisualStudioVersion = 16.0.30804.86 MinimumVisualStudioVersion = 10.0.40219.1 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("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Logger", "Logger\Logger.fsproj", "{A4F183AE-562A-4BAD-88E6-658B4CE15DC3}" EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ParasitemiaCore", "ParasitemiaCore\ParasitemiaCore.fsproj", "{0F8A85F4-9328-40C3-B8FF-44FB39CEB01F}" @@ -27,10 +25,6 @@ Global {70838E65-F211-44FC-B28F-0ED1CA6E850F}.Debug|Any CPU.Build.0 = Debug|Any CPU {70838E65-F211-44FC-B28F-0ED1CA6E850F}.Release|Any CPU.ActiveCfg = Release|Any CPU {70838E65-F211-44FC-B28F-0ED1CA6E850F}.Release|Any CPU.Build.0 = Release|Any CPU - {314FD78E-870E-4794-BB16-EA4586F2ABDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {314FD78E-870E-4794-BB16-EA4586F2ABDB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {314FD78E-870E-4794-BB16-EA4586F2ABDB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {314FD78E-870E-4794-BB16-EA4586F2ABDB}.Release|Any CPU.Build.0 = Release|Any CPU {A4F183AE-562A-4BAD-88E6-658B4CE15DC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A4F183AE-562A-4BAD-88E6-658B4CE15DC3}.Debug|Any CPU.Build.0 = Debug|Any CPU {A4F183AE-562A-4BAD-88E6-658B4CE15DC3}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/Parasitemia/ParasitemiaUI/GUI.fs b/Parasitemia/ParasitemiaUI/GUI.fs index 83e54c2..89f38e3 100644 --- a/Parasitemia/ParasitemiaUI/GUI.fs +++ b/Parasitemia/ParasitemiaUI/GUI.fs @@ -54,13 +54,14 @@ let run (defaultConfig : Config) (fileToOpen : string option) = max 1. (averageRBCSize / 60.) let frameFontSize (averageRBCSize : float) = - max 1. (averageRBCSize / 8.) + max 1. (averageRBCSize / 6.) - let createRBCFrameFromExisting (srcImg : SourceImage) (rbc : RBC) (frame : RBCFrame) (frameThickness : float) (fontSize : float) : RBCFrame = + let createRBCFrameFromExisting (srcImg : SourceImage) (rbc : RBC) (frame : RBCFrame) (frameThickness : float) (fontSize : float) (isTextBelow : bool) : RBCFrame = frame.Visibility <- Visibility.Visible frame.Width <- rbc.size.Width frame.Height <- rbc.size.Height frame.Tag <- rbc + frame.IsTextBelow <- isTextBelow setRBCFrameStyle srcImg rbc frame frame.border.StrokeThickness <- frameThickness frame.txtRBCNumber.Text <- string rbc.num @@ -179,8 +180,8 @@ let run (defaultConfig : Config) (fileToOpen : string option) = updateCurrentImageInformation () updateGlobalParasitemia () - and createRBCFrame (srcImg : SourceImage) (rbc : RBC) (frameThickness : float) (fontSize : float) : RBCFrame = - let frame = createRBCFrameFromExisting srcImg rbc (RBCFrame ()) frameThickness fontSize + and createRBCFrame (srcImg : SourceImage) (rbc : RBC) (frameThickness : float) (fontSize : float) (isTextBelow : bool) : RBCFrame = + let frame = createRBCFrameFromExisting srcImg rbc (RBCFrame ()) frameThickness fontSize isTextBelow 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) @@ -205,9 +206,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 - createRBCFrameFromExisting srcImg rbc (win.stackRBC.Children.[currentPreview] :?> RBCFrame) 1. 12. + createRBCFrameFromExisting srcImg rbc (win.stackRBC.Children.[currentPreview] :?> RBCFrame) 1. 12. false else - let f = createRBCFrame srcImg rbc 1. 12. + let f = createRBCFrame srcImg rbc 1. 12. false f.MouseLeftButtonUp.AddHandler (fun obj args -> zoomToRBC (f.Tag :?> RBC)) win.stackRBC.Children.Add f |> ignore f @@ -232,9 +233,9 @@ let run (defaultConfig : Config) (fileToOpen : string option) = for rbc in srcImg.RBCs do let frame = if currentCanvas < win.canvasCurrentImage.Children.Count then - createRBCFrameFromExisting srcImg rbc (win.canvasCurrentImage.Children.[currentCanvas] :?> RBCFrame) strokeThickness fontSize + createRBCFrameFromExisting srcImg rbc (win.canvasCurrentImage.Children.[currentCanvas] :?> RBCFrame) strokeThickness fontSize true else - let f = createRBCFrame srcImg rbc strokeThickness fontSize + let f = createRBCFrame srcImg rbc strokeThickness fontSize true win.canvasCurrentImage.Children.Add f |> ignore f diff --git a/Parasitemia/ParasitemiaUIControls/RBCFrame.xaml b/Parasitemia/ParasitemiaUIControls/RBCFrame.xaml index 52fb2f8..26a1369 100644 --- a/Parasitemia/ParasitemiaUIControls/RBCFrame.xaml +++ b/Parasitemia/ParasitemiaUIControls/RBCFrame.xaml @@ -16,7 +16,7 @@ - + diff --git a/Parasitemia/ParasitemiaUIControls/RBCFrame.xaml.cs b/Parasitemia/ParasitemiaUIControls/RBCFrame.xaml.cs index 5843111..be023b9 100644 --- a/Parasitemia/ParasitemiaUIControls/RBCFrame.xaml.cs +++ b/Parasitemia/ParasitemiaUIControls/RBCFrame.xaml.cs @@ -4,9 +4,45 @@ namespace ParasitemiaUIControls { public partial class RBCFrame : UserControl { + bool isTextBelow = false; + public RBCFrame() { this.InitializeComponent(); + this.borderRBCNumber.SizeChanged += BorderRBCNumber_SizeChanged; + } + + public bool IsTextBelow + { + get => this.isTextBelow; + set + { + if (value != this.isTextBelow) + { + this.isTextBelow = value; + this.UpdateRBCNumberPosition(); + } + } + } + + void BorderRBCNumber_SizeChanged(object sender, System.Windows.SizeChangedEventArgs e) + { + this.UpdateRBCNumberPosition(); + + //this.UpdateLayout(); + //System.Diagnostics.Debug.WriteLine($"ActuaSize: {this.borderRBCNumber.ActualHeight}"); + } + + void UpdateRBCNumberPosition() + { + var m = this.borderRBCNumber.Margin; + + m.Bottom = + this.isTextBelow + ? - this.borderRBCNumber.ActualHeight - 0.05 * this.borderRBCNumber.ActualHeight + : 0.05 * this.borderRBCNumber.ActualHeight; + + this.borderRBCNumber.Margin = m; } } }