Пример #1
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            backgroundWorker1.WorkerReportsProgress      = true;
            backgroundWorker1.WorkerSupportsCancellation = true;
            CsConst.mstrDefaultPath = Application.StartupPath + @"\Database\Easy_Design.mdb";
            LoadControlsText.LoadButtonCoontrolTypeFromDatabaseToPublicClass();
            HDLSysPF.GetWeekdaysFromPublicStruct();
            //LoadControlsText.CheckAndLoadControlsNew();
            LoadControlsText.LoadControlsTextIdListFromXML();
            LoadControlsText.DisplayTextToFormWhenFirstShow(this);

            CsConst.mstrINIDefault = new IniFile(Application.StartupPath + @"\ini\LAN0.ini");
            ButtonMode.LoadButtonModeFromDatabaseToPublicClass();
            DryMode.LoadButtonModeFromDatabaseToPublicClass();
            ButtonControlType.LoadButtonCoontrolTypeFromDatabaseToPublicClass();
            DryControlType.LoadButtonCoontrolTypeFromDatabaseToPublicClass();
            DeviceTypeList.LoadButtonCoontrolTypeFromDatabaseToPublicClass();
            ControlTemplates.ReadAllGroupCommandsFrmDatabase();


            HDLSysPF.AutoScale((Form)sender);

            HDLSysPF.AddedDevicesIndexToAPublicListInt();
            GetDeviceList();
            // dgOnline.RowCount = 28;
        }
Пример #2
0
        public String ModeName; //中文

        public static void LoadButtonModeFromDatabaseToPublicClass()
        {
            CsConst.myPublicButtonMode = new List <ButtonMode>();

            string          strsql = string.Format("select * from defKeyMode order by KeyModeNO");
            OleDbDataReader dr     = DataModule.SearchAResultSQLDB(strsql, CsConst.mstrDefaultPath);

            if (dr != null)
            {
                while (dr.Read())
                {
                    ButtonMode TmpButtonMode = new ButtonMode();
                    TmpButtonMode.ModeOrder  = (Byte)(dr.GetInt16(0));
                    TmpButtonMode.ModeSaveID = (Byte)(dr.GetInt16(1));
                    if (CsConst.iLanguageId == 0) //
                    {
                        TmpButtonMode.ModeName = dr.GetString(3);
                    }
                    else
                    {
                        TmpButtonMode.ModeName = dr.GetString(2);
                    }
                    CsConst.myPublicButtonMode.Add(TmpButtonMode);
                }
                dr.Close();
            }
        }
Пример #3
0
        private void ShowKeysInformationPanel()
        {
            try
            {
                isRead = true;
                if (MyMHIC == null)
                {
                    return;
                }
                if (MyMHIC.myKeySetting == null)
                {
                    return;
                }
                setAllVisible(false);
                dgvKey.Rows.Clear();
                for (int i = 0; i < MyMHIC.myKeySetting.Count; i++)
                {
                    MHIC.Key temp     = MyMHIC.myKeySetting[i];
                    string   strDelay = CsConst.mstrInvalid;
                    string   strMode  = ButtonMode.ConvertorKeyModeToPublicModeGroup(temp.Mode);
                    if (!clK3.Items.Contains(strMode))
                    {
                        strMode = clK3.Items[0].ToString();
                    }
                    if (temp.Mode == 14) // 机械开关
                    {
                        strDelay = HDLPF.GetStringFromTime(temp.Delay, ":");
                    }
                    string strKey = (dgvKey.RowCount + 1).ToString();
                    if (MyDeviceType == 3076 || MyDeviceType == 3065 || MyDeviceType == 3068 ||
                        MyDeviceType == 3064 || MyDeviceType == 3069 || MyDeviceType == 3078 || MyDeviceType == 3080)
                    {
                        strKey = (i + 1).ToString() + "-" + CsConst.mstrINIDefault.IniReadValue("Public", "0028" + i.ToString(), "");
                    }

                    object[] obj   = new object[] { strKey, temp.Remark, strMode, strDelay, "Test" };
                    int      RowID = dgvKey.Rows.Add(obj);

                    if (temp.Mode != 14)
                    {
                        dgvKey[3, RowID].ReadOnly = true;
                    }
                }
            }
            catch
            {
            }
            isRead = false;
        }
Пример #4
0
        private void dgvRfbuttons_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == -1)
            {
                return;
            }
            if (e.RowIndex == -1)
            {
                return;
            }
            if (myIPModule == null)
            {
                return;
            }
            if (myIPModule.MyRemoteControllers == null)
            {
                return;
            }
            if (cboController.SelectedIndex == -1)
            {
                return;
            }
            Byte RemoteControllerID = (Byte)cboController.SelectedIndex;
            Byte PageID             = (Byte)cboPages.SelectedIndex;

            String Remark = dgvRfbuttons[e.ColumnIndex, e.RowIndex].Value.ToString();

            if (dgvRfbuttons.SelectedRows.Count > 1)
            {
                for (int i = 0; i < dgvRfbuttons.SelectedRows.Count; i++)
                {
                    dgvRfbuttons.SelectedRows[i].Cells[e.ColumnIndex].Value = Remark;
                    if (e.ColumnIndex == 1) // 备注
                    {
                        myIPModule.MyRemoteControllers[RemoteControllerID * IPmoduleDeviceTypeList.HowManyButtonsEachPage + PageID * 8 + e.RowIndex].Remark = Remark;
                    }
                    else if (e.ColumnIndex == 2) // 按键模式
                    {
                        Byte currentMode = ButtonMode.ConvertorKeyModesToPublicModeGroup(dgvRfbuttons[2, e.RowIndex].Value.ToString());
                        myIPModule.MyRemoteControllers[RemoteControllerID * IPmoduleDeviceTypeList.HowManyButtonsEachPage + PageID * 8 + e.RowIndex].Mode = currentMode;
                    }
                }
            }
        }
Пример #5
0
        private void dgvKey_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
        {
            if (isRead)
            {
                return;
            }
            if (e.ColumnIndex == -1 || e.RowIndex == -1)
            {
                return;
            }
            if (dgvKey.CurrentRow.Index < 0)
            {
                return;
            }
            if (dgvKey.RowCount <= 0)
            {
                return;
            }
            Cursor.Current    = Cursors.WaitCursor;
            txtSeries.Visible = false;

            if (dgvKey[2, e.RowIndex].Value == null)
            {
                dgvKey[e.ColumnIndex, e.RowIndex].Value = "";
            }
            String Remark = dgvKey[2, e.RowIndex].Value.ToString();

            if (Remark == CsConst.mstrInvalid)
            {
                return;
            }

            Byte bTmpMode = ButtonMode.ConvertorKeyModesToPublicModeGroup(Remark);

            if (bTmpMode == 14)
            {
                addcontrols(3, e.RowIndex, txtSeries, dgvKey);
                string str = HDLPF.GetStringFromTime(MyMHIC.myKeySetting[e.RowIndex].Delay, ":");
                txtSeries.Text = HDLPF.GetTimeFromString(str, ':');
            }

            Cursor.Current = Cursors.Default;
        }
Пример #6
0
        private void cboPages_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (myIPModule == null)
            {
                return;
            }
            if (cboController.SelectedIndex == -1)
            {
                return;
            }
            if (cboPages.SelectedIndex == -1)
            {
                return;
            }
            dgvRfbuttons.Rows.Clear();
            Byte ControllerID = Convert.ToByte(cboController.SelectedIndex);
            Byte PageID       = Convert.ToByte(cboPages.SelectedIndex);

            for (int i = 0; i < 8; i++)
            {
                HDLButton obutton = myIPModule.MyRemoteControllers[ControllerID * 64 + PageID * 8 + i];
                if (obutton == null)
                {
                    obutton = new HDLButton();
                }
                String ButtonModeString = ButtonMode.ConvertorKeyModeToPublicModeGroup(obutton.Mode);
                int    TmpMode          = cboButtonMode.Items.IndexOf(ButtonModeString);
                if (TmpMode != -1)
                {
                    Object[] obj = new object[] { (i + 1).ToString(), obutton.Remark, ButtonModeString };
                    dgvRfbuttons.Rows.Add(obj);
                }
                else
                {
                    Object[] obj = new object[] { (i + 1).ToString(), obutton.Remark, cboButtonMode.Items[0] };
                    dgvRfbuttons.Rows.Add(obj);
                }
            }
        }
Пример #7
0
        private void dgvListA_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
        {
            if (dgvListA.SelectedRows == null)
            {
                return;
            }
            if (dgvListA.Rows == null)
            {
                return;
            }
            try
            {
                if (e.ColumnIndex >= 1)
                {
                    Byte   Mode = ButtonMode.ConvertorKeyModesToPublicModeGroup(dgvListA[2, e.RowIndex].Value.ToString());
                    Byte[] ModeThatCouldMutexGroup   = new Byte[] { 4, 5, 7 };          //互斥的按键模式
                    Byte[] ModeThatCouldLinkageGroup = new Byte[] { 1, 2, 3, 4, 5, 6 }; // 可以关联的按键

                    dgvListA[6, e.RowIndex].ReadOnly = !ModeThatCouldMutexGroup.Contains(Mode);
                    dgvListA[7, e.RowIndex].ReadOnly = !ModeThatCouldLinkageGroup.Contains(Mode);

                    if (dgvListA[6, e.RowIndex].ReadOnly == true)
                    {
                        dgvListA[6, e.RowIndex].Value = clMutux.Items[0].ToString();
                    }

                    if (dgvListA[7, e.RowIndex].ReadOnly == true)
                    {
                        dgvListA[7, e.RowIndex].Value = CsConst.mstrInvalid;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #8
0
        private void dgvKey_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (isRead)
            {
                return;
            }
            if (e.ColumnIndex == -1 || e.RowIndex == -1)
            {
                return;
            }
            if (dgvKey.CurrentRow.Index < 0)
            {
                return;
            }
            if (dgvKey.RowCount <= 0)
            {
                return;
            }
            Cursor.Current = Cursors.WaitCursor;

            if (dgvKey[e.ColumnIndex, e.RowIndex].Value == null)
            {
                dgvKey[e.ColumnIndex, e.RowIndex].Value = "";
            }
            String Remark = dgvKey[e.ColumnIndex, e.RowIndex].Value.ToString();

            if (dgvKey.SelectedRows.Count > 0)
            {
                for (int i = 0; i < dgvKey.SelectedRows.Count; i++)
                {
                    dgvKey.SelectedRows[i].Cells[e.ColumnIndex].Value = Remark;
                    int index = dgvKey.SelectedRows[i].Index;
                    switch (e.ColumnIndex)
                    {
                    case 1:
                        MyMHIC.myKeySetting[index].Remark = Remark;
                        break;

                    case 2:
                        MyMHIC.myKeySetting[index].Mode = ButtonMode.ConvertorKeyModesToPublicModeGroup(Remark);
                        if (MyMHIC.myKeySetting[index].Mode == 14)
                        {
                            addcontrols(3, index, txtSeries, dgvKey);
                            string str = HDLPF.GetStringFromTime(MyMHIC.myKeySetting[index].Delay, ":");
                            txtSeries.Text = HDLPF.GetTimeFromString(str, ':');
                        }
                        break;

                    case 3:
                        byte[] arayTmp = new byte[3];
                        arayTmp[0] = 18;
                        arayTmp[1] = Convert.ToByte(e.RowIndex + 1);
                        arayTmp[2] = 255;
                        string sTestFlag = dgvKey[4, e.RowIndex].Value.ToString();
                        if (sTestFlag.ToLower() == "false")
                        {
                            arayTmp[2] = 0;
                        }
                        if (CsConst.mySends.AddBufToSndList(arayTmp, 0xE3D8, SubNetID, DevID, false, false, false, CsConst.minAllWirelessDeviceType.Contains(MyDeviceType)) == true)
                        {
                            CsConst.myRevBuf = new byte[1200];
                        }
                        break;
                    }
                }
            }
            Cursor.Current = Cursors.Default;
        }
Пример #9
0
        /// <summary>
        /// 不同类型显示到界面
        /// </summary>
        void DisplayButtonParametersToGridTable()
        {
            if (MyActiveObject is IPModule)
            {
                #region
                IPModule TmpIpModule = (IPModule)MyActiveObject;
                if (TmpIpModule == null)
                {
                    return;
                }
                if (cboController.SelectedIndex == -1)
                {
                    return;
                }
                if (cboPages.SelectedIndex == -1)
                {
                    return;
                }
                dgvListA.Rows.Clear();
                Byte ControllerID = Convert.ToByte(cboController.SelectedIndex);
                Byte PageID       = Convert.ToByte(cboPages.SelectedIndex);

                for (int i = 0; i < 8; i++)
                {
                    HDLButton obutton = TmpIpModule.MyRemoteControllers[ControllerID * 64 + PageID * 8 + i];
                    if (obutton == null)
                    {
                        obutton = new HDLButton();
                    }
                    String   ButtonModeTmp = ButtonMode.ConvertorKeyModeToPublicModeGroup(obutton.Mode);
                    Object[] obj           = new object[] { (i + 1).ToString(), obutton.Remark, ButtonModeTmp, (obutton.IsLEDON == 1), (obutton.IsDimmer == 1),
                                                            (obutton.SaveDimmer == 1), clMutux.Items[obutton.bytMutex], clLink.Items[obutton.byteLink] };
                    dgvListA.Rows.Add(obj);
                }
                #endregion
            }
            else if (MyActiveObject is DLP) //
            {
                Panel TmpPanel = (Panel)MyActiveObject;
                if (TmpPanel == null)
                {
                    return;
                }

                dgvListA.Rows.Clear();
                Byte PageID     = Convert.ToByte(cboPages.SelectedIndex);
                int  wdMaxValue = int.Parse(CsConst.mstrINIDefault.IniReadValue("DeviceType" + mywdDevicerType.ToString(), "MaxValue", "0"));
                for (int i = 0; i < 8; i++)
                {
                    HDLButton obutton = TmpPanel.PanelKey[PageID * 8 + i];
                    if (obutton == null)
                    {
                        obutton = new HDLButton();
                    }
                    String   ButtonModeTmp = ButtonMode.ConvertorKeyModeToPublicModeGroup(obutton.Mode);
                    Object[] obj           = new object[] { (i + 1).ToString(), obutton.Remark, ButtonModeTmp, (obutton.IsLEDON == 0), (obutton.IsDimmer == 1),
                                                            (obutton.SaveDimmer == 1), clMutux.Items[obutton.bytMutex], clLink.Items[obutton.byteLink] };
                    dgvListA.Rows.Add(obj);
                }
            }
            else if (MyActiveObject is Panel)
            {
                #region
                Panel TmpPanel = (Panel)MyActiveObject;
                if (TmpPanel == null)
                {
                    return;
                }

                dgvListA.Rows.Clear();

                for (int i = 0; i < TmpPanel.PanelKey.Count; i++)
                {
                    HDLButton obutton = TmpPanel.PanelKey[i];
                    if (obutton == null)
                    {
                        obutton = new HDLButton();
                    }
                    String ButtonModeTmp = ButtonMode.ConvertorKeyModeToPublicModeGroup(obutton.Mode);
                    if (obutton.bytMutex >= clMutux.Items.Count)
                    {
                        obutton.bytMutex = (Byte)(clMutux.Items.Count - 1);
                    }
                    Object[] obj = new object[] { (i + 1).ToString(), obutton.Remark, ButtonModeTmp, (obutton.IsLEDON == 0), (obutton.IsDimmer == 1),
                                                  (obutton.SaveDimmer == 1), clMutux.Items[obutton.bytMutex], clLink.Items[obutton.byteLink] };
                    dgvListA.Rows.Add(obj);
                }
                #endregion
            }
            else if (MyActiveObject is MS04)
            {
                #region
                MS04 TmpPanel = (MS04)MyActiveObject;
                if (TmpPanel == null)
                {
                    return;
                }

                dgvListA.Rows.Clear();

                for (int i = 0; i < TmpPanel.MSKeys.Count; i++)
                {
                    HDLButton obutton = TmpPanel.MSKeys[i];
                    if (obutton == null)
                    {
                        obutton = new HDLButton();
                    }
                    String   ButtonModeTmp = DryMode.ConvertorKeyModeToPublicModeGroup(obutton.Mode);
                    Object[] obj           = new object[] { (i + 1).ToString(), obutton.Remark, ButtonModeTmp, (obutton.IsLEDON == 0), (obutton.IsDimmer == 1),
                                                            (obutton.SaveDimmer == 1), clMutux.Items[obutton.bytMutex], clLink.Items[obutton.byteLink], DryDim.Items[obutton.IsDimmer] };
                    dgvListA.Rows.Add(obj);
                }
                #endregion
            }
            else if (MyActiveObject is MHRCU)
            {
                #region
                MHRCU TmpPanel = (MHRCU)MyActiveObject;
                if (TmpPanel == null)
                {
                    return;
                }

                dgvListA.Rows.Clear();

                for (int i = 0; i < TmpPanel.MSKeys.Count; i++)
                {
                    HDLButton obutton = TmpPanel.MSKeys[i];
                    if (obutton == null)
                    {
                        obutton = new HDLButton();
                    }
                    String   ButtonModeTmp = DryMode.ConvertorKeyModeToPublicModeGroup(obutton.Mode);
                    Object[] obj           = new object[] { (i + 1).ToString(), obutton.Remark, ButtonModeTmp, (obutton.IsLEDON == 0), (obutton.IsDimmer == 1),
                                                            (obutton.SaveDimmer == 1), clMutux.Items[obutton.bytMutex], clLink.Items[obutton.byteLink], DryDim.Items[obutton.IsDimmer] };
                    dgvListA.Rows.Add(obj);
                }
                #endregion
            }
        }