Beispiel #1
0
        public static ControlTemplates AddNewTemplateToPublicGroup(String TemplateName, List <UVCMD.ControlTargets> TemplatesCMD)
        {
            if (CsConst.myTemplates == null)
            {
                CsConst.myTemplates = new List <ControlTemplates>();
            }

            //添加到结构体
            #region
            ControlTemplates oTmp = new ControlTemplates();
            oTmp.ID      = GetNewIDForGroup();
            oTmp.Name    = TemplateName;
            oTmp.bytType = 1;
            oTmp.bytGpID = 0;
            oTmp.GpCMD   = new List <UVCMD.ControlTargets>();

            for (int i = 0; i < TemplatesCMD.Count; i++)
            {
                UVCMD.ControlTargets oCtrls = (UVCMD.ControlTargets)TemplatesCMD[i].Clone();
                oTmp.GpCMD.Add(oCtrls);
            }
            CsConst.myTemplates.Add(oTmp);
            #endregion
            return(oTmp);
        }
Beispiel #2
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;
        }
Beispiel #3
0
        public static void ReadAllGroupCommandsFrmDatabase()
        {
            CsConst.myTemplates = new List <ControlTemplates>();

            ////read keys commands to buffer
            string          str       = string.Format("select * from dbGrpRemark order by GrpID");
            OleDbDataReader drKeyCmds = DataModule.SearchAResultSQLDB(str);

            if (drKeyCmds != null)
            {
                while (drKeyCmds.Read())
                {
                    ControlTemplates oTmpGrp = new ControlTemplates();
                    oTmpGrp.ID      = drKeyCmds.GetInt16(0);
                    oTmpGrp.Name    = drKeyCmds.GetString(1);
                    oTmpGrp.bytType = drKeyCmds.GetByte(2);
                    oTmpGrp.bytGpID = drKeyCmds.GetByte(3);
                    oTmpGrp.GpCMD   = new List <UVCMD.ControlTargets>();

                    str = string.Format("select * from dbGrpCMD where GrpID = {0} order by objID", oTmpGrp.ID);

                    OleDbDataReader drKeyCmds1 = DataModule.SearchAResultSQLDB(str);

                    if (drKeyCmds1 != null)
                    {
                        while (drKeyCmds1.Read())
                        {
                            UVCMD.ControlTargets TmpCmd = new UVCMD.ControlTargets();
                            TmpCmd.ID       = drKeyCmds1.GetByte(1);
                            TmpCmd.Type     = drKeyCmds1.GetByte(2);
                            TmpCmd.SubnetID = drKeyCmds1.GetByte(3);
                            TmpCmd.DeviceID = drKeyCmds1.GetByte(4);
                            TmpCmd.Param1   = drKeyCmds1.GetByte(5);
                            TmpCmd.Param2   = drKeyCmds1.GetByte(6);
                            TmpCmd.Param3   = drKeyCmds1.GetByte(7);
                            TmpCmd.Param4   = drKeyCmds1.GetByte(8);

                            oTmpGrp.GpCMD.Add(TmpCmd);
                        }
                        drKeyCmds1.Close();
                    }
                    CsConst.myTemplates.Add(oTmpGrp);
                }
                drKeyCmds.Close();
            }
        }
Beispiel #4
0
        private void btnSavetemplate_Click(object sender, EventArgs e)
        {
            try
            {
                ControlTemplates oTmp = ControlTemplates.AddNewTemplateToPublicGroup(tbTemplates.Text, TempCMDGroup);

                if (oTmp != null)
                {
                    ListViewItem oLv = new ListViewItem();
                    // oLv.Text = oTmp.ID.ToString();
                    // oLv.SubItems.Add(oTmp.Name);
                    //tvTemplates.Nodes.Add(oLv);
                }
            }
            catch
            {
            }
        }
Beispiel #5
0
 private void frmMain_FormClosed(object sender, FormClosedEventArgs e)
 {
     ControlTemplates.SaveAllGroupCommandsFrmDatabase();
     if (CsConst.myOnlines != null && CsConst.myOnlines.Count > 0)
     {
         if (MessageBox.Show(CsConst.WholeTextsList[2403].sDisplayName, "", MessageBoxButtons.OKCancel, MessageBoxIcon.Information,
                             MessageBoxDefaultButton.Button1) == DialogResult.OK)
         {
             string strFileName = Application.StartupPath + @"\ini\List.txt";
             if (!File.Exists(strFileName))
             {
                 FileStream   fs1 = new FileStream(strFileName, FileMode.Create, FileAccess.ReadWrite);//创建写入文件
                 StreamWriter sw  = new StreamWriter(fs1);
                 for (int i = 0; i < CsConst.myOnlines.Count; i++)
                 {
                     byte[] arayTmp = HDLSysPF.StructToBytes(CsConst.myOnlines[i]);
                     string str     = "";
                     for (int j = 0; j < arayTmp.Length; j++)
                     {
                         str = str + arayTmp[j].ToString("X") + " ";
                     }
                     str = str.Trim();
                     sw.WriteLine(str);//开始写入值
                 }
                 sw.Close();
                 fs1.Close();
             }
         }
         else
         {
             string strFileName = Application.StartupPath + @"\ini\List.txt";
             if (File.Exists(strFileName))
             {
                 File.WriteAllLines(strFileName, null);
             }
         }
     }
     if (CsConst.calculationWorker != null)
     {
         CsConst.calculationWorker.Dispose();
     }
     this.Dispose();
 }