LayerFrame Censor(CensorOverlaySettings Settings) { var control = Generate(Settings, "Censored", Colors.Black); var vm = new CensorOverlayReactor(Settings); control.Bind(WidthProperty, vm.Width); control.Bind(HeightProperty, vm.Height); control.BindOne(VisibilityProperty, vm.Visible); return(control); }
static float GetTop(CensorOverlaySettings OverlaySettings, float FullHeight) { var y = OverlaySettings.Y; switch (OverlaySettings.VerticalAlignment) { case Alignment.Start: return(y); case Alignment.End: return(FullHeight - y - OverlaySettings.Height); case Alignment.Center: return(FullHeight / 2 + y - OverlaySettings.Height / 2f); default: return(0); } }
static float GetLeft(CensorOverlaySettings OverlaySettings, float FullWidth) { var x = OverlaySettings.X; switch (OverlaySettings.HorizontalAlignment) { case Alignment.Start: return(x); case Alignment.End: return(FullWidth - x - OverlaySettings.Width); case Alignment.Center: return(FullWidth / 2 + x - OverlaySettings.Width / 2f); default: return(0); } }
LayerFrame Censor(CensorOverlaySettings Settings) { var control = Generate(Settings, "Censored", Colors.Black); control.Width = Settings.Width; control.Height = Settings.Height; Settings.PropertyChanged += (S, E) => { Dispatcher.Invoke(() => { control.Width = Settings.Width; control.Height = Settings.Height; }); }; control.PositionUpdated += Rect => { Settings.Width = (int)Rect.Width; Settings.Height = (int)Rect.Height; }; return(control); }