示例#1
0
        /// <summary>
        /// 响应鼠标按下事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override 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; //设置为中心
                RainCover c = new RainCover("雨水检查井", GetMercator(cp), "双击查看详细信息");
                //添加其他相关信息
                c.Location = GetMercator(cp);

                JuncAddCommand cmd = new JuncAddCommand(this, c);
                cmd.Excute();
                CmdManager.getInstance().PushCmd(cmd);
            }
            else if (CurrentMode == DELMODE)
            {
                Path path = e.Source as Path;
                if (path == null)
                {
                    base.OnMouseDown(sender, e);          //若都不是添加或删除命令,则交给父类进行处理
                    return;
                }
                JuncDelCommand cmd = new JuncDelCommand(this, path);
                cmd.Excute();
                CmdManager.getInstance().PushCmd(cmd);
            }
            base.OnMouseDown(sender, e);                //若都不是添加或删除命令,则交给父类进行处理
        }
示例#2
0
        public void DelJunc(RainCover c)
        {
            int index = 0;

            foreach (RainCover tmpc in listRains)
            {
                if (c.Name.Equals(tmpc.Name))
                {
                    break;
                }
                index++;
            }
            if (index < listRains.Count)
            {
                listRains.RemoveAt(index);
                mListScreenpoint.RemoveAt(index);
            }
        }
示例#3
0
        /// <summary>
        ///在现有的检查井中寻找最接近的点
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public RainCover FindClosedCover(Point p)
        {
            RainCover cover = null;
            double    dis   = App.StrokeThinkness;

            for (int i = 0; i < listRains.Count; i++)
            {
                if (Math.Abs(mListScreenpoint.ElementAt(i).X - p.X) > dis || Math.Abs(mListScreenpoint.ElementAt(i).Y - p.Y) > dis)
                {
                    continue;
                }
                double d = Math.Sqrt((mListScreenpoint.ElementAt(i).X - p.X) * (mListScreenpoint.ElementAt(i).X - p.X) +
                                     (mListScreenpoint.ElementAt(i).Y - p.Y) * (mListScreenpoint.ElementAt(i).Y - p.Y));      //计算距离
                if (dis > d)
                {
                    dis   = d;
                    cover = listRains[i];
                }
            }
            return(cover);
        }
示例#4
0
 public void AddJunc(RainCover c)           //添加雨水检查井
 {
     listRains.Add(c);
     //计算点的坐标
     mListScreenpoint.Add(state.Mercator2Screen(c.Location));
 }