private void SetupAntennaSensor() { antennaSensor.Canvas = videoCanvas; antennaSensor.CanvasScale = CanvasScale; antennaSensor.Dimensions = new Point(AppSettings.Default.HeadScale * 100, AppSettings.Default.HeadScale * 100); antennaSensor.Position = Controller.ToCanvasCoordinates(AppSettings.Default.Origin); antennaSensor.Angle = AppSettings.Default.HeadAngle; antennaSensor.MouseDown += (s, e) => { Controller.Pause(); }; antennaSensor.Moved += (s, e) => { var loc = Controller.ToVideoCoordinates(antennaSensor.Position); AppSettings.Default.HeadX = loc.X; AppSettings.Default.HeadY = loc.Y; AppSettings.Default.SaveAsync(); LoadFromSettings(); Controller.RefreshMostRecentFrame(); Controller.Stop(); }; antennaSensor.Scaled += (s, e) => { var loc = Controller.ToVideoCoordinates(antennaSensor.Position); var dims = Controller.ToVideoCoordinates(antennaSensor.Dimensions); AppSettings.Default.HeadX = loc.X; AppSettings.Default.HeadY = loc.Y; AppSettings.Default.HeadScale = antennaSensor.Scale; AppSettings.Default.SaveAsync(); LoadFromSettings(); Controller.RefreshMostRecentFrame(); Controller.Stop(); }; antennaSensor.Rotated += (s, e) => { AppSettings.Default.HeadAngle = antennaSensor.Angle; AppSettings.Default.SaveAsync(); LoadFromSettings(); Controller.RefreshMostRecentFrame(); Controller.Stop(); }; }
public MainWindow() { InitializeComponent(); Processor = new MotionProcessor(); Controller = new VideoPlayerController() { btnBrowse = btnBrowse, btnPlayPause = btnPlayPause, btnStepFrame = btnStepFrame, btnSave = btnSaveActivity, btnStop = btnStop, Canvas = videoCanvas, lblTime = lblTime, lblFPS = lblFPS, sliderTime = sliderTime, txtFileName = txtFileName, Quality = sliderQuality.Value / 100, }; Controller.OnFinishSetupPlayer += OnFinishSetupPlayer; Controller.OnOpen += OnOpen; Controller.OnReset += InitDetector; Controller.OnStartPlaying += OnStartPlaying; Controller.OnProcessed += OnProcessed; Controller.OnRefreshMostRecentFrame += OnRefreshMostRecentFrame; Controller.OnAfterStopped += OnAfterStopped; Controller.Init(); ToggleCompare(); Loaded += (sender, args) => UpdateProcessorBounds(); Closing += (sender, args) => Controller.Stop(); Application.Current.Exit += (sender, args) => Controller.Stop(); #if !DEBUG AppDomain.CurrentDomain.UnhandledException += (sender, args) => { MessageBox.Show((args.ExceptionObject as Exception).Message); }; #endif }
public ProcessorWindow() { AppSettings.Default.Upgrade(); InitializeComponent(); try { Title += " " + ApplicationDeployment.CurrentDeployment.CurrentVersion; } catch { } Controller = new VideoPlayerController { btnBrowse = btnBrowse, btnPlayPause = btnPlayPause, btnSave = btnSaveActivity, btnStop = btnStop, btnStepFrame = btnStepFrame, Canvas = videoCanvas, lblTime = lblTime, lblFPS = lblFPS, sliderTime = sliderTime, txtFileName = txtFileName, Quality = AppSettings.Default.Quality, }; Controller.OnFinishSetupPlayer += OnFinishSetupPlayer; Controller.OnOpen += OnOpen; Controller.OnReset += InitDetector; Controller.OnShowFrame += OnShowFrame; Controller.OnRefreshMostRecentFrame += OnRefreshMostRecentFrame; Controller.OnAfterStopped += () => Activate(); Controller.Init(); sliderX.Label = "X:"; sliderX.SettingsKey = "HeadX"; sliderX.IsEnabled = false; sliderX.LoadFromSettings(); sliderX.OnChanged += SyncAntennaSensor; sliderX.OnBeginChange += Controller.Stop; sliderY.Label = "Y:"; sliderY.SettingsKey = "HeadY"; sliderY.IsEnabled = false; sliderY.LoadFromSettings(); sliderY.OnChanged += SyncAntennaSensor; sliderY.OnBeginChange += Controller.Stop; sliderScale.Label = "Scale:"; sliderScale.SettingsKey = "HeadScale"; sliderScale.IsValueInt = false; sliderScale.IsEnabled = false; sliderScale.LoadFromSettings(); sliderScale.OnChanged += SyncAntennaSensor; sliderScale.OnBeginChange += Controller.Stop; sliderAngle.Label = "Angle:"; sliderAngle.SettingsKey = "HeadAngle"; sliderAngle.IsValueInt = false; sliderAngle.IsEnabled = false; sliderAngle.LoadFromSettings(); sliderAngle.OnChanged += SyncAntennaSensor; sliderAngle.OnBeginChange += Controller.Stop; sliderTreatX.Label = "X:"; sliderTreatX.SettingsKey = "TreatmentSensorX"; sliderTreatX.IsEnabled = false; sliderTreatX.LoadFromSettings(); sliderTreatX.OnChanged += SyncTreatmentSensor; sliderTreatY.Label = "Y:"; sliderTreatY.SettingsKey = "TreatmentSensorY"; sliderTreatY.IsEnabled = false; sliderTreatY.LoadFromSettings(); sliderTreatY.OnChanged += SyncTreatmentSensor; sliderFast.Label = "Fast Motion Threshold:"; sliderFast.SettingsKey = "FastThreshold"; sliderFast.LoadFromSettings(); sliderSlow.Label = "Slow Motion Threshold:"; sliderSlow.SettingsKey = "SlowThreshold"; sliderSlow.LoadFromSettings(); sliderStationary.Label = "Stationary Threshold:"; sliderStationary.SettingsKey = "StationaryThreshold"; sliderStationary.LoadFromSettings(); SizeChanged += (sender, e) => { SetupCanvas(); SyncAntennaSensor(); SyncTreatmentSensor(); SyncExclusionZones(); }; Closing += (sender, args) => { Controller.Stop(); Hide(); WindowManager.ExitIfLastWindow(); }; WindowManager.Exit += (sender, args) => Controller.Stop(); }