public void ExecuteCommand(string cmd, object param) { Dispatcher.Invoke(new Action(delegate { try { if (DataContext != null) { ((LiveViewViewModel)(DataContext)).WindowsManager_Event(cmd, param); } } catch (Exception) { } })); switch (cmd) { case WindowsCmdConsts.LiveViewWnd_Show: Dispatcher.Invoke(new Action(delegate { try { ICameraDevice cameraparam = param as ICameraDevice; var properties = cameraparam.LoadProperties(); if (properties.SaveLiveViewWindow && properties.WindowRect.Width > 0 && properties.WindowRect.Height > 0) { this.Left = properties.WindowRect.Left; this.Top = properties.WindowRect.Top; this.Width = properties.WindowRect.Width; this.Height = properties.WindowRect.Height; } else { this.WindowState = ((Window)ServiceProvider.PluginManager.SelectedWindow).WindowState; } if (cameraparam == SelectedPortableDevice && IsVisible) { Activate(); Focus(); return; } DataContext = new LiveViewViewModel(cameraparam, this); SelectedPortableDevice = cameraparam; Show(); Activate(); Focus(); } catch (Exception exception) { Log.Error("Error initialize live view window ", exception); } } )); break; case WindowsCmdConsts.LiveViewWnd_Hide: Dispatcher.Invoke(new Action(delegate { try { ICameraDevice cameraparam = ((LiveViewViewModel)DataContext).CameraDevice; var properties = cameraparam.LoadProperties(); if (properties.SaveLiveViewWindow) { properties.WindowRect = new Rect(this.Left, this.Top, this.Width, this.Height); } ((LiveViewViewModel)DataContext).UnInit(); } catch (Exception exception) { Log.Error("Unable to stop live view", exception); } Hide(); //ServiceProvider.WindowsManager.ExecuteCommand(WindowsCmdConsts.FocusStackingWnd_Hide); })); break; case WindowsCmdConsts.LiveViewWnd_Message: { Dispatcher.Invoke(new Action(delegate { if (this.IsLoaded) { this.ShowMessageAsync("", (string)param); } else { MessageBox.Show((string)param); } })); } break; case CmdConsts.All_Close: Dispatcher.Invoke(new Action(delegate { if (DataContext != null) { ICameraDevice cameraparam = ((LiveViewViewModel)DataContext).CameraDevice; var properties = cameraparam.LoadProperties(); if (properties.SaveLiveViewWindow) { properties.WindowRect = new Rect(this.Left, this.Top, this.Width, this.Height); } ((LiveViewViewModel)DataContext).UnInit(); Hide(); Close(); } })); break; case CmdConsts.All_Minimize: Dispatcher.Invoke(new Action(delegate { WindowState = WindowState.Minimized; })); break; case WindowsCmdConsts.LiveViewWnd_Maximize: Dispatcher.Invoke(new Action(delegate { WindowState = WindowState.Maximized; })); break; } }
public LiveViewVideoSource(LiveViewViewModel model) { }
public LiveViewView(LiveViewViewModel vm) { DataContext = vm; InitializeComponent(); }
public void ExecuteCommand(string cmd, object param) { Dispatcher.Invoke(new Action(delegate { try { if (DataContext != null) { ((LiveViewViewModel)(DataContext)).WindowsManager_Event(cmd, param); } } catch (Exception) { } })); switch (cmd) { case WindowsCmdConsts.LiveViewWnd_Show: Dispatcher.Invoke(new Action(delegate { try { ICameraDevice cameraparam = param as ICameraDevice; if (cameraparam == SelectedPortableDevice && IsVisible) { Activate(); Focus(); return; } DataContext = new LiveViewViewModel(cameraparam); SelectedPortableDevice = cameraparam; Show(); Activate(); Focus(); } catch (Exception exception) { Log.Error("Error initialize live view window ", exception); } } )); break; case WindowsCmdConsts.LiveViewWnd_Hide: Dispatcher.Invoke(new Action(delegate { Hide(); try { ((LiveViewViewModel)DataContext).UnInit(); } catch (Exception exception) { Log.Error("Unable to stop live view", exception); } //ServiceProvider.WindowsManager.ExecuteCommand(WindowsCmdConsts.FocusStackingWnd_Hide); })); break; case WindowsCmdConsts.LiveViewWnd_Message: { Dispatcher.Invoke(new Action(delegate { if (this.IsLoaded) { this.ShowMessageAsync("", (string)param); } else { MessageBox.Show((string)param); } })); } break; case CmdConsts.All_Close: Dispatcher.Invoke(new Action(delegate { ((LiveViewViewModel)DataContext).UnInit(); Hide(); Close(); })); break; case CmdConsts.All_Minimize: Dispatcher.Invoke(new Action(delegate { WindowState = WindowState.Minimized; })); break; } }