private void button2_Click(object sender, EventArgs e) { Global.WorkVar.tag_IsExit = 0; Global.WorkVar.tag_isFangDaiJieChu = false; if (Global.WorkVar.tag_ResetState != 2) { MessageBoxLog.Show("请先复位!"); return; } if (tag_StationModule == worker._Config.tag_safeStationModule) { MessageBoxLog.Show("此工位为安全配置工位,不能运行"); return; } if (tag_StationModule == null) { MessageBoxLog.Show("请选择工位"); return; } tag_stationName = tag_StationModule.strStationName; tag_PointAggregate = GetIndexPointAggregate(); if (!checkBox3_statioOpen.Checked) { WaitUI wait = new WaitUI(pointRun, pointRunEnd, tag_PointAggregate); wait.ShowDialog(); } else { WaitUI wait = new WaitUI(pointRun2, pointRunEnd, tag_PointAggregate); wait.ShowDialog(); } }
private short pointRun2(object o) { PointAggregate a = (PointAggregate)o; short ret = pointMotion.pointRunStep(a); return(ret); }
/// <summary> /// 判断当前轴运动是否是在PA 的安全 配置列表里面(pa.tag_AxisSafeManage.tag_AxisSafeList) 在返回TRUE /// </summary> /// <param name="_ac"></param> /// <param name="pa"></param> /// <returns></returns> public static bool isIOAxisHavePoint(AxisConfig _ac, PointAggregate pa, double pos) { int i = 0; if (pa == null || pa.tag_AxisSafeManage == null || pa.tag_AxisSafeManage.tag_AxisSafeList == null) { return(false); } while (i < pa.tag_AxisSafeManage.tag_AxisSafeList.Count) { AxisSafe currac = pa.tag_AxisSafeManage.tag_AxisSafeList[i]; if ((int)_ac.tag_MotionCardManufacturer * 1000 + _ac.CardNum * 100 + _ac.AxisNum == currac.tag_AxisId) { double poen_ac = 0.0; NewCtrlCardV0.SR_GetPrfPos((int)_ac.tag_MotionCardManufacturer, _ac.CardNum, _ac.AxisNum, ref poen_ac); // if (i == 0) { poen_ac = poen_ac / _ac.Eucf; if (poen_ac <= currac.tag_max && poen_ac >= currac.tag_min) { return(true); } else { return(false); } } } i++; } return(false); }
private short pointRun(object o) { PointAggregate a = (PointAggregate)o; short ret = pointMotion.pointRunStep(a, a.strStationName); return(ret); }
/// <summary> /// 判断当前位置是否是所在按区域的时候,对应IO是否安全,安全返回TRUE,否则FLASE /// </summary> /// <returns></returns> public static bool IOIsSafe(PointAggregate pa) { if (pa == null || pa.tag_AxisSafeManage == null || pa.tag_AxisSafeManage.tag_InIoList == null || pa.tag_AxisSafeManage.tag_InIoList.Count == 0) { return(true); } foreach (OutIOParameterPoint io in pa.tag_AxisSafeManage.tag_InIoList) { bool var = false; // io.tag_IniO1.tag_name if (io != null && io.tag_IniO2 != null && NewCtrlCardV0.GetInputIoBitStatus(io.tag_IniO2.tag_name, io.tag_IniO2.tag_IOName, out var) == 0) { if (var == io.tag_IniO2.tag_var) { } else { LogOutControl.OutLog("IO:<" + io.tag_IniO2.tag_IOName + " >有安全隐患,可能撞机,请注意", 0); return(false); } } } return(true); }
private void Delete_Click(object sender, EventArgs e) { PointAggregate pvale = (PointAggregate)sender; int j = 0; if (Global.CConst.UserLevel != Global.CConst.USER_SUPERADMIN) { MessageBoxLog.Show("无权限"); return; } if (MessageBoxLog.Show("是否删除", "确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) { return; } tag_StationModule.intUsePointCount = tag_StationModule.arrPoint.Count; for (int i = 0; i < tag_StationModule.intUsePointCount; i++) { if (pvale == tag_StationModule.arrPoint[i]) { tag_StationModule.arrPoint.Remove(pvale); tag_StationModule.intUsePointCount--; break; } } Show(); }
//public DebugFrmSet debugF; public PointDetailedSetUI(PointAggregate pointA) { _PointA = pointA; InitializeComponent(); //debugF=dbf; }
// 工位展开 private void checkBox3_statioOpen_CheckedChanged(object sender, EventArgs e) { tag_PointAggregate = null; SetIndexPointAggregate(); tag_UserControl_ShowAllPoint.UserControl_ShowAllPoint_HeightLight(null, null); RefreshStation(); comboBox_IO.Focus(); }
/// <summary> /// /// </summary> /// <param name="_PoitModule"></param> public PointIODelaySetUI(PointAggregate _PoitModule) { tag_PointModule = _PoitModule; if (tag_PointModule.tag_AxisSafeManage == null) { tag_PointModule.tag_AxisSafeManage = new AxisSafeManage(_PoitModule); } if (tag_PointModule.tag_AxisSafeManage.tag_InIoList == null) { tag_PointModule.tag_AxisSafeManage.tag_InIoList = new List <OutIOParameterPoint>(); tag_PointModule.tag_OutIo = new OutIOParameterPoint(); tag_PointModule.tag_AxisSafeManage.tag_InIoList.Add(tag_PointModule.tag_OutIo); } if (tag_PointModule.tag_AxisSafeManage.tag_InIoList.Count == 0) { tag_PointModule.tag_OutIo = new OutIOParameterPoint(); tag_PointModule.tag_AxisSafeManage.tag_InIoList.Add(tag_PointModule.tag_OutIo); } if (tag_PointModule.tag_AxisSafeManage.tag_InIoList.Count > 0) { tag_OutIo = tag_PointModule.tag_AxisSafeManage.tag_InIoList[0]; } #region UI // // ucl_InIo2 // this.ucl_InIo2.Location = new System.Drawing.Point(806, 59); this.ucl_InIo2.Margin = new System.Windows.Forms.Padding(4); this.ucl_InIo2.Name = "ucl_InIo2"; this.ucl_InIo2.Size = new System.Drawing.Size(366, 33); this.ucl_InIo2.TabIndex = 21; // // ucl_InIo1 // this.ucl_InIo1.Location = new System.Drawing.Point(806, 24); this.ucl_InIo1.Margin = new System.Windows.Forms.Padding(4); this.ucl_InIo1.Name = "ucl_InIo1"; this.ucl_InIo1.Size = new System.Drawing.Size(366, 33); this.ucl_InIo1.TabIndex = 13; // // ucl_InIoName2 // this.ucl_InIoName2.Location = new System.Drawing.Point(315, 60); this.ucl_InIoName2.Margin = new System.Windows.Forms.Padding(4); this.ucl_InIoName2.Name = "ucl_InIoName2"; this.ucl_InIoName2.Size = new System.Drawing.Size(322, 33); this.ucl_InIoName2.TabIndex = 10; // // ucl_InIoName1 // this.ucl_InIoName1.Location = new System.Drawing.Point(313, 24); this.ucl_InIoName1.Margin = new System.Windows.Forms.Padding(4); this.ucl_InIoName1.Name = "ucl_InIoName1"; this.ucl_InIoName1.Size = new System.Drawing.Size(347, 33); this.ucl_InIoName1.TabIndex = 9; #endregion InitializeComponent(); }
private void 添加两个点位ToolStripMenuItem_Click(object sender, EventArgs e) { if (Global.CConst.UserLevel != Global.CConst.USER_SUPERADMIN) { MessageBoxLog.Show("无权限"); return; } string strStationName = "NewStation"; if (tag_work.Config.arrWorkStation.Count > 0) { foreach (StationModule ms in tag_work.Config.arrWorkStation) { if (ms.strStationName != "" && ms.strStationName == strStationName) { { MessageBoxLog.Show("已有工位配置"); return; } } } } StationModule sm = new StationModule(); tag_work.Config.arrWorkStation.Add(sm); tag_work.Config.arrWorkStation[tag_work.Config.arrWorkStation.Count - 1].strStationName = strStationName; PointAggregate pa = new PointAggregate(strStationName, "工位开始"); sm.arrPoint.Add(pa); sm.intUsePointCount++; int pointCount = 0; int i = 0; try { pointCount = int.Parse(texB_Count.Text); } catch (Exception mss) { LogOutControl.OutLog(mss.Message, 0); } while (i < pointCount && i < 100) { i++; pa = new PointAggregate(strStationName, "步骤" + i); sm.intUsePointCount++; sm.arrPoint.Add(pa); } pa = new PointAggregate(strStationName, "工位结束"); sm.intUsePointCount++; sm.arrPoint.Add(pa); tag_work.Config.intUseStationCount++; tag_work.Config.Save(); FrmStationMange_Load(null, null); }
void OutIOStationSelect(object var) { if (var != null) { tag_StationModule = (StationModule)var; tag_PointAggregate = null; SetIndexPointAggregate(); RefreshStation(); tag_UserControl_ShowAllPoint.UserControl_ShowAllPoint_HeightLight(null, null); } }
public bool IsAdd(PointAggregate a) { foreach (PointAggregate pa in tag_PointAggregateList) { if (pa == a) { return(false); } } return(true); }
public PointValueControl(PointAggregate PointSet_, Work _sWorker, int step, StationModule sm) //初始化点位参数数组 { tag_stepName = step; _Worker = _sWorker; tag_stationM = sm; InitializeComponent(); if (PointSet_ != null) { PointSet = PointSet_; } }
//Combox选中工位后自动刷新工位参数 private void StnChioceCB_SelectedIndexChanged(object sender, EventArgs e) { tag_StationModule = StationManage.FindStation(CBStnChioce.Text); tag_PointAggregate = null; SetIndexPointAggregate(); RefreshStation(); tag_UserControl_ShowAllPoint.UserControl_ShowAllPoint_HeightLight(null, null); comboBox_IO.Focus(); comboBox_IO.Text = CBStnChioce.Text; comboBox1_SelectedIndexChanged(sender, e); NewCtrlCardIO.tag_IO_refresh = 10; }
public PointAggregate GetIndexPointAggregate() { int index = tag_UserControl_ShowAllPoint.tag_page_Count * tag_UserControl_ShowAllPoint.tag_page_index; int i = 0; if (checkBox3_statioOpen.Checked) { for (int n = 0; n < tag_StationModule.arrPoint.Count; n++) { PointAggregate pa = tag_StationModule.arrPoint[n]; if (pa.tag_BeginPointAggregateList != null) { foreach (PointAggregate pb in pa.tag_BeginPointAggregateList) { if (i == tag_StationModule.tag_stepId) { return(pb); } i++; } } if (i == tag_StationModule.tag_stepId) { return(pa); } i++; if (pa.tag_EndPointAggregateList != null) { foreach (PointAggregate pb in pa.tag_EndPointAggregateList) { if (i == tag_StationModule.tag_stepId) { return(pb); } i++; } } } } else { if (tag_StationModule.tag_stepId >= tag_StationModule.arrPoint.Count) { tag_StationModule.tag_stepId = 0; } return(tag_StationModule.arrPoint[tag_StationModule.tag_stepId]); } tag_StationModule.tag_stepId = 0; return(tag_StationModule.arrPoint[tag_StationModule.tag_stepId]); }
/// <summary> /// /// </summary> /// <param name="point"></param> public AxisSafeManage(PointAggregate point) { tag_AxisSafeList = new List <AxisSafe>(); StationModule sm = StationManage.FindStation(point.strStationName); if (sm == null) { LogOutControl.OutLog("无" + point.strStationName, 0); return; } foreach (AxisConfig ac in sm.arrAxis) { Add((short)ac.tag_MotionCardManufacturer, ac.CardNum, ac.AxisNum); } }
private void 添加CCD九宫格标定点位ToolStripMenuItem_Click(object sender, EventArgs e) { if (Global.CConst.UserLevel != Global.CConst.USER_SUPERADMIN) { MessageBoxLog.Show("无权限"); return; } string strStationName = "CCD_9宫格标定"; if (tag_work.Config.arrWorkStation.Count > 0) { foreach (StationModule ms in tag_work.Config.arrWorkStation) { if (ms.strStationName != "" && ms.strStationName == strStationName) { { MessageBoxLog.Show("已有工位配置"); return; } } } } StationModule sm = new StationModule(); tag_work.Config.arrWorkStation.Add(sm); tag_work.Config.arrWorkStation[tag_work.Config.arrWorkStation.Count - 1].strStationName = strStationName; PointAggregate pa = new PointAggregate(strStationName, "标定开始"); sm.arrPoint.Add(pa); sm.intUsePointCount++; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { pa = new PointAggregate(strStationName, i + "_" + j + "点位"); sm.arrPoint.Add(pa); sm.intUsePointCount++; } } pa = new PointAggregate(strStationName, "标定结束"); sm.intUsePointCount++; sm.arrPoint.Add(pa); tag_work.Config.intUseStationCount++; tag_work.Config.Save(); FrmStationMange_Load(null, null); }
/// <summary> /// 轴绝对运动 /// </summary> /// <param name="stationName"></param> /// <param name="axisName"></param> /// <param name="pointName"></param> /// <returns></returns> public static short AxisAbsoluteMove(string stationName, string axisName, string pointName, int asxisIndex) { StationModule stationM = StationManage.FindStation(stationName); if (stationM == null) { return(shrFail); } AxisConfig axisC = StationManage.FindAxis(stationM, axisName); if (axisC == null) { return(shrFail); } PointAggregate pointA = StationManage.FindPoint(stationM, pointName); if (pointA == null) { return(shrFail); } NewCtrlCardBase Base_ = tag_NewCtrlCardBase[(int)axisC.tag_MotionCardManufacturer]; if (Base_ == null) { MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)axisC.tag_MotionCardManufacturer) + "控制卡初始化失败!"); return(shrFail); } short shrResult = 0; if (pointA.tag_motionType == 0) { shrResult = Base_.SR_AbsoluteMove(axisC, pointA.arrPoint[asxisIndex]); } else { shrResult = Base_.SR_RelativeMove(axisC, pointA.arrPoint[asxisIndex]); } if (shrResult != shrSuccess) { return(shrFail); } return(shrSuccess); }
/// <summary> /// 轴运动并等待停止并判断位置 /// </summary> /// <param name="stationName"></param> /// <param name="axisName"></param> /// <param name="pointName"></param> /// <param name="asxisIndex"></param> /// <returns></returns> public static short AxisAbsoluteMoveAndWaitStopVrf(string stationName, string axisName, string pointName, int asxisIndex) { if (AxisAbsoluteMove(stationName, axisName, pointName, asxisIndex) != 0) { Global.WorkVar.tag_StopState = 2; if (MessageBoxLog.Show("工位:\r\n" + stationName + "\r\n轴名:\r\n" + axisName + "\t移动异常,请检查伺服驱动!") == DialogResult.OK) { } return(shrFail); } StationModule stationM = StationManage.FindStation(stationName); if (stationM == null) { return(shrFail); } PointAggregate pointA = StationManage.FindPoint(stationM, pointName); if (pointA == null) { return(shrFail); } AxisConfig axisC = StationManage.FindAxis(stationM, axisName); if (WaitAxisStop(axisC) != 0) { return(shrFail); } double pos_loadY = 0; short ret = SR_GetPrfPos((int)axisC.tag_MotionCardManufacturer, axisC.CardNum, axisC.AxisNum, ref pos_loadY); if (Global.WorkVar.tag_SuspendState == 1 || (Global.WorkVar.bSuspendState_L && axisC.AxisName == "左Y轴") || (Global.WorkVar.bSuspendState_R && axisC.AxisName == "右Y轴")) { } else if (pos_loadY / axisC.Eucf < pointA.arrPoint[asxisIndex].dblPonitValue - 1 || pos_loadY / axisC.Eucf > pointA.arrPoint[asxisIndex].dblPonitValue + 1) { return(shrFail); } return(shrSuccess); }
/// <summary> /// 判断当前位置是否是本点的安全区 安全返回TRUE /// </summary> /// <returns></returns> public bool PointIsSafe(PointAggregate point) { foreach (StationModule sm in StationManage._Config.arrWorkStation) { foreach (AxisConfig ac in sm.arrAxis) { AxisSafe asf = GetAxisSafe((short)ac.tag_MotionCardManufacturer, ac.CardNum, ac.AxisNum); if (asf != null) { double poen_ac = 0; NewCtrlCardV0.SR_GetPrfPos((int)ac.tag_MotionCardManufacturer, ac.CardNum, ac.AxisNum, ref poen_ac); poen_ac = poen_ac / ac.Eucf; if (!asf.IsSafe(poen_ac)) //if (!asf.IsSafe(ac.dblEncPos)) { return(false); } } } } return(true); }
private void 制ToolStripMenuItem_Click(object sender, EventArgs e) { if (treView_station.SelectedNode == null || treView_station.SelectedNode.Name == "Root") { return; } else { if (treView_station.SelectedNode.Parent.Name == "Root") { } else { tag_PointAggregate = (PointAggregate)treView_station.SelectedNode.Tag; tag_PointAggregateList = new List <PointAggregate>(); if (tag_PointAggregate != null) { tag_PointAggregateList.Add(tag_PointAggregate); } } } }
/// <summary> /// /// </summary> /// <param name="pa"></param> public AxisSafetyManageUI(PointAggregate pa) { tag_PointAggregate = pa; tag_AxisSafeList = new List <AxisSafetySetControl>(); InitializeComponent(); }
private void 粘贴到本点的列表中ToolStripMenuItem_Click(object sender, EventArgs e) { int index = 0; if (treView_station.SelectedNode.Text == "在本点之前执行") { PointAggregate pa = (PointAggregate)treView_station.SelectedNode.Tag; if (pa.tag_BeginPointAggregateList == null) { pa.tag_BeginPointAggregateList = new List <object>(); } if (tag_PointAggregateList != null) { int n = 0; pa.tag_BeginPointAggregateListIsEnable = true; foreach (PointAggregate ppp in tag_PointAggregateList) { pa.tag_BeginPointAggregateList.Insert(0 + n, ppp); n++; } } treView_station.SelectedNode.Nodes.Clear(); foreach (object pp in pa.tag_BeginPointAggregateList) { PointAggregate p = (PointAggregate)pp; TreeNode tn = new TreeNode(p.strName); tn.Tag = p; tn.Name = treView_station.SelectedNode.Parent.Name + "_" + index; treView_station.SelectedNode.Nodes.Add(tn); index++; } return; } if (treView_station.SelectedNode.Text == "在本点之后执行") { PointAggregate pa = (PointAggregate)treView_station.SelectedNode.Tag; if (pa.tag_EndPointAggregateList == null) { pa.tag_EndPointAggregateListIsEnable = true; pa.tag_EndPointAggregateList = new List <object>(); } if (tag_PointAggregateList != null) { int n = 0; pa.tag_EndPointAggregateListIsEnable = true; foreach (PointAggregate ppp in tag_PointAggregateList) { pa.tag_EndPointAggregateList.Insert(0 + n, ppp); n++; } } treView_station.SelectedNode.Nodes.Clear(); foreach (object pp in pa.tag_EndPointAggregateList) { PointAggregate p = (PointAggregate)pp; TreeNode tn = new TreeNode(p.strName); tn.Tag = p; tn.Name = treView_station.SelectedNode.Parent.Name + "_" + index; treView_station.SelectedNode.Nodes.Add(tn); index++; } return; } }
private void 粘贴到本点后ToolStripMenuItem_Click(object sender, EventArgs e) { int index = 0; if (treView_station.SelectedNode == null || treView_station.SelectedNode.Name == "Root") { return; } else { if (treView_station.SelectedNode.Parent.Name == "Root") { } else { if (treView_station.SelectedNode.Parent.Parent.Name == "Root") { StationModule sm = (StationModule)treView_station.SelectedNode.Parent.Tag; if (tag_PointAggregateList != null) { int n = 0; foreach (PointAggregate ppp in tag_PointAggregateList) { sm.arrPoint.Insert(treView_station.SelectedNode.Index + n, ppp); n++; } } treView_station.SelectedNode = treView_station.SelectedNode.Parent; treView_station.SelectedNode.Nodes.Clear(); foreach (object pp in sm.arrPoint) { PointAggregate p = (PointAggregate)pp; TreeNode tn = new TreeNode(p.strName); tn.Tag = p; tn.Name = treView_station.SelectedNode.Parent.Name + "_" + index; TreeNode tnUp = new TreeNode("在本点之前执行"); tnUp.Tag = p; tn.Nodes.Add(tnUp); TreeNode tnDown = new TreeNode("在本点之后执行"); tnDown.Tag = p; tn.Nodes.Add(tnDown); treView_station.SelectedNode.Nodes.Add(tn); index++; } } else if (treView_station.SelectedNode.Parent.Text == "在本点之后执行") { PointAggregate pa = (PointAggregate)treView_station.SelectedNode.Parent.Tag; if (tag_PointAggregateList != null) { int n = 0; foreach (PointAggregate ppp in tag_PointAggregateList) { pa.tag_EndPointAggregateList.Insert(treView_station.SelectedNode.Index + 1 + n, ppp); n++; } } treView_station.SelectedNode = treView_station.SelectedNode.Parent; treView_station.SelectedNode.Nodes.Clear(); foreach (object pp in pa.tag_EndPointAggregateList) { PointAggregate p = (PointAggregate)pp; TreeNode tn = new TreeNode(p.strName); tn.Tag = p; tn.Name = treView_station.SelectedNode.Parent.Name + "_" + index; treView_station.SelectedNode.Nodes.Add(tn); index++; } } else if (treView_station.SelectedNode.Parent.Text == "在本点之前执行") { PointAggregate pa = (PointAggregate)treView_station.SelectedNode.Parent.Tag; if (tag_PointAggregateList != null) { int n = 0; foreach (PointAggregate ppp in tag_PointAggregateList) { pa.tag_EndPointAggregateList.Insert(treView_station.SelectedNode.Index + 1 + n, ppp); n++; } } treView_station.SelectedNode = treView_station.SelectedNode.Parent; treView_station.SelectedNode.Nodes.Clear(); foreach (object pp in pa.tag_EndPointAggregateList) { PointAggregate p = (PointAggregate)pp; TreeNode tn = new TreeNode(p.strName); tn.Tag = p; tn.Name = treView_station.SelectedNode.Parent.Name + "_" + index; treView_station.SelectedNode.Nodes.Add(tn); index++; } } } } }
private void treView_station_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { int index = 0; if (treView_station.SelectedNode == null || treView_station.SelectedNode.Name == "Root") { return; } else { if (treView_station.SelectedNode.Parent.Name == "Root") { treView_station.SelectedNode.Nodes.Clear(); StationModule lsfm = (StationModule)treView_station.SelectedNode.Tag;; PointAggregate pa = StationManage.FindPoint(lsfm, treView_station.SelectedNode.Text); if (lsfm == null || lsfm.arrPoint == null) { return; } foreach (object pp in lsfm.arrPoint) { PointAggregate p = (PointAggregate)pp; TreeNode tn = new TreeNode(p.strName); tn.Tag = p; tn.Name = treView_station.SelectedNode.Name + "_" + index; TreeNode tnUp = new TreeNode("在本点之前执行"); tnUp.Tag = p; tn.Nodes.Add(tnUp); TreeNode tnDown = new TreeNode("在本点之后执行"); tnDown.Tag = p; tn.Nodes.Add(tnDown); treView_station.SelectedNode.Nodes.Add(tn); index++; } } else { if (treView_station.SelectedNode.Text == "在本点之前执行") { treView_station.SelectedNode.Nodes.Clear(); PointAggregate pa = (PointAggregate)treView_station.SelectedNode.Tag; if (pa == null || pa.tag_BeginPointAggregateList == null) { return; } foreach (object pp in pa.tag_BeginPointAggregateList) { PointAggregate p = (PointAggregate)pp; TreeNode tn = new TreeNode(p.strName); tn.Tag = p; tn.Name = treView_station.SelectedNode.Name + "_" + index; treView_station.SelectedNode.Nodes.Add(tn); index++; } } else if (treView_station.SelectedNode.Text == "在本点之后执行") { treView_station.SelectedNode.Nodes.Clear(); PointAggregate pa = (PointAggregate)treView_station.SelectedNode.Tag; if (pa == null || pa.tag_EndPointAggregateList == null) { return; } foreach (object pp in pa.tag_EndPointAggregateList) { PointAggregate p = (PointAggregate)pp; TreeNode tn = new TreeNode(p.strName); tn.Tag = p; tn.Name = treView_station.SelectedNode.Name + "_" + index; treView_station.SelectedNode.Nodes.Add(tn); index++; } } } } }
private void treView_station_DragDrop(object sender, DragEventArgs e) { //拖拽结束,Drop放下时执行 TreeNode myNode = null; if (e.Data.GetDataPresent(typeof(TreeNode))) { myNode = (TreeNode)(e.Data.GetData(typeof(TreeNode))); //拖拽源节点dragNode } else { MessageBox.Show("errror!"); } ///处理拖拽 Position.X = e.X; Position.Y = e.Y; Position = treView_station.PointToClient(Position); //取得拖拽点的数据 TreeNode dropNode = this.treView_station.GetNodeAt(Position); //1.// 1.目标节点不是空。 //2.目标节点不是被拖拽接点的子节点。 //3.目标节点不是被拖拽节点本身 if (dropNode != null //&& dropNode.Parent != myNode.Parent && dropNode != myNode) { TreeNode dragNode = myNode; myNode.Remove(); dropNode.Nodes.Add(dragNode); #region tete int index = 0; StationModule sm = (StationModule)treView_station.SelectedNode.Parent.Tag; sm.arrPoint.RemoveAt(treView_station.SelectedNode.Index); if (sm.arrPoint == null) { return; } foreach (object pp in sm.arrPoint) { PointAggregate p = (PointAggregate)pp; TreeNode tn = new TreeNode(p.strName); tn.Tag = p; tn.Name = treView_station.SelectedNode.Parent.Name + "_" + index; index++; } #endregion } // 如果目标节点不存在,即拖拽的位置不存在节点,那么就将被拖拽节点放在根节点之下 if (dropNode == null) { TreeNode DragNode = myNode; myNode.Remove(); treView_station.Nodes.Add(DragNode); } }
private void 移除本点ToolStripMenuItem_Click(object sender, EventArgs e) { int index = 0; if (MessageBoxLog.Show("是否移除" + treView_station.SelectedNode.Text, "确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) { return; } if (treView_station.SelectedNode.Text == "在本点之前执行") { PointAggregate pppp = (PointAggregate)treView_station.SelectedNode.Parent.Tag; if (pppp.tag_BeginPointAggregateList != null) { pppp.tag_BeginPointAggregateList.Clear(); treView_station.SelectedNode.Nodes.Clear(); } return; } else if (treView_station.SelectedNode.Text == "在本点之后执行") { PointAggregate pppp = (PointAggregate)treView_station.SelectedNode.Parent.Tag; if (pppp.tag_EndPointAggregateList != null) { pppp.tag_EndPointAggregateList.Clear(); treView_station.SelectedNode.Nodes.Clear(); } return; } if (treView_station.SelectedNode == null || treView_station.SelectedNode.Name == "Root") { return; } else { if (treView_station.SelectedNode.Parent.Name == "Root") { } else { if (treView_station.SelectedNode.Parent.Parent.Name == "Root") { StationModule sm = (StationModule)treView_station.SelectedNode.Parent.Tag; sm.arrPoint.RemoveAt(treView_station.SelectedNode.Index); if (sm.arrPoint == null) { return; } treView_station.SelectedNode = treView_station.SelectedNode.Parent; treView_station.SelectedNode.Nodes.Clear(); foreach (object pp in sm.arrPoint) { PointAggregate p = (PointAggregate)pp; TreeNode tn = new TreeNode(p.strName); tn.Tag = p; tn.Name = treView_station.SelectedNode.Parent.Name + "_" + index; treView_station.SelectedNode.Nodes.Add(tn); index++; } } else { PointAggregate pa = (PointAggregate)treView_station.SelectedNode.Parent.Tag; if (treView_station.SelectedNode.Parent.Text == "在本点之前执行") { if (pa.tag_BeginPointAggregateList == null) { return; } pa.tag_BeginPointAggregateList.RemoveAt(treView_station.SelectedNode.Index); treView_station.SelectedNode = treView_station.SelectedNode.Parent; treView_station.SelectedNode.Nodes.Clear(); foreach (object pp in pa.tag_BeginPointAggregateList) { PointAggregate p = (PointAggregate)pp; TreeNode tn = new TreeNode(p.strName); tn.Tag = p; tn.Name = treView_station.SelectedNode.Parent.Name + "_" + index; treView_station.SelectedNode.Nodes.Add(tn); index++; } } else if (treView_station.SelectedNode.Parent.Text == "在本点之后执行") { if (pa.tag_EndPointAggregateList == null) { return; } pa.tag_EndPointAggregateList.RemoveAt(treView_station.SelectedNode.Index); treView_station.SelectedNode = treView_station.SelectedNode.Parent; treView_station.SelectedNode.Nodes.Clear(); foreach (object pp in pa.tag_EndPointAggregateList) { PointAggregate p = (PointAggregate)pp; TreeNode tn = new TreeNode(p.strName); tn.Tag = p; tn.Name = treView_station.SelectedNode.Parent.Name + "_" + index; treView_station.SelectedNode.Nodes.Add(tn); index++; } } } } } }
public void SetIndexPointAggregate() { int i = 0; // 工位展开 if (checkBox3_statioOpen.Checked) { for (int n = 0; n < tag_StationModule.arrPoint.Count; n++) { PointAggregate pa = tag_StationModule.arrPoint[n]; if (n == tag_StationModule.tag_stepId) { tag_StationModule.tag_stepId = i; return; } if (pa.tag_BeginPointAggregateList != null) { foreach (PointAggregate pb in pa.tag_BeginPointAggregateList) { i++; } } i++; if (pa.tag_EndPointAggregateList != null) { foreach (PointAggregate pb in pa.tag_EndPointAggregateList) { i++; } } } } else { for (int n = 0; n < tag_StationModule.arrPoint.Count; n++) { PointAggregate pa = tag_StationModule.arrPoint[n]; if (i == tag_StationModule.tag_stepId) { tag_StationModule.tag_stepId = n; return; } if (pa.tag_BeginPointAggregateList != null) { foreach (PointAggregate pb in pa.tag_BeginPointAggregateList) { if (i == tag_StationModule.tag_stepId) { tag_StationModule.tag_stepId = n; return; } i++; } } i++; if (pa.tag_EndPointAggregateList != null) { foreach (PointAggregate pb in pa.tag_EndPointAggregateList) { if (i == tag_StationModule.tag_stepId) { tag_StationModule.tag_stepId = n; return; } i++; } } } } tag_StationModule.tag_stepId = 0; }