private void DisplayResult(MessageBoxResult result, WpfMessageBoxProperties msgProperties) { WpfMessageBox.Show( this, "Result is: DialogResult." + result + Environment.NewLine + "Checkbox is " + (msgProperties.IsCheckBoxChecked ? "" : "not ") + "checked" + Environment.NewLine + "Textbox value is: " + msgProperties.TextBoxText); }
private void ButtonWpfMsgBoxLongInstruction_Click(object sender, RoutedEventArgs e) { var msgProperties = new WpfMessageBoxProperties() { Button = MessageBoxButton.OK, Header = "Here we have an example of a very very very very very very very very very very very very very very very very very long instruction text.", Image = MessageBoxImage.Information, Text = "Some text", Title = "Some title", }; MessageBoxResult result = WpfMessageBox.Show(this, ref msgProperties); DisplayResult(result); }
private void ButtonWpfMsgBoxWithHeader_Click(object sender, RoutedEventArgs e) { var msgProperties = new WpfMessageBoxProperties() { Button = MessageBoxButton.OK, Header = "Some header", Image = MessageBoxImage.Exclamation, Text = "Some text", Title = "Some title", }; MessageBoxResult result = WpfMessageBox.Show(this, ref msgProperties); DisplayResult(result); }
private void ButtonWpfMsgBoxWithTextBox_Click(object sender, RoutedEventArgs e) { var msgProperties = new WpfMessageBoxProperties() { Button = MessageBoxButton.OKCancel, IsTextBoxVisible = true, Text = "Some text", TextBoxText = "Pre-defined text", Title = "Some title", }; MessageBoxResult result = WpfMessageBox.Show(this, ref msgProperties); DisplayResult(result, msgProperties); }
private void ButtonWpfMsgBoxWithCheckBox_Click(object sender, RoutedEventArgs e) { var msgProperties = new WpfMessageBoxProperties() { Button = MessageBoxButton.OKCancel, CheckBoxText = "I've pre-checked this for you", IsCheckBoxChecked = true, IsCheckBoxVisible = true, Text = "Some text", Title = "Some title", }; MessageBoxResult result = WpfMessageBox.Show(this, ref msgProperties); DisplayResult(result, msgProperties); }
private void ButtonWpfMsgBoxCustomButtons_Click(object sender, RoutedEventArgs e) { var msgProperties = new WpfMessageBoxProperties() { Button = MessageBoxButton.YesNoCancel, ButtonCancelText = "Cancel, cancel!", ButtonNoText = "Please no", ButtonYesText = "Yes _Sir", Image = MessageBoxImage.Information, Text = "Some text", Title = "Some title", }; MessageBoxResult result = WpfMessageBox.Show(this, ref msgProperties); DisplayResult(result); }
private void ButtonResetSettings_Click(object sender, RoutedEventArgs e) { var msgProperties = new WpfMessageBoxProperties() { Button = MessageBoxButton.OKCancel, ButtonOkText = Properties.Resources.messageBoxResetSettingsButtonOk, ButtonCancelText = Properties.Resources.messageBoxButtonCancel, Image = MessageBoxImage.Question, Text = Properties.Resources.messageBoxResetSettingsText, Title = "Bandcamp Downloader", }; if (WpfMessageBox.Show(this, ref msgProperties) == MessageBoxResult.OK) { ResetSettings(); } }
private async void ButtonCheckForUpdates_Click(object sender, RoutedEventArgs e) { Version latestVersion; try { latestVersion = await UpdatesHelper.GetLatestVersionAsync(); } catch (CouldNotCheckForUpdatesException) { var msgProperties = new WpfMessageBoxProperties() { Button = MessageBoxButton.OK, ButtonOkText = Properties.Resources.messageBoxButtonOK, Image = MessageBoxImage.Error, Text = Properties.Resources.messageBoxCheckForUpdatesError, Title = "Bandcamp Downloader", }; WpfMessageBox.Show(Window.GetWindow(this), ref msgProperties); return; } Version currentVersion = Assembly.GetExecutingAssembly().GetName().Version; if (currentVersion.CompareTo(latestVersion) < 0) { // The latest version is newer than the current one var windowUpdate = new WindowUpdate() { ShowInTaskbar = true, WindowStartupLocation = WindowStartupLocation.CenterScreen, }; windowUpdate.Show(); } else { var msgProperties = new WpfMessageBoxProperties() { Button = MessageBoxButton.OK, ButtonOkText = Properties.Resources.messageBoxButtonOK, Image = MessageBoxImage.Information, Text = String.Format(Properties.Resources.messageBoxNoUpdateAvailable, currentVersion.ToString(3)), Title = "Bandcamp Downloader", }; WpfMessageBox.Show(Window.GetWindow(this), ref msgProperties); } }
private void ButtonWpfMsgBoxNiceExample_Click(object sender, RoutedEventArgs e) { var msgProperties = new WpfMessageBoxProperties() { Button = MessageBoxButton.OKCancel, ButtonOkText = "Set name", CheckBoxText = "Don't ask again", Image = MessageBoxImage.Exclamation, Header = "No name defined", IsCheckBoxChecked = true, IsCheckBoxVisible = true, IsTextBoxVisible = true, Text = "Please enter the name to use. You can leave the field empty in order to continue using the default name.", Title = "A nice example", }; MessageBoxResult result = WpfMessageBox.Show(this, ref msgProperties); DisplayResult(result, msgProperties); }
private void OpenHyperlink(object sender, ExecutedRoutedEventArgs e) { string url = e.Parameter.ToString(); try { Process.Start(url); } catch (Win32Exception ex) when(ex.Message == "The system cannot find the file specified") { // Probably a relative link like "/docs/help-translate.md" var msgProperties = new WpfMessageBoxProperties() { Button = MessageBoxButton.OK, ButtonOkText = Properties.Resources.messageBoxButtonOK, Image = MessageBoxImage.Error, Text = String.Format(Properties.Resources.messageBoxCouldNotOpenUrlError, url), Title = "Bandcamp Downloader", }; WpfMessageBox.Show(Window.GetWindow(this), ref msgProperties); } }
private void WindowMain_Closing(object sender, CancelEventArgs e) { if (_activeDownloads) { // There are active downloads, ask for confirmation var msgProperties = new WpfMessageBoxProperties() { Button = MessageBoxButton.OKCancel, ButtonCancelText = Properties.Resources.messageBoxButtonCancel, ButtonOkText = Properties.Resources.messageBoxCloseWindowWhenDownloadingButtonOk, Image = MessageBoxImage.Warning, Text = Properties.Resources.messageBoxCloseWindowWhenDownloadingText, Title = "Bandcamp Downloader", }; if (WpfMessageBox.Show(this, ref msgProperties) == MessageBoxResult.Cancel) { // Cancel closing the window e.Cancel = true; } } }
private void ButtonWpfMsgBoxAllFeatures_Click(object sender, RoutedEventArgs e) { var msgProperties = new WpfMessageBoxProperties() { Button = MessageBoxButton.YesNoCancel, ButtonCancelText = "Cancel, cancel!", ButtonNoText = "Please no", ButtonYesText = "Yes _Sir", CheckBoxText = "I've pre-checked this for you", Image = MessageBoxImage.Error, Header = "Here we have an example of a very very very very very very very very very very very very very very very very very long instruction text.", IsCheckBoxChecked = true, IsCheckBoxVisible = true, IsTextBoxVisible = true, Text = GetLongSampleText(), TextBoxText = "You should enter something here", Title = "Some title", }; MessageBoxResult result = WpfMessageBox.Show(this, ref msgProperties); DisplayResult(result, msgProperties); }
private void ButtonStop_Click(object sender, RoutedEventArgs e) { var msgProperties = new WpfMessageBoxProperties() { Button = MessageBoxButton.YesNo, ButtonCancelText = Properties.Resources.messageBoxButtonCancel, ButtonOkText = Properties.Resources.messageBoxButtonOK, Image = MessageBoxImage.Question, Text = Properties.Resources.messageBoxCancelDownloadsText, Title = "Bandcamp Downloader", }; if (WpfMessageBox.Show(this, ref msgProperties) != MessageBoxResult.Yes || !_activeDownloads) { // If user cancelled the cancellation or if downloads finished while he choosed to cancel return; } Mouse.OverrideCursor = Cursors.Wait; _userCancelled = true; buttonStop.IsEnabled = false; _downloadManager.CancelDownloads(); }