public void DelWastePipe(WastePipe pipe) { int index = 0; foreach (WastePipe rp in listWastes) { if (pipe.Name.Equals(rp.Name)) { break; } index++; } if (index < listWastes.Count) { listWastes.RemoveAt(index); mListVLine.RemoveAt(index); } }
public new void OnMouseDown(object sender, MouseButtonEventArgs e) { if (CurrentMode == ADDMODE) { Point cp = e.GetPosition(context); //获取相关坐标 cp.X = cp.X + 7 - App.StrokeThinkness / 2; cp.Y = cp.Y + 7 - App.StrokeThinkness / 2; //设置为中心 Cover c = wastepipes.wastejunc.FindClosedCover(cp); //检测最近点位 if (null == c) { if (mMovingPath != null) { context.Children.Remove(mMovingPath); mMovingPath = null; } if (IsDrawLine) { IsDrawLine = false; } return; } if (IsDrawLine == false) { mStartJunc = c; mStartPoint.X = Mercator2ScreenX(mStartJunc.Location.X) + App.StrokeThinkness / 2; //计算管道第一个点位置坐标 mStartPoint.Y = Mercator2ScreenY(mStartJunc.Location.Y) + App.StrokeThinkness / 2; mMovingPath = new Path(); mMovingPath.Stroke = colorCenter.Seleted_Fill_Color; mMovingPath.Data = DrawPipe(mStartPoint, mStartPoint); mMovingPath.StrokeThickness = App.StrokeThinkness / 2; context.Children.Add(mMovingPath); } else { //removing the tmp moving path context.Children.Remove(mMovingPath); mMovingPath = null; mEndJunc = c; mEndPoint.X = Mercator2ScreenX(mEndJunc.Location.X) + App.StrokeThinkness / 2; mEndPoint.Y = Mercator2ScreenY(mEndJunc.Location.Y) + App.StrokeThinkness / 2; WastePipe pipe = new WastePipe(mStartJunc.Name + "-" + mEndJunc.Name, "双击查看信息", mStartJunc, mEndJunc); pipe.Start.Location = GetMercator(mStartPoint); pipe.End.Location = GetMercator(mEndPoint); PipeAddCommand cmd = new PipeAddCommand(this, pipe, mStartJunc, mEndJunc); cmd.Excute(); CmdManager.getInstance().PushCmd(cmd); } IsDrawLine = !IsDrawLine; } else if (CurrentMode == DELMODE) { Path path = e.Source as Path; if (path == null) { base.OnMouseDown(sender, e); //若都不是添加或删除命令,则交给父类进行处理 return; } PipeDelCommand cmd = new PipeDelCommand(this, path); cmd.Excute(); CmdManager.getInstance().PushCmd(cmd); } base.OnMouseDown(sender, e); //若都不是添加或删除命令,则交给父类进行处理 }
public void AddWastePipe(WastePipe pipe) { listWastes.Add(pipe); mListVLine.Add(new VectorLine(pipe.Start.Location, pipe.End.Location)); }