/// <summary> /// 장애물이 삭제될 경우 발생하는 이벤트 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ObsDeleteCommandExecuted(object sender, ExecutedRoutedEventArgs e) { List <ObsShape> deldata = new List <ObsShape>(); foreach (var item in ObsDiagram.SelectedItems) { if (item is ObsShape) { ObsShape del = item as ObsShape; deldata.Add(del); } } VIewer3D.Instance.RemoveObsPoints(); for (int i = 0; i < deldata.Count; i++) { ObsDiagram.RemoveShape(deldata[i]); } if (loadTime == false) { Save(); } }
/// <summary> /// 장애물 노드를 추가해준다. /// </summary> /// <param name="pointX"></param> /// <param name="pointY"></param> /// <param name="pointType"></param> public void add_ObsPoint(float pointX, float pointY, int pointType) { //탭 장애물로 전환해주고 tabCon.SelectedIndex = 1; //인덱스 번호를 찾는다 가장 큰 번호에 +1을 한다. int index = 0; var getindex = ObsDiagram.Items.OfType <ObsShape>().OrderByDescending(x => x.Index).ToList(); if (getindex.Count == 0) { index = 0; } else { index = getindex[0].Index + 1; } //다이어그램에 포인트 추가 var shape = new ObsShape() { Position = new Point(createObsX, createObsY), Index = index, PointType = pointType.ToString(), ObsPointX = pointX, ObsPointY = pointY, _oldPointtype = pointType.ToString() }; shape.chitem += Shape_chitem; ObsDiagram.AddShape(shape); createObsX += 150; if (createObsX == 900) { createObsX = 0; createObsY += 120; } ObsDiagram.AutoFit(); }
/// <summary> /// 장애물의 상태가 변경되면 발생하는 이벤트 3D에 결과(색상)을 변경해준다. /// </summary> /// <param name="item"></param> /// <param name="newCode"></param> /// <param name="oldCode"></param> private void Shape_chitem(ObsShape item, string newCode, string oldCode) { VIewer3D.Instance.ChangeObs((float)item.ObsPointX, (float)item.ObsPointY, int.Parse(newCode), int.Parse(oldCode)); VIewer3D.Instance.ActivateObsPoints((float)item.ObsPointX, (float)item.ObsPointY, int.Parse(newCode)); }