Пример #1
0
            /// <summary>
            ///   set the command to resize form of browser control
            /// </summary>
            /// <param name = "formRectVal">new dimensions of the form</param>
            internal void ResizeWindow(MgRectangle formRectVal)
            {
                _commandType = COMMAND.RESIZE_WINDOW;
                _formRect    = formRectVal;

                GUIMain.getInstance().invoke(new BrowserInteractiveDelegate(Run));
            }
Пример #2
0
        /// <summary>(public)
        /// finds position of control (in pixels) on the form</summary>
        /// <param name = "task">which consists the control </param>
        /// <param name = "opCode">operation code(EXP_OP_CTRL_LEFT|TOP|WIDTH|HEIGHT) </param>
        /// <param name = "ctrlName">name of the control, null if the controls name is not known </param>
        /// <returns> get the parameter of the control.If the control isn't defined yet, the 0 returned. </returns>
        public static int GetControlFocusedData(TaskBase task, int opCode, String ctrlName)
        {
            int res = 0;

            if (task.getForm() != null)
            {
                MgControlBase lastFocCtrl;
                if (string.IsNullOrEmpty(ctrlName))
                {
                    lastFocCtrl = task.getLastParkedCtrl();
                    if (lastFocCtrl == null)
                    {
                        return(0);
                    }
                    // get real, HTML name of control, (if repeatable -> with "_Number_of_line" suffix)
                    ctrlName = lastFocCtrl.getName();
                }

                lastFocCtrl = task.getForm().GetCtrl(ctrlName);
                if (lastFocCtrl != null)
                {
                    var controlRect = new MgRectangle(0, 0, 0, 0);
                    Commands.getBounds(lastFocCtrl, controlRect);

                    // Return the value wanted
                    switch (opCode)
                    {
                    case ExpressionInterface.EXP_OP_CTRL_CLIENT_CX:
                        res = task.getForm().pix2uom(controlRect.x, true);
                        break;

                    case ExpressionInterface.EXP_OP_CTRL_CLIENT_CY:
                        res = task.getForm().pix2uom(controlRect.y, false);
                        break;

                    case ExpressionInterface.EXP_OP_CTRL_WIDTH:
                        res = task.getForm().pix2uom(controlRect.width, true);
                        break;

                    case ExpressionInterface.EXP_OP_CTRL_HEIGHT:
                        res = task.getForm().pix2uom(controlRect.height, false);
                        break;
                    }
                }
            }
            return(res);
        }
Пример #3
0
        /// <summary>
        /// get the saved form bounds of form with 'userStateId'
        /// </summary>
        /// <param name="userStateId">userStateId of the form</param>
        /// <returns>the form bounds</returns>
        public MgRectangle GetFormBounds(string userStateId)
        {
            Debug.Assert(_xmlDoc != null); // FormUserState.Read must be called on process' initialization.

            var rect = new MgRectangle();

            try
            {
                // get the form node
                List <XmlElement> nodes = XmlServices.getMatchingChildrens(_xmlDoc.DocumentElement, STR_FORM, TAG_ID,
                                                                           userStateId);
                if (nodes.Count == 0)
                {
                    return(rect);
                }

                XmlElement formNode = nodes[0];

                // traverse through all child node of form node and get the saved propVal and apply
                foreach (XmlElement currEle in formNode.ChildNodes)
                {
                    if (currEle.Name == STR_LEFT)
                    {
                        rect.x = int.Parse(currEle.GetAttribute(TAG_VALUE)); // read val
                    }
                    else if (currEle.Name == STR_TOP)
                    {
                        rect.y = int.Parse(currEle.GetAttribute(TAG_VALUE)); // read val
                    }
                    else if (currEle.Name == STR_WIDTH)
                    {
                        rect.width = int.Parse(currEle.GetAttribute(TAG_VALUE)); // read val
                    }
                    else if (currEle.Name == STR_HEIGHT)
                    {
                        rect.height = int.Parse(currEle.GetAttribute(TAG_VALUE)); // read val
                    }
                }
            }
            catch (Exception exception)
            {
                Events.WriteExceptionToLog(exception);
            }

            return(rect);
        }
Пример #4
0
        /// <summary>(public)
        /// gets size properties of window
        /// </summary>
        /// <param name = "form">form</param>
        /// <param name = "prop">dimension needed: 'X', 'Y', 'W', 'H' </param>
        /// <returns> size in pixels </returns>
        public static int WinPropGet(MgFormBase form, char prop)
        {
            int res = 0;

            var controlRect = new MgRectangle(0, 0, 0, 0);

            if (form.isSubForm())
            {
                Object ctrl = form.getSubFormCtrl();
                Commands.getBounds(ctrl, controlRect);
            }
            else if (!form.Opened)
            {
                controlRect = Property.getOrgRect(form);
            }
            else
            {
                Commands.getClientBounds(form, controlRect, false);
            }

            // Return the value wanted
            switch (prop)
            {
            case 'X':
                res = form.pix2uom(controlRect.x, true);
                break;

            case 'Y':
                res = form.pix2uom(controlRect.y, false);
                break;

            case 'W':
                res = form.pix2uom(controlRect.width, true);
                break;

            case 'H':
                res = form.pix2uom(controlRect.height, false);
                break;
            }

            return(res);
        }
Пример #5
0
        /// <summary>
        /// Called by BrowserWindowLoading event handler, and handles the event raised by WebBrowser
        /// </summary>
        /// <param name="sender">WebBrowser</param>
        /// <param name="e"></param>
        protected override void BrowserWindowLoading_specific(object sender, EventArgs e)
        {
            Logger.Instance.WriteServerToLog("AuthenticationBrowserWindow.BrowserWindowLoading_specific() started");

            isAuthHandlerBrowserWindowOpen = true;

            MgRectangle authFormRect = FormUserState.GetInstance().GetFormBounds(AUTHENTICATION_FORM_STATE_ID);

            if (authFormRect != null && !authFormRect.IsEmpty)
            {
                Logger.Instance.WriteServerToLog("AuthenticationBrowserWindow.BrowserWindowLoading_specific(): read form bounds. X = " + authFormRect.x + ", Y = " + authFormRect.y + ", Width X Height " + authFormRect.width + "X" + authFormRect.height);
                FormRect = authFormRect;
            }
            else
            {
                Logger.Instance.WriteServerToLog("AuthenticationBrowserWindow.BrowserWindowLoading_specific(): could not read form bounds. Using the default values.");
            }
            //else, e.g. the first time, the window won't be resized

            Logger.Instance.WriteServerToLog("AuthenticationBrowserWindow.BrowserWindowLoading_specific() finished");
        }
Пример #6
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="rect">MgRectangle object describing the window boundaries</param>
 internal AuthenticationBrowserWindow(MgRectangle rect) : base(rect)
 {
 }
Пример #7
0
 /// <summary>
 ///   CTOR
 /// </summary>
 /// <param name = "rect">dimensions of browser window</param>
 public BrowserWindow(MgRectangle rect)
 {
     FormRect = rect;
 }
Пример #8
0
        /// <summary>
        ///   read form-state of the form, and applies them
        /// </summary>
        /// <param name = "mgform"></param>
        internal void Apply(MgFormBase mgform)
        {
            try
            {
                // When opening the MDI form, use the details of the previous MDI form, if available.
                //This details have preference over the current form's persistent state.
                if (mgform.getTask().isMainProg() && mdiFormDetails != null)
                {
                    ApplyFormBounds(mgform, mdiFormDetails.rect.Left, mdiFormDetails.rect.Top, mdiFormDetails.rect.Width, mdiFormDetails.rect.Height, mdiFormDetails.windowState);
                    return;
                }

                XmlElement formNode = GetNode(mgform);
                if (formNode == null)
                {
                    return;
                }

                Int32 oldPersistentFormStateVersion = 0;
                Int32.TryParse(formNode.GetAttribute(TAG_Version), out oldPersistentFormStateVersion);

                if (oldPersistentFormStateVersion != mgform.getProp(PropInterface.PROP_TYPE_PERSISTENT_FORM_STATE_VERSION).GetComputedValueInteger())
                {
                    return;
                }

                // QCR # 734135, check if form has no data to apply. All child elements are control tags.
                List <XmlElement> childNodes = XmlServices.getMatchingChildrens(formNode, STR_CONTROL, null, null);
                if (formNode.ChildNodes.Count == childNodes.Count)
                {
                    return;
                }

                XmlElement framesetsNode = null;
                XmlElement tableNode = null;
                int        left = 0, top = 0, width = 0, height = 0;
                int        startupStyle = 0;

                // traverse through all child node of form node and get the saved propVal and apply
                foreach (XmlElement currEle in formNode.ChildNodes)
                {
                    if (currEle.Name == STR_STARTUP_STYLE)
                    {
                        startupStyle = int.Parse(currEle.GetAttribute(TAG_VALUE));
                    }
                    else if (currEle.Name == STR_LEFT)
                    {
                        left = int.Parse(currEle.GetAttribute(TAG_VALUE)); // read val
                    }
                    else if (currEle.Name == STR_TOP)
                    {
                        top = int.Parse(currEle.GetAttribute(TAG_VALUE)); // read val
                    }
                    else if (currEle.Name == STR_WIDTH)
                    {
                        width = int.Parse(currEle.GetAttribute(TAG_VALUE)); // read val
                    }
                    else if (currEle.Name == STR_HEIGHT)
                    {
                        height = int.Parse(currEle.GetAttribute(TAG_VALUE)); // read val
                    }
                    else if (currEle.Name == STR_FRAMESETS)
                    {
                        framesetsNode = currEle;
                    }
                    else if (currEle.Name == STR_TABLECOLS)
                    {
                        tableNode = currEle;
                    }
                }

                // donot apply form coordinates for nested forms
                if (!mgform.isSubForm() && !mgform.IsChildWindow)
                {
                    //If the left-top corner is beyond the screen boundaries, ignore it.
                    if (!mgform.IsMDIChild)
                    {
                        MgRectangle rect = new MgRectangle();
                        Commands.getDesktopBounds(rect, null);

                        if (left >= rect.width)
                        {
                            left = GuiConstants.DEFAULT_VALUE_INT;
                        }
                        if (top >= rect.height)
                        {
                            top = GuiConstants.DEFAULT_VALUE_INT;
                        }
                    }

                    ApplyFormBounds(mgform, left, top, width, height, startupStyle);
                }

                // apply framesets
                if (framesetsNode != null)
                {
                    ApplyFramesetsProp(framesetsNode, mgform);
                }

                // apply table
                if (tableNode != null)
                {
                    ApplyTableProp(tableNode, mgform);
                }

                // #924756 - do not apply top left width height if the property has an expression attached
                if (startupStyle != Styles.WINDOW_STATE_MAXIMIZE && !mgform.IsChildWindow)
                {
                    mgform.RefreshPropertyByExpression(PropInterface.PROP_TYPE_LEFT);
                    mgform.RefreshPropertyByExpression(PropInterface.PROP_TYPE_TOP);
                    mgform.RefreshPropertyByExpression(PropInterface.PROP_TYPE_WIDTH);
                    mgform.RefreshPropertyByExpression(PropInterface.PROP_TYPE_HEIGHT);
                }
            }
            catch (Exception exception)
            {
                Events.WriteExceptionToLog(exception);
            }
        }