Exemplo n.º 1
0
        /// <summary>Constructs new presenter for MainForm.</summary>
        public FormMainPresenter(IFormMain formMain, ServiceGateway serviceGateway, LogViewModel logViewModel)
        {
            if (formMain == null)
            {
                throw new ArgumentNullException("formMain");
            }
            if (serviceGateway == null)
            {
                throw new ArgumentNullException("serviceGateway");
            }

            _FormMain         = formMain;
            ServiceGateway    = serviceGateway;
            LogViewModel      = logViewModel;
            MainViewPresenter = new MainViewPresenter(ServiceGateway);
            MainViewPresenter.ShowRulesClicked  += MainViewPresenter_ShowRulesClicked;
            MainViewPresenter.ShowEventsClicked += MainViewPresenter_ShowEventsClicked;
            LogViewPresenter = new LogViewPresenter(LogViewModel);

            // Subscribe to form's events.
            _FormMain.ShowMainClicked               += form_ShowMainClicked;
            _FormMain.ShowRulesClicked              += form_ShowRulesClicked;
            _FormMain.ShowPreferencesClicked        += form_ShowPreferencesClicked;
            _FormMain.ShowEventsClicked             += form_ShowEventsClicked;
            _FormMain.CloseAllClicked               += form_CloseAllClicked;
            _FormMain.RefreshRulesClicked           += form_RefreshRulesClicked;
            _FormMain.RefreshEventsClicked          += form_RefreshEventsClicked;
            _FormMain.ClearEventsClicked            += form_ClearEventsClicked;
            _FormMain.ExportEventsClicked           += form_ExportEventsClicked;
            _FormMain.ShowEventDetailsClicked       += form_ShowEventDetailsClicked;
            _FormMain.AutoRefreshEventsCheckChanged += form_AutoRefreshEventsCheckChanged;
            _FormMain.ExitAndShutDownClicked        += form_ExitAndShutDownClicked;
        }
Exemplo n.º 2
0
 private void form_ExitAndShutDownClicked(object sender, EventArgs e)
 {
     if (ServiceGateway.IsStarted)
     {
         ServiceGateway.Stop();
     }
     Application.Exit();//This call cannot be tested.
 }
Exemplo n.º 3
0
            protected override bool OnInitialize(System.Collections.ObjectModel.ReadOnlyCollection <string> commandLineArgs)
            {
                try
                {
                    ChangeUICulture(Settings.Default.UICulture.Name);

                    // Register skins.
                    DevExpress.UserSkins.BonusSkins.Register();
                    DevExpress.UserSkins.OfficeSkins.Register();

                    // Set user skin.
                    UserLookAndFeel.Default.SetSkinStyle(Settings.Default.SkinName);

                    // Initialize automatic error handling.
                    Application.ThreadException += Application_ThreadException;
                    _BugReportPresenter          = new FormBugReportPresenter(new BugSubmitter(), new FormBugReport());
                }
                catch (Exception ex)
                {
                    // NOTE: Here we can't use FormBugReport because it may not be initialized.
                    MessageBox.Show(
                        "Unfortunally FileWall failed to initialize. Please send us screenshot of this window.\r\n" +
                        BugSubmitter.FormatErrorMessage(ex), "FileWall", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                try
                {
                    _FormMain = new FormMain();

                    _ServiceGateway          = new ServiceGateway(new AdvSC("FileWallService"), new ServiceInterfaceManager());
                    _ServiceGateway.Started += ServiceGateway_Started;

                    _Presenter = new FormMainPresenter(_FormMain,
                                                       _ServiceGateway,
                                                       new LogViewModel(new EventLog("APAccess")));

                    // Start service if it's needed.
                    if (!_Presenter.ServiceGateway.IsStarted)
                    {
                        _Presenter.ServiceGateway.Start();
                    }
                    else
                    {
                        // Subscribing to events.
                        var accessRequestedWrapper = new AccessRequestedWrapper(_ServiceGateway.ServiceInterface);
                        accessRequestedWrapper.AccessRequested += AccessRequested;
                    }
                }
                catch (Exception ex)
                {
                    _BugReportPresenter.Show(ex);
                    return(false);
                }

                return(true);
            }
Exemplo n.º 4
0
        public MainViewPresenter(ServiceGateway serviceGateway)
        {
            if (serviceGateway == null)
            {
                throw new ArgumentNullException("serviceGateway");
            }

            _ServiceGateway          = serviceGateway;
            _ServiceGateway.Started += ServiceGateway_Started;
            _ServiceGateway.Stopped += ServiceGateway_Stopped;

            _AutoRefreshTimer = new Timer {
                Interval = 3000
            };
            _AutoRefreshTimer.Tick   += AutoRefreshTimer_Tick;
            _AutoRefreshTimer.Enabled = true;

            // BUG workaround "Start/stop bug on service".
            _TimerBugWorkaround.Tick += TimerBugWorkaround_Tick;
        }