Exemplo n.º 1
0
        /// <summary>
        /// Activates Print Preview form
        /// </summary>
        void OnActivatePrintPreview()
        {
#if !PocketPC
            Form printPreviewForm = (Form)Control.FromHandle(PrintPreviewFocusManager.GetInstance().PrintPreviewFormHandle);
            printPreviewForm.Activate();
#endif
        }
Exemplo n.º 2
0
        /// <summary> Handle form activation. </summary>
        /// <param name="form">the form being activated.</param>
        internal void OnFormActivate(Form form)
        {
#if PocketPC
            // if forms were hidden, we need to show all the forms
            if (!form.Visible)
            {
                GUIManager.Instance.restoreHiddenForms();
            }
#else
            if (PrintPreviewFocusManager.GetInstance().ShouldResetPrintPreviewInfo)
            {
                PrintPreviewFocusManager.GetInstance().ShouldPrintPreviewBeFocused = false;
                PrintPreviewFocusManager.GetInstance().PrintPreviewFormHandle      = IntPtr.Zero;
            }

            // #943264 & 942768. Fixed a .net Framework issue.
            // Suppose, we have a window with a user control (with a child control inside it).
            // When parking on this child control, we open another window.
            // Now, if we close the new window, the focus should be back on the last
            // focused control i.e. the child control in this case.
            // But, this happens only if the widows are opened outside the MDI frame.
            // If they are opened inside the MDI frame, the focus is not set on the child control.
            // So, we need to explicitly set the focus on the last focused control.
            Form activeForm = ((TagData)form.Tag).ActiveChildWindow ?? form;

            if (activeForm.IsMdiContainer)
            {
                Form activeMDIChild = GuiUtils.GetActiveMDIChild(activeForm);
                if (activeMDIChild != null)
                {
                    activeForm = activeMDIChild;
                }
            }

            GuiUtils.restoreFocus(activeForm);
            lastActiveTopLevelForm = GuiUtils.FindTopLevelForm(activeForm);

            Control clientPanel = ((TagData)form.Tag).ClientPanel;
            if (((TagData)form.Tag).IsMDIClientForm)
            {
                clientPanel = ((TagData)form.MdiParent.Tag).ClientPanel;
            }


            MapData mapData = ControlsMap.getInstance().getMapData(clientPanel);
            Events.OnFormActivate(mapData.getForm());

            if (PrintPreviewFocusManager.GetInstance().IsInModalFormOpening)
            {
                PrintPreviewFocusManager.GetInstance().ShouldResetPrintPreviewInfo = true;
            }
#endif
        }
Exemplo n.º 3
0
        /// <summary>
        /// Closes Print Preview form
        /// </summary>
        void onClose()
        {
#if !PocketPC
            Events.OnPrintPreviewClose(_printPreviewData.intPtr2);
            Control control = Control.FromHandle(_printPreviewData.intPtr1);
            if (control is Form)
            {
                ((Form)control).Dispose();
            }
            PrintPreviewFocusManager.GetInstance().ShouldPrintPreviewBeFocused = false;
            PrintPreviewFocusManager.GetInstance().PrintPreviewFormHandle      = IntPtr.Zero;
#endif
        }
Exemplo n.º 4
0
        /// <summary>
        ///  Shows Print Preview Form
        /// </summary>
        void onShow()
        {
#if !PocketPC
            Control control = Control.FromHandle(_printPreviewData.intPtr1);
            if (control is Form)
            {
                // Save last print preview form to be activated when task aborts. This is later used to activate the form.
                PrintPreviewFocusManager.GetInstance().PrintPreviewFormHandle      = _printPreviewData.intPtr1;
                PrintPreviewFocusManager.GetInstance().ShouldPrintPreviewBeFocused = true;
                ((Form)control).Show();
                ((Form)control).Focus();
            }
#endif
        }
Exemplo n.º 5
0
 public void Dispose()
 {
     PrintPreviewFocusManager.GetInstance().ShouldResetPrintPreviewInfo = true;
 }
Exemplo n.º 6
0
 public PrintPreviewInfoResetGuard()
 {
     PrintPreviewFocusManager.GetInstance().ShouldResetPrintPreviewInfo = false;
 }
Exemplo n.º 7
0
        /// <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);
        }