Exemplo n.º 1
0
        public void Address_ToXY_Test()
        {
            int y, x;

            GridControl_Settings.Address_ToXY("1_1", out y, out x);
            Assert.Equal(1, y);
            Assert.Equal(1, x);

            GridControl_Settings.Address_ToXY("1_3", out y, out x);
            Assert.Equal(1, y);
            Assert.Equal(3, x);

            GridControl_Settings.Address_ToXY("7_3", out y, out x);
            Assert.Equal(7, y);
            Assert.Equal(3, x);
        }
Exemplo n.º 2
0
        public void GridBlock_4MacroSetup_Test(string addressMacro, string addressSub, string addressMicro)
        {
            int macroY, macroX;

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

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

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

            var settings  = new GridControl_Settings(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.Name, 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.Contains("."));

            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_Id);
            Assert.Equal(Color.Red, gridMacro.State_Color);
            Assert.Equal(enGrid_BlockEditState.ValueSet, gridMacro.State_EditState);
            gridMacro.State_Id          = 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.Name, 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_Id);
            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.Name, 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_Id);
            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
        }