/// <summary>
 /// 경로 다이어그램 휠 클릭시 클릭 지점을 센터로 두고 이동 함
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void NaviDiagram_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (e.MiddleButton == MouseButtonState.Pressed)
     {
         //클릭 위치 확인 하여 클릭 시점 중앙으로 위치 이동
         Point  ClickPoint  = (this.Navidiagram as RadDiagram).GetTransformedPoint(e.GetPosition(this.Navidiagram as UIElement));
         double width       = Navidiagram.Viewport.Width / 2;
         double heigh       = Navidiagram.Viewport.Height / 2;
         Point  setPoistion = new System.Windows.Point(ClickPoint.X - width, ClickPoint.Y - heigh);
         Navidiagram.BringIntoView(setPoistion, Navidiagram.Zoom, true);
     }
 }
        /// <summary>
        /// 커넥션을 다시 그려준다. autofit 포함
        /// </summary>
        public void reConnection()
        {
            //Navidiagram.BeginInit();
            ////커넥션 전체 삭제
            //var delcon = Navidiagram.Items.OfType<RadDiagramConnection>().ToList();
            //foreach (RadDiagramConnection item in delcon)
            //{
            //    Navidiagram.RemoveConnection(item);
            //}


            //var shapes = Navidiagram.Items.OfType<NaviShape>().ToList();
            //if (shapes.Count >= 2)
            //{
            //    for (int i = 0; i < shapes.Count - 1; i++)
            //    {
            //        shapes[i].PointType = "1";

            //        if (i == 0)
            //        {
            //            shapes[i].PointType = "0";
            //        }

            //        RadDiagramConnection con = new RadDiagramConnection();
            //        con.Source = shapes[i];
            //        con.Target = shapes[i + 1];
            //        con.TargetCapType = CapType.Arrow2Filled;
            //        con.Stroke = new SolidColorBrush(Colors.Black);
            //        con.StrokeThickness = 2;
            //        con.IsEditable = false;

            //        Navidiagram.AddConnection(con);

            //        if (i + 1 == shapes.Count - 1)
            //        {
            //            shapes[i + 1].PointType = "2";
            //        }
            //    }
            //}
            //Navidiagram.EndInit();
            Navidiagram.AutoFit();

            VIewer3D.Instance.navi.Children.Clear();
            VIewer3D.Instance.DrawLinesOnTimeline();
        }
 /// <summary>
 /// 경로, 장애물 다이어그램을 저장한다.
 /// </summary>
 public void Save()
 {
     writeDiagram(Navidiagram.Save(), Global.projectNaviDiagram);
     writeDiagram(ObsDiagram.Save(), Global.projectObsDiagram);
 }
        /// <summary>
        /// 경로 다이어그램 모델 삭제시 발생하는 이벤트
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NaviDeleteCommandExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            List <NaviShape>            deldatas = new List <NaviShape>();
            List <RadDiagramConnection> delcons  = new List <RadDiagramConnection>();

            //삭제 shape 파악
            foreach (var item in Navidiagram.SelectedItems)
            {
                //NaviShape 가 삭제 되면 3D 부분에서도 삭제해야함.
                if (item is NaviShape)
                {
                    NaviShape delshape = item as NaviShape;
                    //VIewer3D.Instance.NaviPointGridRemove(delshape.NaviPointX, delshape.NaviPointY);

                    deldatas.Add(delshape);
                }
                else if (item is RadDiagramConnection)
                {
                    RadDiagramConnection delitem = item as RadDiagramConnection;
                    delcons.Add(delitem);
                }
            }

            if (deldatas.Count > 0)
            {
                VIewer3D.Instance.RemoveNaviPoints();
            }

            for (int i = 0; i < delcons.Count; i++)
            {
                Navidiagram.RemoveConnection(delcons[i]);
            }

            for (int i = 0; i < deldatas.Count; i++)
            {
                //삭제되는 shape에 connection 이 있는지 확인한다.
                //있는경우는 전부 삭제한다.
                var srcCon = Navidiagram.Items.OfType <RadDiagramConnection>().Where(x => x.Source == deldatas[i]).ToList();
                if (srcCon.Count > 0)
                {
                    foreach (RadDiagramConnection item in srcCon)
                    {
                        Navidiagram.RemoveConnection(item);
                    }
                }
                var dstCon = Navidiagram.Items.OfType <RadDiagramConnection>().Where(x => x.Target == deldatas[i]).ToList();
                if (dstCon.Count > 0)
                {
                    foreach (RadDiagramConnection item in dstCon)
                    {
                        Navidiagram.RemoveConnection(item);
                    }
                }
                Navidiagram.RemoveShape(deldatas[i]);
            }

            reConnection();

            if (loadTime == false)
            {
                Save();
            }


            resetNodeNumber();
        }