Esempio n. 1
0
        void updateLogDic()
        {
            List <ItemDicLogGlobe> logHeadRet = cIODicLogHeadProject.readDicGlobeLog();

            for (int i = 0; i < dgvLog.Rows.Count - 1; i++)
            {
                if (dgvLog.Rows[i].Cells["logNameNew"].Value != null && dgvLog.Rows[i].Cells["logSUnit"].Value != null)
                {
                    string          sID        = dgvLog.Rows[i].Cells["logNameNew"].Value.ToString();
                    string          mUnit      = dgvLog.Rows[i].Cells["logSUnit"].Value.ToString();
                    ItemDicLogGlobe selectItem = logHeadRet.FirstOrDefault(p => p.sLogID == sID);
                    if (selectItem == null)
                    {
                        ItemDicLogGlobe newItem = new ItemDicLogGlobe(sID);
                        newItem.sUnit = mUnit;
                        logHeadRet.Add(newItem);
                    }
                    else if (mUnit.Trim() != "")
                    {
                        selectItem.sUnit = mUnit;
                    }
                }
            }
            cIODicLogHeadProject.writeDicGlobe(logHeadRet);
        }
Esempio n. 2
0
        public static void writeDicGlobe(List <ItemDicLogGlobe> listDicLogGlobe)
        {
            string        filePathDic = Path.Combine(cProjectManager.dirPathUserData, "colorCode.txt");
            List <string> listLine    = new List <string>();

            foreach (ItemDicLogGlobe item in listDicLogGlobe)
            {
                listLine.Add(ItemDicLogGlobe.item2Line(item));
            }
            cIOBase.write2file(listLine, filePathDic);
        }
Esempio n. 3
0
        public static string item2Line(ItemDicLogGlobe itemLogHeadInfor)
        {
            List <string> ltStrWrited = new List <string>();

            ltStrWrited.Add(itemLogHeadInfor.sLogID);
            ltStrWrited.Add(itemLogHeadInfor.sLogText);
            ltStrWrited.Add(itemLogHeadInfor.sUnit);
            ltStrWrited.Add(itemLogHeadInfor.sLogColor);
            ltStrWrited.Add(itemLogHeadInfor.fLeftValue.ToString());
            ltStrWrited.Add(itemLogHeadInfor.fRightValue.ToString());
            ltStrWrited.Add(itemLogHeadInfor.iIsLog.ToString());
            ltStrWrited.Add(itemLogHeadInfor.fLineWidth.ToString());
            ltStrWrited.Add(itemLogHeadInfor.iLineType.ToString());
            return(string.Join("\t", ltStrWrited.ToArray()));
        }
Esempio n. 4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            ItemDicLogGlobe item = logHeadRet.FirstOrDefault(p => p.sLogID == sIDlogInpuput);

            if (item != null)
            {
                item.sUnit       = this.tbxLogSunit.Text;
                item.sLogColor   = this.tbxLogColor.Text;
                item.fLineWidth  = (float)this.nUDLineWidth.Value;
                item.iLineType   = this.cbbLineType.SelectedIndex;
                item.iIsLog      = this.cbxLog.Checked == true ? 1 : 0;
                item.fLeftValue  = float.Parse(this.nTBXleftValue.Text);
                item.fRightValue = float.Parse(nTBXrightValue.Text);
                cIODicLogHeadProject.writeDicGlobe(logHeadRet);
            }
        }
Esempio n. 5
0
        void initialForm()
        {
            this.btnOK.DialogResult     = DialogResult.OK;
            this.btnCancel.DialogResult = DialogResult.Cancel;
            this.tbxLogname.Text        = sIDlogInpuput;
            ItemDicLogGlobe item = logHeadRet.FirstOrDefault(p => p.sLogID == sIDlogInpuput);

            if (item == null)
            {
                item = new ItemDicLogGlobe(sIDlogInpuput);
                logHeadRet.Add(item);
            }

            this.tbxLogSunit.Text          = item.sUnit;
            this.tbxLogColor.Text          = item.sLogColor;
            this.nUDLineWidth.Value        = (decimal)item.fLineWidth;
            this.cbbLineType.SelectedIndex = item.iLineType;
            this.cbxLog.Checked            = (item.iIsLog > 0) ? true : false;
            this.nTBXleftValue.Text        = item.fLeftValue.ToString();
            this.nTBXrightValue.Text       = item.fRightValue.ToString();
        }
Esempio n. 6
0
        public static List <ItemDicLogGlobe> readDicGlobeLog()
        {
            string filePathDic = Path.Combine(cProjectManager.dirPathUserData, "ItemLogHead.txt");

            if (!File.Exists(filePathDic))
            {
                File.Copy(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "code", "ItemLogHead.txt"), filePathDic);
            }
            List <ItemDicLogGlobe> listItemLogHeadInfors = new List <ItemDicLogGlobe>();

            try
            {
                using (StreamReader sr = new StreamReader(filePathDic, System.Text.Encoding.UTF8))
                {
                    String line;
                    while ((line = sr.ReadLine()) != null) //delete the line whose legth is 0
                    {
                        string[] split = line.Trim().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                        if (split.Length >= 9)
                        {
                            ItemDicLogGlobe logItem = new ItemDicLogGlobe(split[0]);
                            logItem.sLogText    = split[1];
                            logItem.sUnit       = split[2];
                            logItem.sLogColor   = split[3];
                            logItem.fLeftValue  = float.Parse(split[4]);
                            logItem.fRightValue = float.Parse(split[5]);
                            logItem.iIsLog      = int.Parse(split[6]);
                            logItem.fLineWidth  = float.Parse(split[7]);
                            logItem.iLineType   = int.Parse(split[8]);
                            listItemLogHeadInfors.Add(logItem);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            return(listItemLogHeadInfors);
        }