コード例 #1
0
        public void Address_ToXY_Test()
        {
            int row, col;

            GridControl_Settings.Address_2RowCol("1_1", out row, out col);
            Assert.Equal(1, row);
            Assert.Equal(1, col);

            GridControl_Settings.Address_2RowCol("1_3", out row, out col);
            Assert.Equal(1, row);
            Assert.Equal(3, col);

            GridControl_Settings.Address_2RowCol("7_3", out row, out col);
            Assert.Equal(7, row);
            Assert.Equal(3, col);
            GridControl_Settings.Address_2RowCol("7_3", out row, out col, addressDef: enGrid_AddressDefOrder.ColRow);
            Assert.Equal(3, row);
            Assert.Equal(7, col);
            GridControl_Settings.Address_2RowCol("G_3", out row, out col, addressDef: enGrid_AddressDefOrder.ColRow, addressCol: enGrid_AddressValue.Alfa);
            Assert.Equal(3, row);
            Assert.Equal(7, col);
            GridControl_Settings.Address_2RowCol("G_C", out row, out col, addressDef: enGrid_AddressDefOrder.ColRow, addressCol: enGrid_AddressValue.Alfa, addressRow: enGrid_AddressValue.Alfa);
            Assert.Equal(3, row);
            Assert.Equal(7, col);

            // Reverse
            Assert.Equal("1_1", GridControl_Settings.Address_FromRowCol(1, 1));
            Assert.Equal("1_3", GridControl_Settings.Address_FromRowCol(1, 3));
            Assert.Equal("7_3", GridControl_Settings.Address_FromRowCol(7, 3));
            Assert.Equal("3_7", GridControl_Settings.Address_FromRowCol(7, 3, addressDef: enGrid_AddressDefOrder.ColRow));
            Assert.Equal("C_7", GridControl_Settings.Address_FromRowCol(7, 3, addressDef: enGrid_AddressDefOrder.ColRow, addressCol: enGrid_AddressValue.Alfa));
            Assert.Equal("G_3", GridControl_Settings.Address_FromRowCol(3, 7, addressDef: enGrid_AddressDefOrder.ColRow, addressCol: enGrid_AddressValue.Alfa));
            Assert.Equal("G_C", GridControl_Settings.Address_FromRowCol(3, 7, addressDef: enGrid_AddressDefOrder.ColRow, addressCol: enGrid_AddressValue.Alfa, addressRow: enGrid_AddressValue.Alfa));
        }
コード例 #2
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
        }