X-Git-Url: http://git.euphorik.ch/?p=master-thesis.git;a=blobdiff_plain;f=Parasitemia%2FParasitemiaUIControls%2FRBCFrame.xaml.cs;fp=Parasitemia%2FParasitemiaUIControls%2FRBCFrame.xaml.cs;h=be023b976ff7022c0afad90c74aeeb300146868c;hp=584311167e77df5464787e8712f9b390a0dc3e76;hb=e37e89a261df15d46d5128f18f9764d1cf81fd86;hpb=3c21c6ec590381439a615597342454b4298a8b5c 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; } } }