/// <summary> /// returns true if there is a blocking batcj task above this one /// </summary> /// <param name="form"></param> /// <returns></returns> public static bool IsBlockedByMdiForm(GuiForm form) { long contextid = Manager.GetCurrentContextID(); List <GuiForm> formsList = null; if (forms.TryGetValue(contextid, out formsList)) { bool upperform = false; foreach (var item in formsList) { if (upperform) { //we found blocking batch that is child of current form if (item.ShouldBlockAnsestorActivation && !item.IsDisposed) { return(true); } } //go until we find out form in the list if (item == form) { upperform = true; } } } return(false); }
/// <summary> /// adds events for form /// </summary> /// <param name="form">gui form to which events are attached.</param> /// <param name="isHelpWindow">flag indicating window/form is help window or not.</param> internal void addHandler(GuiForm form) { form.Activated += ActivatedHandler; form.MouseDown += MouseDownHandler; form.MouseUp += MouseUpHandler; form.Closed += ClosedHandler; #if PocketPC form.Resize += ResizeHandler; #endif form.Disposed += DisposedHandler; form.KeyDown += KeyDownHandler; form.GotFocus += GotFocusHandler; #if !PocketPC form.Shown += ShownHandler; form.ResizeBegin += ResizeBeginHandler; form.ResizeEnd += ResizeEndHandler; form.Sizing += SizingHandler; form.Move += MoveHandler; form.Layout += LayoutHandler; form.MdiChildActivate += MdiChildActivatedHandler; form.DragOver += DragOverHandler; form.DragDrop += DragDropHandler; form.GiveFeedback += GiveFeedBackHandler; form.NCMouseDown += NCMouseDownHandler; form.NCActivate += NCActivateHandler; form.CopyData += CopyDataHandler; form.CanReposition += CanRepositionHandler; form.KeyPress += KeyPressHandler; #endif form.Load += LoadHandler; form.WMActivate += WMActivateHandler; }
private GuiForm CreateForm(Type formType) { GuiForm form = (GuiForm)Activator.CreateInstance(formType); RegisterForm(form); return(form); }
public void CloseGui() { // Close gui ActiveGui.OnClose(); // Restore parent gui ActiveGui = (GuiForm)ActiveGui.Parent; Mode = ActiveGui == null ? GameMode.InGame : GameMode.Gui; }
internal void OpenGui(GuiForm gui) { // Save parent gui.Parent = ActiveGui; // Open new gui ActiveGui = gui; gui.Show(); Mode = GameMode.Gui; }
/// <summary> /// Пытаемся получить форму. Если формы еще нет то создаем /// </summary> public GuiForm Get(Type type) { GuiForm form = null; if (forms.TryGetValue(type, out form)) { return(form); } return(CreateForm(type)); }
/// <summary> /// Инстанцируем форму /// </summary> /// <param name="form"></param> private void RegisterForm(GuiForm form) { GameObject formPrefab = Resources.Load <GameObject>(formPaths[form.PrefabName]); GameObject uiObj = UnityEngine.Object.Instantiate(formPrefab, mainCanvas) as GameObject; form.Init(uiObj); forms.Add(form.GetType(), form); }
/// <summary> /// add form to context /// </summary> /// <param name="form"></param> static public void AddForm(GuiForm form) { long contextid = Manager.GetCurrentContextID(); List <GuiForm> formsList = null; if (!forms.TryGetValue(contextid, out formsList)) { formsList = new List <GuiForm>(); forms[contextid] = formsList; } formsList.Add(form); }
/// <summary> /// returns true if form belongs to current context /// </summary> /// <param name="form"></param> /// <returns></returns> static public bool BelongsToCurrentContext(GuiForm form) { long contextid = Manager.GetCurrentContextID(); List <GuiForm> formsList = null; bool result = false; if (forms.TryGetValue(contextid, out formsList)) { result = formsList.Contains(form); } Debug.Assert(true); return(result); }
/// <summary> /// check is this form is last opened form of a context /// </summary> /// <param name="form"></param> /// <returns></returns> static public bool IsLastForm(GuiForm form) { long contextid = Manager.GetCurrentContextID(); List <GuiForm> formsList = null; if (forms.TryGetValue(contextid, out formsList)) { int index = formsList.IndexOf(form); return(index == formsList.Count - 1); } Debug.Assert(true); return(true); }
public void OpenForm(Type openType) { if (currentForm != null) { currentForm.Hide(); } currentForm = Get(openType); if (currentForm != null) { currentForm.Show(true); } }
/// <summary> /// remove form /// </summary> /// <param name="form"></param> static public void RemoveForm(GuiForm form) { long contextid = Manager.GetCurrentContextID(); List <GuiForm> formsList = null; if (forms.TryGetValue(contextid, out formsList)) { formsList.Remove(form); if (formsList.Count == 0) { forms.Remove(contextid); } } }
/// <summary> /// find next form of a context /// </summary> /// <param name="form"></param> /// <returns></returns> static public GuiForm GetNextForm(GuiForm form) { long contextid = Manager.GetCurrentContextID(); List <GuiForm> formsList = null; if (forms.TryGetValue(contextid, out formsList)) { int index = formsList.IndexOf(form) + 1; if (index < formsList.Count) { return(formsList[index]); } } return(null); }
/// <summary> /// move the form to be the last form in the context /// </summary> /// <param name="form"></param> public static void MoveToEnd(GuiForm form) { long contextid = Manager.GetCurrentContextID(); List <GuiForm> formsList = null; if (forms.TryGetValue(contextid, out formsList)) { int index = formsList.IndexOf(form); if (index < formsList.Count - 1) //not last form { formsList.Remove(form); formsList.Add(form); //move to the end } } }
/// <summary> /// get last child batch blocking this form /// </summary> /// <param name="form"></param> /// <returns></returns> public static GuiForm GetBlockingFormToActivate(GuiForm form) { long contextid = Manager.GetCurrentContextID(); List <GuiForm> formsList = null; if (forms.TryGetValue(contextid, out formsList)) { for (int i = formsList.Count - 1; i >= 0; i--) { GuiForm currentForm = formsList[i]; if (currentForm == form) //we checked all children of current form { break; } //we found blocking batch that is child of current form if (currentForm.ShouldBlockAnsestorActivation && !currentForm.IsDisposed) { return(currentForm); } } } return(null); }
private void OnWmActivate(GuiForm form, EventArgs e) { GuiForm lastForm = lastActiveTopLevelForm as GuiForm; System.TimeSpan timeFromActivation = DateTime.Now - form.ActivateAppTime; System.TimeSpan timeFromMouseActivation = DateTime.Now - form.MouseActivateAppTime; ActivateArgs args = (ActivateArgs)e; if (timeFromActivation.TotalMilliseconds < 200 && args.WmParam == NativeWindowCommon.MA_ACTIVATE && (timeFromMouseActivation.Milliseconds > 200)) // we are moving from another application //there was no click on the application { if (lastForm != null && lastForm != form && !lastForm.IsClosing && !ContextForms.IsLastForm(form) && //new from is opening ContextForms.BelongsToCurrentContext(lastForm)) //we are in the same context { if (!lastForm.IsMdiChild && !lastForm.IsMdiContainer) {//the solution is not for MDI windows args.StopActivation = true; lastForm.Activate(); } } } }
/* * (non-Javadoc) * For ContextMenu : MENU_OPENING replaces the SWT's MenuDetect. Since there is no such handler on a control, we needed a way * to block the system's menu and show nothing in case there was no context menu assigned by the user. We also need to decide on * the correct context menu before it opens. * We do that by assigning a new and empty context menu for each control that is created. * When the user right clicks on a control, the empty context (or a real context) shoots a MENU_OPENING. * In this point do a few things : * 1. If this is the 1st opening event for that click, we need to decide if that is the correct menu to be opened. * In case its the 2nd time, the 'ContextCanOpen' flag will be true, verifying that we don't need to check the menu. * 2. To check the menu we have separate methods for table controls and other controls. * each type will have its own 'handleContextMenu'. * * In table, if the clicked cell is already in edit mode, then the control we'll get here will be already a regular edit box. * 3. In case we have discovered that the correct menu to be showed is not the one that had sent us the 'OPENING' event, * we will cancel its opening and insteed we will set the 'ContextCanOpen' to true and call the ContextMenuStrip.Show ourselves. * That way the correct menu will be opened. */ internal override void handleEvent(EventType type, Object sender, EventArgs e) { MapData mapData; GuiMgForm guiMgForm = null; MenuReference menuRef = null; ControlsMap controlsMap; Manager.ContextIDGuard contextIDGuard = null; mapData = ControlsMap.getInstance().getMapData(sender); if (mapData != null) { menuRef = mapData.getMenuReference(); guiMgForm = menuRef.GetMgForm(); if (guiMgForm != null) { contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(guiMgForm)); } } try { switch (type) { // Only ContexMenuStrip and ToolStripMenuItem can be opened. A MenuStrip is never opened, only its childs which are items. // *** see also comment above. case EventType.MENU_OPENING: // only if the context itself is opening // the purpose is to determine the correct menu to be opened on the control. (substitude to the SWT.MENU_DETECT). if (sender is ContextMenuStrip && !((TagData)((ContextMenuStrip)sender).Tag).ContextCanOpen) { ContextMenuStrip contextMenu = (ContextMenuStrip)sender; Control control = contextMenu.SourceControl; GuiMgControl guiMgControl = null; controlsMap = ControlsMap.getInstance(); if (control is Form) { // in case of form control, the real control is its panel control = ((TagData)(control.Tag)).ClientPanel; } /*Defect 131535 : * After 3.1 the MDIClient is covered with a Panel with FitToMDI. * In the defect scenario when user presses the right click on online form and keeping the right click pressed drags the cursor to MDI form and then leaves the button * then, somehow we get the SourceControl of the context menu as MDIClient. * But the MDIClient is not saved in ControlsMap anymore. * In order to fix the problem whenever we get the SourceControl of context menu as MDIClient set it to MgPanel obtained from it's parent's (GuiForm) ClientPanel.*/ if (control is System.Windows.Forms.MdiClient) { GuiForm guiForm = (GuiForm)control.Parent; control = ((TagData)guiForm.Tag).ClientPanel; } ContainerManager containerManager = ((TagData)(control.Tag)).ContainerManager; if (containerManager is TableManager || containerManager is TreeManager || containerManager is BasicControlsManager) { // Use the mouse pos to determine in which row and column we are at. // We cannot use the contextMenu.Left\Top, since its not always the point from which the cursor was opened. // If the menu was opened via keyboard, we will not get here , since the control will be not table control but the cell control itself. Point MousePos = Control.MousePosition; // get the relative location on the menu within the container. Point pt = control.PointToClient(new Point(MousePos.X, MousePos.Y)); mapData = containerManager.HitTest(pt, true, true); if (mapData == null) { if (containerManager is TableManager) { GuiUtils.setTooltip(control, ""); } else { if (control is Panel && ((TagData)(control.Tag)).ContainerTabControl != null) { // in case its the tab panel, the control will be the tab control control = ((TagData)(control.Tag)).ContainerTabControl; } mapData = controlsMap.getMapData(control); } } } else { mapData = controlsMap.getMapData(control); } // Do not go in here if tableManager.handleContextMenu was executed. if (mapData != null) { bool focusChanged = false; guiMgControl = mapData.getControl(); bool onMultiMark = false; if (containerManager == null && ((TagData)control.Tag).IsEditor) { Object obj = controlsMap.object2Widget(guiMgControl, mapData.getIdx()); if (obj is LogicalControl) { containerManager = ((LogicalControl)obj).ContainerManager; } } if (containerManager is ItemsManager) { onMultiMark = ((ItemsManager)containerManager).IsItemMarked(mapData.getIdx()); } focusChanged = Events.OnBeforeContextMenu(guiMgControl, mapData.getIdx(), onMultiMark); //If the focus was changed, the control must have been saved as the focussing control. //So, remove it from here. if (focusChanged) { GuiUtils.removeFocusingControl(GuiUtils.FindForm(control)); } GuiUtils.setTooltip(control, ""); } // Cancel the opening of the context, as we will be handling it thr' event. ((CancelEventArgs)e).Cancel = true; // Add Event to Open a Context Menu, So, that it should be opened after the event added by // OnBeforeContextMenu event. int line = mapData != null?mapData.getIdx() : 0; // If right click in on table control and not any control attached to table control if (control is TableControl && guiMgControl == null) { guiMgControl = controlsMap.getMapData(control).getControl(); } // Invoke the event to open a context menu. Events.OnOpenContextMenu(guiMgControl, mapData != null ? mapData.getForm() : null, contextMenu.Left, contextMenu.Top, line); return; } else { mapData = ControlsMap.getInstance().getMapData(sender); if (mapData == null) { break; } menuRef = mapData.getMenuReference(); guiMgForm = menuRef.GetMgForm(); if (sender is MgToolStripMenuItem) { // This change is to improve performance of pulldown menu. When we apply modality, (while opening a batch task). // We just disable menu items on GuiMenuEntry. actual menu is diabled in .ent whe foreach (ToolStripItem item in ((ToolStripMenuItem)sender).DropDownItems) { if (item is MgToolStripMenuItem) { TagData tagData1 = (TagData)((MgToolStripMenuItem)item).Tag; GuiMenuEntry guiMenuEntry1 = tagData1.guiMenuEntry; if (!(guiMenuEntry1 is MenuEntryEvent || guiMenuEntry1 is MenuEntryMenu)) { if (guiMenuEntry1.getModalDisabled() && (item.Enabled == guiMenuEntry1.getModalDisabled())) { item.Enabled = false; } else if (!item.Enabled && (guiMenuEntry1.getEnabled() == true)) { item.Enabled = guiMenuEntry1.getEnabled(); } } } } // Create windowMenu items for MgToolStripMenuItem (Only sub-menus can define window menu) TagData tagData = (TagData)((MgToolStripMenuItem)sender).Tag; Events.InitWindowListMenuItems(guiMgForm, tagData.guiMenuEntry, tagData.MenuStyle); } } // we get here in 3 cases : // 1. ContextCanOpen is true. i.e. we have a confirmation to open. we are already in the recursive call. // 2. We are in the original opening, but this is the correct menu. // 3. This is a ToolStripMenuItem (i.e. not the context menu itself. //when opening a menu (pulldown or context), check if paste action //should be enabled/disabled. //Don't check for dummy, no need. also, if u try : getLastFocusedControl will throw exception since dummy don't have mapData. // Dummy is only relevant in context menu (not in drop down). if (!(sender is ContextMenuStrip && ((ContextMenuStrip)sender).Name == "Dummy")) { //Call to checkPasteEnable() was introduced for QCR# 241365 in Java RC. //This code is added for following situation: //If there are 3 fields a, b, c. Field C has modifiable = No. //If contex menu of fields a and b show paste as enabled, then the modifiable=no field will also show paste enabled... //and it shouldn't. //When we are on 3rd field, tab to another window and get back (to loose and regain focus) //now, the paste is disabled on c as it should...but tab to the other fields, now the paste is disabled for them as well. //to make paste enabled for Modifiable fields, this call is required here. GuiMgControl guiMgControl = getLastFocusedControl(sender); GuiUtils.checkPasteEnable(guiMgControl, true); } return; // Select event can happen ONLY on MenuItem, not on Menu. (see addHandler). case EventType.MENU_ITEM_SELECTED: onSelection(sender); break; case EventType.MOUSE_ENTER: onItemEnterLeave((ToolStripItem)sender, type); break; case EventType.MOUSE_LEAVE: onItemEnterLeave((ToolStripItem)sender, type); break; case EventType.CLOSED: if (sender is ContextMenuStrip) { ToolStrip menu = (ToolStrip)sender; if (((ContextMenuStrip)sender).Name == "Dummy") { break; } //Current context menu will be disposed , So, create the dummy context menu for control. Control control = ((TagData)menu.Tag).MouseDownOnControl; GuiUtils.setContextMenu(control, null); //Dispose context Menu. GuiMgMenu mgMenu = ((TagData)menu.Tag).GuiMgMenu; Events.OnContextMenuClose(menuRef.GetMgForm(), mgMenu); } break; case EventType.DISPOSED: controlsMap = ControlsMap.getInstance(); GuiMenuEntry guiMenuEntry = null; if (sender is ContextMenuStrip && ((ContextMenuStrip)sender).Name == "Dummy") { break; } mapData = controlsMap.getMapData(sender); if (mapData == null) { break; } menuRef = mapData.getMenuReference(); guiMgForm = menuRef.GetMgForm(); if (guiMgForm != null) { if (sender is ToolStripItem) { ToolStripItem menuItem = (ToolStripItem)sender; MenuStyle menuStyle = ((TagData)menuItem.Tag).MenuStyle; guiMenuEntry = ((TagData)menuItem.Tag).guiMenuEntry; guiMenuEntry.removeMenuIsInstantiated(guiMgForm, menuStyle); //if (menuEntry is MenuEntryMenu) // menuEntry.removeInstantiatedMenuItems(mgForm, menuStyle); if ((guiMenuEntry.ImageFile != null) && menuItem.Image != null) { menuItem.Image.Dispose(); } menuItem.Tag = null; } else if (sender is ToolStrip) { ToolStrip menu = (ToolStrip)sender; MenuStyle menuStyle = ((TagData)menu.Tag).MenuStyle; if (((TagData)menu.Tag).GuiMgMenu != null) { GuiMgMenu mgMenu = ((TagData)menu.Tag).GuiMgMenu; mgMenu.removeInstantiatedMenu(guiMgForm, menuStyle); } //else if (((TagData)menu.Tag).menuEntry != null) //{ // MenuEntry mgMenu = ((TagData)menu.Tag).menuEntry; // menuEntry.removeInstantiatedMenuItems(mgForm, menuStyle); //} menu.Tag = null; } } if (menuRef != null) { Object fromMap = controlsMap.object2Widget(menuRef); if (fromMap != null) { controlsMap.remove(menuRef); } } break; case EventType.KEY_DOWN: { if (((KeyEventArgs)e).KeyCode == Keys.F1) { ToolStrip menu = (ToolStrip)sender; foreach (ToolStripItem menuItem in menu.Items) { if (menuItem.CanSelect && menuItem.Selected) { guiMenuEntry = ((TagData)menuItem.Tag).guiMenuEntry; if (guiMenuEntry.Help > 0) { if (menu.IsDropDown) { // Defect Id 115414: If help is opened then menu needs to be closed. After closing the menu focus should not be on the menu. // Same like when menu is clicked.ToolStripDropDownCloseReason.ItemClicked option closes the menu and // focus does not remains on the menu. ((ToolStripDropDownMenu)menu).Close(ToolStripDropDownCloseReason.ItemClicked); } Events.OnHelpInVokedOnMenu(guiMenuEntry, ((TagData)menuItem.Tag).MapData.getMenuReference().GetMgForm()); break; } } } } else { if (MnemonicHelper.HandleMnemonicForHebrew((ToolStrip)sender, (char)((KeyEventArgs)e).KeyCode)) { ((KeyEventArgs)e).Handled = true; } } } break; default: System.Console.Out.WriteLine(type.ToString()); break; } } finally { if (contextIDGuard != null) { contextIDGuard.Dispose(); } } }
/// <summary> /// Adds closing handler to the form. Since a .NET control may hook closing event of its container form, /// this handler should be added after creating all controls in the form so that the handler will be /// the last one to execute. /// </summary> /// <param name="control">form to which handlers are attached.</param> internal void addClosingHandler(GuiForm form) { form.Closing += ClosingHandler; }
/// <summary> /// Register Dectivate Event Handler. /// </summary> /// <param name="form"></param> internal void addDeActivatedHandler(GuiForm form) { form.Deactivate += DeActivatedHandler; }
/// <summary> /// Register Activate Event Handler for Main Program Form. /// </summary> /// <param name="form"></param> internal void addMainProgramMDIFormActivatedHandler(GuiForm form) { // Avoid getting the form to foreground (hiding other MDI children) form.Activated += sendToBack; }
/// <summary> /// /// </summary> /// <param name="type"></param> /// <param name="sender"></param> /// <param name="e"></param> internal override void handleEvent(EventType type, Object sender, EventArgs e) { Control clientPanel; MapData mapData; GuiMgForm guiMgForm; // When modal window is opened and if we close the form Modal form using external event (i.e. Stop RTE from studio / Exit System event) // We are getting closed event 2 times for a modal window : // 1) First time from GuiCommandsQueue.closeForm() due to form.close() and // 2) We are not able to figure out from where we are getting the second closed event. // When we come here to process closed event second time the object is already disposed, hence we should not process any events. if (GuiUtils.isDisposed((Control)sender)) { return; } clientPanel = ((TagData)((Control)sender).Tag).ClientPanel; if (clientPanel == null) { clientPanel = (Control)sender; } mapData = ControlsMap.getInstance().getMapData(clientPanel); guiMgForm = mapData.getForm(); GuiForm form = (GuiForm)sender; var contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(guiMgForm)); try { switch (type) { case EventType.LOAD: #if !PocketPC // #919192: Icon displayed for an maximised MDI Child is not the one set in // form's Icon property before loading the form. // This is a framework bug. The workaround is to set the icon for Maximised MDI Child again in load handler. if (form.IsMdiChild && form.WindowState == FormWindowState.Maximized) { Icon originalIcon = form.Icon; form.Icon = null; form.Icon = originalIcon; } ContextForms.AddForm(form); #endif form.Activate(); break; case EventType.CAN_REPOSITION: if (form.IsMdiChild && OldZorderManager.getInstance().UseOldZorderAlgorithm) { if (!ContextForms.IsLastForm(form)) { GuiForm nextForm = ContextForms.GetNextForm(form); if (nextForm.Handle != ((RepositionEventArgs)e).HwndInsertAfter) { ((RepositionEventArgs)e).CanReposition = false; } } } break; case EventType.ACTIVATED: //ClientManager.Instance.RefreshMenu(mgForm.getTask().getMgdID()); OnFormActivate(form); //Defect 124155 - if form is ancestor to blocking batch form - return activation to the batch if (form.IsMdiChild && ContextForms.IsBlockedByMdiForm(form)) { GuiForm formToActivate = ContextForms.GetBlockingFormToActivate(form); if (formToActivate != null && !formToActivate.IsClosing) { formToActivate.Activate(); } } break; case EventType.WMACTIVATE: OnWmActivate(form, e); break; #if !PocketPC case EventType.SHOWN: if (form.WindowState == FormWindowState.Normal && ((TagData)form.Tag).WindowType != WindowType.FitToMdi && ((TagData)form.Tag).WindowType != WindowType.Sdi && ((TagData)form.Tag).WindowType != WindowType.MdiFrame) { Rectangle?savedbounds = GuiUtils.getSavedBounds(form); if (savedbounds != null) { Rectangle rect = (Rectangle)savedbounds; if (rect.Size != form.ClientSize) { GuiUtils.setBounds(form, rect); } } } GuiUtils.saveFormBounds(form); form.Resize += FormHandler.getInstance().ResizeHandler; // form is shown, so set the flag as false PrintPreviewFocusManager.GetInstance().IsInModalFormOpening = false; ((TagData)form.Tag).IsShown = true; break; #endif case EventType.MDI_CHILD_ACTIVATED: Events.OnFormActivate(guiMgForm); break; case EventType.RESIZE: if (((TagData)form.Tag).IgnoreWindowResizeAndMove) { return; } onResize(form, guiMgForm); break; case EventType.RESIZE_BEGIN: OnResizeBegin(form); break; case EventType.RESIZE_END: OnResizeEnd(form); break; case EventType.LAYOUT: #if !PocketPC if (GuiUtils.IsFormMinimized(form)) { ((TagData)form.Tag).Minimized = true; } else if (!((TagData)form.Tag).IsShown) { ((TagData)form.Tag).Minimized = false; } #endif if (((TagData)form.Tag).WindowType == WindowType.Sdi) { SDIFormLayout(form); } return; case EventType.SIZING: OnSizing(form, (SizingEventArgs)e); break; #if !PocketPC //tmp case EventType.COPY_DATA: Events.OnCopyData(guiMgForm, ((CopyDataEventArgs)e).Copydata); return; case EventType.MOVE: if (((TagData)form.Tag).WindowType == WindowType.ChildWindow) { Control parent = form.Parent; Debug.Assert(parent is Panel); Form parentform = GuiUtils.FindForm(parent); if (GuiUtils.IsFormMinimized(parentform)) { return; } EditorSupportingPlacementLayout placementLayout = ((TagData)parent.Tag).PlacementLayout; if (placementLayout != null) { //TODO: If the child window is moved due to scrolling of the parent window, //computeAndUpdateLogicalSize() should not be called. placementLayout.computeAndUpdateLogicalSize(parent); } } if (((TagData)form.Tag).IgnoreWindowResizeAndMove) { return; } onMove(form, guiMgForm); break; #endif case EventType.CLOSING: //handle the event only if it was not canceled. if (((CancelEventArgs)e).Cancel == false) { bool clrHandledEvent = false; #if !PocketPC //When MDI Frame is closing, We should not put ACT_EXIT on each it's child windows. //This causes invokation of confirmation dialog, which should be avoided. WindowType windowType = ((TagData)form.Tag).WindowType; if (((FormClosingEventArgs)e).CloseReason == System.Windows.Forms.CloseReason.MdiFormClosing && (windowType == WindowType.MdiChild || windowType == WindowType.FitToMdi)) { return; } #endif clrHandledEvent = Events.OnFormClose(guiMgForm); #if !PocketPC //tmp // If CloseReason is UserClosing, then only set Cancel. if (((FormClosingEventArgs)e).CloseReason == System.Windows.Forms.CloseReason.UserClosing) #endif //If clrHandledEvent is true then 'Cancel' should be false else true. ((CancelEventArgs)e).Cancel = !clrHandledEvent; } return; case EventType.CLOSED: #if PocketPC GUIMain.getInstance().MainForm.closeSoftKeyboard(); #endif break; case EventType.NCMOUSE_DOWN: if (!IsClickOnCloseButton((NCMouseEventArgs)e)) { #if !PocketPC // QCR #414516. Click on title bar mustn't move cursor to the parent task. Form previousActiveForm = Form.ActiveForm ?? lastActiveTopLevelForm; //defect 120508 : if the form was already active - we should not process the mouse down if (GuiUtils.FindTopLevelForm(form) != previousActiveForm) #endif Events.OnMouseDown(guiMgForm, null, null, true, 0, true, true); } break; case EventType.NCACTIVATE: Events.OnNCActivate(guiMgForm); break; case EventType.DISPOSED: Events.OnDispose(guiMgForm); ContextForms.RemoveForm(form); clientPanel.Tag = null; form.Tag = null; return; case EventType.DEACTIVATED: Events.OnCloseHelp(guiMgForm); break; #if PocketPC case EventType.KEY_DOWN: // Key event preview - KeyDown with 'tab' key is usually used by the system to move the focus // between controls. We want to do it ourselves, so we intercept it here and pass it to the control // in focus. if (((KeyEventArgs)e).KeyCode == Keys.Tab) { // get the tagdata and look for the control that has the focus TagData tagData = (TagData)((Control)sender).Tag; // If the control is one of those for which we need to raise the event, aise it and mark the // event as handled. if (tagData.LastFocusedControl is MgTextBox) { ((MgTextBox)tagData.LastFocusedControl).CallKeyDown((KeyEventArgs)e); ((KeyEventArgs)e).Handled = true; } else if (tagData.LastFocusedControl is MgCheckBox) { ((MgCheckBox)tagData.LastFocusedControl).CallKeyDown((KeyEventArgs)e); ((KeyEventArgs)e).Handled = true; } else if (tagData.LastFocusedControl is MgComboBox) { ((MgComboBox)tagData.LastFocusedControl).CallKeyDown((KeyEventArgs)e); ((KeyEventArgs)e).Handled = true; } else if (tagData.LastFocusedControl is MgButtonBase) { ((MgButtonBase)tagData.LastFocusedControl).CallKeyDown((KeyEventArgs)e); ((KeyEventArgs)e).Handled = true; } else if (tagData.LastFocusedControl is MgTabControl) { ((MgTabControl)tagData.LastFocusedControl).CallKeyDown((KeyEventArgs)e); ((KeyEventArgs)e).Handled = true; } } return; #endif } } finally { contextIDGuard.Dispose(); } DefaultHandler.getInstance().handleEvent(type, sender, e, mapData); }