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
                        {
                            this.WindowState = ((Window) ServiceProvider.PluginManager.SelectedWindow).WindowState;

                            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
                    {
                        try
                        {
                            ((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)
                        {
                            ((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 void ExecuteCommand(string cmd, object param)
        {
            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 CmdConsts.All_Close:
                    Dispatcher.Invoke(new Action(delegate
                                                     {
                                                         ((LiveViewViewModel)DataContext).UnInit();
                                                         Hide();
                                                         Close();
                                                     }));
                    break;
            }
        }