Exemple #1
0
 ///<summary>Returns list of SheetFieldDefs for the given sheetFieldLayoutMode.
 ///Orders the list exactly in the same order that it is drawn.</summary>
 public List <SheetFieldDef> GetPertinentSheetFieldDefs(SheetFieldLayoutMode sheetFieldLayoutMode)
 {
     return(_sheetDefDynamicLayoutCur.SheetFieldDefs.Where(x => x.LayoutMode == sheetFieldLayoutMode)
            .OrderByDescending(x => x.FieldType == SheetFieldType.Grid) //Grids First
            .ThenBy(x => x.FieldName.Contains("Button"))                //Buttons last, always drawn on top.
            .ToList());
 }
Exemple #2
0
        ///<summary>Reloads the control with any new sheet layouts available.
        ///This should only be called if a dynamic sheetDef was added/modified/deleted, the SheetLayoutMode has changed, or a new user signed in.</summary>
        public void ReloadSheetLayout(SheetFieldLayoutMode sheetFieldLayoutMode, Dictionary <string, Control> dictionaryControls)
        {
            long practiceDefaultSheetDefNum = PrefC.GetLong(PrefName.SheetsDefaultChartModule);

            ListSheetDefsLayout = SheetDefs.GetCustomForType(_sheetType);
            ListSheetDefsLayout.Add(SheetsInternal.GetSheetDef(SheetsInternal.GetInternalType(_sheetType))); //Internal at bottom of list. UI reflects this too.
            ListSheetDefsLayout = ListSheetDefsLayout
                                  .OrderBy(x => x.SheetDefNum != practiceDefaultSheetDefNum)                 //practice default sheetdef should be at the top of the list
                                  .ThenBy(x => x.SheetDefNum == 0)                                           //if the internal sheetdef is not the default it should be last
                                  .ThenBy(x => x.Description)                                                //order custom sheetdefs by description
                                  .ThenBy(x => x.SheetDefNum).ToList();                                      //then by SheetDefNum to be deterministic order
            InitLayoutForSheetDef(GetLayoutForUser(), sheetFieldLayoutMode, dictionaryControls, true);       //Force refresh in case they edit current layout.
        }
Exemple #3
0
        ///<summary>Uses the given sheetDef to set the location, size, and anchors for dynamic controls.
        ///Usually only called from outside base DynamicLayoutControl when UI is switching to a different layout sheetDef.
        ///Set isUserSelection true in order to save the current layout to the user's preference override.</summary>
        public void InitLayoutForSheetDef(SheetDef sheetDef, SheetFieldLayoutMode sheetFieldLayoutMode, Dictionary <string, Control> dictionaryControls
                                          , bool isForcedRefresh = false, bool isUserSelection = false)
        {
            _hasUserLoggedOff = false;          //At this point we are showing the chart module to a user, reset.
            _userNumCur       = Security.CurUser.UserNum;
            _clinicNumCur     = Clinics.ClinicNum;
            if (!isForcedRefresh && _sheetDefDynamicLayoutCur != null && sheetDef.SheetDefNum == _sheetDefDynamicLayoutCur.SheetDefNum)
            {
                //Not forcing a refresh and _dynamicLayoutCur and sheetDef are the same sheet. No point in re-running logic.  Prevents flicker.
                return;
            }
            _sheetDefDynamicLayoutCur = sheetDef;
            if (_sheetDefDynamicLayoutCur.SheetDefNum != 0)           //0 represents an internal sheetDef, internal sheet defs do not need their field and params set.
            {
                SheetDefs.GetFieldsAndParameters(_sheetDefDynamicLayoutCur);
            }
            List <SheetFieldDef> listSheetFieldDefs  = GetPertinentSheetFieldDefs(sheetFieldLayoutMode);
            List <Control>       listDynamicControls = new List <Control>();

            foreach (SheetFieldDef fieldDef in listSheetFieldDefs)
            {
                Control control = GetControlForField(fieldDef, dictionaryControls);
                if (control == null)
                {
                    continue;                    //For example, HQ only controls when running from customer location.
                }
                //The height above and below calculations assumes the staic controls are all entire at the top or bottom of the this dynamic control.
                int heightAbove = GetStaticControlsHeightAbove(fieldDef.YPos);
                int heightBelow = GetStaticControlsHeightBelow(fieldDef.YPos);
                control.MinimumSize = new Size(0, 0);             //Do not limit min size
                control.MaximumSize = new Size(0, 0);             //Do not limit max size
                SheetUtil.SetControlSizeAndAnchors(fieldDef, control, _controlHosting, (heightAbove + heightBelow));
                control.Location = new Point(fieldDef.XPos, (fieldDef.YPos + heightAbove));
                control.Visible  = true;
                listDynamicControls.Add(control);
            }
            RefreshGridVerticalSpace(sheetFieldLayoutMode, dictionaryControls, listSheetFieldDefs);
            RefreshGridHorizontalSpace(sheetFieldLayoutMode, dictionaryControls);
            _listControlsStatic.ForEach(x => x.BringToFront());
            _controlHosting.Controls.OfType <Control>()
            .Where(x => !listDynamicControls.Contains(x) && !_listControlsStatic.Contains(x))
            .ForEach(x => x.Visible = false);
            if (isUserSelection)
            {
                UpdateChartLayoutUserPref();
            }
        }
Exemple #4
0
        ///<summary>Once all controls are set in their initial place this is called to adjust any controls which might be overlapping on the X axis
        ///due to a grid having GrowthBehaviorEnum.FillDownFitColumns.
        ///Since the width of the grid is determined by the sum of the column widths we might need to move some controls to the right.</summary>
        public void RefreshGridHorizontalSpace(SheetFieldLayoutMode sheetFieldLayoutModeCur, Dictionary <string, Control> dictionaryControls)
        {
            List <SheetFieldDef> listFillDownDefs = _sheetDefDynamicLayoutCur.SheetFieldDefs
                                                    .FindAll(x => x.LayoutMode == sheetFieldLayoutModeCur && x.GrowthBehavior == GrowthBehaviorEnum.FillDownFitColumns);
            List <Control> listDynmaicControls = _sheetDefDynamicLayoutCur.SheetFieldDefs.FindAll(x => x.LayoutMode == sheetFieldLayoutModeCur)
                                                 .Select(x => GetControlForField(x, dictionaryControls)).ToList();

            //There is a grid that might be overlaping controls to the right of the grid since the width of the grid is defined by its columns.
            //We only expect there to be one field with FillDownFitColumns growth behavior, however we loop in case more are added later.
            foreach (SheetFieldDef fillFieldDef in listFillDownDefs)
            {
                Control control  = GetControlForField(fillFieldDef, dictionaryControls);
                int     gridMaxX = (control.Location.X + control.Width);
                foreach (Control controlIntersect in listDynmaicControls.FindAll(x => x != control && x.Bounds.IntersectsWith(control.Bounds)))
                {
                    int diff = (gridMaxX - controlIntersect.Location.X) + 1;
                    controlIntersect.Location = new Point(controlIntersect.Location.X + diff, controlIntersect.Location.Y);
                }
            }
        }
Exemple #5
0
        ///<summary>Once all controls are set in their initial place this is called to adjust any controls which might be overlapping on the Y axis
        ///due to a grid having GrowthBehaviorEnum.FillDownFitColumns or GrowthBehaviorEnum.FillDown.</summary>
        public void RefreshGridVerticalSpace(SheetFieldLayoutMode sheetFieldLayoutModeCur, Dictionary <string, Control> dictControls, List <SheetFieldDef> listSheetFieldDefs)
        {
            List <SheetFieldDef> listFillDownDefs = _sheetDefDynamicLayoutCur.SheetFieldDefs
                                                    .FindAll(x => x.LayoutMode == sheetFieldLayoutModeCur && x.GrowthBehavior.In(GrowthBehaviorEnum.FillDownFitColumns, GrowthBehaviorEnum.FillDown))
                                                    .OrderBy(x => x.YPos)
                                                    .ToList();
            List <Control> listDynamicControls = _sheetDefDynamicLayoutCur.SheetFieldDefs.FindAll(x => x.LayoutMode == sheetFieldLayoutModeCur)
                                                 .Select(x => GetControlForField(x, dictControls)).ToList();

            //tabProc might be overlaping controls vertically below because tabProcs has two different heights depending on state.
            //We only expect there to be one field with FillDownFitColumns growth behavior, however we loop in case more are added later.
            foreach (SheetFieldDef fillFieldDef in listFillDownDefs)
            {
                Control control = GetControlForField(fillFieldDef, dictControls);
                //Do not need to use GetHeightAbove(), all controls in listAboveControls have the above offset accounted for in their possitions.
                int  heightAbove    = 0;
                int  heightBelow    = 0;
                bool anchorToBottom = true;
                switch (fillFieldDef.GrowthBehavior)
                {
                case GrowthBehaviorEnum.FillDownFitColumns:
                    int minY = GetStaticControlsHeightAbove(fillFieldDef.YPos);                          //Uses y position relative to the sheet def.
                    AdjustGridYPosition(fillFieldDef, control, listDynamicControls, minY);
                    heightBelow = GetStaticControlsHeightBelow(fillFieldDef.YPos);
                    break;

                case GrowthBehaviorEnum.FillDown:
                    //Since we update the location below this maintains the correct Y locations set in InitLayoutForSheetDef(...)
                    //Also important that we set this to the real Y value relative to _controlHosting so that GetSheetFieldsHeightBelow(...) can work correctly.
                    heightAbove  = GetStaticControlsHeightAbove(fillFieldDef.YPos);
                    heightBelow  = GetStaticControlsHeightBelow(fillFieldDef.YPos + heightAbove);
                    heightBelow += GetSheetFieldsHeightBelow(fillFieldDef, heightAbove, listSheetFieldDefs, dictControls, out anchorToBottom);
                    break;
                }
                SheetUtil.SetControlSizeAndAnchors(fillFieldDef, control, _controlHosting, (heightAbove + heightBelow), anchorToBottom);
                control.Location = new Point(fillFieldDef.XPos, fillFieldDef.YPos + heightAbove);
            }
        }
Exemple #6
0
 public FormSheetFieldSpecial(SheetDef sheetDef, SheetFieldDef sheetFieldDef, bool isReadOnly, SheetFieldLayoutMode layoutMode) : base(sheetDef, sheetFieldDef, isReadOnly)
 {
     InitializeComponent();
     Lan.F(this);
     LayoutMode = layoutMode;
 }