示例#1
0
        /// <summary> Обработчик нажания кнопки отправить </summary>
        private void ButtonSend_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrWhiteSpace(_modelLogScope.Subject) || String.IsNullOrWhiteSpace(_modelLogScope.Description))
            {
                var message = String.Empty;

                if (String.IsNullOrWhiteSpace(_modelLogScope.Subject))
                {
                    message = Application.Current.TryFindResource(@"ViewErrorReport_SubjectEmpty") + "\n";
                }
                if (String.IsNullOrWhiteSpace(_modelLogScope.Description))
                {
                    message += Application.Current.TryFindResource(@"ViewErrorReport_DescriptionEmpty") + "\n";
                }

                message += Application.Current.TryFindResource(@"ViewErrorReport_ApplyQuestion")?.ToString();

                if (WindowMessageBox.Show(this, message, WindowMessageBoxButonEnum.YesCancel, WindowMessageBoxTypeEnum.Question) != WindowMessageBoxButonEnum.Yes)
                {
                    return;
                }
            }

            OnLockWindow(true);

            _thread.Start();
        }
        /// <summary> Обработчик нажатия галочки Белый список </summary>
        private void CheckBoxDoNotDesturb_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            if ((bool)CheckBoxDoNotDesturb.IsChecked)
            {
                return;
            }

            if (_viewModelUserSettings.CountWhiteContact == 0)
            {
                var message = Application.Current.TryFindResource(@"ViewUserSettings_MustAddContactsToTheWhitelist") as string;

                var windowMessageBoxButon = WindowMessageBox.Show(this, message, WindowMessageBoxButonEnum.Ok, WindowMessageBoxTypeEnum.Information);
            }
            else
            {
                var message = Application.Current.TryFindResource(@"ViewUserSettings_ReceiveIncomingCallsOnlyWhitelist") as string;

                var windowMessageBoxButon = WindowMessageBox.Show(this, message, WindowMessageBoxButonEnum.OkCancel, WindowMessageBoxTypeEnum.Question);

                if (windowMessageBoxButon == WindowMessageBoxButonEnum.Ok)
                {
                    _viewModelUserSettings.CommandEnableWriteList.Execute(true);
                }
            }
        }
        /// <summary> Действие перед закрытием окна </summary>
        public bool BeforeCloseWindow()
        {
            var result = true;

            if (_viewModelUserSettings.CurrentModelUserSettingsChanged)
            {
                var resource = Application.Current.TryFindResource(@"ViewUserSettings_DontSaveSettingsMessage");
                var message  = resource as string ?? String.Empty;

                var windowMessageBoxButon = WindowMessageBox.Show(this, message, WindowMessageBoxButonEnum.YesNoCancel, WindowMessageBoxTypeEnum.Question);

                if (windowMessageBoxButon == WindowMessageBoxButonEnum.Yes)
                {
                    _viewModelUserSettings.CommandSave.Execute(true);
                }

                if (windowMessageBoxButon == WindowMessageBoxButonEnum.No)
                {
                    _viewModelUserSettings.ResetLanguage();
                }

                if (windowMessageBoxButon == WindowMessageBoxButonEnum.Cancel)
                {
                    result = false;
                }
            }

            return(result);
        }
        /// <summary> Обработчик нажатия на кнопку перегенерации ключа шифрования </summary>
        private void ButtonRegenerateEncryptionKey_Click(object sender, RoutedEventArgs e)
        {
            if (WindowMessageBox.Show(FactoryWindow.GetWindowUserSettings(), Application.Current.TryFindResource(@"ViewUserSettings_CreateNewKey") as string, Application.Current.TryFindResource(@"ViewUserSettings_AlertLostCorrespondence") as string, WindowMessageBoxButonEnum.ContinueCancel, WindowMessageBoxTypeEnum.Warning) != WindowMessageBoxButonEnum.Continue)
            {
                return;
            }

            var windowPasswordBox = FactoryWindow.GetWindowPasswordBox(PasswordBoxTypeEnum.RegenerateKey);

            windowPasswordBox.Owner = System.Windows.Window.GetWindow(this);

            windowPasswordBox.ShowDialog();

            if ((windowPasswordBox.ViewUserControl as ViewPasswordBox).Result)
            {
                var resultRegenerate = _viewModelUserSettings.RegenerateKeyPair();

                if (resultRegenerate)
                {
                    _viewModelUserSettings.ExportAviable = _viewModelUserSettings.CheckEncryptionkey();

                    _viewModelUserSettings.LocalSavePublicKey();

                    //Показ окна о генерации экрана, когда будет переделан механизм "растягивания" view на главном окне приложения, заменить здесь.
                    WindowMain.CurrentMainWindow.GridSecurityKeyGeneratedWinidow.Visibility = Visibility.Visible;
                }

                OnCloseWindow();
            }
        }
示例#5
0
        /// <summary> Обработчик запуска приложение </summary>
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            // подписка на необрабатываемые исключения в приложении
            DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Application_DispatcherUnhandledException);

            // подписка на необрабатываемые исключения в приложении
            System.AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;

            // Инициализация всех ModelEnum в главном потоке, в котором стартует GUI
            CommonModelEnum.InitializeModelEnum();

            // привязка смены языка интерфейса к смене языка в приложении
            LocalizationApp.GetInstance().LocalizationChanged += LocalizationUI.ChangeLanguage;

            bool success;

            var userName = WindowsIdentity.GetCurrent().Name.Replace(@"\", "-");

            Mutex = new Mutex(true, "DCBF3DE8-032E-4DCA-8158-AE0CF30A15AC" /*userName*/, out success);

            if (!success)
            {
                var allProcess     = System.Diagnostics.Process.GetProcesses();
                var currentProcess = System.Diagnostics.Process.GetCurrentProcess();

                foreach (var process in allProcess)
                {
                    if (currentProcess.ProcessName == process.ProcessName && currentProcess.Id != process.Id)
                    {
                        var hWndStartup = FindWindow(null, "DCBF3DE8-032E-4DCA-8158-AE0CF30A15AC" + userName);

                        if (hWndStartup != IntPtr.Zero)
                        {
                            ShowWindow(hWndStartup, 1);
                            SetForegroundWindow(hWndStartup);
                        }
                        else
                        {
                            WindowMessageBox.Show("Application is run");
                        }
                    }
                }

                Environment.Exit(0);
            }
        }
        /// <summary> Обработчик нажания галочки CheckBoxTrace </summary>
        private void CheckBoxTrace_Checked(object sender, RoutedEventArgs e)
        {
            if (!IsLoaded)
            {
                return;
            }

            var resource = Application.Current.TryFindResource(@"ViewUserSettings_InformationTraceMode");
            var message  = resource as string ?? String.Empty;

            var windowMessageBoxButon = WindowMessageBox.Show(this, message, WindowMessageBoxButonEnum.YesNo, WindowMessageBoxTypeEnum.Question);

            if (windowMessageBoxButon == null || windowMessageBoxButon == WindowMessageBoxButonEnum.No)
            {
                CheckBoxTrace.IsChecked = false;
            }
            else
            {
                _viewModelUserSettings.CurrentModelUserSettings.TraceMode = true;
            }
        }
        /// <summary> Обработчик нажатия кнопки Импортировать </summary>
        private void ButtonImport_Click(object sender, RoutedEventArgs e)
        {
            var windowPasswordBox = FactoryWindow.GetWindowPasswordBox(PasswordBoxTypeEnum.Import);

            windowPasswordBox.Owner = WindowMain.CurrentMainWindow;

            windowPasswordBox.ShowDialog();

            if ((windowPasswordBox.ViewUserControl as ViewPasswordBox).Result)
            {
                var resultImport = _viewModelUserSettings.ImportAndSaveCryptKey();

                if (resultImport)
                {
                    ImportedPanel.Visibility = Visibility.Visible;
                }
                else
                {
                    WindowMessageBox.Show(this, Application.Current.TryFindResource(@"ViewUserSettings_ImportFail") as string);
                }
            }
        }
示例#8
0
        /// <summary> Отправить отчет об ошибке </summary>
        private void SendTroubleTicket()
        {
            try
            {
                if (DataSourceLogScope.SendTroubleTicket(_modelLogScope))
                {
                    Dispatcher.Invoke(() =>
                    {
                        WindowMessageBox.Show(this, Application.Current.TryFindResource(@"ViewErrorReport_SendSuccessful") as string + " " + _modelLogScope.IssueId + ".");

                        OnCloseWindow();
                    });
                }
                else
                {
                    Dispatcher.Invoke(() => WindowMessageBox.Show(this, Application.Current.TryFindResource(@"ViewErrorReport_SendFail") as string, WindowMessageBoxButonEnum.Ok, WindowMessageBoxTypeEnum.Error));
                }
            }
            finally
            {
                OnLockWindow(false);
            }
        }
 /// <summary> Обработчик нажания кнопки очистки логов </summary>
 private void ButtonClearLogs_Click(object sender, RoutedEventArgs e)
 {
     WindowMessageBox.Show(this, Application.Current.TryFindResource(@"ViewUserSettings_LogClearSuccessful") as string);
 }
 /// <summary> Обработчик нажания кнопки с не реализованным функционалом </summary>
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     WindowMessageBox.Show(this, Application.Current.TryFindResource(@"Common_ComingSoon") as string);
 }