private void btnSure_Click(object sender, EventArgs e) { try { if (txtName.Text.Trim() == "") { MessageBox.Show("名称不能为空!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ///Start Add by xiao at 2017/3/15 if (cm.IsExistsNodeName("ClsLinedata", txtName.Text, cm.XmlDoc.ChildNodes)) { MessageBox.Show("相同名称已经存在!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ///End ClsLinedata tempdata = new ClsLinedata(); tempdata.Name = txtName.Text; tempdata.Symbolname = cboSymbol.Text; tempdata.Penid = cboPenType.Text; tempdata.X = Convert.ToSingle(numD_X.Value); tempdata.Y = Convert.ToSingle(numD_Y.Value); tempdata.Span_x = Convert.ToSingle(numD_SpanX.Value); tempdata.Span_y = Convert.ToSingle(numD_SpanY.Value); tempdata.Scale = txtScale.Text; tempdata.Basevalue = txtBaseVal.Text; tempdata.Broken = txtBrokenSet.Text; cm.newnode = new TreeNode(); cm.newnode.Text = tempdata.Name; cm.newnode.Name = tempdata.Name; cm.newnode.Tag = tempdata; this.Close(); } catch { cm.newnode = null; } }
private void picTemperatureShow_MouseMove(object sender, MouseEventArgs e) { _strTip = ""; _ptTip = new Point(e.X + 10, e.Y); tlbllocation.Text = "当前鼠标坐标:" + "X:" + e.X.ToString() + " Y:" + e.Y.ToString(); if (tdrag) { int spanx = e.X - p1.X; int spany = e.Y - p1.Y; try { if (trvTemperture.SelectedNode.Tag != null) { if (trvTemperture.SelectedNode.Tag.ToString() == "TempertureEditor.Element.ClsRec") { ClsRec temp = (ClsRec)trvTemperture.SelectedNode.Tag; Rectangle rec = new Rectangle(temp.Rec.X + spanx, temp.Rec.Y + spany, temp.Rec.Width, temp.Rec.Height); temp.Rec = rec; trvTemperture.SelectedNode.Tag = temp; } else if (trvTemperture.SelectedNode.Tag.ToString() == "TempertureEditor.Element.ClsLine") { ClsLine temp = (ClsLine)trvTemperture.SelectedNode.Tag; temp.X1 = temp.X1 + spanx; temp.Y1 = temp.Y1 + spany; temp.X2 = temp.X2 + spanx; temp.Y2 = temp.Y2 + spany; trvTemperture.SelectedNode.Tag = temp; } else if (trvTemperture.SelectedNode.Tag.ToString() == "TempertureEditor.Element.ClsText") { ClsText temp = (ClsText)trvTemperture.SelectedNode.Tag; temp.X1 = temp.X1 + spanx; temp.Y1 = temp.Y1 + spany; trvTemperture.SelectedNode.Tag = temp; } else if (trvTemperture.SelectedNode.Tag.ToString() == "TempertureEditor.Element.ClsText") { ClsText temp = (ClsText)trvTemperture.SelectedNode.Tag; temp.X1 = temp.X1 + spanx; temp.Y1 = temp.Y1 + spany; trvTemperture.SelectedNode.Tag = temp; } else if (trvTemperture.SelectedNode.Tag.ToString() == "TempertureEditor.Element.ClsImg") { ClsImg temp = (ClsImg)trvTemperture.SelectedNode.Tag; temp.X = temp.X + spanx; temp.Y = temp.Y + spany; trvTemperture.SelectedNode.Tag = temp; } this.propertyGrid1.SelectedObject = trvTemperture.SelectedNode.Tag; } } catch { } p1.X = e.X; p1.Y = e.Y; this.picTemperatureShow.Refresh(); } else { foreach (Page page in cm.Pages) { foreach (ClsDataObj obj in page.Objs) { //if(obj.Typename== "TempertureEditor.Element.ClsLinedata") object objtype = cm.GetVDataSetByName(obj.Typename); if (objtype == null) { continue; } if (objtype.ToString() == "TempertureEditor.Element.ClsLinedata") { ClsLinedata lindedata = (ClsLinedata)objtype; ClsSymbol symbol = cm.getClsSymbolByName(lindedata.Symbolname); if (symbol != null) { Rectangle rc = new Rectangle((int)obj.X, (int)obj.Y, Convert.ToInt32(symbol.fontsize) + symbol.cx, Convert.ToInt32(symbol.fontsize) + symbol.cy); if (rc.Contains(e.X, e.Y)) { _strTip = obj.Val.ToString(); break; } } } } } picTemperatureShow.Refresh(); } }
/// <summary> /// 整体调整位置 /// </summary> /// <param name="span_rx"></param> /// <param name="span_ry"></param> /// <param name="isSelectNode"></param> private void AllElementReLocation(int span_rx, int span_ry, bool isSelectNode) { try { foreach (TreeNode tn in trvTemperture.Nodes) { foreach (TreeNode tnelement in tn.Nodes) { //元素集合 if (isSelectNode) { if (trvTemperture.SelectedNode != null) { if (tnelement.Name != trvTemperture.SelectedNode.Name) { continue; } } else { break; } } if (tn.Name == "element") { if (tnelement.Tag.ToString().Contains("ClsRec")) { ClsRec temp = (ClsRec)tnelement.Tag; Rectangle rec = new Rectangle(temp.Rec.X + span_rx, temp.Rec.Y + span_ry, temp.Rec.Width, temp.Rec.Height); temp.Rec = rec; tnelement.Tag = temp; cm.UpdateXml(1, tnelement, cm.XmlDoc, trvTemperture); } else if (tnelement.Tag.ToString() == "TempertureEditor.Element.ClsText") { ClsText temp = (ClsText)tnelement.Tag; temp.X1 = temp.X1 + span_rx; temp.Y1 = temp.Y1 + span_ry; tnelement.Tag = temp; cm.UpdateXml(1, tnelement, cm.XmlDoc, trvTemperture); } else if (tnelement.Tag.ToString() == "TempertureEditor.Element.ClsLine") { ClsLine temp = (ClsLine)tnelement.Tag; temp.X1 = temp.X1 + span_rx; temp.Y1 = temp.Y1 + span_ry; temp.X2 = temp.X2 + span_rx; temp.Y2 = temp.Y2 + span_ry; tnelement.Tag = temp; cm.UpdateXml(1, tnelement, cm.XmlDoc, trvTemperture); } else if (tnelement.Tag.ToString() == "TempertureEditor.Element.ClsImg") { ClsImg temp = (ClsImg)tnelement.Tag; temp.X = temp.X + span_rx; temp.Y = temp.Y + span_ry; tnelement.Tag = temp; cm.UpdateXml(1, tnelement, cm.XmlDoc, trvTemperture); } } else if (tn.Name == "vdataset") { if (tnelement.Tag.ToString() == "TempertureEditor.Element.ClsLinedata") { ClsLinedata temp = (ClsLinedata)tnelement.Tag; temp.X = temp.X + span_rx; temp.Y = temp.Y + span_ry; tnelement.Tag = temp; cm.UpdateXml(1, tnelement, cm.XmlDoc, trvTemperture); //cm.GetTestPages(); } else if (tnelement.Tag.ToString() == "TempertureEditor.Element.ClsTextdata") { ClsTextdata temp = (ClsTextdata)tnelement.Tag; temp.X = temp.X + span_rx; temp.Y = temp.Y + span_ry; tnelement.Tag = temp; cm.UpdateXml(1, tnelement, cm.XmlDoc, trvTemperture); //cm.GetTestPages(); } } } } if (trvTemperture.SelectedNode != null) { propertyGrid1.SelectedObject = trvTemperture.SelectedNode.Tag; } cm.GetTestPages(); this.picTemperatureShow.Refresh(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }