Put the RBC number text below border on the main image.
[master-thesis.git] / Parasitemia / ParasitemiaUIControls / RBCFrame.xaml.cs
index 5843111..be023b9 100644 (file)
@@ -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;
         }
     }
 }