Пример #1
0
        private void pre_refresh(Form frm)
        {
            foreach (Control ctrl in frm.Controls)
            {
                if (ctrl is ParaLine)
                {
                    ParaLine ctr = ctrl as ParaLine;

                    int index = Convert.ToInt16(ctr.Tag);
                    ctr.Tagname    = Form_Main.dt_para.Rows[index - 1]["中文名称"].ToString();
                    ctr.Tagname_EN = Form_Main.dt_para.Rows[index - 1]["英文名称"].ToString();
                    ctr.Min        = Form_Main.dt_para.Rows[index - 1]["最小值"].ToString();
                    ctr.Max        = Form_Main.dt_para.Rows[index - 1]["最大值"].ToString();
                    ctr.Unit       = Form_Main.dt_para.Rows[index - 1]["公制单位"].ToString();
                    if (Form_Main.Unit == 1)
                    {
                        ctr.Unit = Form_Main.dt_para.Rows[index - 1]["英制单位"].ToString();
                    }
                    ctr.refresh();
                }
                if (ctrl is Gauge)
                {
                    Gauge ctr = ctrl as Gauge;

                    int index = Convert.ToInt16(ctr.Tag);
                    ctr.Tagname = Form_Main.dt_para.Rows[index - 1]["中文名称"].ToString();
                    //ctr.Tagname_EN = Form_Main.dt_para.Rows[index - 1]["英文名称"].ToString();
                    ctr.Min  = Form_Main.dt_para.Rows[index - 1]["最小值"].ToString();
                    ctr.Max  = Form_Main.dt_para.Rows[index - 1]["最大值"].ToString();
                    ctr.Unit = Form_Main.dt_para.Rows[index - 1]["公制单位"].ToString();
                    if (Form_Main.Unit == 1)
                    {
                        ctr.Unit = Form_Main.dt_para.Rows[index - 1]["英制单位"].ToString();
                    }
                }


                if (ctrl is Parashow)
                {
                    Parashow ctrl2 = ctrl as Parashow;

                    int index = Convert.ToInt16(ctrl2.Tag);
                    ctrl2.Tagname    = Form_Main.dt_para.Rows[index - 1]["中文名称"].ToString();
                    ctrl2.Tagname_EN = Form_Main.dt_para.Rows[index - 1]["英文名称"].ToString();
                    ctrl2.Unit       = Form_Main.dt_para.Rows[index - 1]["公制单位"].ToString();
                    if (Form_Main.Unit == 1)
                    {
                        ctrl2.Unit = Form_Main.dt_para.Rows[index - 1]["英制单位"].ToString();
                    }
                    ctrl2.refresh();
                }

                if (ctrl is Parashownew)
                {
                    Parashownew ctrl2 = ctrl as Parashownew;

                    int index = Convert.ToInt16(ctrl2.Tag);
                    ctrl2.Tagname    = Form_Main.dt_para.Rows[index - 1]["中文名称"].ToString();
                    ctrl2.Tagname_EN = Form_Main.dt_para.Rows[index - 1]["英文名称"].ToString();
                    ctrl2.Unit       = Form_Main.dt_para.Rows[index - 1]["公制单位"].ToString();
                    if (Form_Main.Unit == 1)
                    {
                        ctrl2.Unit = Form_Main.dt_para.Rows[index - 1]["英制单位"].ToString();
                    }
                    ctrl2.refresh();
                }
            }
            //更新坐标轴

            ((Form_Main)Application.OpenForms["Form_Main"]).trend_refresh("0");
            ((Frm_Realtrend)Application.OpenForms["Frm_Realtrend"]).trend_refresh("0");
            ((Frm_Realtrend2)Application.OpenForms["Frm_Realtrend2"]).trend_refresh("1");
        }
Пример #2
0
        public void xml_load()
        {
            try
            {
                string      path = Application.StartupPath + "\\Config\\preference.xml";
                XmlDocument doc  = new XmlDocument();
                doc.Load(path);
                XmlNode root = doc.DocumentElement;
                //现读取paraLine控件的信息
                XmlNodeList nodeList = root.SelectNodes("Form[Name='Frm_Paraanalog2']//Controlsshow//Control");

                //1115新增,parashow控件
                foreach (Control ctr in this.Controls)
                {
                    if (ctr is Parashownew)
                    {
                        Parashownew ctr2 = ctr as Parashownew;
                        foreach (XmlNode node in nodeList)
                        {
                            if (ctr2.Name == node.SelectSingleNode("@name").InnerText)
                            {
                                //ctr2.Tagname = node.SelectSingleNode("@tagname").InnerText;
                                //ctr2.Tagname_EN = node.SelectSingleNode("@tagname_en").InnerText;
                                //ctr2.Unit = node.SelectSingleNode("@unit").InnerText;
                                //ctr2.Tag = node.SelectSingleNode("@index").InnerText;
                                //0513修改,信息从para读取
                                ctr2.Tag = node.SelectSingleNode("@index").InnerText;
                                int index = Convert.ToInt16(ctr2.Tag);
                                ctr2.Tagname    = Form_Main.dt_para.Rows[index - 1]["中文名称"].ToString();
                                ctr2.Tagname_EN = Form_Main.dt_para.Rows[index - 1]["英文名称"].ToString();
                                ctr2.Unit       = Form_Main.dt_para.Rows[index - 1]["公制单位"].ToString();
                                if (Form_Main.Unit == 1)
                                {
                                    ctr2.Unit = Form_Main.dt_para.Rows[index - 1]["英制单位"].ToString();
                                }
                                ctr2.Color = Comm.ReadColor.getcolor(node.SelectSingleNode("@color").InnerText);

                                //if (Form_Main.Unit == 1) ctr2.Unit = Form_Main.factor_unit[Convert.ToInt16(ctr2.Tag)];
                                ctr2.refresh();
                            }
                        }
                    }
                }
                //1115新增,gauge控件
                nodeList = root.SelectNodes("Form[Name='Frm_Paraanalog2']//Controlsgauge//Control");
                foreach (Control ctr in this.Controls)
                {
                    if (ctr is Gauge)
                    {
                        Gauge ctr2 = ctr as Gauge;
                        foreach (XmlNode node in nodeList)
                        {
                            if (ctr2.Name == node.SelectSingleNode("@name").InnerText)
                            {
                                //ctr2.Tagname = node.SelectSingleNode("@tagname").InnerText;
                                //ctr2.Unit = node.SelectSingleNode("@unit").InnerText;
                                //ctr2.Tag = node.SelectSingleNode("@index").InnerText;
                                //ctr2.Min = node.SelectSingleNode("@min").InnerText;
                                //ctr2.Max = node.SelectSingleNode("@max").InnerText;
                                ctr2.Tag = node.SelectSingleNode("@index").InnerText;
                                int index = Convert.ToInt16(ctr2.Tag);
                                ctr2.Tagname = Form_Main.dt_para.Rows[index - 1]["中文名称"].ToString();
                                ctr2.Unit    = Form_Main.dt_para.Rows[index - 1]["公制单位"].ToString();
                                ctr2.Min     = Form_Main.dt_para.Rows[index - 1]["最小值"].ToString();
                                ctr2.Max     = Form_Main.dt_para.Rows[index - 1]["最大值"].ToString();
                                if (Form_Main.Unit == 1)
                                {
                                    ctr2.Unit = Form_Main.dt_para.Rows[index - 1]["英制单位"].ToString();
                                }
                                //if (Form_Main.Unit == 1) ctr2.Unit = Form_Main.factor_unit[Convert.ToInt16(ctr2.Tag)];
                                ctr2.refresh();
                            }
                            //初始化大表盘的参数
                            if (node.SelectSingleNode("@name").InnerText == "gauge0")
                            {
                                //gauge0.Tagname = node.SelectSingleNode("@tagname").InnerText;
                                //gauge0.Unit = node.SelectSingleNode("@unit").InnerText;
                                //gauge0.Tag = node.SelectSingleNode("@index").InnerText;
                                //gauge0.Min = node.SelectSingleNode("@min").InnerText;
                                //gauge0.Max = node.SelectSingleNode("@max").InnerText;
                                //if (Form_Main.Unit == 1) gauge0.Unit = Form_Main.factor_unit[Convert.ToInt16(gauge0.Tag)];
                                gauge0.Tag = node.SelectSingleNode("@index").InnerText;
                                int index = Convert.ToInt16(gauge0.Tag);
                                gauge0.Tagname = Form_Main.dt_para.Rows[index - 1]["中文名称"].ToString();
                                gauge0.Unit    = Form_Main.dt_para.Rows[index - 1]["公制单位"].ToString();
                                gauge0.Min     = Form_Main.dt_para.Rows[index - 1]["最小值"].ToString();
                                gauge0.Max     = Form_Main.dt_para.Rows[index - 1]["最大值"].ToString();
                                gauge0.refresh();
                            }
                        }
                    }
                }


                //foreach (Control ctrl in this.tabControl1.Controls)
                //{
                //    if (ctrl is TabPage)
                //    {
                //        TabPage ctrl2 = ctrl as TabPage;
                //        foreach (Control ctr in ctrl2.Controls)
                //        {
                //            if (ctr is Parashow)
                //            {
                //                Parashow ctr2 = ctr as Parashow;
                //                foreach (XmlNode node in nodeList)
                //                {
                //                    if (ctr2.Name == node.SelectSingleNode("@name").InnerText)
                //                    {
                //                        ctr2.Tagname = node.SelectSingleNode("@tagname").InnerText;
                //                        ctr2.Unit = node.SelectSingleNode("@unit").InnerText;
                //                        ctr2.Tag = node.SelectSingleNode("@index").InnerText;
                //                        ctr2.refresh();
                //                    }

                //                }
                //            }
                //        }
                //    }
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #3
0
        private void xml_load()
        {
            try
            {
                string      path = Application.StartupPath + "\\Config\\preference.xml";
                XmlDocument doc  = new XmlDocument();
                doc.Load(path);
                XmlNode root = doc.DocumentElement;
                //现读取paraLine控件的信息
                XmlNodeList nodeList = root.SelectNodes("Form[Name='Frm_Paradigital']//Controlsshow//Control");

                //1115新增
                foreach (Control ctr in this.Controls)
                {
                    if (ctr is Parashownew)
                    {
                        Parashownew ctr2 = ctr as Parashownew;
                        foreach (XmlNode node in nodeList)
                        {
                            if (ctr2.Name == node.SelectSingleNode("@name").InnerText)
                            {
                                ctr2.Tagname = node.SelectSingleNode("@tagname").InnerText;
                                ctr2.Unit    = node.SelectSingleNode("@unit").InnerText;
                                ctr2.Tag     = node.SelectSingleNode("@index").InnerText;
                                ctr2.Color   = Comm.ReadColor.getcolor(node.SelectSingleNode("@color").InnerText);
                                ctr2.refresh();
                            }
                        }
                    }
                }



                //foreach (Control ctrl in this.tabControl1.Controls)
                //{
                //    if (ctrl is TabPage)
                //    {
                //        TabPage ctrl2 = ctrl as TabPage;
                //        foreach (Control ctr in ctrl2.Controls)
                //        {
                //            if (ctr is Parashow)
                //            {
                //                Parashow ctr2 = ctr as Parashow;
                //                foreach (XmlNode node in nodeList)
                //                {
                //                    if (ctr2.Name == node.SelectSingleNode("@name").InnerText)
                //                    {
                //                        ctr2.Tagname = node.SelectSingleNode("@tagname").InnerText;
                //                        ctr2.Unit = node.SelectSingleNode("@unit").InnerText;
                //                        ctr2.Tag = node.SelectSingleNode("@index").InnerText;
                //                        ctr2.refresh();
                //                    }

                //                }
                //            }
                //        }
                //    }
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #4
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            string[] message = btn_s.Tag.ToString().Split(',');
            if (btn_s != null)
            {
                if (ctr_line != null)
                {
                    ctr_line.Tagname    = message[5];
                    ctr_line.Tagname_EN = message[6];
                    ctr_line.Tag        = message[0];
                    ctr_line.Unit       = message[2];
                    ctr_line.Max        = txb_max.Text;
                    ctr_line.Min        = txb_min.Text;
                    ctr_line.Color      = tag_color;
                    //保存修改到偏好配置文件

                    string      path = Application.StartupPath + "\\Config\\preference.xml";
                    XmlDocument doc  = new XmlDocument();
                    doc.Load(path);
                    XmlNode     root     = doc.DocumentElement;
                    XmlNodeList nodeList = root.SelectNodes("Form[Name='" + Frm_name + "']//Controlsline//Control");


                    foreach (XmlNode node in nodeList)
                    {
                        if (ctr_line.Name == node.SelectSingleNode("@name").InnerText)
                        {
                            node.SelectSingleNode("@tagname").InnerText    = ctr_line.Tagname;
                            node.SelectSingleNode("@tagname_en").InnerText = ctr_line.Tagname_EN;
                            node.SelectSingleNode("@min").InnerText        = ctr_line.Min;
                            node.SelectSingleNode("@max").InnerText        = ctr_line.Max;
                            node.SelectSingleNode("@unit").InnerText       = ctr_line.Unit;
                            node.SelectSingleNode("@index").InnerText      = ctr_line.Tag.ToString();
                            node.SelectSingleNode("@color").InnerText      = ctr_line.Color.R.ToString() + "," +
                                                                             ctr_line.Color.G.ToString() + "," + ctr_line.Color.B.ToString();
                        }
                    }
                    doc.Save(path);
                    this.ctr_line.label1.Visible    = true;
                    this.ctr_line.label2.Visible    = true;
                    this.ctr_line.label3.Visible    = true;
                    this.ctr_line.label4.Visible    = true;
                    this.ctr_line.label6.Visible    = true;
                    this.ctr_line.checkBox1.Checked = true;
                    ctr_line.refresh();
                    switch (Frm_name)
                    {
                    // case "Form_Main": ((Form_Main)Application.OpenForms[Frm_name]).trend_refresh(ctr_line.Name, Convert.ToInt16(ctr_line.Tag)); break;
                    case "Form_Main": ((Form_Main)Application.OpenForms[Frm_name]).trend_refresh(ctr_line.Name); break;

                    case "Frm_Realtrend": ((Frm_Realtrend)Application.OpenForms[Frm_name]).trend_refresh(ctr_line.Name); break;

                    case "Frm_Realtrend2": ((Frm_Realtrend2)Application.OpenForms[Frm_name]).trend_refresh(ctr_line.Name); break;

                    case "Frm_print":
                    {
                        ((Frm_print)Application.OpenForms[Frm_name]).trend_refresh(ctr_line.Name);
                        ((Frm_print)Application.OpenForms[Frm_name]).btn_refresh.PerformClick();
                        break;
                    }
                    }
                }
                if (ctr_show != null)
                {
                    ctr_show.Tagname    = message[5];
                    ctr_show.Tagname_EN = message[6];
                    ctr_show.Tag        = message[0];
                    ctr_show.Unit       = message[2];
                    ctr_show.Color      = tag_color;
                    //保存修改到偏好配置文件

                    string      path = Application.StartupPath + "\\Config\\preference.xml";
                    XmlDocument doc  = new XmlDocument();
                    doc.Load(path);
                    XmlNode     root     = doc.DocumentElement;
                    XmlNodeList nodeList = root.SelectNodes("Form[Name='" + Frm_name + "']//Controlsshow//Control");


                    foreach (XmlNode node in nodeList)
                    {
                        if (ctr_show.Name == node.SelectSingleNode("@name").InnerText)
                        {
                            node.SelectSingleNode("@tagname").InnerText    = ctr_show.Tagname;
                            node.SelectSingleNode("@tagname_en").InnerText = ctr_show.Tagname_EN;
                            node.SelectSingleNode("@unit").InnerText       = ctr_show.Unit;
                            node.SelectSingleNode("@index").InnerText      = ctr_show.Tag.ToString();
                            node.SelectSingleNode("@color").InnerText      = ctr_show.Color.R.ToString() + "," +
                                                                             ctr_show.Color.G.ToString() + "," + ctr_show.Color.B.ToString();
                        }
                    }
                    doc.Save(path);
                    ctr_show.label1.Visible = true;
                    ctr_show.label2.Visible = true;
                    ctr_show.label3.Visible = true;
                    ctr_show.refresh();
                }

                if (ctr_show2 != null)
                {
                    ctr_show2.Tagname    = message[5];
                    ctr_show2.Tagname_EN = message[6];
                    ctr_show2.Tag        = message[0];
                    ctr_show2.Unit       = message[2];
                    ctr_show2.Color      = tag_color;
                    //保存修改到偏好配置文件

                    string      path = Application.StartupPath + "\\Config\\preference.xml";
                    XmlDocument doc  = new XmlDocument();
                    doc.Load(path);
                    XmlNode     root     = doc.DocumentElement;
                    XmlNodeList nodeList = root.SelectNodes("Form[Name='" + Frm_name + "']//Controlsshow//Control");


                    foreach (XmlNode node in nodeList)
                    {
                        if (ctr_show2.Name == node.SelectSingleNode("@name").InnerText)
                        {
                            node.SelectSingleNode("@tagname").InnerText    = ctr_show2.Tagname;
                            node.SelectSingleNode("@tagname_en").InnerText = ctr_show2.Tagname_EN;
                            node.SelectSingleNode("@unit").InnerText       = ctr_show2.Unit;
                            node.SelectSingleNode("@index").InnerText      = ctr_show2.Tag.ToString();
                            node.SelectSingleNode("@color").InnerText      = ctr_show2.Color.R.ToString() + "," +
                                                                             ctr_show2.Color.G.ToString() + "," + ctr_show2.Color.B.ToString();
                        }
                    }
                    doc.Save(path);
                    ctr_show2.refresh();
                }


                if (ctr_gauge != null)
                {
                    ctr_gauge.Tagname = btn_s.Text;
                    ctr_gauge.Tag     = message[0];
                    ctr_gauge.Unit    = message[2];
                    ctr_gauge.Max     = txb_max.Text;
                    ctr_gauge.Min     = txb_min.Text;
                    //保存修改到偏好配置文件

                    string      path = Application.StartupPath + "\\Config\\preference.xml";
                    XmlDocument doc  = new XmlDocument();
                    doc.Load(path);
                    XmlNode     root     = doc.DocumentElement;
                    XmlNodeList nodeList = root.SelectNodes("Form[Name='" + Frm_name + "']//Controlsgauge//Control");


                    foreach (XmlNode node in nodeList)
                    {
                        if (ctr_gauge.Name == node.SelectSingleNode("@name").InnerText)
                        {
                            node.SelectSingleNode("@tagname").InnerText = ctr_gauge.Tagname;
                            node.SelectSingleNode("@min").InnerText     = ctr_gauge.Min;
                            node.SelectSingleNode("@max").InnerText     = ctr_gauge.Max;
                            node.SelectSingleNode("@unit").InnerText    = ctr_gauge.Unit;
                            node.SelectSingleNode("@index").InnerText   = ctr_gauge.Tag.ToString();
                        }
                    }
                    doc.Save(path);


                    ctr_gauge.refresh();
                }

                if (ctr_gaugemid != null)
                {
                    ctr_gaugemid.Tagname = btn_s.Text;
                    ctr_gaugemid.Tag     = message[0];
                    ctr_gaugemid.Unit    = message[2];
                    ctr_gaugemid.Max     = txb_max.Text;
                    ctr_gaugemid.Min     = txb_min.Text;
                    //保存修改到偏好配置文件

                    string      path = Application.StartupPath + "\\Config\\preference.xml";
                    XmlDocument doc  = new XmlDocument();
                    doc.Load(path);
                    XmlNode     root     = doc.DocumentElement;
                    XmlNodeList nodeList = root.SelectNodes("Form[Name='" + Frm_name + "']//Controlsgauge//Control");


                    foreach (XmlNode node in nodeList)
                    {
                        if (ctr_gaugemid.Name == node.SelectSingleNode("@name").InnerText)
                        {
                            node.SelectSingleNode("@tagname").InnerText = ctr_gaugemid.Tagname;
                            node.SelectSingleNode("@min").InnerText     = ctr_gaugemid.Min;
                            node.SelectSingleNode("@max").InnerText     = ctr_gaugemid.Max;
                            node.SelectSingleNode("@unit").InnerText    = ctr_gaugemid.Unit;
                            node.SelectSingleNode("@index").InnerText   = ctr_gaugemid.Tag.ToString();
                        }
                    }
                    doc.Save(path);


                    ctr_gaugemid.refresh();
                }
            }

            //保存修改的量程到配置文件

            string      path2 = Application.StartupPath + "\\Config\\" + "Para.xml";
            XmlDocument xml   = new XmlDocument();

            xml.Load(path2);
            XmlNodeList list = xml.GetElementsByTagName("item");

            for (int i = 0; i < list.Count; ++i)
            {
                XmlNode node = list.Item(i);
                if (node.Attributes["序号"].Value == message[0])
                {
                    node.Attributes["最大值"].Value = txb_max.Text;
                    node.Attributes["最小值"].Value = txb_min.Text;
                }
            }
            xml.Save(path2);



            this.Close();
        }