Esempio n. 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");
        }
Esempio n. 2
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();
        }