Beispiel #1
0
        public void GridControl_SettingsSetup_Test()
        {
            var settings = GridControl_Settings.Setup(null, 1, 1, 1, 1, 1, 1, 100, 30);

            Assert.Equal(100, settings.Size_MicroWidth);
            Assert.Equal(30, settings.Size_MicroHeight);
        }
Beispiel #2
0
        public void GridBlock_4MacroSetup_Fail(string addressMacro, string addressSub, string addressMicro)
        {
            var settings = GridControl_Settings.Setup(macroRows: 5, macroCols: 1, subRows: 5, subCols: 6,
                                                      microRows: 6, microCols: 6);
            var gridSetup = new GridBlock_5Setup(null, settings);

            Assert.Throws <ArgumentException>(() => gridSetup.GetChild_MacroGridBlock(addressMacro) as GridBlock_3Macro);
            Assert.Throws <ArgumentException>(() => gridSetup.GetChild_SubGridBlock("1.1", addressSub));
            Assert.Throws <ArgumentException>(() => gridSetup.GetChild_MicroGridBlock("1.1", "1.1", addressMicro));
        }
Beispiel #3
0
        public void GridPrefix_Test()
        {
            // null, null
            var ex = Assert.Throws <ArgumentNullException>(() => GridBlock_zMethods.GridPrefix(null, null));

            Assert.Equal("Value cannot be null.".NL() + "Parameter name: grid", ex.Message);

            // macro, null
            var             settings   = GridControl_Settings.Setup(1, 1, 1, 1, 1, 1);
            var             gridCuboid = new GridBlock_5Setup(OnCreateGridControl1, settings);
            IGridBlock_Base grid       = gridCuboid.GetChild_MacroGridBlock("1_1");

            ex = Assert.Throws <ArgumentNullException>(() => GridBlock_zMethods.GridPrefix(grid, null));
            Assert.Equal("Value cannot be null.".NL() + "Parameter name: settings", ex.Message);
        }
Beispiel #4
0
        public void GridBlock_Frontend_Test2()
        {
            GridControl_Settings settings = GridControl_Settings.Setup(1, 1, 1, 1, 5, 5);
            var gridCuboid = new GridBlock_5Setup(null, settings);
            var treeStr    = gridCuboid.TreeNameList().zTo_Str("".NL());

            #region result
            var treeResult =
                @"R1
R1cub1_1
R1cub1_1R1
R1cub1_1R1macro1_1
R1cub1_1R1macro1_1R1
R1cub1_1R1macro1_1R1sub1_1
R1cub1_1R1macro1_1R1sub1_1R1
R1cub1_1R1macro1_1R1sub1_1R1mic1_1
R1cub1_1R1macro1_1R1sub1_1R1mic1_2
R1cub1_1R1macro1_1R1sub1_1R1mic1_3
R1cub1_1R1macro1_1R1sub1_1R1mic1_4
R1cub1_1R1macro1_1R1sub1_1R1mic1_5
R1cub1_1R1macro1_1R1sub1_1R2
R1cub1_1R1macro1_1R1sub1_1R2mic2_1
R1cub1_1R1macro1_1R1sub1_1R2mic2_2
R1cub1_1R1macro1_1R1sub1_1R2mic2_3
R1cub1_1R1macro1_1R1sub1_1R2mic2_4
R1cub1_1R1macro1_1R1sub1_1R2mic2_5
R1cub1_1R1macro1_1R1sub1_1R3
R1cub1_1R1macro1_1R1sub1_1R3mic3_1
R1cub1_1R1macro1_1R1sub1_1R3mic3_2
R1cub1_1R1macro1_1R1sub1_1R3mic3_3
R1cub1_1R1macro1_1R1sub1_1R3mic3_4
R1cub1_1R1macro1_1R1sub1_1R3mic3_5
R1cub1_1R1macro1_1R1sub1_1R4
R1cub1_1R1macro1_1R1sub1_1R4mic4_1
R1cub1_1R1macro1_1R1sub1_1R4mic4_2
R1cub1_1R1macro1_1R1sub1_1R4mic4_3
R1cub1_1R1macro1_1R1sub1_1R4mic4_4
R1cub1_1R1macro1_1R1sub1_1R4mic4_5
R1cub1_1R1macro1_1R1sub1_1R5
R1cub1_1R1macro1_1R1sub1_1R5mic5_1
R1cub1_1R1macro1_1R1sub1_1R5mic5_2
R1cub1_1R1macro1_1R1sub1_1R5mic5_3
R1cub1_1R1macro1_1R1sub1_1R5mic5_4
R1cub1_1R1macro1_1R1sub1_1R5mic5_5";
            #endregion

            Assert.Equal(treeResult, treeStr);
        }
Beispiel #5
0
        public void GridBlock_Frontend_Test1()
        {
            var settings    = GridControl_Settings.Setup(1, 1, 1, 1, 1, 1);
            var gridCuboid2 = new GridBlock_5Setup(OnCreateGridControl1, settings);

            #region Result: Tree
            var treeResult =
                @"R1
R1cub1_1
R1cub1_1R1
R1cub1_1R1macro1_1
R1cub1_1R1macro1_1R1
R1cub1_1R1macro1_1R1sub1_1
R1cub1_1R1macro1_1R1sub1_1R1
R1cub1_1R1macro1_1R1sub1_1R1mic1_1";

            #endregion

            #region Result: TreeControls
            var treeControlsStr =
                @"Row//?//R1//CuboidGrid
Grid//R1//R1cub1_1//CuboidGrid
Row//R1cub1_1//R1cub1_1R1//MacroBlock
Grid//R1cub1_1R1//R1cub1_1R1macro1_1//MacroBlock
Row//R1cub1_1R1macro1_1//R1cub1_1R1macro1_1R1//SubBlock
Grid//R1cub1_1R1macro1_1R1//R1cub1_1R1macro1_1R1sub1_1//SubBlock
Row//R1cub1_1R1macro1_1R1sub1_1//R1cub1_1R1macro1_1R1sub1_1R1//MicroBlock
Grid//R1cub1_1R1macro1_1R1sub1_1R1//R1cub1_1R1macro1_1R1sub1_1R1mic1_1//MicroBlock";
            #endregion

            var treeStr2 = gridCuboid2.TreeNameList().zTo_Str("".NL());
            Assert.Equal(treeResult, treeStr2);

            var treeControls = _ListTest1.zTo_Str("".NL());
            Assert.Equal(treeControlsStr, treeControls);
            Assert.Equal(treeControlsStr, gridCuboid2.TreeControlList().zTo_Str("".NL()));
        }
Beispiel #6
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);
        }
Beispiel #7
0
        public void GridBlock_Frontend_Test3()
        {
            var settings   = GridControl_Settings.Setup(2, 2, 2, 2, 2, 2);
            var gridCuboid = new GridBlock_5Setup(null, settings);
            var treeStr    = gridCuboid.TreeNameList().zTo_Str("".NL());

            #region result
            var treeResult =
                @"R1
R1cub1_1
R1cub1_1R1
R1cub1_1R1macro1_1
R1cub1_1R1macro1_1R1
R1cub1_1R1macro1_1R1sub1_1
R1cub1_1R1macro1_1R1sub1_1R1
R1cub1_1R1macro1_1R1sub1_1R1mic1_1
R1cub1_1R1macro1_1R1sub1_1R1mic1_2
R1cub1_1R1macro1_1R1sub1_1R2
R1cub1_1R1macro1_1R1sub1_1R2mic2_1
R1cub1_1R1macro1_1R1sub1_1R2mic2_2
R1cub1_1R1macro1_1R1sub1_2
R1cub1_1R1macro1_1R1sub1_2R1
R1cub1_1R1macro1_1R1sub1_2R1mic1_1
R1cub1_1R1macro1_1R1sub1_2R1mic1_2
R1cub1_1R1macro1_1R1sub1_2R2
R1cub1_1R1macro1_1R1sub1_2R2mic2_1
R1cub1_1R1macro1_1R1sub1_2R2mic2_2
R1cub1_1R1macro1_1R2
R1cub1_1R1macro1_1R2sub2_1
R1cub1_1R1macro1_1R2sub2_1R1
R1cub1_1R1macro1_1R2sub2_1R1mic1_1
R1cub1_1R1macro1_1R2sub2_1R1mic1_2
R1cub1_1R1macro1_1R2sub2_1R2
R1cub1_1R1macro1_1R2sub2_1R2mic2_1
R1cub1_1R1macro1_1R2sub2_1R2mic2_2
R1cub1_1R1macro1_1R2sub2_2
R1cub1_1R1macro1_1R2sub2_2R1
R1cub1_1R1macro1_1R2sub2_2R1mic1_1
R1cub1_1R1macro1_1R2sub2_2R1mic1_2
R1cub1_1R1macro1_1R2sub2_2R2
R1cub1_1R1macro1_1R2sub2_2R2mic2_1
R1cub1_1R1macro1_1R2sub2_2R2mic2_2
R1cub1_1R1macro1_2
R1cub1_1R1macro1_2R1
R1cub1_1R1macro1_2R1sub1_1
R1cub1_1R1macro1_2R1sub1_1R1
R1cub1_1R1macro1_2R1sub1_1R1mic1_1
R1cub1_1R1macro1_2R1sub1_1R1mic1_2
R1cub1_1R1macro1_2R1sub1_1R2
R1cub1_1R1macro1_2R1sub1_1R2mic2_1
R1cub1_1R1macro1_2R1sub1_1R2mic2_2
R1cub1_1R1macro1_2R1sub1_2
R1cub1_1R1macro1_2R1sub1_2R1
R1cub1_1R1macro1_2R1sub1_2R1mic1_1
R1cub1_1R1macro1_2R1sub1_2R1mic1_2
R1cub1_1R1macro1_2R1sub1_2R2
R1cub1_1R1macro1_2R1sub1_2R2mic2_1
R1cub1_1R1macro1_2R1sub1_2R2mic2_2
R1cub1_1R1macro1_2R2
R1cub1_1R1macro1_2R2sub2_1
R1cub1_1R1macro1_2R2sub2_1R1
R1cub1_1R1macro1_2R2sub2_1R1mic1_1
R1cub1_1R1macro1_2R2sub2_1R1mic1_2
R1cub1_1R1macro1_2R2sub2_1R2
R1cub1_1R1macro1_2R2sub2_1R2mic2_1
R1cub1_1R1macro1_2R2sub2_1R2mic2_2
R1cub1_1R1macro1_2R2sub2_2
R1cub1_1R1macro1_2R2sub2_2R1
R1cub1_1R1macro1_2R2sub2_2R1mic1_1
R1cub1_1R1macro1_2R2sub2_2R1mic1_2
R1cub1_1R1macro1_2R2sub2_2R2
R1cub1_1R1macro1_2R2sub2_2R2mic2_1
R1cub1_1R1macro1_2R2sub2_2R2mic2_2
R1cub1_1R2
R1cub1_1R2macro2_1
R1cub1_1R2macro2_1R1
R1cub1_1R2macro2_1R1sub1_1
R1cub1_1R2macro2_1R1sub1_1R1
R1cub1_1R2macro2_1R1sub1_1R1mic1_1
R1cub1_1R2macro2_1R1sub1_1R1mic1_2
R1cub1_1R2macro2_1R1sub1_1R2
R1cub1_1R2macro2_1R1sub1_1R2mic2_1
R1cub1_1R2macro2_1R1sub1_1R2mic2_2
R1cub1_1R2macro2_1R1sub1_2
R1cub1_1R2macro2_1R1sub1_2R1
R1cub1_1R2macro2_1R1sub1_2R1mic1_1
R1cub1_1R2macro2_1R1sub1_2R1mic1_2
R1cub1_1R2macro2_1R1sub1_2R2
R1cub1_1R2macro2_1R1sub1_2R2mic2_1
R1cub1_1R2macro2_1R1sub1_2R2mic2_2
R1cub1_1R2macro2_1R2
R1cub1_1R2macro2_1R2sub2_1
R1cub1_1R2macro2_1R2sub2_1R1
R1cub1_1R2macro2_1R2sub2_1R1mic1_1
R1cub1_1R2macro2_1R2sub2_1R1mic1_2
R1cub1_1R2macro2_1R2sub2_1R2
R1cub1_1R2macro2_1R2sub2_1R2mic2_1
R1cub1_1R2macro2_1R2sub2_1R2mic2_2
R1cub1_1R2macro2_1R2sub2_2
R1cub1_1R2macro2_1R2sub2_2R1
R1cub1_1R2macro2_1R2sub2_2R1mic1_1
R1cub1_1R2macro2_1R2sub2_2R1mic1_2
R1cub1_1R2macro2_1R2sub2_2R2
R1cub1_1R2macro2_1R2sub2_2R2mic2_1
R1cub1_1R2macro2_1R2sub2_2R2mic2_2
R1cub1_1R2macro2_2
R1cub1_1R2macro2_2R1
R1cub1_1R2macro2_2R1sub1_1
R1cub1_1R2macro2_2R1sub1_1R1
R1cub1_1R2macro2_2R1sub1_1R1mic1_1
R1cub1_1R2macro2_2R1sub1_1R1mic1_2
R1cub1_1R2macro2_2R1sub1_1R2
R1cub1_1R2macro2_2R1sub1_1R2mic2_1
R1cub1_1R2macro2_2R1sub1_1R2mic2_2
R1cub1_1R2macro2_2R1sub1_2
R1cub1_1R2macro2_2R1sub1_2R1
R1cub1_1R2macro2_2R1sub1_2R1mic1_1
R1cub1_1R2macro2_2R1sub1_2R1mic1_2
R1cub1_1R2macro2_2R1sub1_2R2
R1cub1_1R2macro2_2R1sub1_2R2mic2_1
R1cub1_1R2macro2_2R1sub1_2R2mic2_2
R1cub1_1R2macro2_2R2
R1cub1_1R2macro2_2R2sub2_1
R1cub1_1R2macro2_2R2sub2_1R1
R1cub1_1R2macro2_2R2sub2_1R1mic1_1
R1cub1_1R2macro2_2R2sub2_1R1mic1_2
R1cub1_1R2macro2_2R2sub2_1R2
R1cub1_1R2macro2_2R2sub2_1R2mic2_1
R1cub1_1R2macro2_2R2sub2_1R2mic2_2
R1cub1_1R2macro2_2R2sub2_2
R1cub1_1R2macro2_2R2sub2_2R1
R1cub1_1R2macro2_2R2sub2_2R1mic1_1
R1cub1_1R2macro2_2R2sub2_2R1mic1_2
R1cub1_1R2macro2_2R2sub2_2R2
R1cub1_1R2macro2_2R2sub2_2R2mic2_1
R1cub1_1R2macro2_2R2sub2_2R2mic2_2";
            #endregion

            Assert.Equal(treeResult, treeStr);
        }
Beispiel #8
0
        public void GridBlock_4MacroSetup_Test(string addressMacro, string addressSub, string addressMicro)
        {
            int macroY, macroX;

            GridControl_Settings.Address_2RowCol(addressMacro, out macroY, out macroX);
            int subY, subX;

            GridControl_Settings.Address_2RowCol(addressSub, out subY, out subX);
            int microY, microX;

            GridControl_Settings.Address_2RowCol(addressMicro, out microY, out microX);

            var settings  = GridControl_Settings.Setup(macroRows: 5, macroCols: 1, subRows: 5, subCols: 6, microRows: 6, microCols: 6);
            var gridSetup = new GridBlock_5Setup(null, settings);

            #region Cuboid

            var gridCubiod = gridSetup.GridCuboid;
            Assert.Equal(5 * 6 * 5 * 6 * 6, gridCubiod.Child_Count);
            Assert.Equal(enGrid_BlockType.MacroBlock, gridCubiod.Child_BlockType);
            Assert.Equal(enGrid_BlockDisplayType.Address, gridCubiod.Child_DisplayType);
            gridCubiod.State_Setup(0, 0, Color.Red);  // There is not state

            #endregion

            #region Macro block
            var gridMacro = gridSetup.GetChild_MacroGridBlock(addressMacro) as GridBlock_3Macro;
            Assert.NotEqual(null, gridMacro);
            Assert.Equal(enGrid_BlockEditState.Undefined, gridMacro.State_EditState);  // First time state is undefined
            Assert.Equal(double.NaN, gridMacro.State_ValueDouble);
            Assert.Equal(null, gridMacro.zGridControl);

            Assert.Equal(true, gridMacro.Name_Caption(settings).Contains("."));
            settings.Address_Seperator = "_";
            Assert.Equal(false, gridMacro.Name_Caption(settings).Contains("."));
            Assert.Equal(true, gridMacro.Name_Caption(settings).Contains("_"));
            settings.Address_Seperator = ".";

            gridMacro.State_Setup(123.55, 2, Color.Red);  // Setup method makes state ValueSet
            Assert.Equal(123.55, gridMacro.State_ValueDouble);
            Assert.Equal(2, gridMacro.State_EnumValue);
            Assert.Equal(Color.Red, gridMacro.State_Color);
            Assert.Equal(enGrid_BlockEditState.ValueSet, gridMacro.State_EditState);
            gridMacro.State_EnumValue   = 1;             // Setting values makes the state Changed
            gridMacro.State_ValueDouble = 2.5;
            Assert.Equal(enGrid_BlockEditState.Changed, gridMacro.State_EditState);
            Assert.Equal(addressMacro, gridMacro.Name_Address);
            Assert.Equal(6 * 5 * 6 * 6, gridMacro.Child_Count);
            Assert.Equal(enGrid_BlockType.SubBlock, gridMacro.Child_BlockType);
            Assert.Equal(enGrid_BlockDisplayType.Address, gridMacro.Child_DisplayType);
            Assert.Equal(macroY, gridMacro.State_Row);
            Assert.Equal(macroX, gridMacro.State_Col);
            #endregion

            #region Sub block
            var gridSub = gridMacro.GetChild_GridBlock(addressSub) as GridBlock_2Sub;
            Assert.NotEqual(null, gridSub);
            Assert.Equal(Color.Black, gridSub.State_Color);
            Assert.Equal(enGrid_BlockEditState.Undefined, gridSub.State_EditState);  // First time state is undefined
            Assert.Equal(double.NaN, gridSub.State_ValueDouble);

            gridSub.State_Setup(123.55, 2, Color.Red);  // Setup method makes state ValueSet
            Assert.Equal(123.55, gridSub.State_ValueDouble);
            Assert.Equal(2, gridSub.State_EnumValue);
            Assert.Equal(Color.Red, gridSub.State_Color);
            Assert.Equal(enGrid_BlockEditState.ValueSet, gridSub.State_EditState);

            Assert.Equal(addressSub, gridSub.Name_Address);
            Assert.Equal(6 * 6, gridSub.Child_Count);
            Assert.Equal(gridMacro, gridSub._Parent);
            Assert.Equal(enGrid_BlockType.MicroBlock, gridSub.Child_BlockType);
            Assert.Equal(enGrid_BlockDisplayType.Address, gridSub.Child_DisplayType);
            Assert.Equal(subY, gridSub.State_Row);
            Assert.Equal(subX, gridSub.State_Col);

            // Child_GridBlockSub
            var gridSub2 = gridSetup.GetChild_SubGridBlock(addressMacro, addressSub);
            Assert.Equal(gridSub, gridSub2);

            #endregion

            #region Micro block
            var gridMicro = gridSub.GetChild_GridBlock(addressMicro) as GridBlock_1Micro;
            Assert.NotEqual(null, gridMicro);
            Assert.Equal(Color.Black, gridMicro.State_Color);
            Assert.Equal(double.NaN, gridMicro.State_ValueDouble);
            Assert.Equal(enGrid_BlockEditState.Undefined, gridMicro.State_EditState); // First time state is undefined

            gridMicro.State_Setup(123.55, 2, Color.Red);                              // Setup method makes state ValueSet
            Assert.Equal(123.55, gridMicro.State_ValueDouble);
            Assert.Equal(2, gridMicro.State_EnumValue);
            Assert.Equal(Color.Red, gridMicro.State_Color);
            Assert.Equal(enGrid_BlockEditState.ValueSet, gridMicro.State_EditState);

            Assert.Equal(addressMicro, gridMicro.Name_Address);
            Assert.Equal(gridSub, gridMicro._Parent);
            Assert.Equal(microY, gridMicro.State_Row);
            Assert.Equal(microX, gridMicro.State_Col);


            // Child_GridBlockMicro
            var gridMicro2 = gridSetup.GetChild_MicroGridBlock(addressMacro, addressSub, addressMicro);
            Assert.Equal(gridMicro, gridMicro2);
            #endregion
        }