예제 #1
0
        /// <summary>
        /// </summary>
        /// <param name = "mgform"></param>
        internal void ApplyDefault(MgFormBase mgform)
        {
            // if is a main window
            if (!mgform.isSubForm() && !mgform.IsChildWindow)
            {
                mgform.getProp(PropInterface.PROP_TYPE_WIDTH).RefreshDisplay(true);
                mgform.getProp(PropInterface.PROP_TYPE_HEIGHT).RefreshDisplay(true);

                mgform.startupPosition(); // positions x,y

                mgform.getProp(PropInterface.PROP_TYPE_STARTUP_MODE).RefreshDisplay(true);
            }

            // restore width/height of frames in framesets
            if (mgform.IsFrameSet)
            {
                List <MgControlBase> frameSetCtrls = mgform.getCtrls(MgControlType.CTRL_TYPE_FRAME_SET);

                foreach (MgControlBase frameset in frameSetCtrls)
                {
                    var widthList  = new List <int>();
                    var heightList = new List <int>();

                    foreach (MgControlBase childCtrl in frameset.getLinkedControls())
                    {
                        widthList.Add(childCtrl.getProp(PropInterface.PROP_TYPE_WIDTH).getValueInt());
                        heightList.Add(childCtrl.getProp(PropInterface.PROP_TYPE_HEIGHT).getValueInt());
                    }

                    Commands.addAsync(CommandType.SET_FRAMES_WIDTH, frameset, 0, widthList);
                    Commands.addAsync(CommandType.SET_FRAMES_HEIGHT, frameset, 0, heightList);

                    // execute layout of the frameset
                    Commands.addAsync(CommandType.EXECUTE_LAYOUT, frameset, true);
                }
            }

            // restore order of columns in table
            if (mgform.isLineMode())
            {
                var columnData = new List <int>(); // {layer}
                List <MgControlBase> columnCtrls = mgform.getColumnControls();

                for (int idx = 0;
                     idx < columnCtrls.Count;
                     idx++)
                {
                    MgControlBase columnCtrl = columnCtrls[idx];
                    columnCtrl.getProp(PropInterface.PROP_TYPE_WIDTH).RefreshDisplay(true);
                    columnData.Add(idx);
                }

                Commands.addAsync(CommandType.RESTORE_COLUMNS, mgform.getTableCtrl(), 0, columnData);
            }

            // apply default of all subforms (if any).
            List <MgControlBase> subformCtrls = mgform.getCtrls(MgControlType.CTRL_TYPE_SUBFORM);

            if (subformCtrls.Count > 0)
            {
                foreach (MgControlBase subformControl in subformCtrls)
                {
                    MgFormBase subformForm = subformControl.GetSubformMgForm();
                    if (subformForm != null)
                    {
                        ApplyDefault(subformForm);
                    }
                }
            }
        }