Example #1
0
 /// <summary>
 /// 图层移动
 /// </summary>
 public sealed override void Moveto(Coord pos, bool swf)
 {
     if (!MatchUtils.IsEmpty(this.Target) && this.Equals(this.Target.Netmap) && this.Target.Enable && this.Enable)
     {
         try
         {
             pos = this.Extent.Correct(this.Target, this.Target.Option.Exist("Limits") ? this.Target.Option.Fetch <Bound>("Limits").Correct(this.Target, pos) : pos);
         }
         catch
         {
             pos = null;
         }
         finally
         {
             if (pos != null && (!pos.Compare(this.Target, this.Target.Center) || (new StackFrame(1)).GetMethod().Equals(typeof(Geog).GetMethod("Resize"))))
             {
                 // 动画移动
                 if (swf)
                 {
                     AnimeUtils.Launch(new Action <MagicAnime, Coord, Tile>((anime, point, maper) =>
                     {
                         try
                         {
                             if (!MatchUtils.IsEmpty(Tile.anime) && !Tile.anime.Equals(anime))
                             {
                                 Tile.anime.Abort();
                             }
                         }
                         catch
                         {
                             anime.Abort();
                             {
                                 anime = null;
                                 point = null;
                                 maper = null;
                             }
                         }
                         finally
                         {
                             if (!MatchUtils.IsEmpty(Tile.anime = anime))
                             {
                                 if (!maper.Equals(maper.Target.Netmap) || maper.Target.Manual)
                                 {
                                     maper.Noswf();
                                     {
                                         anime = null;
                                         point = null;
                                         maper = null;
                                     }
                                 }
                                 else
                                 {
                                     Pixel middle = maper.Crd2px(maper.Target.Center), finish = maper.Crd2px(point);
                                     if (!MatchUtils.IsEmpty(middle) && !MatchUtils.IsEmpty(finish))
                                     {
                                         double dev, inv;
                                         // 移动地图
                                         if (finish.Compare(maper.Target, middle.Offset(
                                                                (inv = Math.Abs(dev = finish.X - middle.X)) > maper.Speed ? maper.Speed * inv / dev : dev,
                                                                (inv = Math.Abs(dev = finish.Y - middle.Y)) > maper.Speed ? maper.Speed * inv / dev : dev
                                                                )))
                                         {
                                             maper.Noswf();
                                             {
                                                 maper.Moveto(finish);
                                             }
                                         }
                                         else
                                         {
                                             maper.Moveto(middle);
                                         }
                                     }
                                 }
                             }
                         }
                     }), new Object[] { pos, this });
                 }
                 else
                 {
                     Pixel middle = this.Crd2px(pos);
                     if (!MatchUtils.IsEmpty(middle))
                     {
                         // 地图位置
                         Canvas.SetTop(this.Target.Vessel, this.Nature.T  = Math.Round(this.Nature.Y + this.Target.Screen.Y - middle.Y));
                         Canvas.SetLeft(this.Target.Vessel, this.Nature.L = Math.Round(this.Nature.X + this.Target.Screen.X - middle.X));
                         // 重绘地图
                         {
                             this.Build(middle);
                         }
                         // 事件通知
                         this.Trigger(this.Target.Listen.DragEvent, this.Target.Center = pos);
                     }
                 }
             }
         }
     }
 }