Exemplo n.º 1
0
        private void RefreshDGW(int iIndex)
        {
            if (iIndex < 0 || iIndex > ListCur.Count)
            {
                return;
            }

            int k = 0;

            if (iIndex == 0)
            {
                k = -1;
            }
            else
            {
                k = ListCur[iIndex - 1].iYAxis;
            }
            int n = iIndex + k + 1;

            while (dGV1.RowCount > n + 1)
            {
                dGV1.Rows.RemoveAt(n);
            }
            string[] str1 = new string[] { "第1轴", "测量值1", "" };
            int      iRow = 0;

            for (int i = iIndex; i < ListCur.Count; i++)
            {
                CLSCurve cCur = ListCur[i];

                if (i >= ListColor.Length)
                {
                    cCur.LineColor = Color.FromArgb(0xFF, Color.FromArgb(i * 7000));
                }
                else
                {
                    cCur.LineColor = ListColor[i];
                }
                if (cCur.iYAxis != k)
                {
                    k    = cCur.iYAxis;
                    str1 = new string[] { "第" + (k + 1).ToString() + "轴", sCurveGroupName[k], "" };
                    iRow = dGV1.Rows.Add(str1);
                    dGV1.Rows[iRow].DefaultCellStyle.BackColor = Color.LightGray;
                    dGV1.Rows[iRow].DefaultCellStyle.Font      = new System.Drawing.Font(dGV1.Font.FontFamily, dGV1.Font.Size + 2, FontStyle.Bold);
                    dGV1.Rows[iRow].DefaultCellStyle.ForeColor = Color.Red;
                    dGV1.Rows[iRow].Cells[2].Style.BackColor   = cCur.LineColor;
                }
                str1 = new string[] { (i + 1).ToString(), cCur.Text, cCur.LineColor.ToArgb().ToString("X8"), cCur.StaVarName };
                iRow = dGV1.Rows.Add(str1);
                dGV1.Rows[iRow].Cells[2].Style.BackColor = cCur.LineColor;
            }
        }
Exemplo n.º 2
0
        private void butAdd1_Click(object sender, EventArgs e)
        {
            butApply.Enabled = true;
            Button nBut = (Button)sender;
            int    i    = Convert.ToInt32(nBut.Name.Substring(6, 1)) - 1;

            TreeNode node  = treeView1.SelectedNode;
            string   sType = node.Name.Substring(0, 3);

            if (sType == "Var")
            {
                int      iSta = Convert.ToInt32(node.Parent.Name.Substring(4));
                int      iVar = Convert.ToInt32(node.Name.Substring(4));
                CStation sta2 = frmMain.staComm.ListStation[iSta];
                CVar     nVar = sta2.StaDevice.ListDevVar[iVar];
                if (nVar != null)
                {
                    foreach (CLSCurve cCur in ListCur)
                    {
                        if (nVar == cCur.cVar)
                        {
                            MessageBox.Show("该变量已添加!", "错误");
                            return;
                        }
                    }
                    CLSCurve nCur = new CLSCurve(nVar);
                    nCur.iYAxis = i;
                    if (iSelIndex <= i)
                    {
                        iSelIndex = i + 1;
                    }
                    for (int j = 0; j < ListCur.Count; j++)
                    {
                        if (i < ListCur[j].iYAxis)
                        {
                            ListCur.Insert(j, nCur);
                            RefreshDGW(ListCur.IndexOf(nCur));
                            return;
                        }
                    }
                    ListCur.Add(nCur);
                    RefreshDGW(ListCur.IndexOf(nCur));
                }
            }
        }
Exemplo n.º 3
0
        private void butDown1_Click(object sender, EventArgs e)
        {
            try
            {
                string str1 = dGV1.Rows[dGV1.SelectedCells[0].RowIndex].Cells[0].Value.ToString();
                if (str1 != "")
                {
                    int i = Convert.ToInt32(str1);
                    if (i >= 1 || i < ListCur.Count)
                    {
                        if (ListCur[i].iYAxis != ListCur[i - 1].iYAxis)
                        {
                            if (i == 1 || ListCur[i - 2].iYAxis != ListCur[i - 1].iYAxis)
                            {
                                {
                                    for (int j = i; j < ListCur.Count; j++)
                                    {
                                        ListCur[j].iYAxis--;
                                    }
                                }
                            }

                            ListCur[i - 1].iYAxis = ListCur[i].iYAxis;
                            butApply.Enabled      = true;
                            RefreshDGW(i - 1);
                        }
                        else
                        {
                            CLSCurve lcc = ListCur[i - 1];
                            ListCur[i - 1]   = ListCur[i];
                            ListCur[i]       = lcc;
                            butApply.Enabled = true;
                            RefreshDGW(i - 1);
                        }
                    }
                }
            }
            catch
            {
            }
        }
Exemplo n.º 4
0
 public void LoadFromXML(XmlElement Node)
 {
     try
     {
         FontColor    = ColorTranslator.FromHtml(Node.GetAttribute("FontColor"));
         ScaleMinAuto = Convert.ToBoolean(Node.GetAttribute("ScaleMinAuto"));
         ScaleMaxAuto = Convert.ToBoolean(Node.GetAttribute("ScaleMaxAuto"));
         ScaleMin     = Convert.ToDouble(Node.GetAttribute("ScaleMin"));
         ScaleMax     = Convert.ToDouble(Node.GetAttribute("ScaleMax"));
         foreach (XmlElement node in Node.ChildNodes)
         {
             string   StaName = node.GetAttribute("StaName");
             string   VarName = node.GetAttribute("VarName");
             CLSCurve nCur    = new CLSCurve(StaName, VarName);
             nCur.LoadFromXML(node);
             ListCur.Add(nCur);
         }
     }
     catch (Exception e)
     {
     }
 }