private void Button_Click(object sender, RoutedEventArgs e) { if (sender == btnOk) { _result = MessageBoxResult.OK; } else if (sender == btnYes) { _result = MessageBoxResult.Yes; } else if (sender == btnNo) { _result = MessageBoxResult.No; } else if (sender == btnCancel) { _result = MessageBoxResult.Cancel; } else { _result = MessageBoxResult.None; } _messageBox.Close(); _messageBox = null; }
private void OpenFileClick(object sender, RoutedEventArgs e) { string file_path = string.Empty; string file_name = string.Empty; using (OpenFileDialog openFileDialog = new OpenFileDialog()) { openFileDialog.InitialDirectory = "c:\\"; openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; openFileDialog.FilterIndex = 1; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { file_path = openFileDialog.FileName; file_name = Path.GetFileName(file_path); } } if (file_path != string.Empty) { if (!_baseArrayWorkerVM.FileRead(file_path)) { MessageBoxView.Show(file_name, "Файл " + file_name + " содержит недопустимые значения", MessageBoxType.Error); } else { MessageBoxView.Show(file_name, "Файл " + file_name + " успешно прочитан", MessageBoxType.Information); } } }
private void ClearArray(object sender, RoutedEventArgs e) { MessageBoxResult messageBoxResult = MessageBoxView.Show("Очистить массив?", "Старый массив будет утерян! Очистить массив?", MessageBoxButton.YesNo, MessageBoxImage.Question); if (messageBoxResult == MessageBoxResult.Yes) { _baseArrayWorkerVM.Clear(); } }
private void WriteFileClick(object sender, RoutedEventArgs e) { string file_path = string.Empty; string file_name = string.Empty; using (SaveFileDialog saveFileDialog1 = new SaveFileDialog()) { saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; saveFileDialog1.FilterIndex = 1; saveFileDialog1.RestoreDirectory = true; if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (!string.IsNullOrEmpty(file_path = saveFileDialog1.FileName)) { file_name = Path.GetFileName(file_path); _baseArrayWorkerVM.FileWrite(file_path); MessageBoxView.Show(file_name, "Файл " + file_name + " успешно записан", MessageBoxType.Information); } } } }
public static MessageBoxResult Show(string caption, string text, MessageBoxButton button, MessageBoxImage image) { Brush window_brush; if (image == MessageBoxImage.Warning || image == MessageBoxImage.Error) { window_brush = Brushes.IndianRed; } else { window_brush = new SolidColorBrush(Color.FromRgb(0x0F, 0xFF, 0x0F)); } _messageBox = new MessageBoxView() { BorderBrush = window_brush, txtMsg = { Text = text }, MessageTitle = { Text = caption } }; SetVisibilityOfButtons(button); SetImageOfMessageBox(image); _messageBox.ShowDialog(); return(_result); }
private void СreateArrayClick(object sender, RoutedEventArgs e) { if (nb_array_size.Value.HasValue) { MessageBoxResult messageBoxResult = MessageBoxView.Show("Создать рандомный массив?", "Старый массив будет утерян! Создать рандомный массив?", MessageBoxButton.YesNo, MessageBoxImage.Question); if (messageBoxResult != MessageBoxResult.Yes) { ((Button)sender).Command = null; ((Button)sender).CommandParameter = null; } else { ((Button)sender).Command = _baseArrayWorkerVM.RandomGenerateCommand; ((Button)sender).CommandParameter = nb_array_size.Value.Value; Close(); } } else { MessageBoxView.Show("Введите параметр!", "Введите размер массива", MessageBoxButton.OK, MessageBoxImage.Warning); } }