public LeadOpportunitySaveHandler(IRecordContext RecordContext,System.ComponentModel.CancelEventArgs e) { _recordContext = RecordContext; _leadOpportunityRecord = _recordContext.GetWorkspaceRecord(_recordContext.WorkspaceTypeName) as ICustomObject; cancelSaveOperation = e; logger = OSCLogService.GetLog(); }
public void Run() { if (threads == null) { throw new InvalidOperationException("threads is null"); } System.ComponentModel.CancelEventArgs e = new System.ComponentModel.CancelEventArgs(); OnRunning(e); if (e.Cancel) { OnRan(); return; } IEnumerable<Thread> updateThreads; lock (Common.PatrolSyncRoot) { updateThreads = threads.Where(thread => updateable(thread)); } Thread[] copyUpdateThreads = updateThreads.ToArray(); foreach (Thread thread in copyUpdateThreads) { try { thread.Update(); } catch (System.Net.WebException ex) { Common.Logs.Add("通信エラー", ex.Message, LogStatus.Error); continue; } } OnRan(); }
// TODO : Remove below line //public WorkOrderSaveHandler() public WorkOrderSaveHandler(IRecordContext RecordContext, System.ComponentModel.CancelEventArgs e) { _recordContext = RecordContext; _cancelEventArgs = e; _workOrderRecord = _recordContext.GetWorkspaceRecord(_recordContext.WorkspaceTypeName) as ICustomObject; _log = ToaLogService.GetLog(); }
private void _edDivideBy_Validating(object sender, ValidationEventArgs<string> e) { var c = new System.ComponentModel.CancelEventArgs(); if (null != DivideByValidating) DivideByValidating(_edDivideBy.Text, c); if (c.Cancel) e.AddError("The provided text can not be converted"); }
public void Run() { System.ComponentModel.CancelEventArgs e = new System.ComponentModel.CancelEventArgs(); OnRunning(e); if (e.Cancel) { OnRan(); return; } IEnumerable<Thread> downloadThreads = threads.Where(thread => downloadable(thread)); Thread[] copyDownloadThreads = downloadThreads.ToArray(); try { Parallel.ForEach(copyDownloadThreads, thread => { try { thread.Run(); } catch (InvalidOperationException ex) { Common.Logs.Add("ダウンロード中断", thread.Title + ": " + ex.Message, LogStatus.Error); } }); } catch (AggregateException ex) { ex.Handle((innerException) => { if (innerException is System.IO.IOException) { Common.Logs.Add("保存エラー", innerException.Message, LogStatus.Error); return true; } return false; }); } OnRan(); }
/// <summary> /// /// </summary> /// <param name="grid"></param> /// <returns></returns> public static bool CheckControlValue(this IArchiveGrid grid) { bool ret = true; System.ComponentModel.CancelEventArgs e = new System.ComponentModel.CancelEventArgs(); if (grid.ArchiveGridHelper.InsertionRow != null && grid.ArchiveGridHelper.InsertionRow.IsBeingEdited) { ret &= grid.ArchiveGridHelper.DoValidateRow(grid.ArchiveGridHelper.InsertionRow, e); if (!ret) { return false; } } foreach (Xceed.Grid.DataRow row in grid.DataRows) { ret &= grid.ArchiveGridHelper.DoValidateRow(row, e); if (!ret) { return false; } } return true; }
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo) { if (null != _parent.TextValidating) { System.ComponentModel.CancelEventArgs cea = new System.ComponentModel.CancelEventArgs(); _parent.TextValidating((string)value, cea); if (cea.Cancel) return new ValidationResult(false, "The entered text is not valid"); } return ValidationResult.ValidResult; }
private void window_incorrect_Closing(object sender, System.ComponentModel.CancelEventArgs e) { game.Show(); }
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { // SettingsSaving 이벤트를 처리하는 코드를 여기에 추가하십시오. }
IntPtr WindowProcedure(IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lParam) { switch (message) { #region Size / Move / Style events case WindowMessage.ACTIVATE: // See http://msdn.microsoft.com/en-us/library/ms646274(VS.85).aspx (WM_ACTIVATE notification): // wParam: The low-order word specifies whether the window is being activated or deactivated. bool new_focused_state = Focused; if (IntPtr.Size == 4) focused = (wParam.ToInt32() & 0xFFFF) != 0; else focused = (wParam.ToInt64() & 0xFFFF) != 0; if (new_focused_state != Focused) FocusedChanged(this, EventArgs.Empty); break; case WindowMessage.ENTERMENULOOP: case WindowMessage.ENTERSIZEMOVE: // Entering the modal size/move loop: we don't want rendering to // stop during this time, so we register a timer callback to continue // processing from time to time. StartTimer(handle); break; case WindowMessage.EXITMENULOOP: case WindowMessage.EXITSIZEMOVE: // ExitingmModal size/move loop: the timer callback is no longer // necessary. StopTimer(handle); break; case WindowMessage.ERASEBKGND: return new IntPtr(1); case WindowMessage.WINDOWPOSCHANGED: unsafe { WindowPosition* pos = (WindowPosition*)lParam; if (window != null && pos->hwnd == window.WindowHandle) { Point new_location = new Point(pos->x, pos->y); if (Location != new_location) { bounds.Location = new_location; Move(this, EventArgs.Empty); } Size new_size = new Size(pos->cx, pos->cy); if (Size != new_size) { bounds.Width = pos->cx; bounds.Height = pos->cy; Win32Rectangle rect; Functions.GetClientRect(handle, out rect); client_rectangle = rect.ToRectangle(); Functions.SetWindowPos(child_window.WindowHandle, IntPtr.Zero, 0, 0, ClientRectangle.Width, ClientRectangle.Height, SetWindowPosFlags.NOZORDER | SetWindowPosFlags.NOOWNERZORDER | SetWindowPosFlags.NOACTIVATE | SetWindowPosFlags.NOSENDCHANGING); if (suppress_resize <= 0) Resize(this, EventArgs.Empty); } } } break; case WindowMessage.STYLECHANGED: unsafe { if (wParam.ToInt64() == (long)GWL.STYLE) { WindowStyle style = ((StyleStruct*)lParam)->New; if ((style & WindowStyle.Popup) != 0) windowBorder = WindowBorder.Hidden; else if ((style & WindowStyle.ThickFrame) != 0) windowBorder = WindowBorder.Resizable; else if ((style & ~(WindowStyle.ThickFrame | WindowStyle.MaximizeBox)) != 0) windowBorder = WindowBorder.Fixed; } } break; case WindowMessage.SIZE: SizeMessage state = (SizeMessage)wParam.ToInt64(); WindowState new_state = windowState; switch (state) { case SizeMessage.RESTORED: new_state = borderless_maximized_window_state ? WindowState.Maximized : WindowState.Normal; break; case SizeMessage.MINIMIZED: new_state = WindowState.Minimized; break; case SizeMessage.MAXIMIZED: new_state = WindowBorder == WindowBorder.Hidden ? WindowState.Fullscreen : WindowState.Maximized; break; } if (new_state != windowState) { windowState = new_state; WindowStateChanged(this, EventArgs.Empty); } break; #endregion #region Input events case WindowMessage.CHAR: if (IntPtr.Size == 4) key_press.KeyChar = (char)wParam.ToInt32(); else key_press.KeyChar = (char)wParam.ToInt64(); KeyPress(this, key_press); break; case WindowMessage.MOUSEMOVE: Point point = new Point( (short)((uint)lParam.ToInt32() & 0x0000FFFF), (short)(((uint)lParam.ToInt32() & 0xFFFF0000) >> 16)); mouse.Position = point; if (!CursorVisible) HideCursor(); if (mouse_outside_window) { // Once we receive a mouse move event, it means that the mouse has // re-entered the window. mouse_outside_window = false; EnableMouseTracking(); MouseEnter(this, EventArgs.Empty); } break; case WindowMessage.MOUSELEAVE: mouse_outside_window = true; // Mouse tracking is disabled automatically by the OS if (!CursorVisible) ShowCursor(); MouseLeave(this, EventArgs.Empty); break; case WindowMessage.MOUSEWHEEL: // This is due to inconsistent behavior of the WParam value on 64bit arch, whese // wparam = 0xffffffffff880000 or wparam = 0x00000000ff100000 mouse.WheelPrecise += ((long)wParam << 32 >> 48) / 120.0f; break; case WindowMessage.LBUTTONDOWN: Functions.SetCapture(window.WindowHandle); mouse[MouseButton.Left] = true; break; case WindowMessage.MBUTTONDOWN: Functions.SetCapture(window.WindowHandle); mouse[MouseButton.Middle] = true; break; case WindowMessage.RBUTTONDOWN: Functions.SetCapture(window.WindowHandle); mouse[MouseButton.Right] = true; break; case WindowMessage.XBUTTONDOWN: Functions.SetCapture(window.WindowHandle); mouse[((wParam.ToInt32() & 0xFFFF0000) >> 16) != (int)MouseKeys.XButton1 ? MouseButton.Button1 : MouseButton.Button2] = true; break; case WindowMessage.LBUTTONUP: Functions.ReleaseCapture(); mouse[MouseButton.Left] = false; break; case WindowMessage.MBUTTONUP: Functions.ReleaseCapture(); mouse[MouseButton.Middle] = false; break; case WindowMessage.RBUTTONUP: Functions.ReleaseCapture(); mouse[MouseButton.Right] = false; break; case WindowMessage.XBUTTONUP: Functions.ReleaseCapture(); mouse[((wParam.ToInt32() & 0xFFFF0000) >> 16) != (int)MouseKeys.XButton1 ? MouseButton.Button1 : MouseButton.Button2] = false; break; // Keyboard events: case WindowMessage.KEYDOWN: case WindowMessage.KEYUP: case WindowMessage.SYSKEYDOWN: case WindowMessage.SYSKEYUP: bool pressed = message == WindowMessage.KEYDOWN || message == WindowMessage.SYSKEYDOWN; // Shift/Control/Alt behave strangely when e.g. ShiftRight is held down and ShiftLeft is pressed // and released. It looks like neither key is released in this case, or that the wrong key is // released in the case of Control and Alt. // To combat this, we are going to release both keys when either is released. Hacky, but should work. // Win95 does not distinguish left/right key constants (GetAsyncKeyState returns 0). // In this case, both keys will be reported as pressed. bool extended = (lParam.ToInt64() & ExtendedBit) != 0; switch ((VirtualKeys)wParam) { case VirtualKeys.SHIFT: // The behavior of this key is very strange. Unlike Control and Alt, there is no extended bit // to distinguish between left and right keys. Moreover, pressing both keys and releasing one // may result in both keys being held down (but not always). // The only reliable way to solve this was reported by BlueMonkMN at the forums: we should // check the scancodes. It looks like GLFW does the same thing, so it should be reliable. // Note: we release both keys when either shift is released. // Otherwise, the state of one key might be stuck to pressed. if (ShiftRightScanCode != 0 && pressed) { unchecked { if (((lParam.ToInt64() >> 16) & 0xFF) == ShiftRightScanCode) keyboard[Input.Key.ShiftRight] = pressed; else keyboard[Input.Key.ShiftLeft] = pressed; } } else { // Windows 9x and NT4.0 or key release event. keyboard[Input.Key.ShiftLeft] = keyboard[Input.Key.ShiftRight] = pressed; } return IntPtr.Zero; case VirtualKeys.CONTROL: if (extended) keyboard[Input.Key.ControlRight] = pressed; else keyboard[Input.Key.ControlLeft] = pressed; return IntPtr.Zero; case VirtualKeys.MENU: if (extended) keyboard[Input.Key.AltRight] = pressed; else keyboard[Input.Key.AltLeft] = pressed; return IntPtr.Zero; case VirtualKeys.RETURN: if (extended) keyboard[Key.KeypadEnter] = pressed; else keyboard[Key.Enter] = pressed; return IntPtr.Zero; default: if (!KeyMap.ContainsKey((VirtualKeys)wParam)) { Debug.Print("Virtual key {0} ({1}) not mapped.", (VirtualKeys)wParam, (long)lParam); break; } else { keyboard[KeyMap[(VirtualKeys)wParam]] = pressed; } return IntPtr.Zero; } break; case WindowMessage.SYSCHAR: return IntPtr.Zero; case WindowMessage.KILLFOCUS: keyboard.ClearKeys(); break; #endregion #region Creation / Destruction events case WindowMessage.CREATE: CreateStruct cs = (CreateStruct)Marshal.PtrToStructure(lParam, typeof(CreateStruct)); if (cs.hwndParent == IntPtr.Zero) { bounds.X = cs.x; bounds.Y = cs.y; bounds.Width = cs.cx; bounds.Height = cs.cy; Win32Rectangle rect; Functions.GetClientRect(handle, out rect); client_rectangle = rect.ToRectangle(); invisible_since_creation = true; } break; case WindowMessage.CLOSE: System.ComponentModel.CancelEventArgs e = new System.ComponentModel.CancelEventArgs(); Closing(this, e); if (!e.Cancel) { DestroyWindow(); break; } return IntPtr.Zero; case WindowMessage.DESTROY: exists = false; Functions.UnregisterClass(ClassName, Instance); window.Dispose(); child_window.Dispose(); Closed(this, EventArgs.Empty); break; #endregion } return Functions.DefWindowProc(handle, message, wParam, lParam); }
async Task DoSave(IEntity entity, SaveBehaviour behaviour) { var mode = entity.IsNew ? SaveMode.Insert : SaveMode.Update; var asEntity = entity as Entity; if (mode == SaveMode.Update && (asEntity._ClonedFrom?.IsStale == true) && AnyOpenTransaction()) { throw new InvalidOperationException("This " + entity.GetType().Name + " instance in memory is out-of-date. " + "A clone of it is already updated in the transaction. It is not allowed to update the same instance multiple times in a transaction, because then the earlier updates would be overwriten by the older state of the instance in memory. \r\n\r\n" + @"BAD: Database.Update(myObject, x=> x.P1 = ...); // Note: this could also be nested inside another method that's called here instead. Database.Update(myObject, x=> x.P2 = ...); GOOD: Database.Update(myObject, x=> x.P1 = ...); myObject = Database.Reload(myObject); Database.Update(myObject, x=> x.P2 = ...);"); } if (Entity.Services.IsImmutable(entity)) { throw new ArgumentException("An immutable record must be cloned before any modifications can be applied on it. " + $"Type={entity.GetType().FullName}, Id={entity.GetId()}."); } var dataProvider = GetProvider(entity); if (!IsSet(behaviour, SaveBehaviour.BypassValidation)) { await Entity.Services.RaiseOnValidating(entity as Entity, EventArgs.Empty); await entity.Validate(); } else if (!dataProvider.SupportValidationBypassing()) { throw new ArgumentException(dataProvider.GetType().Name + " does not support bypassing validation."); } #region Raise saving event if (!IsSet(behaviour, SaveBehaviour.BypassSaving)) { var savingArgs = new System.ComponentModel.CancelEventArgs(); await Entity.Services.RaiseOnSaving(entity, savingArgs); if (savingArgs.Cancel) { Cache.Remove(entity); return; } } #endregion if (!IsSet(behaviour, SaveBehaviour.BypassLogging)) { if (mode == SaveMode.Insert) { await Audit.LogInsert(entity); } else { await Audit.LogUpdate(entity); } } await dataProvider.Save(entity); Cache.UpdateRowVersion(entity); if (mode == SaveMode.Update && asEntity?._ClonedFrom != null && AnyOpenTransaction()) { asEntity._ClonedFrom.IsStale = true; asEntity.IsStale = false; } if (mode == SaveMode.Insert) { Entity.Services.SetSaved(entity); } Cache.Remove(entity); if (Transaction.Current != null) { Transaction.Current.TransactionCompleted += (s, e) => { Cache.Remove(entity); } } ; DbTransactionScope.Root?.OnTransactionCompleted(() => Cache.Remove(entity)); await Updated.Raise(entity); if (!IsSet(behaviour, SaveBehaviour.BypassSaved)) { await Entity.Services.RaiseOnSaved(entity, new SaveEventArgs(mode)); } // OnSaved event handler might have read the object again and put it in the cache, which would // create invalid CachedReference objects. Cache.Remove(entity); }
/// <summary> /// Closes a project. If the project is dirty, the user is asked for saving the project. /// </summary> public void CloseProject() { if (CurrentOpenProject != null) { System.ComponentModel.CancelEventArgs e = new System.ComponentModel.CancelEventArgs(); if (this.CurrentOpenProject.IsDirty) AskForSavingOfProject(e); if (e.Cancel == false) { //if (saveCombinePreferencies) // SaveCombinePreferences(CurrentOpenCombine, openCombineFileName); Altaxo.AltaxoDocument closedProject = CurrentOpenProject; //CurrentSelectedProject = null; //CurrentOpenCombine = CurrentSelectedCombine = null; openProjectFileName = null; WorkbenchSingleton.Workbench.CloseAllViews(); OnProjectClosed(new ProjectEventArgs(closedProject)); //closedProject.Dispose(); // now create a new project CurrentOpenProject = new Altaxo.AltaxoDocument(); OnProjectOpened(new ProjectEventArgs(CurrentOpenProject)); } } }
public static void ShowDialogToVerifyOpeningOfDocumentsWithoutException() { if (Current.Project.IsDirty) { var e = new System.ComponentModel.CancelEventArgs(); Current.ProjectService.AskForSavingOfProject(e); if (e.Cancel) return; } var testOptions = new TestAllProjectsInFolderOptions(); if (!Current.Gui.ShowDialog(ref testOptions, "Test Altaxo project files on your disk", false)) return; var monitor = new Altaxo.Main.Services.ExternalDrivenBackgroundMonitor(); Current.Gui.ShowBackgroundCancelDialog(10, monitor, () => InternalVerifyOpeningOfDocumentsWithoutExceptionStart(testOptions, monitor)); }
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e) { store.Add("navigatedBack", "true"); }
/// <summary> /// Hides only the dialog when user closes it /// </summary> private void DialogClosing(Object sender, System.ComponentModel.CancelEventArgs e) { e.Cancel = true; Globals.CurrentDocument.Activate(); this.Hide(); }
private void MainWindow1_Closing(object sender, System.ComponentModel.CancelEventArgs e) { MyService.StopService(); }
private void UI_Closing(object sender, System.ComponentModel.CancelEventArgs e) { IsClosing = true; }
private void ReactiveWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { propertiesWindow?.Close(); ((this.DataContext as MainViewModel).Client as IEHSIProvider).StopEHSI(); }
/// <summary> /// Sends Request to TCP Server /// </summary> /// <param name="server"></param> /// <param name="port"></param> /// <param name="method"></param> /// <param name="data"></param> /// <returns>string, reuslt of request or exception log</returns> private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { client.Dispose(); }
private void openFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e) { }
public void CloseWindow() { System.ComponentModel.CancelEventArgs e = new System.ComponentModel.CancelEventArgs(); OnClosing(e); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { DisconnectUser(); }
private void contextMenuNode_Opening(object sender, CancelEventArgs e) { List<NodeBase> selNodeData = new List<NodeBase>( from vn in this.objectView.SelectedNodes where vn.Tag is NodeBase select vn.Tag as NodeBase); List<object> selObjData = selNodeData.OfType<ComponentNode>().Select(n => n.Component).AsEnumerable<object>().Concat( selNodeData.OfType<GameObjectNode>().Select(n => n.Obj)).ToList(); bool noSelect = selNodeData.Count == 0; bool singleSelect = selNodeData.Count == 1; bool multiSelect = selNodeData.Count > 1; bool gameObjSelect = selNodeData.Any(n => n is GameObjectNode); this.newToolStripMenuItem.Visible = (singleSelect && gameObjSelect) || noSelect; this.toolStripSeparatorNew.Visible = !multiSelect && gameObjSelect && !noSelect; this.renameToolStripMenuItem.Visible = !noSelect && gameObjSelect; this.cloneToolStripMenuItem.Visible = !noSelect && gameObjSelect; this.deleteToolStripMenuItem.Visible = !noSelect; this.toolStripSeparatorGameObject.Visible = gameObjSelect; this.lockedToolStripMenuItem.Visible = gameObjSelect; this.contextMenuNode_UpdateLockHideItem(); this.renameToolStripMenuItem.Enabled = singleSelect; // Provide custom actions Type mainResType = null; if (selObjData.Any()) { mainResType = selObjData.First().GetType(); // Find mutual type foreach (var obj in selObjData) { Type resType = obj.GetType(); while (mainResType != null && !mainResType.IsAssignableFrom(resType)) mainResType = mainResType.BaseType; } } for (int i = this.contextMenuNode.Items.Count - 1; i >= 0; i--) { if (this.contextMenuNode.Items[i].Tag is IEditorAction) this.contextMenuNode.Items.RemoveAt(i); } if (mainResType != null) { this.toolStripSeparatorCustomActions.Visible = true; int baseIndex = this.contextMenuNode.Items.IndexOf(this.toolStripSeparatorCustomActions); var customActions = CorePluginRegistry.GetEditorActions( mainResType, CorePluginRegistry.ActionContext_ContextMenu, selObjData) .ToArray(); foreach (var actionEntry in customActions) { ToolStripMenuItem actionItem = new ToolStripMenuItem(actionEntry.Name, actionEntry.Icon); actionItem.Click += this.customObjectActionItem_Click; actionItem.Tag = actionEntry; actionItem.ToolTipText = actionEntry.Description; this.contextMenuNode.Items.Insert(baseIndex, actionItem); baseIndex++; } if (customActions.Length == 0) this.toolStripSeparatorCustomActions.Visible = false; } else this.toolStripSeparatorCustomActions.Visible = false; // Reset "New" menu to original state this.gameObjectToolStripMenuItem.Image = CorePluginRegistry.GetTypeImage(typeof(GameObject)); List<ToolStripItem> oldItems = new List<ToolStripItem>(this.newToolStripMenuItem.DropDownItems.OfType<ToolStripItem>()); this.newToolStripMenuItem.DropDownItems.Clear(); foreach (ToolStripItem item in oldItems.Skip(2)) item.Dispose(); this.newToolStripMenuItem.DropDownItems.AddRange(oldItems.Take(2).ToArray()); // Populate the "New" menu List<ToolStripItem> newItems = new List<ToolStripItem>(); foreach (Type cmpType in this.QueryComponentTypes()) { // Generate category item string[] category = CorePluginRegistry.GetTypeCategory(cmpType); ToolStripMenuItem categoryItem = this.newToolStripMenuItem; for (int i = 0; i < category.Length; i++) { ToolStripMenuItem subCatItem; if (categoryItem == this.newToolStripMenuItem) subCatItem = newItems.FirstOrDefault(item => item.Name == category[i]) as ToolStripMenuItem; else subCatItem = categoryItem.DropDownItems.Find(category[i], false).FirstOrDefault() as ToolStripMenuItem; if (subCatItem == null) { subCatItem = new ToolStripMenuItem(category[i]); subCatItem.Name = category[i]; subCatItem.Tag = cmpType.Assembly; subCatItem.DropDownItemClicked += this.newToolStripMenuItem_DropDownItemClicked; if (categoryItem == this.newToolStripMenuItem) EditorBasePlugin.InsertToolStripTypeItem(newItems, subCatItem); else EditorBasePlugin.InsertToolStripTypeItem(categoryItem.DropDownItems, subCatItem); } categoryItem = subCatItem; } ToolStripMenuItem cmpTypeItem = new ToolStripMenuItem(cmpType.Name, ComponentNode.GetTypeImage(cmpType)); cmpTypeItem.Tag = cmpType; if (categoryItem == this.newToolStripMenuItem) EditorBasePlugin.InsertToolStripTypeItem(newItems, cmpTypeItem); else EditorBasePlugin.InsertToolStripTypeItem(categoryItem.DropDownItems, cmpTypeItem); } this.newToolStripMenuItem.DropDownItems.AddRange(newItems.ToArray()); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { Logout(); }
private void Dlg_FileOk(object sender, System.ComponentModel.CancelEventArgs e) { path = (sender as OpenFileDialog).FileName; }
static void ProcessWindowEvent(Sdl2NativeWindow window, WindowEvent e) { switch (e.Event) { case WindowEventID.CLOSE: var close_args = new System.ComponentModel.CancelEventArgs(); try { window.is_in_closing_event = true; window.OnClosing(close_args); } finally { window.is_in_closing_event = false; } if (!close_args.Cancel) { window.OnClosed(EventArgs.Empty); window.must_destroy = true; } break; case WindowEventID.ENTER: window.OnMouseEnter(EventArgs.Empty); break; case WindowEventID.LEAVE: window.OnMouseLeave(EventArgs.Empty); break; case WindowEventID.EXPOSED: // do nothing break; case WindowEventID.FOCUS_GAINED: window.is_focused = true; window.OnFocusedChanged(EventArgs.Empty); break; case WindowEventID.FOCUS_LOST: window.is_focused = false; window.OnFocusedChanged(EventArgs.Empty); break; case WindowEventID.HIDDEN: window.is_visible = false; window.OnVisibleChanged(EventArgs.Empty); break; case WindowEventID.SHOWN: window.is_visible = true; window.OnVisibleChanged(EventArgs.Empty); break; case WindowEventID.MAXIMIZED: window.window_state = WindowState.Maximized; window.OnWindowStateChanged(EventArgs.Empty); break; case WindowEventID.MINIMIZED: window.previous_window_state = window.window_state; window.window_state = WindowState.Minimized; window.OnWindowStateChanged(EventArgs.Empty); break; case WindowEventID.RESTORED: window.window_state = window.previous_window_state; window.OnWindowStateChanged(EventArgs.Empty); break; case WindowEventID.MOVED: window.OnMove(EventArgs.Empty); break; case WindowEventID.RESIZED: case WindowEventID.SIZE_CHANGED: window.OnResize(EventArgs.Empty); break; default: Debug.Print("SDL2 unhandled event: {0}", e.Type); break; } }
private void nodeTextBoxName_EditorShowing(object sender, CancelEventArgs e) { if (e.Cancel) return; if (this.objectView.SelectedNode == null) { e.Cancel = true; return; } NodeBase node = this.objectView.SelectedNode.Tag as NodeBase; GameObjectNode objNode = node as GameObjectNode; if (objNode == null) { e.Cancel = true; } else { DesignTimeObjectData data = DesignTimeObjectData.Get(objNode.Obj); if (data.IsLocked) e.Cancel = true; } if (!e.Cancel) { this.lastEditedNode = node; this.objectView.ContextMenuStrip = null; } }
private static void QuickPatrol() { System.ComponentModel.CancelEventArgs e = new System.ComponentModel.CancelEventArgs(); OnQuickPatrolling(e); if (e.Cancel) { return; } lock (patrolSyncRoot) { QuickPatrolMarker.Run(); QuickUpdater.Run(); } QuickDownloader.Run(); OnQuickPatrolled(); }
/// <summary> /// Sends a simple progress update with a free text status and an integral percentage. /// </summary> /// <returns>True if the event handlers have set the cancel property to true, otherwise false.</returns> protected bool OnLoadDataSourceProgress(string status, int percentage) { if (LoadDataSourceProgress != null) { var e = new System.ComponentModel.CancelEventArgs(); LoadDataSourceProgress(this, status, percentage, e); if (e.Cancel) return true; } return false; }
/// <summary> /// メイン動作を実行します /// 新規スレッドを取得して現在のスレッドを更新します /// </summary> public void Run() { System.ComponentModel.CancelEventArgs e = new System.ComponentModel.CancelEventArgs(); OnRunning(e); if (e.Cancel) { OnRan(); return; } Update(); AddAliveThreads(); UpdatePastLogThreads(); RemoveDownloadCompletedThreads(); OnRan(); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { daoService.Close(); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { _logger.Close(); }
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { // Adicione código para manipular o evento SettingsSaving aqui. }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { e.Cancel = true; }
/// <summary> /// 登録してあるパターンからのスレッド取得・ダウンロードの一連動作を実装 /// </summary> private static void Patrol() { System.ComponentModel.CancelEventArgs e = new System.ComponentModel.CancelEventArgs(); OnPatrolling(e); if (e.Cancel) { return; } lock (patrolSyncRoot) { Patroller.Run(); Updater.Run(); } Downloader.Run(); OnPatrolled(); }
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { // Добавьте здесь код для обработки события SettingsSaving. }
private void contextMenuNode_Opening(object sender, CancelEventArgs e) { List<NodeBase> selNodeData = new List<NodeBase>( from vn in this.objectView.SelectedNodes where vn.Tag is NodeBase select vn.Tag as NodeBase); List<object> selObjData = selNodeData.OfType<ComponentNode>().Select(n => n.Component).AsEnumerable<object>().Concat( selNodeData.OfType<GameObjectNode>().Select(n => n.Obj)).ToList(); bool noSelect = selNodeData.Count == 0; bool singleSelect = selNodeData.Count == 1; bool multiSelect = selNodeData.Count > 1; bool gameObjSelect = selNodeData.Any(n => n is GameObjectNode); this.newToolStripMenuItem.Visible = (singleSelect && gameObjSelect) || noSelect; this.toolStripSeparatorNew.Visible = !multiSelect && gameObjSelect && !noSelect; this.renameToolStripMenuItem.Visible = !noSelect && gameObjSelect; this.cloneToolStripMenuItem.Visible = !noSelect && gameObjSelect; this.deleteToolStripMenuItem.Visible = !noSelect; this.toolStripSeparatorGameObject.Visible = gameObjSelect; this.lockedToolStripMenuItem.Visible = gameObjSelect; this.contextMenuNode_UpdateLockHideItem(); this.renameToolStripMenuItem.Enabled = singleSelect; // Provide custom actions Type mainResType = null; if (selObjData.Any()) { mainResType = selObjData.First().GetType(); // Find mutual type foreach (var obj in selObjData) { Type resType = obj.GetType(); while (mainResType != null && !mainResType.IsAssignableFrom(resType)) mainResType = mainResType.BaseType; } } for (int i = this.contextMenuNode.Items.Count - 1; i >= 0; i--) { if (this.contextMenuNode.Items[i].Tag is IEditorAction) this.contextMenuNode.Items.RemoveAt(i); } if (mainResType != null) { this.toolStripSeparatorCustomActions.Visible = true; int baseIndex = this.contextMenuNode.Items.IndexOf(this.toolStripSeparatorCustomActions); var customActions = DualityEditorApp.GetEditorActions(mainResType, selObjData).ToArray(); foreach (var actionEntry in customActions) { ToolStripMenuItem actionItem = new ToolStripMenuItem(actionEntry.Name, actionEntry.Icon); actionItem.Click += this.customObjectActionItem_Click; actionItem.Tag = actionEntry; actionItem.ToolTipText = actionEntry.Description; this.contextMenuNode.Items.Insert(baseIndex, actionItem); baseIndex++; } if (customActions.Length == 0) this.toolStripSeparatorCustomActions.Visible = false; } else this.toolStripSeparatorCustomActions.Visible = false; this.gameObjectToolStripMenuItem.Image = typeof(GameObject).GetEditorImage(); // Omit abstract and invisible Component Types var cmpTypes = DualityApp.GetAvailDualityTypes(typeof (Component)) .Where(t => !t.IsAbstract) .Where(t => { EditorHintFlagsAttribute editorHintFlags = t.GetCustomAttributes<EditorHintFlagsAttribute>().FirstOrDefault(); return (editorHintFlags == null || !editorHintFlags.Flags.HasFlag(MemberFlags.Invisible)); }); HierarchicalContextMenuBuilder.CreateHierarchicalContextMenuItemsFromTypes( this.newToolStripMenuItem, cmpTypes, ComponentNode.GetTypeImage, this.newToolStripMenuItem_DropDownItemClicked, new DefaultEditorCategoryProvider()); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { SaveConfiguration(); }
IntPtr WindowProcedure(IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lParam) { switch (message) { #region Size / Move / Style events case WindowMessage.ACTIVATE: // See http://msdn.microsoft.com/en-us/library/ms646274(VS.85).aspx (WM_ACTIVATE notification): // wParam: The low-order word specifies whether the window is being activated or deactivated. bool new_focused_state = Focused; if (IntPtr.Size == 4) focused = (wParam.ToInt32() & 0xFFFF) != 0; else focused = (wParam.ToInt64() & 0xFFFF) != 0; if (new_focused_state != Focused) FocusedChanged(this, EventArgs.Empty); break; case WindowMessage.ENTERMENULOOP: case WindowMessage.ENTERSIZEMOVE: // Entering the modal size/move loop: we don't want rendering to // stop during this time, so we register a timer callback to continue // processing from time to time. is_in_modal_loop = true; StartTimer(handle); if (!CursorVisible) UngrabCursor(); break; case WindowMessage.EXITMENULOOP: case WindowMessage.EXITSIZEMOVE: // Exiting from Modal size/move loop: the timer callback is no longer // necessary. is_in_modal_loop = false; StopTimer(handle); // Ensure cursor remains grabbed if (!CursorVisible) GrabCursor(); break; case WindowMessage.ERASEBKGND: return new IntPtr(1); case WindowMessage.WINDOWPOSCHANGED: unsafe { WindowPosition* pos = (WindowPosition*)lParam; if (window != null && pos->hwnd == window.Handle) { Point new_location = new Point(pos->x, pos->y); if (Location != new_location) { bounds.Location = new_location; Move(this, EventArgs.Empty); } Size new_size = new Size(pos->cx, pos->cy); if (Size != new_size) { bounds.Width = pos->cx; bounds.Height = pos->cy; Win32Rectangle rect; Functions.GetClientRect(handle, out rect); client_rectangle = rect.ToRectangle(); Functions.SetWindowPos(child_window.Handle, IntPtr.Zero, 0, 0, ClientRectangle.Width, ClientRectangle.Height, SetWindowPosFlags.NOZORDER | SetWindowPosFlags.NOOWNERZORDER | SetWindowPosFlags.NOACTIVATE | SetWindowPosFlags.NOSENDCHANGING); if (suppress_resize <= 0) Resize(this, EventArgs.Empty); } if (!is_in_modal_loop) { // If we are in a modal resize/move loop, cursor grabbing is // handled inside [ENTER|EXIT]SIZEMOVE case above. // If not, then we have to handle cursor grabbing here. if (!CursorVisible) GrabCursor(); } } } break; case WindowMessage.STYLECHANGED: unsafe { if (wParam.ToInt64() == (long)GWL.STYLE) { WindowStyle style = ((StyleStruct*)lParam)->New; if ((style & WindowStyle.Popup) != 0) windowBorder = WindowBorder.Hidden; else if ((style & WindowStyle.ThickFrame) != 0) windowBorder = WindowBorder.Resizable; else if ((style & ~(WindowStyle.ThickFrame | WindowStyle.MaximizeBox)) != 0) windowBorder = WindowBorder.Fixed; } } // Ensure cursor remains grabbed if (!CursorVisible) GrabCursor(); break; case WindowMessage.SIZE: SizeMessage state = (SizeMessage)wParam.ToInt64(); WindowState new_state = windowState; switch (state) { case SizeMessage.RESTORED: new_state = borderless_maximized_window_state ? WindowState.Maximized : WindowState.Normal; break; case SizeMessage.MINIMIZED: new_state = WindowState.Minimized; break; case SizeMessage.MAXIMIZED: new_state = WindowBorder == WindowBorder.Hidden ? WindowState.Fullscreen : WindowState.Maximized; break; } if (new_state != windowState) { windowState = new_state; WindowStateChanged(this, EventArgs.Empty); // Ensure cursor remains grabbed if (!CursorVisible) GrabCursor(); } break; #endregion #region Input events case WindowMessage.CHAR: if (IntPtr.Size == 4) key_press.KeyChar = (char)wParam.ToInt32(); else key_press.KeyChar = (char)wParam.ToInt64(); KeyPress(this, key_press); break; case WindowMessage.MOUSEMOVE: Point point = new Point( (short)((uint)lParam.ToInt32() & 0x0000FFFF), (short)(((uint)lParam.ToInt32() & 0xFFFF0000) >> 16)); mouse.Position = point; if (mouse_outside_window) { // Once we receive a mouse move event, it means that the mouse has // re-entered the window. mouse_outside_window = false; EnableMouseTracking(); MouseEnter(this, EventArgs.Empty); } break; case WindowMessage.MOUSELEAVE: mouse_outside_window = true; // Mouse tracking is disabled automatically by the OS MouseLeave(this, EventArgs.Empty); break; case WindowMessage.MOUSEWHEEL: // This is due to inconsistent behavior of the WParam value on 64bit arch, whese // wparam = 0xffffffffff880000 or wparam = 0x00000000ff100000 mouse.WheelPrecise += ((long)wParam << 32 >> 48) / 120.0f; break; case WindowMessage.LBUTTONDOWN: Functions.SetCapture(window.Handle); mouse[MouseButton.Left] = true; break; case WindowMessage.MBUTTONDOWN: Functions.SetCapture(window.Handle); mouse[MouseButton.Middle] = true; break; case WindowMessage.RBUTTONDOWN: Functions.SetCapture(window.Handle); mouse[MouseButton.Right] = true; break; case WindowMessage.XBUTTONDOWN: Functions.SetCapture(window.Handle); mouse[((wParam.ToInt32() & 0xFFFF0000) >> 16) != (int)MouseKeys.XButton1 ? MouseButton.Button1 : MouseButton.Button2] = true; break; case WindowMessage.LBUTTONUP: Functions.ReleaseCapture(); mouse[MouseButton.Left] = false; break; case WindowMessage.MBUTTONUP: Functions.ReleaseCapture(); mouse[MouseButton.Middle] = false; break; case WindowMessage.RBUTTONUP: Functions.ReleaseCapture(); mouse[MouseButton.Right] = false; break; case WindowMessage.XBUTTONUP: Functions.ReleaseCapture(); mouse[((wParam.ToInt32() & 0xFFFF0000) >> 16) != (int)MouseKeys.XButton1 ? MouseButton.Button1 : MouseButton.Button2] = false; break; // Keyboard events: case WindowMessage.KEYDOWN: case WindowMessage.KEYUP: case WindowMessage.SYSKEYDOWN: case WindowMessage.SYSKEYUP: bool pressed = message == WindowMessage.KEYDOWN || message == WindowMessage.SYSKEYDOWN; // Shift/Control/Alt behave strangely when e.g. ShiftRight is held down and ShiftLeft is pressed // and released. It looks like neither key is released in this case, or that the wrong key is // released in the case of Control and Alt. // To combat this, we are going to release both keys when either is released. Hacky, but should work. // Win95 does not distinguish left/right key constants (GetAsyncKeyState returns 0). // In this case, both keys will be reported as pressed. bool extended = (lParam.ToInt64() & ExtendedBit) != 0; short scancode = (short)((lParam.ToInt64() >> 16) & 0xFF); VirtualKeys vkey = (VirtualKeys)wParam; bool is_valid; Key key = KeyMap.TranslateKey(scancode, vkey, extended, false, out is_valid); if (is_valid) { keyboard.SetKey(key, (byte)scancode, pressed); } return IntPtr.Zero; case WindowMessage.SYSCHAR: return IntPtr.Zero; case WindowMessage.KILLFOCUS: keyboard.ClearKeys(); break; #endregion #region Creation / Destruction events case WindowMessage.CREATE: CreateStruct cs = (CreateStruct)Marshal.PtrToStructure(lParam, typeof(CreateStruct)); if (cs.hwndParent == IntPtr.Zero) { bounds.X = cs.x; bounds.Y = cs.y; bounds.Width = cs.cx; bounds.Height = cs.cy; Win32Rectangle rect; Functions.GetClientRect(handle, out rect); client_rectangle = rect.ToRectangle(); invisible_since_creation = true; } break; case WindowMessage.CLOSE: System.ComponentModel.CancelEventArgs e = new System.ComponentModel.CancelEventArgs(); Closing(this, e); if (!e.Cancel) { DestroyWindow(); break; } return IntPtr.Zero; case WindowMessage.DESTROY: exists = false; Functions.UnregisterClass(ClassName, Instance); window.Dispose(); child_window.Dispose(); Closed(this, EventArgs.Empty); break; #endregion } return Functions.DefWindowProc(handle, message, wParam, lParam); }
//----------------------------------------------------------------------------------------------------------- // WPF Event handlers //----------------------------------------------------------------------------------------------------------- /// <summary> /// Unhooks hooks on program exit /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { MouseHook.Stop(); Application.Current.Shutdown(); }
unsafe IntPtr WindowProcedure(IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lParam) { switch (message) { #region Size / Move / Style events case WindowMessage.ACTIVATE: // See http://msdn.microsoft.com/en-us/library/ms646274(VS.85).aspx (WM_ACTIVATE notification): // wParam: The low-order word specifies whether the window is being activated or deactivated. bool new_focused_state = Focused; if (IntPtr.Size == 4) focused = (wParam.ToInt32() & 0xFFFF) != 0; else focused = (wParam.ToInt64() & 0xFFFF) != 0; if (new_focused_state != Focused && FocusedChanged != null) FocusedChanged(this, EventArgs.Empty); break; case WindowMessage.ENTERMENULOOP: case WindowMessage.ENTERSIZEMOVE: case WindowMessage.EXITMENULOOP: case WindowMessage.EXITSIZEMOVE: break; case WindowMessage.ERASEBKGND: return new IntPtr(1); case WindowMessage.WINDOWPOSCHANGED: WindowPosition* pos = (WindowPosition*)lParam; if (window != null && pos->hwnd == window.WindowHandle) { Point new_location = new Point(pos->x, pos->y); if (Location != new_location) { bounds.Location = new_location; if (Move != null) Move(this, EventArgs.Empty); } Size new_size = new Size(pos->cx, pos->cy); if (Size != new_size) { bounds.Width = pos->cx; bounds.Height = pos->cy; Win32Rectangle rect; API.GetClientRect(handle, out rect); client_rectangle = rect.ToRectangle(); API.SetWindowPos(child_window.WindowHandle, IntPtr.Zero, 0, 0, ClientRectangle.Width, ClientRectangle.Height, SetWindowPosFlags.NOZORDER | SetWindowPosFlags.NOOWNERZORDER | SetWindowPosFlags.NOACTIVATE | SetWindowPosFlags.NOSENDCHANGING); if (suppress_resize <= 0 && Resize != null) Resize(this, EventArgs.Empty); } } break; case WindowMessage.STYLECHANGED: if (wParam.ToInt64() == (long)GWL.STYLE) { WindowStyle style = ((StyleStruct*)lParam)->New; if ((style & WindowStyle.Popup) != 0) hiddenBorder = true; else if ((style & WindowStyle.ThickFrame) != 0) hiddenBorder = false; } break; case WindowMessage.SIZE: SizeMessage state = (SizeMessage)wParam.ToInt64(); WindowState new_state = windowState; switch (state) { case SizeMessage.RESTORED: new_state = WindowState.Normal; break; case SizeMessage.MINIMIZED: new_state = WindowState.Minimized; break; case SizeMessage.MAXIMIZED: new_state = hiddenBorder ? WindowState.Fullscreen : WindowState.Maximized; break; } if (new_state != windowState) { windowState = new_state; if (WindowStateChanged != null) WindowStateChanged(this, EventArgs.Empty); } break; #endregion #region Input events case WindowMessage.CHAR: if (IntPtr.Size == 4) key_press.KeyChar = (char)wParam.ToInt32(); else key_press.KeyChar = (char)wParam.ToInt64(); if (KeyPress != null) KeyPress(this, key_press); break; case WindowMessage.MOUSEMOVE: Point point = new Point( (short)((uint)lParam.ToInt32() & 0x0000FFFF), (short)(((uint)lParam.ToInt32() & 0xFFFF0000) >> 16)); mouse.Position = point; if (mouse_outside_window) { // Once we receive a mouse move event, it means that the mouse has // re-entered the window. mouse_outside_window = false; EnableMouseTracking(); if (MouseEnter != null) MouseEnter(this, EventArgs.Empty); } break; case WindowMessage.MOUSELEAVE: mouse_outside_window = true; // Mouse tracking is disabled automatically by the OS if (MouseLeave != null) MouseLeave(this, EventArgs.Empty); break; case WindowMessage.MOUSEWHEEL: // This is due to inconsistent behavior of the WParam value on 64bit arch, whese // wparam = 0xffffffffff880000 or wparam = 0x00000000ff100000 mouse.WheelPrecise += ((long)wParam << 32 >> 48) / 120.0f; return IntPtr.Zero; case WindowMessage.LBUTTONDOWN: mouse[MouseButton.Left] = true; break; case WindowMessage.MBUTTONDOWN: mouse[MouseButton.Middle] = true; break; case WindowMessage.RBUTTONDOWN: mouse[MouseButton.Right] = true; break; case WindowMessage.XBUTTONDOWN: mouse[(((ulong)wParam.ToInt64() >> 16) & 0xFFFF) != (int)MouseKeys.XButton1 ? MouseButton.Button1 : MouseButton.Button2] = true; break; case WindowMessage.LBUTTONUP: mouse[MouseButton.Left] = false; break; case WindowMessage.MBUTTONUP: mouse[MouseButton.Middle] = false; break; case WindowMessage.RBUTTONUP: mouse[MouseButton.Right] = false; break; case WindowMessage.XBUTTONUP: mouse[(((ulong)wParam.ToInt64() >> 16) & 0xFFFF) != (int)MouseKeys.XButton1 ? MouseButton.Button1 : MouseButton.Button2] = false; break; // Keyboard events: case WindowMessage.KEYDOWN: case WindowMessage.KEYUP: case WindowMessage.SYSKEYDOWN: case WindowMessage.SYSKEYUP: bool pressed = message == WindowMessage.KEYDOWN || message == WindowMessage.SYSKEYDOWN; // Shift/Control/Alt behave strangely when e.g. ShiftRight is held down and ShiftLeft is pressed // and released. It looks like neither key is released in this case, or that the wrong key is // released in the case of Control and Alt. // To combat this, we are going to release both keys when either is released. Hacky, but should work. // Win95 does not distinguish left/right key constants (GetAsyncKeyState returns 0). // In this case, both keys will be reported as pressed. bool extended = (lParam.ToInt64() & ExtendedBit) != 0; switch ((VirtualKeys)wParam) { case VirtualKeys.SHIFT: // The behavior of this key is very strange. Unlike Control and Alt, there is no extended bit // to distinguish between left and right keys. Moreover, pressing both keys and releasing one // may result in both keys being held down (but not always). ushort lShiftState = API.GetKeyState( (int)VirtualKeys.LSHIFT ); ushort rShiftState = API.GetKeyState( (int)VirtualKeys.RSHIFT ); Keyboard[Input.Key.ShiftLeft] = (lShiftState >> 15) == 1; Keyboard[Input.Key.ShiftRight] = (rShiftState >> 15) == 1; return IntPtr.Zero; case VirtualKeys.CONTROL: if (extended) keyboard[Input.Key.ControlRight] = pressed; else keyboard[Input.Key.ControlLeft] = pressed; return IntPtr.Zero; case VirtualKeys.MENU: if (extended) keyboard[Input.Key.AltRight] = pressed; else keyboard[Input.Key.AltLeft] = pressed; return IntPtr.Zero; case VirtualKeys.RETURN: if (extended) keyboard[Key.KeypadEnter] = pressed; else keyboard[Key.Enter] = pressed; return IntPtr.Zero; default: Key tkKey; if (!KeyMap.TryGetMappedKey((VirtualKeys)wParam, out tkKey)) { Debug.Print("Virtual key {0} ({1}) not mapped.", (VirtualKeys)wParam, lParam.ToInt64()); break; } else{ keyboard[tkKey] = pressed; } return IntPtr.Zero; } break; case WindowMessage.SYSCHAR: return IntPtr.Zero; case WindowMessage.KILLFOCUS: keyboard.ClearKeys(); break; #endregion #region Creation / Destruction events case WindowMessage.CREATE: CreateStruct cs = (CreateStruct)Marshal.PtrToStructure(lParam, typeof(CreateStruct)); if (cs.hwndParent == IntPtr.Zero) { bounds.X = cs.x; bounds.Y = cs.y; bounds.Width = cs.cx; bounds.Height = cs.cy; Win32Rectangle rect; API.GetClientRect(handle, out rect); client_rectangle = rect.ToRectangle(); invisible_since_creation = true; } break; case WindowMessage.CLOSE: System.ComponentModel.CancelEventArgs e = new System.ComponentModel.CancelEventArgs(); if (Closing != null) Closing(this, e); if (!e.Cancel) { if (Unload != null) Unload(this, EventArgs.Empty); DestroyWindow(); break; } return IntPtr.Zero; case WindowMessage.DESTROY: exists = false; API.UnregisterClass(ClassName, Instance); window.Dispose(); child_window.Dispose(); if (Closed != null) Closed(this, EventArgs.Empty); break; #endregion } return API.DefWindowProc(handle, message, wParam, lParam); }
protected override void OnClosing(System.ComponentModel.CancelEventArgs e) { SelectedLanguage = uiLanguageComboBox1.SelectedLanguage; base.OnClosing(e); }
IntPtr WindowProcedure(IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lParam) { bool mouse_about_to_enter = false; switch (message) { #region Size / Move / Style events case WindowMessage.ACTIVATE: // See http://msdn.microsoft.com/en-us/library/ms646274(VS.85).aspx (WM_ACTIVATE notification): // wParam: The low-order word specifies whether the window is being activated or deactivated. bool new_focused_state = Focused; if (IntPtr.Size == 4) focused = (wParam.ToInt32() & 0xFFFF) != 0; else focused = (wParam.ToInt64() & 0xFFFF) != 0; if (new_focused_state != Focused && FocusedChanged != null) FocusedChanged(this, EventArgs.Empty); break; case WindowMessage.ENTERMENULOOP: case WindowMessage.ENTERSIZEMOVE: // Entering the modal size/move loop: we don't want rendering to // stop during this time, so we register a timer callback to continue // processing from time to time. timer_handle = Functions.SetTimer(handle, ModalLoopTimerId, ModalLoopTimerPeriod, ModalLoopCallback); if (timer_handle == UIntPtr.Zero) Debug.Print("[Warning] Failed to set modal loop timer callback ({0}:{1}->{2}).", GetType().Name, handle, Marshal.GetLastWin32Error()); break; case WindowMessage.EXITMENULOOP: case WindowMessage.EXITSIZEMOVE: // ExitingmModal size/move loop: the timer callback is no longer // necessary. if (!Functions.KillTimer(handle, timer_handle)) Debug.Print("[Warning] Failed to kill modal loop timer callback ({0}:{1}->{2}).", GetType().Name, handle, Marshal.GetLastWin32Error()); timer_handle = UIntPtr.Zero; break; case WindowMessage.NCCALCSIZE: // Need to update the client rectangle, because it has the wrong size on Vista with Aero enabled. //if (m.WParam == new IntPtr(1)) //{ // unsafe // { // NcCalculateSize* nc_calc_size = (NcCalculateSize*)m.LParam; // //nc_calc_size->NewBounds = nc_calc_size->OldBounds; // //nc_calc_size->OldBounds = nc_calc_size->NewBounds; // //client_rectangle = rect.OldClientRectangle; // } // m.Result = new IntPtr((int)(NcCalcSizeOptions.ALIGNTOP | NcCalcSizeOptions.ALIGNLEFT/* | NcCalcSizeOptions.REDRAW*/)); //} break; case WindowMessage.ERASEBKGND: return new IntPtr(1); case WindowMessage.WINDOWPOSCHANGED: unsafe { WindowPosition* pos = (WindowPosition*)lParam; if (window != null && pos->hwnd == window.WindowHandle) { Point new_location = new Point(pos->x, pos->y); if (Location != new_location) { bounds.Location = new_location; if (Move != null) Move(this, EventArgs.Empty); } Size new_size = new Size(pos->cx, pos->cy); if (Size != new_size) { bounds.Width = pos->cx; bounds.Height = pos->cy; Rectangle rect; Functions.GetClientRect(handle, out rect); client_rectangle = rect.ToRectangle(); Functions.SetWindowPos(child_window.WindowHandle, IntPtr.Zero, 0, 0, ClientRectangle.Width, ClientRectangle.Height, SetWindowPosFlags.NOZORDER | SetWindowPosFlags.NOOWNERZORDER | SetWindowPosFlags.NOACTIVATE | SetWindowPosFlags.NOSENDCHANGING); if (Resize != null) Resize(this, EventArgs.Empty); } } } break; case WindowMessage.STYLECHANGED: unsafe { if (wParam.ToInt64() == (long)GWL.STYLE) { WindowStyle style = ((StyleStruct*)lParam)->New; if ((style & WindowStyle.Popup) != 0) windowBorder = WindowBorder.Hidden; else if ((style & WindowStyle.ThickFrame) != 0) windowBorder = WindowBorder.Resizable; else if ((style & ~(WindowStyle.ThickFrame | WindowStyle.MaximizeBox)) != 0) windowBorder = WindowBorder.Fixed; } } break; case WindowMessage.SIZE: SizeMessage state = (SizeMessage)wParam.ToInt64(); WindowState new_state = windowState; switch (state) { case SizeMessage.RESTORED: new_state = borderless_maximized_window_state ? WindowState.Maximized : WindowState.Normal; break; case SizeMessage.MINIMIZED: new_state = WindowState.Minimized; break; case SizeMessage.MAXIMIZED: new_state = WindowBorder == WindowBorder.Hidden ? WindowState.Fullscreen : WindowState.Maximized; break; } if (new_state != windowState) { windowState = new_state; if (WindowStateChanged != null) WindowStateChanged(this, EventArgs.Empty); } break; #endregion #region Input events case WindowMessage.CHAR: if (IntPtr.Size == 4) key_press.KeyChar = (char)wParam.ToInt32(); else key_press.KeyChar = (char)wParam.ToInt64(); if (KeyPress != null) KeyPress(this, key_press); break; //case WindowMessage.MOUSELEAVE: // Cursor.Current = Cursors.Default; // break; //case WindowMessage.MOUSE_ENTER: // Cursor.Current = Cursors.Default; // break; // Mouse events: case WindowMessage.NCMOUSEMOVE: mouse_about_to_enter = true; // Used to simulate a mouse enter event. break; case WindowMessage.MOUSEMOVE: mouse.Position = new System.Drawing.Point( (int)(lParam.ToInt32() & 0x0000FFFF), (int)(lParam.ToInt32() & 0xFFFF0000) >> 16); if (mouse_about_to_enter) { //Cursor.Current = Cursors.Default; mouse_about_to_enter = false; } break; case WindowMessage.MOUSEWHEEL: // This is due to inconsistent behavior of the WParam value on 64bit arch, whese // wparam = 0xffffffffff880000 or wparam = 0x00000000ff100000 mouse.Wheel += (int)((long)wParam << 32 >> 48) / 120; break; case WindowMessage.LBUTTONDOWN: mouse[MouseButton.Left] = true; break; case WindowMessage.MBUTTONDOWN: mouse[MouseButton.Middle] = true; break; case WindowMessage.RBUTTONDOWN: mouse[MouseButton.Right] = true; break; case WindowMessage.XBUTTONDOWN: mouse[((wParam.ToInt32() & 0xFFFF0000) >> 16) != (int)MouseKeys.XButton1 ? MouseButton.Button1 : MouseButton.Button2] = true; break; case WindowMessage.LBUTTONUP: mouse[MouseButton.Left] = false; break; case WindowMessage.MBUTTONUP: mouse[MouseButton.Middle] = false; break; case WindowMessage.RBUTTONUP: mouse[MouseButton.Right] = false; break; case WindowMessage.XBUTTONUP: // TODO: Is this correct? mouse[((wParam.ToInt32() & 0xFFFF0000) >> 16) != (int)MouseKeys.XButton1 ? MouseButton.Button1 : MouseButton.Button2] = false; break; // Keyboard events: case WindowMessage.KEYDOWN: case WindowMessage.KEYUP: case WindowMessage.SYSKEYDOWN: case WindowMessage.SYSKEYUP: bool pressed = message == WindowMessage.KEYDOWN || message == WindowMessage.SYSKEYDOWN; // Shift/Control/Alt behave strangely when e.g. ShiftRight is held down and ShiftLeft is pressed // and released. It looks like neither key is released in this case, or that the wrong key is // released in the case of Control and Alt. // To combat this, we are going to release both keys when either is released. Hacky, but should work. // Win95 does not distinguish left/right key constants (GetAsyncKeyState returns 0). // In this case, both keys will be reported as pressed. bool extended = (lParam.ToInt64() & ExtendedBit) != 0; switch ((VirtualKeys)wParam) { case VirtualKeys.SHIFT: // The behavior of this key is very strange. Unlike Control and Alt, there is no extended bit // to distinguish between left and right keys. Moreover, pressing both keys and releasing one // may result in both keys being held down (but not always). // The only reliably way to solve this was reported by BlueMonkMN at the forums: we should // check the scancodes. It looks like GLFW does the same thing, so it should be reliable. // TODO: Not 100% reliable, when both keys are pressed at once. if (ShiftRightScanCode != 0) { unchecked { if (((lParam.ToInt64() >> 16) & 0xFF) == ShiftRightScanCode) keyboard[Input.Key.ShiftRight] = pressed; else keyboard[Input.Key.ShiftLeft] = pressed; } } else { // Should only fall here on Windows 9x and NT4.0- keyboard[Input.Key.ShiftLeft] = pressed; } return IntPtr.Zero; case VirtualKeys.CONTROL: if (extended) keyboard[Input.Key.ControlRight] = pressed; else keyboard[Input.Key.ControlLeft] = pressed; return IntPtr.Zero; case VirtualKeys.MENU: if (extended) keyboard[Input.Key.AltRight] = pressed; else keyboard[Input.Key.AltLeft] = pressed; return IntPtr.Zero; case VirtualKeys.RETURN: if (extended) keyboard[Key.KeypadEnter] = pressed; else keyboard[Key.Enter] = pressed; return IntPtr.Zero; default: if (!WMInput.KeyMap.ContainsKey((VirtualKeys)wParam)) { Debug.Print("Virtual key {0} ({1}) not mapped.", (VirtualKeys)wParam, (int)lParam); break; } else { keyboard[WMInput.KeyMap[(VirtualKeys)wParam]] = pressed; } return IntPtr.Zero; } break; case WindowMessage.SYSCHAR: return IntPtr.Zero; case WindowMessage.KILLFOCUS: keyboard.ClearKeys(); break; #endregion #region Creation / Destruction events case WindowMessage.CREATE: CreateStruct cs = (CreateStruct)Marshal.PtrToStructure(lParam, typeof(CreateStruct)); if (cs.hwndParent == IntPtr.Zero) { bounds.X = cs.x; bounds.Y = cs.y; bounds.Width = cs.cx; bounds.Height = cs.cy; Rectangle rect; Functions.GetClientRect(handle, out rect); client_rectangle = rect.ToRectangle(); } break; case WindowMessage.CLOSE: System.ComponentModel.CancelEventArgs e = new System.ComponentModel.CancelEventArgs(); if (Closing != null) Closing(this, e); if (!e.Cancel) { if (Unload != null) Unload(this, EventArgs.Empty); DestroyWindow(); break; } return IntPtr.Zero; case WindowMessage.DESTROY: exists = false; Functions.UnregisterClass(ClassName, Instance); //Marshal.FreeHGlobal(ClassName); window.Dispose(); child_window.Dispose(); if (Closed != null) Closed(this, EventArgs.Empty); break; #endregion } return Functions.DefWindowProc(handle, message, wParam, lParam); }
// If the main window (this one) is closed, make sure the results window is closed as well. private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { this.resultsView.Close(); }
private void EhButtonOKPressed(object sender, RoutedEventArgs e) { _btOk.Focus(); // Trick to drag the focus away from the embedded control in order to trigger its validation code <b>before</b> the controls Apply routine is called. (This is only needed if user pressed Enter on the keyboard). var eventArgs = new System.ComponentModel.CancelEventArgs(); if (null != ButtonOKPressed) ButtonOKPressed(eventArgs); if (!eventArgs.Cancel) { this.DialogResult = true; } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { instance = null; }
/// <summary> /// Opens a Altaxo project. If the current project is dirty, the user is ask for saving the current project. /// </summary> /// <param name="filename"></param> public void OpenProject(string filename) { if (CurrentOpenProject != null) { System.ComponentModel.CancelEventArgs e = new System.ComponentModel.CancelEventArgs(); if (this.CurrentOpenProject.IsDirty) AskForSavingOfProject(e); if (e.Cancel == true) return; CloseProject(); } if (!FileUtility.TestFileExists(filename)) { return; } StatusBarService.SetMessage("${res:MainWindow.StatusBar.OpeningCombineMessage}"); if (Path.GetExtension(filename).ToUpper() == ".AXOPRJ") { string validproject = Path.ChangeExtension(filename, ".axoprj"); if (File.Exists(validproject)) { LoadProject(validproject); } } else { LoadProject(filename); } StatusBarService.SetMessage("${res:MainWindow.StatusBar.ReadyMessage}"); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { u.UltimaConexao = DateTime.Now; UsuarioDAO.AlterarUsuario(u); }
public override void Run() { if (Current.Project.IsDirty) { System.ComponentModel.CancelEventArgs cancelargs = new System.ComponentModel.CancelEventArgs(); Current.ProjectService.AskForSavingOfProject(cancelargs); if (cancelargs.Cancel) return; } bool saveDirtyState = Current.Project.IsDirty; // save the dirty state of the project in case the user cancels the open file dialog Current.Project.IsDirty = false; // set document to non-dirty var openFileDialog1 = new Microsoft.Win32.OpenFileDialog(); openFileDialog1.Filter = "Altaxo project files (*.axoprj)|*.axoprj|All files (*.*)|*.*"; openFileDialog1.FilterIndex = 1; openFileDialog1.RestoreDirectory = true; if (true == openFileDialog1.ShowDialog((System.Windows.Window)Current.Workbench.ViewObject)) { Current.ProjectService.OpenProject(openFileDialog1.FileName, false); FileService.RecentOpen.AddLastProject(openFileDialog1.FileName); } else // in case the user cancels the open file dialog { Current.Project.IsDirty = saveDirtyState; // restore the dirty state of the current project } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { uiTimer.Stop(); }
private void MainForm_FormClosing(object sender, CancelEventArgs e) { if (Save) SaveSettings (); }
void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { run_arduino_thread = false; }//end method
/// <summary> /// Start the edit operation with the current editor specified in the Model property. /// </summary> public void StartEdit() { if (Cell == null) throw new SourceGridException("No cell at position " + Position.ToString()); if (Grid == null) throw new SourceGridException("Grid is null"); if (Cell.Editor != null && IsEditing() == false && //se la cella non è già in stato edit Cell.Editor.EnableEdit && Grid.Selection.Focus(Position, true)) //per finire eventuali altri edit e posizionare il focus su questa cella { System.ComponentModel.CancelEventArgs cancelEventArgs = new System.ComponentModel.CancelEventArgs(); Grid.Controller.OnEditStarting(this, cancelEventArgs); if (cancelEventArgs.Cancel == false) { Cell.Editor.InternalStartEdit(this); Grid.Controller.OnEditStarted(this, EventArgs.Empty); } } }
//public MainWindow() //{ // InitializeComponent(); // //} // //private void Window_Loaded(object sender, RoutedEventArgs e) //{ // //HwndSource hwndSource = (HwndSource)HwndSource.FromVisual(myCanvas); // //myHWND = hwndSource.Handle; // //myEngineThread = new Thread(() => { RunGfxEngine(); }); // //myEngineThread.Start(); // //} //private void RunGfxEngine() //{ // lock (myCanvas) // { // myEngineBridge = new EngineBridge(); // myEngineBridge.Init(myHWND, 1280, 720); // } //} private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { myEngineBridge.ShutDown(); myEngineThread.Join(); }
private void contextMenuNode_Opening(object sender, CancelEventArgs e) { this.UpdateContextMenu(); }
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { // Add code to handle the SettingsSaving event here. }
void HandleClose(IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lParam) { System.ComponentModel.CancelEventArgs e = new System.ComponentModel.CancelEventArgs(); Closing(this, e); if (!e.Cancel) { DestroyWindow(); } }
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { }
private void EhTabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (!object.ReferenceEquals(e.OriginalSource, _tabCtrl)) return; e.Handled = true; if (0 == _tabControl_SelectionChanged_Calls) { ++_tabControl_SelectionChanged_Calls; bool shouldBeCancelled = false; if (e.RemovedItems.Count > 0 && null != TabValidating) { if (!(e.RemovedItems[0] is TabItem)) { Current.Gui.ErrorMessageBox(string.Format("Homework for the programmer: SelectionChangeHandler is not finalized with e.Handled=true")); e.Handled = true; goto end_of_function; } var tp = (TabItem)e.RemovedItems[0]; var cancelEventArgs = new System.ComponentModel.CancelEventArgs(); if (null != TabValidating) TabValidating(this, cancelEventArgs); shouldBeCancelled = cancelEventArgs.Cancel; if (shouldBeCancelled) _tabCtrl.SelectedItem = tp; } if (!shouldBeCancelled) { foreach (var it in e.RemovedItems) if (it is TabItem) ((TabItem)it).Content = null; if (null != PageChanged) { var tp = (TabItem)_tabCtrl.SelectedItem; PageChanged(tp.Name); } } end_of_function: --_tabControl_SelectionChanged_Calls; } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { Settings.Quit(this.SavedChanges, this, this.Load, e); }