Exemple #1
0
        private void buttonOK_Click(object sender, RoutedEventArgs e)
        {
            var hours   = this.upDownTemporaryUptimeHours.Value.Value;
            var minutes = this.upDownTemporaryUptimeMinutes.Value.Value;

            if (hours == 0 && minutes == 0)
            {
                System.Windows.MessageBox.Show(string.Format(Wsapm.Resources.Wsapm.TemporaryUptimeWindow_ErrorNoUptimeDefined, Environment.NewLine), Wsapm.Resources.Wsapm.General_MessageBoxErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            try
            {
                var temporaryUptime        = new TemporaryUptime(hours, minutes);
                var temporaryUptimeManager = new TemporaryUptimeManager();
                temporaryUptimeManager.SaveTemporaryUptime(temporaryUptime);
                this.DialogResult = true;
            }
            catch (WsapmException ex)
            {
                System.Windows.MessageBox.Show(string.Format("{1}:{0}{0}{2}", Environment.NewLine, ex.Message, ex.InnerException.Message), Wsapm.Resources.Wsapm.General_MessageBoxErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error);
                this.DialogResult = false;
            }
            finally
            {
                this.Close();
            }
        }
Exemple #2
0
        public MainWindow()
        {
            if (AlreadyRunning())
            {
                MessageBox.Show(Wsapm.Resources.Wsapm.MainWindow_AppAlreadyRunning, Wsapm.Resources.Wsapm.MainWindow_Title, MessageBoxButton.OK, MessageBoxImage.Information);
                App.Current.Shutdown();
                return;
            }

            ParseArgs();

            try
            {
                this.settingsLock           = new object();
                this.logManager             = new LogManager(WsapmTools.GetCommonApplicationDataFolder(), WsapmConstants.WsapmApplicationLogFile);
                this.logManager.LogChanged += logManager_LogChanged;

                InitializeComponent();

                this.serviceManager  = new ServiceManager();
                this.settingsManager = new SettingsManager();

                lock (this.settingsLock)
                {
                    this.currentSettings = this.settingsManager.LoadSettings();
                }

                this.logManager.Start();

                if (this.textBoxLog != null && this.scrollViewerLog != null)
                {
                    this.textBoxLog.Text = this.logManager.Log; // Load current log manually for the first time.
                    this.scrollViewerLog.ScrollToEnd();
                }

                this.temporaryUptimeManager = new TemporaryUptimeManager();
            }
            catch (Exception ex)
            {
                UnhandledExceptionManager.HandleException(ex);
            }
        }