private void DeleteButton_Click(object sender, System.Windows.RoutedEventArgs e) { var grid = MainDataGrid; var userSettings = grid.SelectedItems.Cast <UserSetting>().ToArray(); var form = new MessageBoxWindow(); var result = form.ShowDialog("Do you want to delete selected settings?", "X360CE - Delete Settings", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { // Remove from local settings. foreach (var item in userSettings) { SettingsManager.UserSettings.Items.Remove(item); } SettingsManager.Save(); // Remove from cloud settings. Task.Run(new Action(() => { foreach (var item in userSettings) { Global.CloudClient.Add(CloudAction.Delete, new UserSetting[] { item }); } })); } }
private void ResetToDefaultButton_Click(object sender, EventArgs e) { var game = CurrentItem; if (game == null) { return; } var program = _DefaultSettings; if (program == null) { return; } var form = new MessageBoxWindow(); var result = form.ShowDialog("Reset current settings to default?", "Reset", System.Windows.MessageBoxButton.OKCancel, System.Windows.MessageBoxImage.Question); if (result != System.Windows.MessageBoxResult.OK) { return; } // Reset to default all properties which affects checksum. game.XInputMask = program.XInputMask; game.XInputPath = program.XInputPath ?? ""; game.HookMask = program.HookMask; game.AutoMapMask = (int)MapToMask.None; game.EmulationType = (int)EmulationType.None; game.DInputMask = program.DInputMask; game.DInputFile = program.DInputFile ?? ""; game.FakeVID = program.FakeVID; game.FakePID = program.FakePID; game.Timeout = program.Timeout; }
private void btnDelete_Click(object sender, RoutedEventArgs e) { if (ComList.SelectedIndex > -1) { AMS.ViewModel.ViewModelCommandDetail vm = (AMS.ViewModel.ViewModelCommandDetail) this.ComList.SelectedItem; if (vm_IssuedInfoList.DelCommandDetailInfo(vm.Id.Value)) { MessageBoxWindow mbw = new MessageBoxWindow(); mbw.vm_MessageBoxWindow = new AMS.ViewModel.ViewModelMessageBoxWindow(AMS.Model.Enum.MessageBoxType.Success, "删除成功"); mbw.ShowDialog(); DataBinding(); } else { MessageBoxWindow mbw = new MessageBoxWindow(); mbw.vm_MessageBoxWindow = new AMS.ViewModel.ViewModelMessageBoxWindow(AMS.Model.Enum.MessageBoxType.Error, "删除失败"); mbw.ShowDialog(); } } else { MessageBoxWindow mbw = new MessageBoxWindow(); mbw.vm_MessageBoxWindow = new AMS.ViewModel.ViewModelMessageBoxWindow(AMS.Model.Enum.MessageBoxType.Warning, "请选中删除"); mbw.ShowDialog(); } }
/// <summary> /// Delete selected Programs (Default Game Settings) from current settings. /// </summary> void DeleteSelectedPrograms() { var grid = MainDataGrid; var itemsToDelete = grid.SelectedItems.Cast <Engine.Data.Program>().ToArray(); var form = new MessageBoxWindow(); string message; if (itemsToDelete.Length == 1) { var item = itemsToDelete[0]; message = string.Format("Are you sure you want to delete default settings for?\r\n\r\n\tFile Name: {0}\r\n\tProduct Name: {1}", item.FileName, item.FileProductName); } else { message = string.Format("Delete {0} default setting(s)?", itemsToDelete.Length); } var result = form.ShowDialog(message, "Delete", System.Windows.MessageBoxButton.OKCancel, System.Windows.MessageBoxImage.Warning); if (result == System.Windows.MessageBoxResult.OK) { foreach (var item in itemsToDelete) { SettingsManager.Programs.Items.Remove(item); } SettingsManager.Save(); } }
private void AutoButton_Click(object sender, RoutedEventArgs e) { var ud = _UserDevice; if (ud == null) { return; } var description = Attributes.GetDescription(_MappedTo); var form = new MessageBoxWindow(); var buttons = MessageBoxButton.YesNo; var text = string.Format("Do you want to fill {0} settings automatically?", description); if (ud.Device == null && !TestDeviceHelper.ProductGuid.Equals(ud.ProductGuid)) { text = string.Format("Device is off-line. Please connect device to fill {0} settings automatically.", description); buttons = MessageBoxButton.OK; } var result = form.ShowDialog(text, "Fill Controller Settings", buttons, MessageBoxImage.Question); if (result != MessageBoxResult.Yes) { return; } var ps = AutoMapHelper.GetAutoPreset(ud); _PadSetting.Load(ps); }
private static void UserDevices_Items_ListChanged(object sender, ListChangedEventArgs e) { var pd = e.PropertyDescriptor; if (pd != null && e.ListChangedType == ListChangedType.ItemChanged) { if (e.PropertyDescriptor.Name == nameof(Engine.Data.UserDevice.IsHidden)) { var ud = UserDevices.Items[e.NewIndex]; if (ud.AllowHide) { var canModify = ViGEm.HidGuardianHelper.CanModifyParameters(true); if (canModify) { //var ids = AppHelper.GetIdsToAffect(ud.HidDeviceId, ud.HidHardwareIds); var ids = new string[] { ud.DevDeviceId }; //ud.IsHidden = !ud.IsHidden; // Use begin invoke which will prevent mouse multi-select rows. ControlsHelper.BeginInvoke(() => { AppHelper.SynchronizeToHidGuardian(ud.InstanceGuid); }); } else { var form = new MessageBoxWindow(); form.ShowDialog("Can't modify HID Guardian registry.\r\nPlease run this application as Administrator once in order to fix permissions.", "Permission Denied", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); } } } } }
public void DeleteCampusWindow() { MessageBoxWindow mbw = new MessageBoxWindow(); mbw.vm_MessageBoxWindow = new AMS.ViewModel.ViewModelMessageBoxWindow(AMS.Model.Enum.MessageBoxType.Warning, "该操作会删除该校区下的设备信息,您确定要删除该校区?"); mbw.ShowDialog(); if (mbw.vm_MessageBoxWindow.Result) { if (ViewModelCampusWindow.ButtomSubmit()) { mbw = new MessageBoxWindow(); mbw.vm_MessageBoxWindow = new AMS.ViewModel.ViewModelMessageBoxWindow(AMS.Model.Enum.MessageBoxType.Success, "删除成功"); mbw.ShowDialog(); } } //MessageBoxResult r = MessageBox.Show("该操作会删除该校区下的设备信息,您确定要删除该校区?", "删除", MessageBoxButton.OKCancel); //if (r == MessageBoxResult.OK) //{ // IsSuccess = ViewModelCampusWindow.ButtomSubmit(); // if (IsSuccess) // { // MessageBox.Show("操作成功。"); // } //} }
private void MessageBoxShow() { MessageBoxWindow mbw = new MessageBoxWindow(); mbw.vm_MessageBoxWindow = new AMS.ViewModel.ViewModelMessageBoxWindow(AMS.Model.Enum.MessageBoxType.Error, "媒体文件下载失败!"); mbw.ShowDialog(); }
/// <summary> /// Displays an error message box /// </summary> /// <param name="errorMessage">The error error message to display</param> /// <param name="title">The title of the message box</param> /// <param name="IsRTL">(Optional) If true the MessageBox FlowDirection will be RightToLeft</param> public static void ShowError(string errorMessage, string title, bool IsRTL = false) { try { using (var msg = new MessageBoxWindow()) { msg.Title = title; msg.TxtTitle.Text = title; msg.TxtMessage.Text = errorMessage; msg.TitleBackgroundPanel.Background = Brushes.Red; msg.BorderBrush = Brushes.Red; msg.BtnCancel.Visibility = Visibility.Collapsed; if (IsRTL) { msg.FlowDirection = FlowDirection.RightToLeft; } msg.BtnOk.Focus(); msg.ShowDialog(); } } catch (Exception) { MessageBox.Show(errorMessage); } }
public static bool?ShowMessageBox(this Window owner, string windowTitle, string messageText, string subText = null, MessageBoxButton buttons = MessageBoxButton.OK, int width = 420, int height = 260) { var messageBox = new MessageBoxWindow(); messageBox.Title = windowTitle ?? string.Empty; messageBox.Width = width; messageBox.Height = height; messageBox.MessageText = messageText ?? string.Empty; messageBox.SubText = subText ?? string.Empty; if (buttons == MessageBoxButton.OK) { messageBox.CancelButtonColumnWidth = new GridLength(1, GridUnitType.Auto); messageBox.CancelButtonVisibility = Visibility.Collapsed; } if (buttons.HasFlag(MessageBoxButton.YesNo)) { messageBox.OkButtonText = "_Yes"; messageBox.CancelButtonText = "_No"; } if (!owner.IsLoaded) { owner.Show(); } messageBox.Owner = owner; return(messageBox.ShowDialog()); }
public static MessageBoxResult ShowWithCancel(string message, bool isError, bool IsRTL = false) { try { using (var msg = new MessageBoxWindow()) { msg.Title = MessageBoxTitle; msg.TxtTitle.Text = MessageBoxTitle; msg.TxtMessage.Text = message; msg.TitleBackgroundPanel.Background = isError ? Brushes.Red : new SolidColorBrush(Color.FromRgb(3, 169, 244)); msg.BorderBrush = isError ? Brushes.Red : new SolidColorBrush(Color.FromRgb(3, 169, 244)); if (IsRTL) { msg.FlowDirection = FlowDirection.RightToLeft; } msg.BtnOk.Focus(); msg.ShowDialog(); return(msg.Result == MessageBoxResult.OK ? MessageBoxResult.OK : MessageBoxResult.Cancel); } } catch (Exception) { MessageBox.Show(message); return(MessageBoxResult.Cancel); } }
private void OnOkClick(object window) { var wnd = window as System.Windows.Window; string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(methodName); if (projectManager.ServerMethodFolderItems.Exists(fileNameWithoutExtension)) { ProjectItem folder = projectManager.ServerMethodFolderItems.Item(fileNameWithoutExtension); string methodNameWithExtension = !Path.HasExtension(methodName) ? methodName + ".cs" : methodName; if (folder.ProjectItems.Exists(methodNameWithExtension)) { var messageWindow = new MessageBoxWindow(); var dialogReuslt = messageWindow.ShowDialog(wnd, "Method already added to project. Do you want replace method?", "Warning", MessageButtons.YesNo, MessageIcon.None); if (dialogReuslt != MessageDialogResult.Yes) { return; } } } wnd.DialogResult = true; wnd.Close(); }
private MessageBoxResult SetOwnerAndShow(MessageBoxWindow msg) { msg.Owner = Application.Current.MainWindow; msg.ShowDialog(); return(msg.Result); }
public static bool?Show(string message, string detail, MessageBoxWindowType windowType, MessageBoxWindowButtonsType buttonType) { MessageBoxWindow window = new MessageBoxWindow(); window.Message = message; window.Detail = detail; window.WindowType = windowType; window.ButtonsType = buttonType; switch (windowType) { case MessageBoxWindowType.Information: window.Title = LanguageString.Find("Presentation_Windows_MessageBoxWindow_Information"); break; case MessageBoxWindowType.Question: window.Title = LanguageString.Find("Presentation_Windows_MessageBoxWindow_Question"); break; case MessageBoxWindowType.Warning: window.Title = LanguageString.Find("Presentation_Windows_MessageBoxWindow_Warning"); break; case MessageBoxWindowType.Error: window.Title = LanguageString.Find("Presentation_Windows_MessageBoxWindow_Error"); break; default: window.Title = LanguageString.Find("Presentation_Windows_MessageBoxWindow_Information"); break; } return(window.ShowDialog()); }
/// <summary> /// 删除设备信息 /// </summary> /// <returns></returns> public void DeleteDevice() { MessageBoxWindow mbw = new MessageBoxWindow(); mbw.vm_MessageBoxWindow = new AMS.ViewModel.ViewModelMessageBoxWindow(AMS.Model.Enum.MessageBoxType.Warning, "确定删除该设备信息吗?"); mbw.ShowDialog(); if (mbw.vm_MessageBoxWindow.Result) { if (ViewModelDevice.ButtonSubmit(0)) { mbw = new MessageBoxWindow(); mbw.vm_MessageBoxWindow = new AMS.ViewModel.ViewModelMessageBoxWindow(AMS.Model.Enum.MessageBoxType.Success, "删除成功"); mbw.ShowDialog(); } } //ViewModelDevice.Cmd = AMS.ViewModel.Enum.HandleType.Delete; //MessageBoxResult r = MessageBox.Show("确定删除该设备信息吗?", "删除", MessageBoxButton.OKCancel); //if (r == MessageBoxResult.OK) //{ // IsSuccess =ViewModelDevice.ButtonSubmit(); // if (IsSuccess) // { // MessageBox.Show("删除成功。"); // } //} }
/// <summary> /// Delete selected Programs (Default Game Settings) from current settings. /// </summary> void DeleteSelectedPrograms() { var grid = ProgramsDataGridView; var selection = JocysCom.ClassLibrary.Controls.ControlsHelper.GetSelection <string>(grid, nameof(Engine.Data.Program.FileName)); var itemsToDelete = SettingsManager.Programs.Items.Where(x => selection.Contains(x.FileName)).ToArray(); var form = new MessageBoxWindow(); string message; if (itemsToDelete.Length == 1) { var item = itemsToDelete[0]; message = string.Format("Are you sure you want to delete default settings for?\r\n\r\n\tFile Name: {0}\r\n\tProduct Name: {1}", item.FileName, item.FileProductName); } else { message = string.Format("Delete {0} default setting(s)?", itemsToDelete.Length); } var result = form.ShowDialog(message, "Delete", System.Windows.MessageBoxButton.OKCancel, System.Windows.MessageBoxImage.Warning); if (result == System.Windows.MessageBoxResult.OK) { foreach (var item in itemsToDelete) { SettingsManager.Programs.Items.Remove(item); } SettingsManager.Save(); } }
private void button4_Click(object sender, RoutedEventArgs e) { //获取设备类型 int deviceType = -1; if ((bool)this.rbtnSeatDevice.IsChecked) { deviceType = 0; } if ((bool)this.rbtnSpaceDevice.IsChecked) { deviceType = 1; } if ((bool)this.rbtnLockerDevice.IsChecked) { deviceType = 2; } IsSuccess = ViewModelDevice.ButtonSubmit(deviceType); if (IsSuccess) { MessageBoxWindow mbw = new MessageBoxWindow(); mbw.vm_MessageBoxWindow = new AMS.ViewModel.ViewModelMessageBoxWindow(AMS.Model.Enum.MessageBoxType.Success, "操作成功!"); mbw.ShowDialog(); this.Close(); } }
/// <summary> /// Displays a message box with a no button /// </summary> /// <param name="message">The message to display</param> /// <param name="isError">If the message is an error</param> /// <returns>Message box Result Yes or No</returns> public static MessageBoxResult ShowWithCancel(string message, bool isError) { try { using (var msg = new MessageBoxWindow()) { msg.TxtTitle.Text = MessageBoxTitle; msg.TxtMessage.Text = message; msg.TitleBackgroundPanel.Background = isError ? Brushes.Red : new SolidColorBrush(Color.FromRgb(3, 169, 244)); msg.BorderBrush = isError ? Brushes.Red : new SolidColorBrush(Color.FromRgb(3, 169, 244)); msg.BtnOk.Focus(); msg.BtnCancel.Content = "Non"; msg.BtnOk.Content = "Oui"; msg.ShowDialog(); return(msg.Result == MessageBoxResult.OK ? MessageBoxResult.OK : MessageBoxResult.Cancel); } } catch (Exception) { MessageBox.Show(message); return(MessageBoxResult.Cancel); } }
private void MessageBoxShow() { MessageBoxWindow mbw = new MessageBoxWindow(); mbw.vm_MessageBoxWindow = new AMS.ViewModel.ViewModelMessageBoxWindow(AMS.Model.Enum.MessageBoxType.Success, "下载成功!"); mbw.ShowDialog(); }
private void btn_Save_Click(object sender, RoutedEventArgs e) { MessageBoxWindow mbw = new MessageBoxWindow(); if (image == null) { mbw.viewModel.Message = "请先预览生成图片!"; mbw.viewModel.Type = Code.MessageBoxType.Error; mbw.ShowDialog(); } SaveFileDialog openFileDialog = new SaveFileDialog(); openFileDialog.Title = "保存为"; openFileDialog.Filter = "jpg文件|*.jpg|bmp文件|*.bmp|所有文件|*.*"; openFileDialog.FileName = string.Empty; openFileDialog.FilterIndex = 1; openFileDialog.RestoreDirectory = true; openFileDialog.DefaultExt = "jpg"; bool result = (bool)openFileDialog.ShowDialog(); if (!result) { return; } string fileName = openFileDialog.FileName; image.Save(fileName); mbw = new MessageBoxWindow(); mbw.viewModel.Message = "保存完成!"; mbw.viewModel.Type = Code.MessageBoxType.Success; mbw.ShowDialog(); }
private void OnRenameFolderClick(object window) { var viewModel = new FolderNameViewModel(); var view = new FolderNameDialog(); view.DataContext = viewModel; view.Owner = window as Window; if (view.ShowDialog() == true) { string newFolderName = viewModel.FolderName; string newFullPath = Path.Combine(Path.GetDirectoryName(selectDirectoryItem.FullPath), newFolderName); if (string.Equals(selectDirectoryItem.FullPath, newFullPath)) { return; } try { System.IO.Directory.Move(selectDirectoryItem.FullPath, newFullPath); selectDirectoryItem.FullPath = newFullPath; } catch (Exception ex) { var messageWindow = new MessageBoxWindow(); messageWindow.ShowDialog(window as Window, ex.Message, "Aras VS method plugin", MessageButtons.OK, MessageIcon.Error); } } }
public static bool DownloadAndInstall(Uri uri, string localPath, Uri infoPage, bool runElevated = false) { try { var file = DownloadFile(uri, localPath); if (runElevated) { var proc = new ProcessStartInfo(); proc.UseShellExecute = true; proc.WorkingDirectory = Environment.CurrentDirectory; proc.FileName = file.FullName; proc.Verb = "runas"; Process.Start(proc); //Win32.UacHelper.RunElevatedAsync(file.FullName, null); } else { ControlsHelper.OpenPath(file.FullName); } return(true); } catch (Exception ex) { var form = new MessageBoxWindow(); ControlsHelper.CheckTopMost(form); var text = string.Format("Unable to download {0} file:\r\n\r\n{1}\r\n\r\nOpen source web page?", uri.AbsoluteUri, ex.Message); var result = form.ShowDialog(text, "Download Error", System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Question); if (result == System.Windows.MessageBoxResult.Yes) { ControlsHelper.OpenUrl("https://support.microsoft.com/en-gb/help/2977003/the-latest-supported-visual-c-downloads"); } } return(false); }
private void OnDeleteFolderClick(object window) { string message = $"Are you sure you want to delete the {selectDirectoryItem.Name} folder?"; var messageWindow = new MessageBoxWindow(); var dialogResult = messageWindow.ShowDialog(window as Window, message, "Aras VS method plugin", MessageButtons.OKCancel, MessageIcon.Warning); if (dialogResult == MessageDialogResult.OK) { try { System.IO.Directory.Delete(selectDirectoryItem.FullPath, true); if (selectDirectoryItem.Parent != null) { selectDirectoryItem.Parent.Update(); } } catch (Exception ex) { var errorWindow = new MessageBoxWindow(); errorWindow.ShowDialog(window as Window, ex.Message, "Aras VS method plugin", MessageButtons.OK, MessageIcon.Error); } } }
/// <summary> /// 保存 /// </summary> /// <returns></returns> public bool Save() { SeatManage.Bll.FileOperate fileOperation = new SeatManage.Bll.FileOperate(); SeatManage.ClassModel.UserGuideInfo model = new SeatManage.ClassModel.UserGuideInfo(); foreach (GuideImageItem item in _GuideImages) { if (!fileOperation.UpdateFile(item.ImageUrl, item.ImageNmae, SeatManage.EnumType.SeatManageSubsystem.UserGuide)) { ErrorMessage = string.Format("文件{0}上传失败!", item.ImageNmae); return(false); } model.ImageFilePath.Add(item.ImageNmae); } model.XMLContent = model.ToXml(); if (SeatManage.Bll.T_SM_SystemSet.UpdateUserGuide(model)) { MessageBoxWindow mbw = new MessageBoxWindow(); mbw.viewModel.Message = "保存成功!"; mbw.viewModel.Type = Code.MessageBoxType.Success; mbw.ShowDialog(); return(true); } else { ErrorMessage = string.Format("保存失败!"); return(false); } }
public void Login(Window window) { if (window == null) { return; } try { var accountCount = DataProvider.Ins.DB.TAIKHOANs.Where(p => p.TENTK == UserName && p.MATKHAU == Password).Count(); if (accountCount > 0) { MainViewModel.LoginAccount = DataProvider.Ins.DB.TAIKHOANs.Where(p => p.TENTK == UserName && p.MATKHAU == Password).SingleOrDefault(); IsLogin = true; IsActiveSnackBar = false; window.Close(); } else { IsLogin = false; IsActiveSnackBar = true; } } catch (Exception) { MessageBoxWindow mess2 = new MessageBoxWindow(); mess2.Tag = "Hãy kiểm tra kết nối tới CSDL"; mess2.ShowDialog(); // MessageBox.Show("Hãy kiểm tra kết nối tới CSDL", "Lỗi", MessageBoxButton.OK, MessageBoxImage.Error); } }
public async Task <bool> ShowAsync(string title, string content, string ok = "Ok", string cancel = null) { var window = new MessageBoxWindow(title, content); string result = await window.ShowDialog(_window); return(true); }
private static void UserDevices_Items_ListChanged(object sender, ListChangedEventArgs e) { // If list item was not changed then return. if (e.ListChangedType != ListChangedType.ItemChanged) { return; } // If not IsHidden changed then return. if (e.PropertyDescriptor?.Name != nameof(Engine.Data.UserDevice.IsHidden)) { return; } var ud = UserDevices.Items[e.NewIndex]; // If device allowed to be hidden then... if (ud.AllowHide) { var canModify = ViGEm.HidGuardianHelper.CanModifyParameters(true); if (canModify) { var ids = new string[] { ud.DevDeviceId }; // Use begin invoke which will prevent mouse multi-select rows. ControlsHelper.BeginInvoke(() => AppHelper.SynchronizeToHidGuardian(ud.InstanceGuid)); } else { var form = new MessageBoxWindow(); form.ShowDialog("Can't modify HID Guardian registry.\r\nPlease run this application as Administrator once in order to fix permissions.", "Permission Denied", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); } } }
/// <summary> /// 删除 /// </summary> public void Delete(int index) { try { string error = ""; error = SeatManage.Bll.AdvertisementOperation.DeleteAdModel(new SeatManage.ClassModel.AMS_Advertisement() { ID = TitleList[index].ID }); if (error == "") { ErrorMessage = "删除成功!"; MessageBoxWindow mbw = new MessageBoxWindow(); mbw.viewModel.Message = "删除成功!"; mbw.viewModel.Type = Code.MessageBoxType.Success; mbw.ShowDialog(); } else { ErrorMessage = "删除失败"; } } catch (Exception ex) { ErrorMessage = ex.Message; SeatManage.SeatManageComm.WriteLog.Write("删除失败" + ex.Message); } }
private void RemoveButton_Click(object sender, RoutedEventArgs e) { var win = new MessageBoxWindow(); var text = "Do you really want to remove selected user setting?"; var result = win.ShowDialog(text, "X360CE - Remove?", System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Question, System.Windows.MessageBoxResult.No); if (result != System.Windows.MessageBoxResult.Yes) { return; } var game = SettingsManager.CurrentGame; // Return if game is not selected. if (game == null) { return; } var settingsOld = SettingsManager.GetSettings(game.FileName, _MappedTo); SettingsManager.UnMapGamePadDevices(game, _UserSetting, SettingsManager.Options.HidGuardianConfigureAutomatically); var settingsNew = SettingsManager.GetSettings(game.FileName, _MappedTo); // if all devices unmapped and mapping is enabled then... if (settingsOld.Count > 0 && settingsNew.Count == 0 && (EnabledCheckBox.IsChecked == true)) { // Disable mapping. EnabledCheckBox_Click(null, null); } }
public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon) { MessageBoxWindow messageBox = new MessageBoxWindow(messageBoxText, caption, button, icon); messageBox.ShowDialog(); return(messageBox.Result); }
/// <summary> /// Display a message-box to the user, based upon the given options. /// This particular method is the one that all of the other Notify methods invoke to do the actual work. /// </summary> /// <param name="options">a MessageBoxConfiguration object that fully specifies everything about the message-box</param> /// <returns>a MessageResult indicating which action the user took, or TimedOut if the user took no action before the timeout expired</returns> public MessageResult NotifyUser(IMessageBoxConfiguration options) { MessageBoxConfiguration configuration = options as MessageBoxConfiguration; var messageBoxWindow = new MessageBoxWindow(this, configuration); // If the developer who is calling this has provided a custom visual element // to show within the message-box, set that now. //CBL //if (_customElement != null) //{ // messageBoxWindow.SetCustomElement(_customElement); //} // If we are doing testing, and have specified that a specific button is to be emulated as having been selected by the user, // then verify that that button is indeed present.. if (IsTesting) { if (TestFacility.ButtonResultToSelect.HasValue) { string complaint; if (!GetWhetherButtonIsIncluded(configuration.ButtonFlags, out complaint)) { // Announce the error throw new ArgumentOutOfRangeException(complaint); } } } //TODO: The following should not be needed for Silverlight.. // Try to give it a parent-window to position itself relative to. #if !SILVERLIGHT FrameworkElement parentElement = configuration.ParentElement; Window parentWindow = null; if (parentElement == null) { // When running unit-tests, Application.Current might be null. if (Application.Current != null) { parentWindow = Application.Current.MainWindow; // If the parent-window has not actually been shown yet, this would cause an exception. if (parentWindow != null && parentWindow.IsLoaded) { messageBoxWindow.Owner = parentWindow; } } } else if (parentElement.IsLoaded) { parentWindow = parentElement as Window; if (parentWindow != null) { messageBoxWindow.Owner = parentWindow; } } #endif // Finally, show the message-box. //TODO: for Silverlight, need to prepare to receive the result asynchronously!!! #if SILVERLIGHT messageBox.Show(); #else _messageBoxWindow = messageBoxWindow; if (configuration.IsAsynchronous) { messageBoxWindow.Show(); } else { messageBoxWindow.ShowDialog(); } #endif return messageBoxWindow.Result; }