System.Windows.MessageBox.Show(string, string, System.Windows.MessageBoxButton, System.Windows.MessageBoxImage)

Here are the examples of the csharp api System.Windows.MessageBox.Show(string, string, System.Windows.MessageBoxButton, System.Windows.MessageBoxImage) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1257 Examples 7

19 View Source File : MainWindow.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnBrowseBackCommandExecuted(object sender, ExecutedRoutedEventArgs e) {
			MessageBox.Show("Browse backward a page here.", "Back Executed", MessageBoxButton.OK, MessageBoxImage.Information);
		}

19 View Source File : DataModelDesignModel.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

void Login()
        {
            try
            {
                SelecTesreplacedem.RequestId = RandomOperate.Generate(8);
                GlobalContext.SetRequestContext(ZeroApplication.Config.ServiceKey, SelecTesreplacedem.RequestId);
                GlobalContext.Customer.DeviceId = User.DeviceId;
                GlobalContext.RequestInfo.Token = User.DeviceId;
                var client = new ApiClient
                {
                    Station = "UserCenter",
                    Commmand = "v1/login/account",
                    Argument = JsonConvert.SerializeObject(new PhoneLoginRequest
                    {
                        MobilePhone = User.UserName,
                        UserPreplacedword = User.PreplacedWord
                    })
                };
                client.CallCommand();
                SelecTesreplacedem.GlobalId = client.GlobalId;
                var result = JsonConvert.DeserializeObject<ApiResult<LoginResponse>>(client.Result);
                if (!result.Success)
                {
                    MessageBox.Show(result.Status?.ClientMessage, "登录", MessageBoxButton.OK,
                        MessageBoxImage.Error);
                    return;
                }
                User.AccessToken = result.ResultData.AccessToken;
                User.RefreshToken = result.ResultData.RefreshToken;
                VerifyAccessToken();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "登录", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnToggleBreakpointEnabledButtonClick(object sender, RoutedEventArgs e) {
			// Get the breakpoints at the caret and toggle their enabled states
			var tagRanges = editor.Doreplacedent.IndicatorManager.Breakpoints.GetInstances(new TextSnapshotRange(editor.ActiveView.Selection.EndSnapshotOffset));
			var count = 0;
			foreach (var tagRange in tagRanges) {
				if (editor.Doreplacedent.IndicatorManager.Breakpoints.ToggleEnabledState(tagRange.Tag))
					count++;
			}

			if (count == 0)
				MessageBox.Show("No breakpoints were found at the caret.", "Toggle Breakpoint Enabled State", MessageBoxButton.OK, MessageBoxImage.Exclamation);

			// Focus the editor
			editor.Focus();
		}

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnAddIndicatorButtonClick(object sender, RoutedEventArgs e) {
			// Validate
			if (editor.ActiveView.Selection.IsZeroLength) {
				MessageBox.Show("Please make a selection of at least one character.", "Add Indicator", MessageBoxButton.OK, MessageBoxImage.Exclamation);
				return;
			}

			// Add an indicator
			this.AddIndicator(editor.ActiveView.Selection.SnapshotRange);

			// Focus the editor
			editor.Focus();
		}

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnEmailDoreplacedentMenuItemClick(object sender, RoutedEventArgs e) {
			MessageBox.Show("This is an example of how to wire up extended functionality for a SyntaxEditor from custom buttons inside of it.  In this example you'd e-mail the doreplacedent text here.", "E-mail Doreplacedent", MessageBoxButton.OK, MessageBoxImage.Information);
		}

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnButtonClick(object sender, RoutedEventArgs e) {
			MessageBox.Show("You clicked a button", "ZoomContentControl", MessageBoxButton.OK, MessageBoxImage.Information);
		}

19 View Source File : Settings.xaml.cs
License : GNU General Public License v3.0
Project Creator : adrianlungu

public static void SetupStartup()
        {
            try
            {
                var key =
                    Microsoft.Win32.Registry.CurrentUser.OpenSubKey(
                        "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
                var curreplacedembly = replacedembly.GetExecutingreplacedembly();

                if (Properties.Settings.Default.RunOnStartup)
                {
                    key.SetValue(curreplacedembly.GetName().Name, curreplacedembly.Location);
                }
                else
                {
                    key.DeleteValue(curreplacedembly.GetName().Name, false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error setting up application startup. " + ex.ToString(),
                    "Error",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
            }
        }

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void SimulateFileCopy() {
			FileCopyData fileCopyData = this.FileCopyData;
			if (0 != fileCopyData.RemainingFileCount) {

				if (this.CanSimulateAPause && (40 == fileCopyData.RemainingFileCount)) {
					this.animatedProgressBar.State = OperationState.Paused;
					MessageBox.Show("The file 'xyz.txt' already exists, would you like to overwrite it?",
						"File Copy (Simluated)", MessageBoxButton.YesNo, MessageBoxImage.Question);
					this.animatedProgressBar.State = OperationState.Normal;
				}
				else if (this.CanSimulateAnError && (30 == fileCopyData.RemainingFileCount)) {
					this.animatedProgressBar.State = OperationState.Error;
					MessageBox.Show("An error occurred while copying the file 'abc.txt'.",
						"File Copy (Simluated)", MessageBoxButton.OK, MessageBoxImage.Error);
					this.animatedProgressBar.State = OperationState.Normal;
				}

				double fileTime = fileCopyData.TimeRemaining.TotalSeconds / fileCopyData.RemainingFileCount;
				double fileSize = fileCopyData.RemainingFileSize / fileCopyData.RemainingFileCount;
				fileCopyData.RemainingFileCount--;
				fileCopyData.RemainingFileSize -= fileSize;
				fileCopyData.CopiedFileSize = fileCopyData.TotalFileSize - fileCopyData.RemainingFileSize;
				fileCopyData.Speed = ((double)this.random.Next(6000) + 3000) / 100.0;
				fileCopyData.TimeRemaining -= TimeSpan.FromSeconds(fileTime);
			}
			this.FileCopyData = fileCopyData;
		}

private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            config.default_powershell_path = DefaultPowerShellPath.Text;
            config.default_cmd_path = DefaultCMDPath.Text;
            config.powershell_arguments = PowerShellArguments.Text;
            config.console_background = ConsoleBackground.Text;
            config.console_foreground = ConsoleForeground.Text;
            config.console_ignore_color_tags = GetComboBoxValue(ConsoleIgnoreColorTags);
            config.clear_events_when_reload = GetComboBoxValue(ClearEventsWhenReload);

            config.restrictions.block_tabs_remove = GetComboBoxValue(BlockTabsRemove);
            config.restrictions.block_buttons_remove = GetComboBoxValue(BlockButtonsRemove);
            config.restrictions.block_tabs_add = GetComboBoxValue(BlockTabsAdd);
            config.restrictions.block_buttons_add = GetComboBoxValue(BlockButtonsAdd);
            config.restrictions.block_buttons_reorder = GetComboBoxValue(BlockButtonsReorder);
            config.restrictions.block_buttons_edit = GetComboBoxValue(BlockButtonsEdit);
            config.restrictions.block_tabs_rename = GetComboBoxValue(BlockTabsRename);
            config.restrictions.hide_menu_item_file_reload_config = GetComboBoxValue(HideFileReloadConfigMenuItem);
            config.restrictions.hide_menu_item_file_open_app_folder = GetComboBoxValue(HideFileOpenAppFolderMenuItem);
            config.restrictions.hide_menu_item_file_clear_events_list = GetComboBoxValue(HideFileClearEventsListMenuItem);
            config.restrictions.hide_menu_item_settings = GetComboBoxValue(HideSettingsMenuItem);
            config.restrictions.hide_menu_item_settings_workflow = GetComboBoxValue(HideSettingsWorkflowMenuItem);
            config.restrictions.hide_menu_item_settings_workflow_reorder_tabs = GetComboBoxValue(HideSettingsWorkflowReorderTabsMenuItem);
            config.restrictions.hide_menu_item_settings_workflow_add_tab = GetComboBoxValue(HideSettingsWorkflowAddTabMenuItem);
            config.restrictions.hide_menu_item_settings_workflow_remove_current_tab = GetComboBoxValue(HideSettingsWorkflowRemoveCurrentTabMenuItem);
            config.restrictions.hide_menu_item_settings_workflow_rename_current_tab = GetComboBoxValue(HideSettingsWorkflowRenameCurrentTabMenuItem);
            config.restrictions.hide_menu_item_settings_workflow_add_button_to_current_tab = GetComboBoxValue(HideSettingsWorkflowAddButtonToCurrentTabMenuItem);
            config.restrictions.hide_menu_item_settings_workflow_reorder_buttons_in_current_tab = GetComboBoxValue(HideSettingsWorkflowReorderButtonsInCurrentTabMenuItem);
            config.restrictions.hide_menu_item_settings_configuration = GetComboBoxValue(HideSettingsConfigurationMenuItem);
            config.restrictions.hide_menu_item_help = GetComboBoxValue(HideHelpMenuItem);
            config.restrictions.hide_menu_item_help_troubleshooting = GetComboBoxValue(HideHelpTroubleshootingMenuItem);
            config.restrictions.hide_menu_item_help_colortags = GetComboBoxValue(HideHelpColorTagsMenuItem);
            config.restrictions.hide_menu_item_help_about = GetComboBoxValue(HideHelpAboutMenuItem);

            if(ConfigUtils.SaveFromConfigToFile(config) == true)
            {
                MessageBox.Show("Settings saved!", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnPopupButtonPopupOpening(object sender, CancelRoutedEventArgs e) {
			if (this.PreventPopups) {
				MessageBox.Show("The popup is temporarily blocked, please uncheck the prevent popups checkbox to enable it again.",
					"PopupButton", MessageBoxButton.OK, MessageBoxImage.Error);
				e.Cancel = true;
				return;
			}

			// NOTE: The PopupMenu or PopupContent can be fully initialized customized in this event before the popup/menu is opened

			// For this sample, we'll update the header of a menu item to show the current time
			customMenuItem.Header = "Opened at: " + DateTime.Now.ToLongTimeString();
		}

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnUnbindCustomAction(object sender, RoutedEventArgs e) {
			// Unbind
			this.UnbindCustomEditAction();

			// Notify user
			MessageBox.Show("Unbound Ctrl+P.", "Result", MessageBoxButton.OK, MessageBoxImage.Information);
			editor.Focus();
		}

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnCalculateStatisticsButtonClick(object sender, RoutedEventArgs e) {
			// Validate path
			string folderPath = folderTextBox.Text.Trim();
			if ((string.IsNullOrEmpty(folderPath)) || (!Directory.Exists(folderPath))) {
				MessageBox.Show("Please enter a valid folder path.", "Invalid Folder", MessageBoxButton.OK, MessageBoxImage.Exclamation);
				return;
			}

			// Initialize the background worker
			processingBackgroundWorker = new BackgroundWorker();
			processingBackgroundWorker.WorkerReportsProgress = true;
			processingBackgroundWorker.DoWork += delegate(object sndr, DoWorkEventArgs eventArgs) {
				StatData data = (StatData)eventArgs.Argument;

				// Recurse and queue files
				List<string> queuedFiles = new List<string>();
				this.QueueFolder(queuedFiles, data.FolderPath);
				
				// Add stats for files
				for (int index = 0; index < queuedFiles.Count; index++) {
					processingBackgroundWorker.ReportProgress(
						(int)((index + 1) * 100.0 / queuedFiles.Count), 
						String.Format("Examining {0}...", queuedFiles[index])
						);
					this.AddStatsForFile(data, queuedFiles[index]);
				}

			};
			processingBackgroundWorker.ProgressChanged += delegate(object sndr, ProgressChangedEventArgs eventArgs) {
				messageTextBox.Text = eventArgs.UserState.ToString();
				progressBar.Value = eventArgs.ProgressPercentage;
			};
			processingBackgroundWorker.RunWorkerCompleted += delegate(object sndr, RunWorkerCompletedEventArgs eventArgs) {
				// Show results
				List<ActiproSoftware.Text.ITextStatistic> statistics = new List<ActiproSoftware.Text.ITextStatistic>();
				statistics.Add(ActiproSoftware.Text.Implementation.TextStatistics.CreateStatistic("RootPath", "Root Path", currentData.FolderPath));
				statistics.Add(ActiproSoftware.Text.Implementation.TextStatistics.CreateStatistic("TotalFiles", "Total Files", currentData.CSharpFileCount + currentData.VBFileCount + currentData.XamlFileCount));
				statistics.Add(ActiproSoftware.Text.Implementation.TextStatistics.CreateStatistic("C#Files", "C# Files", currentData.CSharpFileCount));
				statistics.Add(ActiproSoftware.Text.Implementation.TextStatistics.CreateStatistic("VBFiles", "VB Files", currentData.VBFileCount));
				statistics.Add(ActiproSoftware.Text.Implementation.TextStatistics.CreateStatistic("XAMLFiles", "XAML Files", currentData.XamlFileCount));
				statistics.Add(ActiproSoftware.Text.Implementation.TextStatistics.CreateStatistic("TotalLines", "Total Lines", currentData.NonWhitespaceLineCount + currentData.WhitespaceLineCount));
				statistics.Add(ActiproSoftware.Text.Implementation.TextStatistics.CreateStatistic("NonWhitespaceLines", "Non-Whitespace Lines", currentData.NonWhitespaceLineCount));
				statistics.Add(ActiproSoftware.Text.Implementation.TextStatistics.CreateStatistic("WhitespaceLines", "Whitespace Lines", currentData.WhitespaceLineCount));
				statistics.Add(ActiproSoftware.Text.Implementation.TextStatistics.CreateStatistic("WhitespaceLinePercent", "Whitespace Line %", currentData.WhitespaceLineCount * 100.0 / Math.Max(1, currentData.NonWhitespaceLineCount + currentData.WhitespaceLineCount)));
				resultsListView.ItemsSource = statistics;

				// Processing is complete
				messageTextBox.Text = "Ready";
				progressBar.Value = 0;
				calculateStatisticsButton.IsEnabled = true;
			};

			// Initialize UI
			calculateStatisticsButton.IsEnabled = false;
			messageTextBox.Text = "Discovering files...";
			progressBar.Value = 0;

			// Start the background work
			currentData = new StatData();
			currentData.FolderPath = folderPath;
			processingBackgroundWorker.RunWorkerAsync(currentData);
		}

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void fileOpenCommand_Execute(object sender, ExecutedRoutedEventArgs e) {
			// Open a doreplacedent
			OpenFileDialog dialog = new OpenFileDialog();
			dialog.Filter = "Images Files (*.bmp; *.gif; *.jpg; *.jpeg; *.png; *.tif; *.tiff)|*.bmp;*.gif;*.jpg;*.jpeg;*.png;*.tif;*.tiff";
			if (dialog.ShowDialog() == true) {
				ImageSource imageSource = null;
				try {
					BitmapDecoder decoder = BitmapDecoder.Create(dialog.OpenFile(), BitmapCreateOptions.None, BitmapCacheOption.None);
					imageSource = decoder.Frames[0];
				}
				catch (Exception) {
					// No-op
				}

				if (null == imageSource) {
					MessageBox.Show("Unable to open image file.", "ZoomContentControl", MessageBoxButton.OK, MessageBoxImage.Error);
					return;
				}

				this.zoomContentControl.BeginUpdate();
				try {
					this.image.Source = imageSource;
					this.zoomContentControl.UpdateLayout();
					this.zoomContentControl.ZoomToFit();
				}
				finally {
					this.zoomContentControl.EndUpdate(false);
				}
			}
		}

19 View Source File : MainWindow.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnHelpCommandExecuted(object sender, ExecutedRoutedEventArgs e) {
			MessageBox.Show("Show doreplacedentation here.", "Doreplacedentation", MessageBoxButton.OK, MessageBoxImage.Information);
		}

19 View Source File : RichTextBoxExtended.cs
License : MIT License
Project Creator : Actipro

private void OnFontFamilyExecute(object sender, ExecutedRoutedEventArgs e) {
			FontFamilyValueCommandParameter parameter = e.Parameter as FontFamilyValueCommandParameter;
			if (parameter != null) {
				if ((parameter.Value != null) && (!RibbonControls.FontFamilyComboBox.IsValidFontFamilyName(parameter.Value.Source)))
					MessageBox.Show(String.Format("The font family '{0}' does not exist.", parameter.Value), "Invalid Font Family", MessageBoxButton.OK, MessageBoxImage.Exclamation);
				else {
					switch (parameter.Action) {
						case ValueCommandParameterAction.CancelPreview:
							this.DeactivatePreviewMode(true);
							break;
						case ValueCommandParameterAction.Commit:
							this.DeactivatePreviewMode(false);
							this.SelectionFontFamily = parameter.Value;
							break;
						case ValueCommandParameterAction.Preview:
							this.ActivatePreviewMode();
							this.SelectionFontFamily = parameter.PreviewValue;
							break;
					}
				}
				e.Handled = true;
			}
		}

19 View Source File : MainWindow.xaml.cs
License : MIT License
Project Creator : ADeltaX

private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            var sel = treeView.SelectedItem;

            if (sel == null)
                return;

            //TODO: IMPLEMENT FOR HIVE TOO

            if (sel is RegistryHiveTreeView)
                return;

            if (sel is RegistryKeyTreeView key)
            {
                CreateValueWindow cvw = new CreateValueWindow(key.Path);
                cvw.Owner = this;
                var result = cvw.ShowDialog();
                if (result.HasValue && result.Value)
                {
                    var subKey = key.AttachedHive.Root.OpenSubKey(key.Path);

                    if (subKey.GetValue(cvw.GetValueName()) == null)
                    {
                        subKey.SetValueRaw(cvw.GetValueName(), cvw.GetValueData(), (RegistryValueType)cvw.GetValueType());
                    }
                    else
                    {
                        MessageBox.Show($"A key named {cvw.GetValueName()} already exists. Value not created", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                    
                }
            }

            //
        }

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnRemoveReferenceButtonClick(object sender, RoutedEventArgs e) {
			if (referencesListView.SelectedIndex == -1) {
				MessageBox.Show("Select a reference first.", "No Reference Selected", MessageBoxButton.OK, MessageBoxImage.Exclamation);
				return;
			}

			// Remove the selected reference
			projectreplacedembly.replacedemblyReferences.RemoveAt(referencesListView.SelectedIndex);

			// Reset list
			referencesListView.ItemsSource = null;
			referencesListView.ItemsSource = projectreplacedembly.replacedemblyReferences;
		}

19 View Source File : FileExplorerViewModel.cs
License : MIT License
Project Creator : afxw

private void DeleteFile(string s)
        {
            var result = MessageBox.Show($"Delete {SelectedFile.Name}?", "File deletion", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (result == MessageBoxResult.Yes)
                Client.Owner.SendPacket(new DeleteFileRequestPacket(SelectedFile.Path));
        }

19 View Source File : DirectoryHelper.cs
License : MIT License
Project Creator : ABTSoftware

public static string GetPathForExport(string defaultPath)
        {
            var isGoodPath = false;
            string ret = null;
            while (!isGoodPath)
            {
                var dialog = new FolderBrowserDialog { SelectedPath = defaultPath };

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    string error;
                    isGoodPath = HasWriteAccessToFolder(dialog.SelectedPath, out error);
                    if (isGoodPath)
                    {
                        ret = dialog.SelectedPath;
                    }
                    else
                    {
                        MessageBox.Show(error, "SciChart", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
                else
                {
                    isGoodPath = true;
                }
            }

            return ret;
        }

19 View Source File : SettingsControl.xaml.cs
License : MIT License
Project Creator : AkiniKites

private void btnDeletePack_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show($"Are you sure you want to delete {IoC.Config.PatchFile}?", $"Delete File",
                MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes)
            {
                return;
            }

            if (File.Exists(Configs.PatchPath))
                File.Delete(Configs.PatchPath);

            UpdatePatchStatus();
        }

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnEditorDoreplacedentTextChanging(object sender, EditorSnapshotChangingEventArgs e) {
			e.Cancel = (cancelCheckBox.IsChecked == true);

			if (e.Cancel) {
				if (alternateTextCheckBox.IsChecked == true) {
					// Temporarily turn off cancel and insert date/time instead
					cancelCheckBox.IsChecked = false;
					editor.ActiveView.ReplaceSelectedText(TextChangeTypes.Custom, DateTime.Now.ToString());
					cancelCheckBox.IsChecked = true;
					MessageBox.Show("Text change cancelled, current date/time inserted instead.", "Notification", MessageBoxButton.OK, MessageBoxImage.Information);
				}
				else {
					// Simple cancel
					MessageBox.Show("Text change cancelled.", "Notification", MessageBoxButton.OK, MessageBoxImage.Information);
				}
			}
		}

19 View Source File : ApplicationViewModel.cs
License : MIT License
Project Creator : Actipro

private void OpenExternalSampleCore(string fullName) {
			if (!string.IsNullOrEmpty(fullName)) {
				try {
					var demoWindow = Application.LoadComponent(new Uri(fullName, UriKind.Relative)) as Window;
					if (demoWindow != null)
						demoWindow.Show();
				}
				catch (Exception ex) {
					while (ex.InnerException != null)
						ex = ex.InnerException;

					MessageBox.Show(string.Format("The sample '{0}' was unable to be loaded.\r\n\r\n{1}", fullName, ex.Message),
						"Sample Not Loaded", MessageBoxButton.OK, MessageBoxImage.Exclamation);
				}
			}
		}

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnDesignerDrop(object sender, DragEventArgs e) {
			// Lookup the dropped control (only a single item is supported)
			ControlTreeNodeModel controlModel = CustomTreeListBoxItemAdapter
				.GetDraggedModels(e.Data, treeListBox)
				.OfType<ControlTreeNodeModel>()
				.FirstOrDefault();

			// Here is where the dropped item would be processed. For this demo, only a message will be displayed.
			if (controlModel is null)
				MessageBox.Show($"The dropped item is not supported by this designer.", "UI Designer", MessageBoxButton.OK, MessageBoxImage.Warning);
			else
				MessageBox.Show($"Add the following control to the designer:\r\n\r\n\t{controlModel.FullName}", "UI Designer", MessageBoxButton.OK, MessageBoxImage.Information);
		}

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnPostToBlogMenuItemClick(object sender, RoutedEventArgs e) {
			MessageBox.Show("This is an example of how to wire up extended functionality for a SyntaxEditor from custom buttons inside of it.  In this example you'd post the doreplacedent text to a blog here.", "Post Doreplacedent to Blog", MessageBoxButton.OK, MessageBoxImage.Information);
		}

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnAddReferenceButtonClick(object sender, RoutedEventArgs e) {
			// Show a file open dialog
			OpenFileDialog dialog = new OpenFileDialog();
			if (!BrowserInteropHelper.IsBrowserHosted)
				dialog.CheckFileExists = true;
			dialog.Multiselect = false;
			dialog.Filter = "replacedemblies (*.dll)|*.dll|All files (*.*)|*.*";
			if (dialog.ShowDialog() == true) {
				try {
					// Add to references
					projectreplacedembly.replacedemblyReferences.AddFrom(dialog.FileName);
				}
				catch (Exception ex) {
					MessageBox.Show("An exception occurred: " + ex.Message, "Error Loading replacedembly", MessageBoxButton.OK, MessageBoxImage.Exclamation);
				}
			}
		}

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnEditActionListViewDoubleClick(object sender, MouseButtonEventArgs e) {
			ListBox listBox = (ListBox)sender;
			EditActionData actionData = listBox.SelectedItem as EditActionData;
			if (actionData != null) {
				// If the action can execute...
				if (actionData.Action.CanExecute(editor.ActiveView)) {
					// Focus the editor
					editor.Focus();

					// Execute it
					actionData.Action.Execute(editor.ActiveView);
				}
				else {
					// Display a message
					MessageBox.Show("The selected edit action cannot currently execute based on the current selection context.", "Cannot Execute", MessageBoxButton.OK, MessageBoxImage.Information);
				}
			}
		}

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnCollapseButtonClick(object sender, RoutedEventArgs e) {
			if (editor.ActiveView.Selection.IsZeroLength) {
				MessageBox.Show("Please select at least one character to collapse.", "No Selection", MessageBoxButton.OK, MessageBoxImage.Exclamation);
				return;
			}

			// Get the tagger that was created by the language and has been persisted in the doreplacedent's properties
			//   while the language is active on the doreplacedent
			CollapsedRegionTagger tagger = null;
			if (editor.Doreplacedent.Properties.TryGetValue(typeof(CollapsedRegionTagger), out tagger)) {
				// Create a version range
				ITextVersionRange versionRange = editor.ActiveView.Selection.SnapshotRange.ToVersionRange(TextRangeTrackingModes.DeleteWhenZeroLength);

				// Create a formatted text
				FormattedText formattedText = new FormattedText("...", CultureInfo.CurrentCulture, FlowDirection.LeftToRight,
					new Typeface(editor.FontFamily, editor.FontStyle, editor.FontWeight, editor.FontStretch),
					editor.FontSize, Brushes.Gray, VisualTreeHelper.GetDpi(editor).PixelsPerDip);
				
				// Create a tag that will be used to both collapse text and drive an intra-text placeholder...
				//   Since the tags in this sample are persisted in a collection while active, 
				//   we can use the tag itself as the key... the key is used to retrieve
				//   the bounds of the spacer later on so adornments can be rendered in it, thus is must be unique
				CollapsedRegionTag tag = new CollapsedRegionTag();
				tag.Key = tag;
				tag.Text = formattedText.Text;
				tag.Baseline = formattedText.Baseline;
				tag.Size = new Size(formattedText.WidthIncludingTrailingWhitespace, formattedText.Height);

				// Add the tag to the tagger
				tagger.Add(new TagVersionRange<ICollapsedRegionTag>(versionRange, tag));
			}

			// Focus the editor
			editor.Focus();
		}

19 View Source File : ConvertItemHelper.cs
License : MIT License
Project Creator : Actipro

private static void ReportError(string text) {
			MessageBox.Show(text, "Breadcrumb Sample", MessageBoxButton.OK, MessageBoxImage.Error);
		}

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnToggleBookmarkEnabledButtonClick(object sender, RoutedEventArgs e) {
			// Get the bookmarks at the caret and toggle their enabled states
			var tagRanges = editor.Doreplacedent.IndicatorManager.Bookmarks.GetInstances(editor.ActiveView.Selection.EndSnapshotOffset.Line);
			var count = 0;
			foreach (var tagRange in tagRanges) {
				if (editor.Doreplacedent.IndicatorManager.Bookmarks.ToggleEnabledState(tagRange.Tag))
					count++;
			}

			if (count == 0)
				MessageBox.Show("No bookmarks were found at the caret.", "Toggle Bookmark Enabled State", MessageBoxButton.OK, MessageBoxImage.Exclamation);

			// Focus the editor
			editor.Focus();
		}

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnPropertyGridChildPropertyAdding(object sender, PropertyModelChildChangeEventArgs e) {
			var person = e.ParentPropertyModel.Target as Person;
			var message = string.Format("Adding child to {0}, {1}", person.LastName, person.FirstName);
			this.AppendMessage(message);

			var result = MessageBox.Show("Are you sure you want to add a new child?", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question);
			e.Cancel = (MessageBoxResult.No == result);
			e.Handled = true;
		}

19 View Source File : DebuggingHelper.cs
License : MIT License
Project Creator : Actipro

public static void ToggleBreakpoint(TextSnapshotOffset snapshotOffset, bool isEnabled) {
			var doreplacedent = snapshotOffset.Snapshot.Doreplacedent as IEditorDoreplacedent;
			if (doreplacedent == null)
				return;

			var parseData = doreplacedent.ParseData as IDotNetParseData;
			if (parseData == null)
				return;

			// Find the containing statement
			var node = FindContainingStatement(parseData, snapshotOffset);
			if ((node == null) || (!node.StartOffset.HasValue) || (!node.EndOffset.HasValue)) {
				MessageBox.Show("Please move the caret inside of a valid C# statement.", "Toggle Breakpoint", MessageBoxButton.OK, MessageBoxImage.Exclamation);
				return;
			}

			// Get the snapshot range of the statement
			var snapshotRange = new TextSnapshotRange(parseData.Snapshot ?? snapshotOffset.Snapshot, node.StartOffset.Value, node.EndOffset.Value);

			// Create a breakpoint tag
			var tag = new BreakpointIndicatorTag();
			tag.IsEnabled = isEnabled;

			// Toggle the indicator
			var tagRange = doreplacedent.IndicatorManager.Breakpoints.Toggle(snapshotRange, tag);

			// Set the tag's content provider (quick info for the glyph) if a tag was added
			if (tagRange != null)
				tag.ContentProvider = new BreakpointIndicatorTagContentProvider(tagRange);
		}

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnBreadcrumbConverreplacedem(object sender, BreadcrumbConverreplacedemEventArgs e) {
			// If here and the trail is null, then the default conversion handling has failed.
			if (BreadcrumbConverreplacedemTargetType.Trail == e.TargetType && null == e.Trail)
				MessageBox.Show("The specified path could not be found.", "Breadcrumb Sample", MessageBoxButton.OK, MessageBoxImage.Error);
		}

19 View Source File : MainWindow.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnHelpCommandExecuted(object sender, ExecutedRoutedEventArgs e) {
			MessageBox.Show("Open the doreplacedentation here.", "Help", MessageBoxButton.OK, MessageBoxImage.Information);
		}

19 View Source File : OculusDemoForm.cs
License : MIT License
Project Creator : ab4d

private void InitializeOvrAndDirectX()
        {
            if (UseOculusRift)
            {
                // Initializing Oculus VR is very simple when using OculusWrapVirtualRealityProvider
                // First we create an instance of OculusWrapVirtualRealityProvider
                _oculusRiftVirtualRealityProvider = new OculusWrapVirtualRealityProvider(_ovr, multisamplingCount: 4);

                try
                {
                    // Then we initialize Oculus OVR and create a new DXDevice that uses the same adapter (graphic card) as Oculus Rift
                    _dxDevice = _oculusRiftVirtualRealityProvider.InitializeOvrAndDXDevice(requestedOculusSdkMinorVersion: 17);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed to initialize the Oculus runtime library.\r\nError: " + ex.Message, "Oculus error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                string ovrVersionString = _ovr.GetVersionString();
                _originalWindowreplacedle += string.Format(" (OVR v{0})", ovrVersionString);
                _renderForm.Text = _originalWindowreplacedle;


                // Reset tracking origin at startup
                _ovr.RecenterTrackingOrigin(_oculusRiftVirtualRealityProvider.SessionPtr);
            }
            else
            {
                // Create DXDevice that will be used to create DXViewportView
                var dxDeviceConfiguration = new DXDeviceConfiguration();
                dxDeviceConfiguration.DriverType             = DriverType.Hardware;
                dxDeviceConfiguration.SupportedFeatureLevels = new FeatureLevel[] { FeatureLevel.Level_11_0 }; // Oculus requires at least feature level 11.0

                _dxDevice = new DXDevice(dxDeviceConfiguration);
                _dxDevice.InitializeDevice();
            }


            // Now create DXScene object from the RenderForm Handle
            // The DXScene will use SwapChain to show the rendered scene
            _dxScene                 = _dxDevice.CreateDXSceneWithSwapChain(_renderForm.Handle, _renderForm.ClientSize.Width, _renderForm.ClientSize.Height, preferedMultisampleCount: 4);
            _dxScene.BackgroundColor = System.Windows.Media.Colors.LightBlue.ToColor4();
            _dxScene.ShaderQuality   = ShaderQuality.Normal;

            // _mainViewport3D will define the 3D scene. The scene is defined with using WPF's Viewport3D object.
            // Because Viewport3D is used, this means that we can use many helper objects from Ab3d.PowerToys library.
            _mainViewport3D = new Viewport3D();

            // When we use Viewport3D to define the 3D scene, we need to use DXViewportView to render its content in Ab3d.DXEngine.
            // The DXViewportView will convert all 3D objects defined in Viewport3D to DXEngine's SceneNodes.
            // It is also possible to define 3D scene with using only SceneNode and other low level DXEngine objects.
            // See PictureBoxForm sample and samples in "Advanced usage" section in Ab3d.DXEngine.Samples project.
            _dxViewportView = new DXViewportView(_dxScene, _mainViewport3D);

            _dxViewportView.BackgroundColor = Colors.Aqua;

            // Currently DXEngine support showing Oculus mirror texture only with DirectXOverlay presentation type (not with DirectXImage)
            _dxViewportView.PresentationType = DXView.PresentationTypes.DirectXOverlay;


            if (UseOculusRift)
            {
                // The _dxViewportView will show Oculus mirrow window.
                // The mirror window can be any size, for this sample we use 1/2 the HMD resolution.
                _dxViewportView.Width = _oculusRiftVirtualRealityProvider.HmdDescription.Resolution.Width / 2.0;
                _dxViewportView.Height = _oculusRiftVirtualRealityProvider.HmdDescription.Resolution.Height / 2.0;
            }


            // Initialize Virtual reality rendering
            _dxViewportView.DXScene.InitializeVirtualRealityRendering(_oculusRiftVirtualRealityProvider);


            // Initialized shadow rendering (see Ab3d.DXEngine.Wpf.Samples project - DXEngine/ShadowRenderingSample for more info
            _varianceShadowRenderingProvider = new VarianceShadowRenderingProvider()
            {
                ShadowMapSize          = 1024,
                ShadowDepthBluringSize = 2,
                ShadowThreshold        = 0.2f
            };

            _dxViewportView.DXScene.InitializeShadowRendering(_varianceShadowRenderingProvider);



            // Set DXDiagnostics.CurrentDXView to allow using DXEngineSnoop tool (see https://www.ab4d.com/DirectX/3D/Diagnostics.aspx)
            // Note that CurrentDXView is using WeakReference to prevent rooting the _dxViewportView by a static filed.
            Ab3d.DirectX.DXDiagnostics.CurrentDXView = _dxViewportView;


            // Enable collecting rendering statistics (see _dxViewportView.DXScene.Statistics clreplaced)
            DXDiagnostics.IsCollectingStatistics = true;


            // Set DXDiagnostics.CurrentDXView to allow using DXEngineSnoop tool (see https://www.ab4d.com/DirectX/3D/Diagnostics.aspx)
            // Note that CurrentDXView is using WeakReference to prevent rooting the _dxViewportView by a static filed.
            Ab3d.DirectX.DXDiagnostics.CurrentDXView = _dxViewportView;


            // Create FirstPersonCamera
            _camera = new FirstPersonCamera()
            {
                TargetViewport3D = _mainViewport3D,
                Position         = new Point3D(0, 1, 4),
                Heading          = 0,
                Atreplacedude         = 0,
                ShowCameraLight  = ShowCameraLightType.Never
            };

            _camera.Refresh(); // We need to manually call Refresh because this camera is not added to WPF objects tree and therefore its Loaded event is never fired.


            // Initialize XBOX controller that will control the FirstPersonCamera
            _xInputCameraController = new XInputCameraController()
            {
                TargetCamera = _camera,
                RotationSpeed = 120,                          // rotation: 120 degrees per second
                MovementSpeed = 2,                            // movement: 2 meters per second
                RotateOnlyHorizontally = true,                // do not rotate up and down (changing atreplacedude) with controller - this is done only HMD
                MoveVerticallyWithDPadButtons = true,
                AutomaticallyStartCheckingController = false, // We will manually call CheckController method so we need to disable automatic checking (the reason is because we are rendering at higher frame rate then 60 FPS that is use when automatically checking the controller).
            };


            // Create a sample 3D scene
            CreateSceneObjects();


            // Add lights
            var lightsVisual3D = new ModelVisual3D();
            var lightsGroup    = new Model3DGroup();

            var directionalLight = new DirectionalLight(Colors.White, new Vector3D(0.5, -0.3, -0.3));
            directionalLight.SetDXAttribute(DXAttributeType.IsCastingShadow, true); // Set this light to cast shadow
            lightsGroup.Children.Add(directionalLight);

            var ambientLight = new AmbientLight(System.Windows.Media.Color.FromRgb(30, 30, 30));
            lightsGroup.Children.Add(ambientLight);

            lightsVisual3D.Content = lightsGroup;
            _mainViewport3D.Children.Add(lightsVisual3D);


            // And finally render the first frame
            RenderScene();
        }

19 View Source File : MainWindow.xaml.cs
License : MIT License
Project Creator : ADeltaX

private void LoadAndVerifyHives(string[] filenames)
        {
            //TODO: background thread processing.

            bool isMoreThanOneFile = filenames.Length > 1;

            StringBuilder aggregatedMessages = null;

            if (isMoreThanOneFile)
                aggregatedMessages = new StringBuilder();

            foreach (var file in filenames)
            {
                var isloaded = IsHiveAlreadyLoaded(file);

                if (isloaded)
                {
                    //ToDo: more meaningful warning message
                    if (isMoreThanOneFile)
                        aggregatedMessages.AppendLine("This registry hive is already loaded\nFile: " + file + "\n");
                    else
                        MessageBox.Show("This registry hive is already loaded\nFile: " + file, "Hive already loaded", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
                else
                {
                    try
                    {
                        var res = LoadHive(file, true); //TEST
                        if (res)
                        {
                            //Get the root item (as treeviewitem given the datatemplate) and open it
                            var uwu = treeView.ItemContainerGenerator.ContainerFromIndex(0) as TreeViewItem;
                            uwu.IsExpanded = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        if (isMoreThanOneFile)
                            aggregatedMessages.AppendLine("This registry hive couldn't be loaded\nDetails: " + ex.Message + "\n");
                        else
                            MessageBox.Show("This registry hive couldn't be loaded\nDetails: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }

            if (isMoreThanOneFile && aggregatedMessages.Length > 0)
                MessageBox.Show(aggregatedMessages.ToString(), "Multiple messages", MessageBoxButton.OK, MessageBoxImage.Exclamation);
        }

19 View Source File : CustomizeQat.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnAddToQatButtonClick(object sender, RoutedEventArgs e) {
			// Ensure that the control has not already been added
			RibbonControlReference controlRef = (RibbonControlReference)availableQareplacedemsListBox.SelectedItem;
			if (controlRef.IsAlreadyAdded(qareplacedems)) {
				MessageBox.Show("The selected command is already on the Quick Access Toolbar.", "Quick Access Toolbar", MessageBoxButton.OK, MessageBoxImage.Exclamation);
				return;
			}

			// Clone the selected control and add it to the QAT items list
			UIElement clonedControl = controlRef.Clone();
			qareplacedems.Insert(qareplacedemsListBox.SelectedIndex + 1, new RibbonControlReference(clonedControl));
			qareplacedemsListBox.SelectedIndex = qareplacedemsListBox.SelectedIndex + 1;
		}

19 View Source File : AuthenticationPage.xaml.cs
License : MIT License
Project Creator : Adoxio

private void OnWorkerCompletedRegisterDevice(RunWorkerCompletedEventArgs args)
		{
			var deviceCredentials = args.Result as ClientCredentials;

			if (args.Error != null)
			{
				var errorPage = new ErrorPage(_connectionData)
				{
					CaptionText = "Failed to register device credentials.",
					DetailsText = args.Error.Message,
					DetailsIsVisible = true
				};

				errorPage.Return += connectionPage_Return;

				if (NavigationService != null)
				{
					NavigationService.Navigate(errorPage);
				}
			}
			else if (!args.Cancelled & deviceCredentials != null)
			{
				UpdateDeviceCredentials(deviceCredentials);

				const string messageBoxText = "New Device ID and Device Preplacedword values have been generated and registered.\n\nSave device credentials for future use?";
				const string caption = "Device Credentials";
				const MessageBoxButton messageBoxButton = MessageBoxButton.YesNo;
				const MessageBoxImage messageBoxImage = MessageBoxImage.None;

				var result = MessageBox.Show(messageBoxText, caption, messageBoxButton, messageBoxImage);

				switch (result)
				{
					case MessageBoxResult.Yes:

						WriteDevice(deviceCredentials);

						break;

					case MessageBoxResult.No:

						return;
				}
			}
		}

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnLoadStateButtonClick(object sender, RoutedEventArgs e) {
			// Deserialize the list of QAT items that was previous persisted
			ICollection<Exception> exceptions = ribbon.DeserializeQuickAccessToolBarItems(serializedQareplacedems);

			// Reinitialize 
			this.Initialize();

			// Show a message if there was a problem
			if (exceptions.Count > 0)
				MessageBox.Show(exceptions.Count + " error(s) occured while deserializing the QAT items.  The collection of exceptions in OnLoadStateButtonClick explains the problem.  This messagebox is for debugging-only purposes in this QuickStart.", "Loading Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
		}

19 View Source File : FolderRegPickerWindow.xaml.cs
License : MIT License
Project Creator : advancedmonitoring

private void ButtonOk_OnClick(object sender, RoutedEventArgs e)
        {
            var p = EdtPath.Text.Trim();
            if (_isFolderPicker)
            {
                if (Directory.Exists(p))
                {
                    PathName = p;
                    DialogResult = true;
                    Close();
                }
                else
                {
                    MessageBox.Show("Unable to open directory (not found or access denied).", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                if (GetKeyFromString(p) != null)
                {
                    PathName = p;
                    DialogResult = true;
                    Close();
                }
                else
                {
                    MessageBox.Show("Unable to open registry key (not found or access denied).", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnCollapseButtonClick(object sender, RoutedEventArgs e) {
			if (editor.ActiveView.Selection.IsZeroLength) {
				MessageBox.Show("Please select at least one character to collapse.", "No Selection", MessageBoxButton.OK, MessageBoxImage.Exclamation);
				return;
			}

			// Get the tagger that was created by the language and has been persisted in the doreplacedent's properties
			//   while the language is active on the doreplacedent
			CollapsedRegionTagger tagger = null;
			if (editor.Doreplacedent.Properties.TryGetValue(typeof(CollapsedRegionTagger), out tagger)) {
				// Create a version range
				ITextVersionRange versionRange = editor.ActiveView.Selection.SnapshotRange.ToVersionRange(TextRangeTrackingModes.DeleteWhenZeroLength);

				// Add the tag to the tagger
				tagger.Add(new TagVersionRange<ICollapsedRegionTag>(versionRange, new CollapsedRegionTag()));

				// Collapse the selection
				editor.ActiveView.Selection.Collapse();
			}

			// Focus the editor
			editor.Focus();
		}

19 View Source File : DataModelDesignModel.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

void VerifyAccessToken()
        {
            try
            {
                SelecTesreplacedem.RequestId = RandomOperate.Generate(8);
                GlobalContext.SetRequestContext(ZeroApplication.Config.ServiceKey, SelecTesreplacedem.RequestId);
                var client = new ApiClient
                {
                    Station = "Auth",
                    Commmand = "v1/verify/at",
                    Argument = JsonConvert.SerializeObject(new
                    {
                        Token = User.AccessToken
                    })
                };
                client.CallCommand();
                SelecTesreplacedem.GlobalId = client.GlobalId;
                var result = JsonConvert.DeserializeObject<ApiResult<LoginUserInfo>>(client.Result);
                if (!result.Success)
                {
                    MessageBox.Show(result.Status?.ClientMessage, "校验AT", MessageBoxButton.OK,
                        MessageBoxImage.Error);
                    return;
                }
                User.Customer = result.ResultData;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "校验AT", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }

19 View Source File : MainWindow.xaml.MachineTab.cs
License : MIT License
Project Creator : 3RD-Dimension

private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            Properties.Settings.Default.Save();

            if (machine.Connected)
            {
                MessageBox.Show("Can't close while connected!", "Please Disconnect", MessageBoxButton.OK,MessageBoxImage.Information);
                e.Cancel = true;
                return;
            }

            settingsWindow.Close();
            Application.Current.Shutdown();
        }

19 View Source File : DataModelDesignModel.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

string LoadDeviceId()
        {
            try
            {
                SelecTesreplacedem.RequestId = RandomOperate.Generate(8);
                GlobalContext.SetRequestContext(ZeroApplication.Config.ServiceKey, SelecTesreplacedem.RequestId);
                var client = new ApiClient
                {
                    Station = "UserCenter",
                    Commmand = "v1/refresh/did"
                };
                client.CallCommand();
                SelecTesreplacedem.GlobalId = client.GlobalId;
                var result = JsonConvert.DeserializeObject<ApiResult<string>>(client.Result);
                if (!result.Success)
                {
                    MessageBox.Show(result.Status?.ClientMessage, "获取DeviceId", MessageBoxButton.OK,
                        MessageBoxImage.Error);
                    return null;
                }

                return result.ResultData;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "获取DeviceId", MessageBoxButton.OK, MessageBoxImage.Error);
                return null;
            }
        }

19 View Source File : CustomCompletionProvider.cs
License : MIT License
Project Creator : Actipro

private void OnSessionCommitting(object sender, CancelEventArgs e) {
			var session = (ICompletionSession)sender;
			
			// If not cancelled and there is a selection...
			if ((!e.Cancel) && (session.Selection != null)) {
				// Get the selected item
				var item = session.Selection.Item;

				// If the dialog item was selected...
				if ("MsgBox".Equals(item.Tag)) {
					// Cancel the auto-complete
					e.Cancel = true;

					// Show a messagebox instead
					MessageBox.Show("Show a dialog for building a URL here.  Note that auto-complete was cancelled in code-behind.", "URL Builder", MessageBoxButton.OK, MessageBoxImage.Information);
				}
			}
		}

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnPopupButtonClick(object sender, RoutedEventArgs e) {
			// Ignore clicks on other buttons within the popup
			if (e.OriginalSource is PopupButton)
				MessageBox.Show("You clicked a PopupButton's button portion.", "PopupButton", MessageBoxButton.OK, MessageBoxImage.Information);
		}

19 View Source File : GrblSettingsWindow.xaml.cs
License : MIT License
Project Creator : 3RD-Dimension

private void ButtonGrblExport_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("This will export the currently displayed settings to a file - even any modified values that you have entered.  If you need to export the settings before modifications, please export before changing.  Continue To Export?", "Important", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
            { // YES - Export               
                SaveFileDialog exportFileName = new SaveFileDialog();
                exportFileName.Filter = "Text File (*.txt)|*.txt";
                exportFileName.replacedle = "Save exported GRBL Settings";
                exportFileName.FileName = "Exported_GRBL_Settings.txt";

                if (exportFileName.ShowDialog() == true)
                {
                    List<Tuple<int, double>> ToExport = new List<Tuple<int, double>>();
                    foreach (KeyValuePair<int, double> kvp in CurrentSettings)
                    {
                        ToExport.Add(new Tuple<int, double>(kvp.Key, kvp.Value));
                    }

                    using (StreamWriter sw = new StreamWriter(exportFileName.FileName))
                    {
                        sw.WriteLine("{0,-10} {1,-10} {2,-18} {3, -35}", "Setting", "Value", "Units", "Description");

                        foreach (Tuple<int, double> setting in ToExport)
                        // setting.Item1 = GRBL Code, setting.Item2 = Setting Value, Util.GrblCodeTranslator.Settings[setting.Item1].Item1 = Setting Description, Util.GrblCodeTranslator.Settings[setting.Item1].Item2 = Units
                        {
                            sw.WriteLine("{0,-10} {1,-10} {2,-18} {3, -35}", "$" + setting.Item1, setting.Item2.ToString(Util.Constants.DecimalOutputFormat), Util.GrblCodeTranslator.Settings[setting.Item1].Item2, Util.GrblCodeTranslator.Settings[setting.Item1].Item1);
                        }
                        MessageBox.Show("Settings Exported to " + exportFileName.FileName, "Exported GRBL Settings", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
            }
            else
            { // NO
                return;
            }
        }

19 View Source File : MainWindow.xaml.cs
License : MIT License
Project Creator : ab4d

private void InitializeOvrAndDirectX()
        {
            if (UseOculusRift)
            {
                // Initializing Oculus VR is very simple when using OculusWrapVirtualRealityProvider
                // First we create an instance of OculusWrapVirtualRealityProvider
                _oculusRiftVirtualRealityProvider = new OculusWrapVirtualRealityProvider(_ovr,  multisamplingCount: 4);

                try
                {
                    // Then we initialize Oculus OVR and create a new DXDevice that uses the same adapter (graphic card) as Oculus Rift
                    _dxDevice = _oculusRiftVirtualRealityProvider.InitializeOvrAndDXDevice(requestedOculusSdkMinorVersion: 17);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed to initialize the Oculus runtime library.\r\nError: " + ex.Message, "Oculus error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                string ovrVersionString = _ovr.GetVersionString();
                _originalWindowreplacedle = string.Format("DXEngine OculusWrap Sample (OVR v{0})", ovrVersionString);
                this.replacedle = _originalWindowreplacedle;


                // Reset tracking origin at startup
                _ovr.RecenterTrackingOrigin(_oculusRiftVirtualRealityProvider.SessionPtr);
            }
            else
            {
                // Create DXDevice that will be used to create DXViewportView
                var dxDeviceConfiguration = new DXDeviceConfiguration();
                dxDeviceConfiguration.DriverType = DriverType.Hardware;
                dxDeviceConfiguration.SupportedFeatureLevels = new FeatureLevel[] { FeatureLevel.Level_11_0 }; // Oculus requires at least feature level 11.0

                _dxDevice = new DXDevice(dxDeviceConfiguration);
                _dxDevice.InitializeDevice();

                _originalWindowreplacedle = this.replacedle;
            }



            // Create WPF's Viewport3D
            _viewport3D = new Viewport3D();

            // Create DXViewportView - a control that will enable DirectX 11 rendering of standard WPF 3D content defined in Viewport3D.
            // We use a specified DXDevice that was created by the _oculusRiftVirtualRealityProvider.InitializeOvrAndDXDevice (this way the same adapter is used by Oculus and DXEngine).
            _dxViewportView = new DXViewportView(_dxDevice, _viewport3D);
            
            _dxViewportView.BackgroundColor = Colors.Aqua;

            // Currently DXEngine support showing Oculus mirror texture only with DirectXOverlay presentation type (not with DirectXImage)
            _dxViewportView.PresentationType = DXView.PresentationTypes.DirectXOverlay;

            if (UseOculusRift)
            {
                // The _dxViewportView will show Oculus mirrow window.
                // The mirror window can be any size, for this sample we use 1/2 the HMD resolution.
                _dxViewportView.Width = _oculusRiftVirtualRealityProvider.HmdDescription.Resolution.Width / 2.0;
                _dxViewportView.Height = _oculusRiftVirtualRealityProvider.HmdDescription.Resolution.Height / 2.0;
            }


            // When the DXViewportView is initialized, we set the _oculusRiftVirtualRealityProvider to the DXScene object
            _dxViewportView.DXSceneInitialized += delegate (object sender, EventArgs args)
            {
                if (_dxViewportView.UsedGraphicsProfile.DriverType != GraphicsProfile.DriverTypes.Wpf3D &&
                    _dxViewportView.DXScene != null &&
                    _oculusRiftVirtualRealityProvider != null)
                {
                    // Initialize Virtual reality rendering
                    _dxViewportView.DXScene.InitializeVirtualRealityRendering(_oculusRiftVirtualRealityProvider);


                    // Initialized shadow rendering (see Ab3d.DXEngine.Wpf.Samples project - DXEngine/ShadowRenderingSample for more info
                    _varianceShadowRenderingProvider = new VarianceShadowRenderingProvider()
                    {
                        ShadowMapSize = 1024,
                        ShadowDepthBluringSize = 2,
                        ShadowThreshold = 0.2f
                    };

                    _dxViewportView.DXScene.InitializeShadowRendering(_varianceShadowRenderingProvider);
                }
            };


            // Enable collecting rendering statistics (see _dxViewportView.DXScene.Statistics clreplaced)
            DXDiagnostics.IsCollectingStatistics = true;

            // Subscribe to SceneRendered to collect FPS statistics
            _dxViewportView.SceneRendered += DXViewportViewOnSceneRendered;

            // Add _dxViewportView to the RootGrid
            // Before that we resize the window to be big enough to show the mirrored texture
            this.Width = _dxViewportView.Width + 30;
            this.Height = _dxViewportView.Height + 50;

            RootGrid.Children.Add(_dxViewportView);


            // Create FirstPersonCamera
            _camera = new FirstPersonCamera()
            {
                TargetViewport3D = _viewport3D,
                Position = new Point3D(0, 1, 4),
                Heading = 0,
                Atreplacedude = 0,
                ShowCameraLight = ShowCameraLightType.Never
            };

            RootGrid.Children.Add(_camera);


            // Initialize XBOX controller that will control the FirstPersonCamera
            _xInputCameraController = new XInputCameraController()
            {
                TargetCamera = _camera,
                RotationSpeed = 120,                          // rotation: 120 degrees per second
                MovementSpeed = 2,                            // movement: 2 meters per second
                RotateOnlyHorizontally = true,                // do not rotate up and down (changing atreplacedude) with controller - this is done only HMD
                MoveVerticallyWithDPadButtons = true,
            };

            _xInputCameraController.StartCheckingController();


            // Now we can create our sample 3D scene
            CreateSceneObjects();

            // Add lights
            var lightsVisual3D = new ModelVisual3D();
            var lightsGroup = new Model3DGroup();

            var directionalLight = new DirectionalLight(Colors.White, new Vector3D(0.5, -0.3, -0.3));
            directionalLight.SetDXAttribute(DXAttributeType.IsCastingShadow, true); // Set this light to cast shadow
            lightsGroup.Children.Add(directionalLight);

            var ambientLight = new AmbientLight(System.Windows.Media.Color.FromRgb(30, 30, 30));
            lightsGroup.Children.Add(ambientLight);

            lightsVisual3D.Content = lightsGroup;
            _viewport3D.Children.Add(lightsVisual3D);


            // Start rendering
            if (RenderAt90Fps)
            {
                // WPF do not support rendering at more the 60 FPS.
                // But with a trick where a rendering loop is created in a background thread, it is possible to achieve more than 60 FPS.
                // In case of submitting frames to Oculus Rift at higher FPS, the ovr.SubmitFrame method will limit rendering to 90 FPS.
                // 
                // NOTE:
                // When using DXEngine, it is also possible to render the scene in a background thread. 
                // This requires that the 3D scene is also created in the background thread and that the events and other messages are 
                // preplaceded between UI and background thread in a thread safe way. This is too complicated for this simple sample project.
                // To see one possible implementation of background rendering, see the BackgroundRenderingSample in the Ab3d.DXEngine.Wpf.Samples project.
                var backgroundWorker = new BackgroundWorker();
                backgroundWorker.DoWork += (object sender, DoWorkEventArgs args) =>
                {
                    // Create an action that will be called by Dispatcher
                    var refreshDXEngineAction = new Action(() =>
                    {
                        UpdateScene();

                        // Render DXEngine's 3D scene again
                        if (_dxViewportView != null)
                            _dxViewportView.Refresh();
                    });

                    while (_dxViewportView != null && !_dxViewportView.IsDisposed) // Render until window is closed
                    {
                        if (_oculusRiftVirtualRealityProvider != null && _oculusRiftVirtualRealityProvider.LastSessionStatus.ShouldQuit) // Stop rendering - this will call RunWorkerCompleted where we can quit the application
                            break;

                        // Sleep for 1 ms to allow WPF tasks to complete (for example handling XBOX controller events)
                        System.Threading.Thread.Sleep(1);

                        // Call Refresh to render the DXEngine's scene
                        // This is a synchronous call and will wait until the scene is rendered. 
                        // Because Oculus is limited to 90 fps, the call to ovr.SubmitFrame will limit rendering to 90 FPS.
                        Dispatcher.Invoke(refreshDXEngineAction); 
                    }
                };

                backgroundWorker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs args)
                {
                    if (_oculusRiftVirtualRealityProvider != null && _oculusRiftVirtualRealityProvider.LastSessionStatus.ShouldQuit)
                        this.Close(); // Exit the application
                };

                backgroundWorker.RunWorkerAsync();
            }
            else
            {
                // Subscribe to WPF rendering event (called approximately 60 times per second)
                CompositionTarget.Rendering += CompositionTargetOnRendering;
            }
        }

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnPropertyGridValidationError(object sender, ValidationErrorEventArgs e) {
			switch (e.Action) {
				case ValidationErrorEventAction.Added:
					errorListBox.Items.Add(e.Error);

					// As a demonstration, show a dialog with the error message for property 'ErrorReporting3'
					var container = VisualTreeHelperExtended.GetAncestor<PropertyGridItem>(e.OriginalSource as DependencyObject);
					if (container != null) {
						var propertyModel = container.Content as IPropertyModel;
						if ((propertyModel != null) && (propertyModel.Name == "ErrorReporting3"))
							MessageBox.Show(Convert.ToString(e.Error.ErrorContent, CultureInfo.CurrentCulture), "Data Validation", MessageBoxButton.OK, MessageBoxImage.Error);
					}
					break;
				case ValidationErrorEventAction.Removed:
					errorListBox.Items.Add(e.Error);
					break;
			}

		}

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnPropertyGridChildPropertyRemoving(object sender, PropertyModelChildChangeEventArgs e) {
			var parent = e.ParentPropertyModel.Target as Person;
			var child = e.ChildPropertyModel.Value as Person;
			var message = string.Format("Removing child {0}, {1} from parent {2}, {3}", child.LastName, child.FirstName, parent.LastName, parent.FirstName);
			this.AppendMessage(message);

			var result = MessageBox.Show(string.Format("Are you sure you want to remove {0}, {1}?", child.LastName, child.FirstName),
				"Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question);
			e.Cancel = (MessageBoxResult.No == result);
			e.Handled = true;
		}

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnBindCustomAction(object sender, RoutedEventArgs e) {
			// Unbind
			this.UnbindCustomEditAction();

			// Add a command binding to action
			var command = new CustomAction();
			customCommandBinding = command.CreateCommandBinding();
			editor.CommandBindings.Insert(0, customCommandBinding);

			// Bind to Ctrl+P
			customInputBinding = new KeyBinding(command, Key.P, ModifierKeys.Control);
			editor.InputBindings.Add(customInputBinding);

			// Notify user
			MessageBox.Show("Bound Ctrl+P to custom edit action.", "Result", MessageBoxButton.OK, MessageBoxImage.Information);
			editor.Focus();
		}

See More Examples