コード例 #1
0
        /// <summary>
        /// callback - get the ControlDesignerInfo for the requested object
        /// </summary>
        /// <param name="component"></param>
        /// <returns></returns>
        ControlDesignerInfo GetControlDesignerInfo(object component)
        {
            object mgObject = ControlsMap.getInstance().GetObjectFromWidget(component);

            if (mgObject == null || !controlDesignerInfoDictionary.ContainsKey(mgObject)) //TMP - prevent subform exception yoel
            {
                return(null);
            }

            if (mgObject != null)
            {
                controlDesignerInfoDictionary[mgObject].PreviousPlacementBounds = EditorSupportingPlacementLayout.GetPlacementDifRect(component);
            }
            return(mgObject != null ? controlDesignerInfoDictionary[mgObject] : null);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="mapData"></param>
        internal void handleEvent(EventType type, Control sender, EventArgs e, MapData mapData)
        {
            MapData          orgMapData       = mapData;
            ContainerManager containerManager = GuiUtils.getContainerManager(sender);

            switch (type)
            {
#if !PocketPC
            case EventType.DRAG_OVER:
            case EventType.DRAG_DROP:
                // Need to get current Control, Hence needed
                Point pt     = new Point(((DragEventArgs)e).X, ((DragEventArgs)e).Y);
                Point screen = sender.PointToClient(pt);
                mapData = containerManager.HitTest(screen, true, false);
                break;
#endif
            case EventType.MOUSE_MOVE:
                // the mouse move will handle the tooltip
                mapData = containerManager.HitTest(new Point(((MouseEventArgs)e).X, ((MouseEventArgs)e).Y), true, false);
                break;

            case EventType.NCMOUSE_DOWN:
                MapData containerMapData = ControlsMap.getInstance().getMapData(sender);
                Events.OnMouseDown(containerMapData.getForm(), containerMapData.getControl(), null, true, 0, true, true);
                break;

            case EventType.MOUSE_DOWN:
                // check if a point on some table child
                // fixed bug #986057 (same in online)
                // * when pressing Rclick(button != 1) on Table or on the divider the Table's Context Menu will be
                // display( if press on other row no focus will move to the new row)
                // * when pressing Rclick exactly edit the context menu of the edit will be display and the focus
                // will move to the control
                bool LeftClickWasPressed = ((MouseEventArgs)e).Button == MouseButtons.Left;
                bool findExact           = (sender is TableControl && LeftClickWasPressed ? false : true);
                mapData = containerManager.HitTest(new Point(((MouseEventArgs)e).X, ((MouseEventArgs)e).Y), findExact, true);
                if (mapData != null)
                {
                    // Defect# 130085: When we click on a control (say checkbox) placed on table header, mouseDown is not needed to be processed.
                    // Actually, this is received from WM_PARENTNOTIFY from TableControl. This will avoid multiple ACT_CTRL_HIT on table header child
                    // control and Table control. Another option was to set WS_EX_NOPARENTNOTIFY style to table header child.
                    GuiMgControl mgControl = mapData.getControl();
                    if (mgControl.IsTableHeaderChild)
                    {
                        return;
                    }
                    // mark that we need to focus on the control
                    GuiUtils.saveFocusingControl(GuiUtils.FindForm(sender), mapData);
                }
                else if (sender is TableControl)
                {
                    GuiUtils.restoreFocus(GuiUtils.FindForm(sender));
                }
                break;

            case EventType.MOUSE_UP:
                // for mouse up we need control the has been clicked and not nearest control
                mapData = containerManager.HitTest(new Point(((MouseEventArgs)e).X, ((MouseEventArgs)e).Y), true, true);
                break;

            case EventType.MOUSE_DBLCLICK:
                if (!(sender is TableControl)) //TODO
                {
                    mapData = containerManager.HitTest(new Point(((MouseEventArgs)e).X, ((MouseEventArgs)e).Y), true, true);
                }
                break;

            case EventType.PRESS:
                findExact = !(sender is TableControl);
                // Mobile clients for which this event type is applicable must
                // pass actual press co-ords
                Point point = new Point(0, 0);
                mapData = containerManager.HitTest(point, findExact, true);
                if (mapData != null)
                {
                    GuiUtils.saveFocusingControl(GuiUtils.FindForm(sender), mapData);
                }
                break;

            case EventType.PAINT:
                if (containerManager is BasicControlsManager)
                {
                    ((BasicControlsManager)containerManager).Paint(((PaintEventArgs)e).Graphics);
                }
                break;

#if PocketPC
            case EventType.RESIZE:
                EditorSupportingPlacementLayout placementLayout1 = ((TagData)sender.Tag).PlacementLayout;
                if (placementLayout1 != null)
                {
                    LayoutEventArgs le = new LayoutEventArgs();
                    placementLayout1.layout(sender, le);
                }
                break;
#endif
            case EventType.LAYOUT:
                EditorSupportingPlacementLayout placementLayout = ((TagData)sender.Tag).PlacementLayout;
                if (placementLayout != null)
                {
                    placementLayout.layout(sender, (LayoutEventArgs)e);
                }
                break;

            case EventType.DISPOSED:
                containerManager.Dispose();
                break;
            }

            if (mapData == null)
            {
                mapData = orgMapData;
            }
            DefaultHandler.getInstance().handleEvent(type, sender, e, mapData);
        }
コード例 #3
0
ファイル: FormHandler.cs プロジェクト: rinavin/RCJS
        /// <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);
        }