private async void ShowCustomDialog(object sender, RoutedEventArgs e) { var dialog = new CustomDialog(this.MetroDialogOptions) { Content = this.Resources["CustomDialogTest"], Title = "This dialog allows arbitrary content." }; await this.ShowMetroDialogAsync(dialog); var textBlock = dialog.FindChild <TextBlock>("MessageTextBlock"); textBlock.Text = "A message box will appear in 3 seconds."; await Task.Delay(3000); await this.ShowMessageAsync("Secondary dialog", "This message is shown on top of another.", MessageDialogStyle.Affirmative, new MetroDialogSettings() { OwnerCanCloseWithDialog = true, ColorScheme = this.MetroDialogOptions.ColorScheme }); textBlock.Text = "The dialog will close in 2 seconds."; await Task.Delay(2000); await this.HideMetroDialogAsync(dialog); }
private async void ButtonProxy_Click(object sender, RoutedEventArgs e) { this.proxyDialog.Title = "代理服务器设置"; await this.ShowMetroDialogAsync(this.proxyDialog); Button buttonProxyOK = proxyDialog.FindChild <Button>("buttonProxyOK"); Button buttonProxyCancel = proxyDialog.FindChild <Button>("buttonProxyCancel"); TextBox textBoxProxyServer = proxyDialog.FindChild <TextBox>("textBoxProxyServer"); TextBox textBoxProxyPort = proxyDialog.FindChild <TextBox>("textBoxProxyPort"); this.viewModel.UseSystemProxy = this.useSystemProxy; if (!this.useSystemProxy) { textBoxProxyServer.Text = this.proxyServer; textBoxProxyPort.Text = this.proxyPort.ToString(); } RoutedEventHandler proxyDialogButtonOKClick = null; RoutedEventHandler proxyDialogButtonCancelClick = null; proxyDialogButtonOKClick = async(o, args) => { buttonProxyOK.Click -= proxyDialogButtonOKClick; buttonProxyCancel.Click -= proxyDialogButtonCancelClick; this.useSystemProxy = this.viewModel.UseSystemProxy; if (!this.viewModel.UseSystemProxy) { this.proxyServer = textBoxProxyServer.Text; this.proxyPort = Convert.ToInt32(textBoxProxyPort.Text); } await this.HideMetroDialogAsync(this.proxyDialog); }; proxyDialogButtonCancelClick = async(o, args) => { buttonProxyOK.Click -= proxyDialogButtonOKClick; buttonProxyCancel.Click -= proxyDialogButtonCancelClick; await this.HideMetroDialogAsync(this.proxyDialog); }; buttonProxyOK.Click += proxyDialogButtonOKClick; buttonProxyCancel.Click += proxyDialogButtonCancelClick; }
private async void buttonAddRss_Click(object sender, RoutedEventArgs e) { this.rssDialog.Title = "添加RSS源"; await this.ShowMetroDialogAsync(this.rssDialog); Button buttonOK = rssDialog.FindChild <Button>("buttonOK"); Button buttonCancel = rssDialog.FindChild <Button>("buttonCancel"); TextBox textBoxRssName = rssDialog.FindChild <TextBox>("textBoxRssName"); TextBox textBoxRssUrl = rssDialog.FindChild <TextBox>("textBoxRssUrl"); RssListBinding rlb = new RssListBinding(); textBoxRssName.Text = rlb.Name; textBoxRssUrl.Text = rlb.Name; RoutedEventHandler addRssDialogButtonOKClick = null; RoutedEventHandler addRssDialogButtonCancelClick = null; addRssDialogButtonOKClick = async(o, args) => { buttonOK.Click -= addRssDialogButtonOKClick; buttonCancel.Click -= addRssDialogButtonCancelClick; rlb.Name = textBoxRssName.Text; rlb.URL = textBoxRssUrl.Text; rlb.Selected = true; if (this.viewModel.RssList.Contains(rlb)) { this.viewModel.RssList.Remove(rlb); this.viewModel.RssListEx.Remove(rlb); this.database.RemoveRssList(rlb); } this.viewModel.RssList.Add(rlb); this.viewModel.RssListEx.Add(rlb); this.database.AddRssList(rlb); await this.HideMetroDialogAsync(this.rssDialog); }; addRssDialogButtonCancelClick = async(o, args) => { buttonOK.Click -= addRssDialogButtonOKClick; buttonCancel.Click -= addRssDialogButtonCancelClick; await this.HideMetroDialogAsync(this.rssDialog); }; buttonOK.Click += addRssDialogButtonOKClick; buttonCancel.Click += addRssDialogButtonCancelClick; }
private void JoinMeeting() { var customDialog = new CustomDialog() { Title = "Mit Meeting verbinden" }; var dataContext = new MeetingInfoContent(async instance => { await this.HideMetroDialogAsync(customDialog); if (instance.Remember) { Properties.Settings.Default.RememberLastMeetingDetails = instance.Remember; Properties.Settings.Default.LastMeetingId = instance.MeetingId; Properties.Settings.Default.LastMeetingPassword = StringCipher.Encrypt(instance.MeetingPassword, instance.MeetingId); Properties.Settings.Default.LastUserName = instance.UserName ?? "JW Admin"; Properties.Settings.Default.Save(); } await this.JoinMeetingAsync(instance.MeetingId, instance.MeetingPassword, instance.UserName); }, instance => this.HideMetroDialogAsync(customDialog)); dataContext.Remember = Properties.Settings.Default.RememberLastMeetingDetails; dataContext.MeetingId = Properties.Settings.Default.LastMeetingId; if (!string.IsNullOrWhiteSpace(dataContext.MeetingId) && !string.IsNullOrWhiteSpace(Properties.Settings.Default.LastMeetingPassword)) { dataContext.MeetingPassword = StringCipher.Decrypt(Properties.Settings.Default.LastMeetingPassword, dataContext.MeetingId); } dataContext.UserName = string.IsNullOrWhiteSpace(Properties.Settings.Default.LastUserName) ? "JW Admin" : Properties.Settings.Default.LastUserName; customDialog.Content = new MeetingInfoDialog { DataContext = dataContext }; ((MeetingInfoDialog)customDialog.Content).MeetingPassword.Password = dataContext.MeetingPassword; this.ShowMetroDialogAsync(customDialog).ContinueWith((e) => { TextBox textBox = customDialog.FindChild <TextBox>("MeetingIdTextBox"); Dispatcher.BeginInvoke(DispatcherPriority.Input, new Action(delegate() { Keyboard.ClearFocus(); textBox.Focus(); Keyboard.Focus(textBox); })); }); }