public override void Run(Alert alert)
 {
     _alert = alert;
     ViewRefresh();
     _eMalertService.SetSettings(alert);
     View.Show();
 }
        public MainPresenter(IApplicationController controller, IMainView view, ISettingsService settingsService, IEmailAlertService eMalertService)
            : base(controller, view)
        {
            // View localization
            View.SourcesPageText            = Locale.Instance.Get("Main/sourcesPage");
            View.SettingsPageText           = Locale.Instance.Get("Main/settingsPage");
            View.AskAddSamplesText          = Locale.Instance.Get("Main/AskAddSamples");
            View.CreateGridCommonErrorText  = Locale.Instance.Get("Main/CreateGridCommonError");
            View.CreateGridNoLibErrorText   = Locale.Instance.Get("Main/CreateGridNoLibError");
            View.CreateGridBadVerErrorText  = Locale.Instance.Get("Main/CreateGridBadVerError");
            View.CreateGridEndErrorText     = Locale.Instance.Get("Main/CreateGridEndError");
            View.SettingsSaveErrorText      = Locale.Instance.Get("Main/SettingsSaveError");
            View.SettingsLoadErrorText      = Locale.Instance.Get("Main/SettingsLoadError");
            View.SettingsAccesErrorText     = Locale.Instance.Get("Main/SettingsAccesError");
            View.HintOpenCtrlText           = Locale.Instance.Get("Main/hintOpenCtrl");
            View.HintAddCameraText          = Locale.Instance.Get("Main/hintAddCamera");
            View.HintDropCameraText         = Locale.Instance.Get("Main/hintDropCamera");
            View.HintRTSP1Text              = Locale.Instance.Get("Main/hintRTSP1");
            View.HintRTSP2Text              = Locale.Instance.Get("Main/hintRTSP2");
            View.FullScreenMenuItemText     = Locale.Instance.Get("Main/fullScreenMenuItem");
            View.ExitFullScreenMenuItemText = Locale.Instance.Get("Main/exitFullScreenMenuItem");

            // View actions
            View.OpenClosePanelClick  += OpenClosePanelClick;
            View.SourcesPageSelected  += SourcesPageSelected;
            View.SettingsPageSelected += SettingsPageSelected;
            View.SplitterMoved        += SplitterMoved;

            // Settings
            _settingsService = settingsService;
            try { _appSettings = settingsService.GetSettings(); }
            catch (UnauthorizedAccessException e) { View.ErrorAccessSettings(e.Message); }
            catch (Exception e) { View.ErrorOnLoadSettings(e.Message); }
            if (_appSettings == null)
            {
                _appSettings = settingsService.GetSettings();
            }
            if (_appSettings.cams.Length == 0)
            {
                if (View.AskIfAddSamples())
                {
                    settingsService.AddSampleCameras();
                }
            }

            View.CtrlPanelWidth = _appSettings.controlPanelWidth;

            // Alerts
            _eMalertService = eMalertService;
            _eMalertService.SetSettings(_appSettings.alert);

            // Sources grid
            try { CreateGrid(); }
            catch (System.IO.FileNotFoundException e) { View.ErrorOnCreateGridNoLib(e.Message); } //no VLC or ActiveX lib
            catch (System.NotSupportedException e) { View.ErrorOnCreateGridBadVer(e.Message); }   //bad VLC version
            catch (System.InvalidCastException e) { View.ErrorOnCreateGridBadVer(e.Message); }    //bad VLC version
            catch (Exception e) { View.ErrorOnCreateGridOther(e.Message); }
            foreach (Camera m in _appSettings.cams)
            {
                m.Edit += () => EditSrcClick(m);
            }
            // Process command line arguments
            ProcessCommandLine(Environment.GetCommandLineArgs());
            // Prepare hints engine
            _appSettings.hint.onShow += ShowHintWithWait;
            _appSettings.hint.onHide += HideHint;
            View.HideHintTimer       += () => _appSettings.hint.Hide();
            View.ShowHintTimer       += ShowHint;
            // Hint if empty grid and control is not shown
            if (!View.PanelState)
            {
                bool camPosFound = false;
                foreach (Camera c in _appSettings.cams)
                {
                    if (c.position >= 0)
                    {
                        camPosFound = true;
                    }
                }
                if (!camPosFound)
                {
                    _appSettings.hint.Show(HintType.OpenCtrl);
                }
            }
        }