예제 #1
0
        private void Frontend_Settings()
        {
            // Get frontend values
            // =====================================
            // Sizes
            _Settings.Size_MicroHeight = textHeight.Text.zTo_Int();
            _Settings.Size_MicroWidth  = textWidth.Text.zTo_Int();

            // Macro scope
            _Settings.Total_MacroCols = textMacroCols.Text.zTo_Int();
            _Settings.Total_MacroRows = textMacroRows.Text.zTo_Int();

            // Sub-Grids scope
            _Settings.Total_SubCols = textSubCols.Text.zTo_Int();
            _Settings.Total_SubRows = textSubRows.Text.zTo_Int();

            // Micro scope
            _Settings.Total_MicroCols = textMicroCols.Text.zTo_Int();
            _Settings.Total_MicroRows = textMicroRows.Text.zTo_Int();

            // Visible
            _Settings.Visible_MacroGrids = checkMacro.Checked;
            _Settings.Visible_SubGrids   = checkSub.Checked;
            _Settings.Visible_MicroGrids = checkMicro.Checked;

            // Color
            _Settings.ColorDefault_MacroGrid = labelColorMacro.BackColor;
            _Settings.ColorDefault_SubGrid   = labelColorSub.BackColor;
            _Settings.ColorDefault_MicroGrid = labelColorMicro.BackColor;

            // Display type
            if (radioAddress.Checked)
            {
                _Settings.DisplayMode_MicroGrids = enGrid_BlockDisplayType.Address;
            }
            if (radioValue.Checked)
            {
                _Settings.DisplayMode_MicroGrids = enGrid_BlockDisplayType.Value;
            }
            if (radioName.Checked)
            {
                _Settings.DisplayMode_MicroGrids = enGrid_BlockDisplayType.Name;
            }

            _Settings.Refresh_Calculations();
        }
        public void Frontend_Settings()
        {
            // Get frontend values

            // =====================================
            // Sizes
            _Settings.Size_MicroHeight = gridHeight;
            _Settings.Size_MicroWidth  = gridWidth;

            // Macro scope
            _Settings.Total_MacroCols = macroCols;
            _Settings.Total_MacroRows = macroRows;

            // Sub-grids scope
            _Settings.Total_SubCols = subCols;
            _Settings.Total_SubRows = subRows;

            // Micro scope
            _Settings.Total_MicroCols = microCols;
            _Settings.Total_MicroRows = microRows;

            // Visible
            _Settings.Visible_MacroGrids = visibleMacro;
            _Settings.Visible_SubGrids   = visibleSub;
            _Settings.Visible_MicroGrids = visibleMicro;
            // Color
            _Settings.ColorDefault_MacroGrid = macroGridDefaultColor;
            _Settings.ColorDefault_SubGrid   = subGridDefaultColor;
            _Settings.ColorDefault_MicroGrid = microGridDefaultColor;

            // Display type
            if (displayAddress)
            {
                _Settings.DisplayMode_MicroGrids = enGrid_BlockDisplayType.Address;
            }
            if (displayValue)
            {
                _Settings.DisplayMode_MicroGrids = enGrid_BlockDisplayType.Value;
            }
            if (displayName)
            {
                _Settings.DisplayMode_MicroGrids = enGrid_BlockDisplayType.Name;
            }

            _Settings.Refresh_Calculations();
        }
예제 #3
0
        public void GridControl_Settings_SizeTest()
        {
            #region Input
            var settings = new GridControl_Settings(2, 2, 2, 2, 5, 5, 32, 30);
            #endregion

            #region Test1: Sizes calc
            Assert.Equal(32, settings.Size_MicroWidth);
            Assert.Equal(30, settings.Size_MicroHeight);
            Assert.Equal(170, settings.Size_SubWidth);
            Assert.Equal(170, settings.Size_SubHeight);
            Assert.Equal(350, settings.Size_MacroWidth);
            Assert.Equal(360, settings.Size_MacroHeight);
            Assert.Equal(710, settings.Size_CuboidWidth);
            Assert.Equal(740, settings.Size_CuboidHeight);
            #endregion

            #region Test2: Add rows and recalc
            settings.Total_SubRows   = 3;
            settings.Total_MacroCols = 3;
            settings.Refresh_Calculations();
            Assert.Equal(32, settings.Size_MicroWidth);
            Assert.Equal(30, settings.Size_MicroHeight);
            Assert.Equal(170, settings.Size_SubWidth);
            Assert.Equal(170, settings.Size_SubHeight);
            Assert.Equal(350, settings.Size_MacroWidth);
            Assert.Equal(530, settings.Size_MacroHeight);
            Assert.Equal(1060, settings.Size_CuboidWidth);
            Assert.Equal(1080, settings.Size_CuboidHeight);
            #endregion

            settings.Color_ID.Clear();
            settings.Color_ID.Add(1, Color.Green);
            settings.Color_ID.Add(2, Color.Yellow);
            settings.Color_ID.Add(3, Color.Red);

            settings.Setup(1, 1, 1, 1, 1, 4);
            var gridCuboid = new GridBlock_5Setup(null, settings);

            // Load data
            // Load data into grids
            // 1.1
            var gridMicro = gridCuboid.GetChild_MicroGridBlock("1_1", "1_1", "1_1");
            gridMicro.State_Setup(1.5, 1, Color.Red);

            // 1.2
            var gridSub = gridCuboid.GetChild_SubGridBlock("1_1", "1_1");
            gridMicro = gridSub.GetChild_GridBlock("1_2");
            gridMicro.State_Setup(1.52, 2, Color.Blue);

            // 1.3
            gridSub.GetChild_GridBlock("1_3").State_Setup(2.52, 3, Color.Green);

            // 1.4
            var state = gridSub.GetChild_GridBlock("1_4") as IGridBlock_State;
            if (state != null)
            {
                state.State_ValueDouble = 3.3;
                state.State_Color       = Color.Aqua;
            }

            GridControlTools.Syncronise(gridCuboid, settings, true, OnGridChangeEvent);
        }
        /// <summary>
        /// Syncronise the settings with the frontend controls.
        /// </summary>
        /// <param name="grids">The grids.</param>
        /// <param name="settings">The settings.</param>
        /// <param name="resetColors">if set to <c>true</c> [reset colors].</param>
        /// <param name="onGridChangeEvent">The on grid change.</param>
        /// <param name="onGridCreate">The on grid create.</param>
        public static void Syncronise(GridBlock_5Setup grids, GridControl_Settings settings, bool resetColors = false,
                                      onGrid_ChangeEvent onGridChangeEvent = null)
        {
            settings.Refresh_Calculations();


            var cuboid    = grids.GridCuboid as IGridBlock_Base;
            int addWidth  = 10;
            int addHeight = 26;

            int widthTotal    = 0;
            int heightTotal   = 0;
            int widthMacro    = 0;
            int widthMacroMax = 0;
            int heightMacro   = 0;

            // Calculate the sizes
            List <IGridBlock_Base> macroGrids = cuboid.GridBlocksDictionary.Values.ToList();

            foreach (IGridBlock_Base macro in macroGrids)
            {
                // Sub Grids
                List <IGridBlock_Base> subGrids = macro.GridBlocksDictionary.Values.ToList();
                int widthSub    = 0;
                int widthSubMax = 0;
                int heightSub   = 0;
                foreach (IGridBlock_Base sub in subGrids)
                {
                    // Micro Grids
                    var microGrids    = sub.GridBlocksDictionary.Values.ToList();
                    int widthMicro    = 0;
                    int widthMicroMax = 0;
                    int heightMicro   = 0;
                    foreach (IGridBlock_Base micro in microGrids)
                    {
                        micro.zGridControl.Width         = settings.Size_MicroWidth;
                        micro.zGridControl._Parent.Width = settings.Size_MicroHeight; // Row height
                        GridSync_CalcSize(micro, ref widthMicro, ref heightMicro);    // update the grid settings
                        widthMicroMax = Math.Max(widthMicroMax, widthMicro);
                    }
                    // Sub
                    var subControl = sub.zGridControl;
                    var subRow     = subControl._Parent;
                    subControl.Width = Math.Max(widthMicroMax + addWidth, settings.Min_SubSize);
                    if (subControl.Left + subControl.Width > macro.zGridControl.Width)
                    {
                        macro.zGridControl.Width = subControl.Left + subControl.Width + addWidth;                                                                  // Make sure children fit
                    }
                    subRow.Height = Math.Max(subRow.Height, Math.Max(heightMicro + addHeight, settings.Min_SubSize));
                    GridSync_CalcSize(sub, ref widthSub, ref heightSub);    // update the grid settings
                    widthSubMax = Math.Max(widthSubMax, widthSub);
                    //heightTotal += subRow.Height;
                }
                var macroControl = macro.zGridControl;
                var macroRow     = macroControl._Parent;
                macroControl.Width = Math.Max(macroControl.Width, Math.Max(widthSubMax + addWidth, settings.Min_MacroSize));
                if (macroControl.Left + macroControl.Width > cuboid.zGridControl.Width)
                {
                    cuboid.zGridControl.Width = macroControl.Left + macroControl.Width + addWidth;                                                                    // Make sure children fit
                }
                macroRow.Height = Math.Max(macroRow.Height, Math.Max(heightSub + addHeight, settings.Min_MacroSize));
                GridSync_CalcSize(macro, ref widthMacro, ref heightMacro);   // update the grid settings
                widthMacroMax = Math.Max(widthMacroMax, widthMacro);
            }
            var cuboidControl = cuboid.zGridControl;
            var cuboidRow     = cuboidControl._Parent;

            //cuboidControl.Width = widthMacroMax + addWidth;
            cuboidRow.Height = heightMacro + addHeight;

            // Macro Grids
            foreach (IGridBlock_Base macro in macroGrids)
            {
                // Sub Grids
                List <IGridBlock_Base> subGrids = macro.GridBlocksDictionary.Values.ToList();
                foreach (IGridBlock_Base sub in subGrids)
                {
                    // Micro Grids
                    var microGrids = sub.GridBlocksDictionary.Values.ToList();
                    foreach (IGridBlock_Base micro in microGrids)
                    {
                        GridSync(micro, settings, resetColors, onGridChangeEvent); // update the grid settings
                    }
                    GridSync(sub, settings, resetColors, onGridChangeEvent);       // update the grid settings
                }
                GridSync(macro, settings, resetColors, onGridChangeEvent);         // update the grid settings
            }
            GridSync(cuboid, settings, resetColors, onGridChangeEvent);            // update the grid settings
        }