private void btnEdit_Click(object sender, RoutedEventArgs e) { try { Review review = (Review)ReviewGrid.SelectedItem; if (review != null) { ReviewEditor = new ReviewEditor(_reviewRepo) { Owner = Window.GetWindow(this) }; ReviewEditor.SetReview(review); ReviewEditor.ShowDialog(); RefreshReviewList(); } else { MessageBox.Show("No current row to Edit", Utils.AssemblyTitle); } } catch (Exception ex) { Utils.HandleException(ex); } }
private void OnStartupComplete() { CreateOutputWindow(); CreateStatusBarIcon(); solutionEvents = events.SolutionEvents; buildEvents = events.BuildEvents; windowEvents = events.WindowEvents; solutionEvents.Opened += OnSolutionOpened; solutionEvents.AfterClosing += OnSolutionClosed; buildEvents.OnBuildBegin += OnBuildBegin; buildEvents.OnBuildDone += OnBuildDone; debugService = (IVsDebugger)GetGlobalService(typeof(SVsShellDebugger)); debugService.AdviseDebuggerEvents(this, out debugCookie); var componentModel = (IComponentModel)GetGlobalService(typeof(SComponentModel)); operationState = componentModel.GetService <IOperationState>(); operationState.StateChanged += OperationStateOnStateChanged; application = Application.Current; application.Activated += OnApplicationActivated; application.Deactivated += OnApplicationDeactivated; windowEvents.WindowActivated += OnWindowActivated; SystemEvents.SessionSwitch += OnSessionSwitch; SystemEvents.PowerModeChanged += OnPowerModeChanged; VSColorTheme.ThemeChanged += OnThemeChanged; chart.Loaded += (s, a) => { Window window = Window.GetWindow(chart); new Lid(window).StatusChanged += OnLidStatusChanged; }; ListenToScreenSaver(); sm = new VSStateMachine(); if (application.Windows.OfType <Window>() .All(w => !w.IsActive)) { sm.On(VSStateMachine.Events.LostFocus); } if (dte.Solution.Count > 0) { sm.On(VSStateMachine.Events.SolutionOpened); } sm.StateChanged += s => Output("Current state: {0}", s.ToString()); Output("Startup complete"); Output("Current state: {0}", sm.CurrentState.ToString()); }
private void New_Click(object sender, RoutedEventArgs e) { var createModDialog = new CreateModDialog(ViewModel.ModConfigService); createModDialog.Owner = Window.GetWindow(this); createModDialog.ShowDialog(); }
private void btnAdd_Click(object sender, RoutedEventArgs e) { try { if (VSIDEHelper.VisualStudioInstance.Solution.IsOpen) { if (VSIDEHelper.VisualStudioInstance.ActiveDocument != null) { ReviewEditor = new ReviewEditor(_reviewRepo) { Owner = Window.GetWindow(this) }; ReviewEditor.SetReview(null); ReviewEditor.ShowDialog(); RefreshReviewList(); } else { MessageBox.Show(NoFileOpen); } } else { MessageBox.Show(SolutionNotOpen); } } catch (Exception ex) { Utils.HandleException(ex); } }
private void OnLoaded(object sender, RoutedEventArgs e) { _owner = Window.GetWindow(this); _owner !.KeyDown += TrySwitchPage; ControllerSupport.SubscribeCustomInputs(ProcessCustomInputs); this.Loaded -= OnLoaded; }
private void Tutorial_Click(object sender, System.Windows.RoutedEventArgs e) { var firstLaunchWindow = new FirstLaunch(); firstLaunchWindow.Owner = Window.GetWindow(this); firstLaunchWindow.ShowDialog(); }
private static bool EditModDialog(EditModDialogViewModel viewmodel, object?owner) { var createModDialog = new EditModDialog(viewmodel); if (owner != null) { createModDialog.Owner = Window.GetWindow((DependencyObject)owner); } return(ShowDialogAndGetResult(createModDialog)); }
private void Close() { if (!(this is DependencyObject dependencyObject)) { return; } if (Window.GetWindow(dependencyObject) is Window window) { window.Close(); } }
private static IGraphicsContext GetOrCreateSharedOpenGLContext(GLWpfControlSettings settings) { if (_sharedContext != null) { var isSameContext = GLWpfControlSettings.WouldResultInSameContext(settings, _sharedContextSettings); if (!isSameContext) { throw new ArgumentException($"The provided {nameof(GLWpfControlSettings)} would result" + $"in a different context creation to one previously created. To fix this," + $" either ensure all of your context settings are identical, or provide an " + $"external context via the '{nameof(GLWpfControlSettings.ContextToUse)}' field."); } } else { var nws = NativeWindowSettings.Default; nws.StartFocused = false; nws.StartVisible = false; nws.NumberOfSamples = 0; // if we ask GLFW for 1.0, we should get the highest level context available with full compat. nws.APIVersion = new Version(settings.MajorVersion, settings.MinorVersion); nws.Flags = ContextFlags.Offscreen | settings.GraphicsContextFlags; // we have to ask for any compat in this case. nws.Profile = settings.GraphicsProfile; nws.WindowBorder = WindowBorder.Hidden; nws.WindowState = WindowState.Minimized; var glfwWindow = new NativeWindow(nws); var provider = new GLFWBindingsContext(); Wgl.LoadBindings(provider); // we're already in a window context, so we can just cheat by creating a new dependency object here rather than passing any around. var depObject = new DependencyObject(); // retrieve window handle/info var window = Window.GetWindow(depObject); var baseHandle = window is null ? IntPtr.Zero : new WindowInteropHelper(window).Handle; var hwndSource = new HwndSource(0, 0, 0, 0, 0, "GLWpfControl", baseHandle); _sharedContext = glfwWindow.Context; _sharedContextSettings = settings; _sharedContextResources = new IDisposable[] { hwndSource, glfwWindow }; // GL init // var mode = new GraphicsMode(ColorFormat.Empty, 0, 0, 0, 0, 0, false); // _commonContext = new GraphicsContext(mode, _windowInfo, _settings.MajorVersion, _settings.MinorVersion, // _settings.GraphicsContextFlags); // _commonContext.LoadAll(); _sharedContext.MakeCurrent(); } Interlocked.Increment(ref _sharedContextReferenceCount); return(_sharedContext); }
private void DisplayFirstLaunchWarningIfNeeded() { var loaderConfig = Lib.IoC.Get <LoaderConfig>(); if (loaderConfig.FirstLaunch) { IConfig <LoaderConfig> .ToPath(loaderConfig, Paths.LoaderConfigPath); var firstLaunchWindow = new FirstLaunch(); firstLaunchWindow.Owner = Window.GetWindow(this); firstLaunchWindow.ShowDialog(); loaderConfig.FirstLaunch = false; } }
public async Task Save() { var createdMod = await RealViewModel.CreateMod(ShowNonUniqueWindow); if (createdMod == null) { return; } var modConfigService = Lib.IoC.Get <ModConfigService>(); var mod = await ActionWrappers.TryGetValueAsync(() => modConfigService.ItemsById[createdMod.Config.ModId], 5000, 32); if (mod != null) { var createModDialog = new EditModDialog(new EditModDialogViewModel(mod, Lib.IoC.Get <ApplicationConfigService>(), modConfigService)); createModDialog.Owner = Window.GetWindow(this); createModDialog.ShowDialog(); } this.Close(); }
public MessageBoxView() { InitializeComponent(); MessageBoxViewModel vm = (MessageBoxViewModel)DataContext; vm.PropertyChanged += (_, args) => { if (args.PropertyName == nameof(vm.Message)) { InlineExpression.SetInlineExpression(MessageBlock, vm.Message); } }; Loaded += (_, _) => { // Window Setup _window = Window.GetWindow(this); Debug.Assert(_window != null, nameof(_window) + " != null"); _window.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)); (double dpiWidthFactor, double dpiHeightFactor) = WindowHelpers.GetDpiFactors(_window); Rect screen = vm.openOnScreen?.WorkingArea ?? _window.CurrentScreen().WorkingArea; _window.CenterOnScreen(screen, dpiWidthFactor, dpiHeightFactor); //Set the window style to noactivate. if (!vm.getsFocus) { var helper = new WindowInteropHelper(_window); SetWindowLong(helper.Handle, GWL_EXSTYLE, GetWindowLong(helper.Handle, GWL_EXSTYLE) | WS_EX_NOACTIVATE); } }; MouseDown += (_, e) => { if (e.ChangedButton == MouseButton.Left) { _window.DragMove(); } }; }
/// <summary> /// Handles the Click event of the btnSummary control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void btnSummary_Click(object sender, RoutedEventArgs e) { try { if (VSIDEHelper.VisualStudioInstance.Solution.IsOpen) { Summary = new Summary() { Owner = Window.GetWindow(this) }; Summary.SetSummary(_reviewRepo.CodeReview); Summary.ShowDialog(); } else { MessageBox.Show(SolutionNotOpen); } } catch (Exception ex) { Utils.HandleException(ex); } }