/// <summary>
 /// 释放资源
 /// </summary>
 public virtual void Dispose()
 {
     FlickerStop();
     if (m_mapContainer != null)
     {
         m_mapContainer.MouseMove -= new MouseEventHandler(OnMouseMove);
     }
     m_markLayer    = null;
     m_mapContainer = null;
 }
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="markControl">要显示的标注点控件对象</param>
 /// <param name="coordinateType">坐标类型(默认是屏幕坐标,如果是逻辑坐标,在绘图时会根据地图容器的LogicToScreen方法转换坐标)</param>
 /// <param name="mLayer">标注图层对象,为“null”时会内部自动获取</param>
 public MarkBase(FrameworkElement markControl, CoordinateType coordinateType = CoordinateType.Screen, MarkLayer mLayer = null)
 {
     if (mLayer != null)
     {
         m_markLayer    = mLayer;
         m_mapContainer = mLayer.MapContainer;
     }
     if (markControl != null)
     {
         this.m_markControl                 = markControl;
         m_coordinateType                   = coordinateType;
         this.m_markControl.Tag             = this;
         this.m_markControl.Loaded         += new RoutedEventHandler(OnLoaded);
         m_markControl.MouseLeftButtonDown += new MouseButtonEventHandler(OnMouseLeftButtonDown);
         m_markControl.MouseLeftButtonUp   += new MouseButtonEventHandler(OnMouseLeftButtonUp);
     }
 }
 /// <summary>
 /// 控件加载完毕
 /// </summary>
 /// <param name="sender">事件发送者</param>
 /// <param name="e">事件数据源</param>
 protected virtual void OnLoaded(object sender, RoutedEventArgs e)
 {
     this.m_markControl.Loaded -= new RoutedEventHandler(OnLoaded);
     if (m_markControl != null && m_markControl.Parent is MarkLayer)
     {
         m_markLayer    = m_markControl.Parent as MarkLayer;
         m_mapContainer = m_markLayer.MapContainer;
         if (m_mapContainer != null)
         {
             if (m_xLogicChange || m_yLogicChange)
             {
                 double ml_x = Canvas.GetLeft(this.m_markLayer);
                 double ml_y = Canvas.GetTop(this.m_markLayer);
                 double w    = double.IsNaN(m_markControl.Width) ? 0 : m_markControl.Width / 2;   //m_markControl.ActualWidth / 2;//
                 double h    = double.IsNaN(m_markControl.Height) ? 0 : m_markControl.Height / 2; //m_markControl.ActualHeight / 2;//
                 if (m_coordinateType == CoordinateType.Logic && m_mapContainer != null)
                 {
                     Point pnt = m_mapContainer.LogicToScreen(m_x, m_y);
                     if (!double.IsNaN(pnt.X) && !double.IsNaN(pnt.Y))
                     {
                         Canvas.SetLeft(m_markControl, pnt.X - w - ml_x);
                         Canvas.SetTop(m_markControl, pnt.Y - h - ml_y);
                     }
                 }
                 else
                 {
                     Canvas.SetLeft(m_markControl, m_x - w - ml_x);
                     Canvas.SetTop(m_markControl, m_y - h - ml_y);
                 }
             }
             if (m_enableDrag)
             {
                 m_mapContainer.MouseMove += new MouseEventHandler(OnMouseMove);
             }
             else
             {
                 m_mapContainer.MouseMove -= new MouseEventHandler(OnMouseMove);
             }
         }
     }
     m_yLogicChange = false;
     m_xLogicChange = false;
 }
Exemple #4
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="coordinateType">坐标类型(默认是屏幕坐标,如果是逻辑坐标,在绘图时会根据地图容器的LogicToScreen方法转换坐标)</param>
        /// <param name="mLayer">标注图层对象,为“null”时会内部自动获取</param>
        /// <remarks>
        /// 下载示例代码<br/>
        /// <a href="http://www.lbsmap.net/imsdownload/IMSPolymericMark_Demo.rar">IMSPolymericMark_Demo</a>
        /// </remarks>
        public IMSmyPolymericMark(CoordinateType coordinateType = CoordinateType.Screen, MarkLayer mLayer = null) :
            base(null, coordinateType, mLayer)
        {
            m_ellipseName = "CE_" + (++PolymericMarkNum).ToString();
            Canvas canvas = new Canvas()
            {
                Width = 20, Height = 20
            };                                                      //, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center };

            m_ellipse = new Ellipse()
            {
                Name            = m_ellipseName,//"CenEllipse",
                Fill            = new SolidColorBrush(Colors.Yellow),
                StrokeThickness = 2,
                Stroke          = new SolidColorBrush(Colors.Black),
                Width           = 20,
                Height          = 20
            };
            canvas.Children.Add(m_ellipse);
            Canvas.SetZIndex(m_ellipse, 2);
            m_textBlock = new TextBlock()
            {
                TextAlignment     = TextAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Width             = 20,
                Height            = 20,
                Text       = "0",
                FontWeight = FontWeights.Bold
            };
            canvas.Children.Add(m_textBlock);
            Canvas.SetZIndex(m_textBlock, 3);
            Canvas.SetTop(m_textBlock, 2);

            m_markControl = canvas;
            if (this.m_markControl != null)
            {
                m_coordinateType                   = coordinateType;
                this.m_markControl.Tag             = this;
                this.m_markControl.Loaded         += new RoutedEventHandler(OnLoaded);
                m_markControl.MouseLeftButtonDown += new MouseButtonEventHandler(OnMouseLeftButtonDown);
                m_markControl.MouseLeftButtonUp   += new MouseButtonEventHandler(OnMouseLeftButtonUp);
                m_markControl.Cursor               = Cursors.Hand;
                m_markControl.MouseEnter          += new MouseEventHandler(OnMouseEnter1);
                m_markControl.MouseLeave          += new MouseEventHandler(OnMouseLeave1);
            }
            m_timer               = new DispatcherTimer();
            m_timer.Interval      = new TimeSpan(0, 0, 0, 0, 50);
            m_timer.Tick         += new EventHandler(Rotation_Tick);
            m_closeTimer          = new DispatcherTimer();
            m_closeTimer.Interval = new TimeSpan(0, 0, 0, 0, 500);
            m_closeTimer.Tick    += new EventHandler(Close_Tick);
            m_openTimer           = new DispatcherTimer();
            m_openTimer.Interval  = new TimeSpan(0, 0, 0, 0, 300);
            m_openTimer.Tick     += new EventHandler(Open_Tick);

            m_storyboard = new Storyboard();
            DoubleAnimation da = new DoubleAnimation();

            da.From           = 2;
            da.To             = 1;
            da.Duration       = new TimeSpan(0, 0, 0, 0, 500);
            da.AutoReverse    = true;
            da.RepeatBehavior = RepeatBehavior.Forever;
            Storyboard.SetTarget(da, m_ellipse);    //"CenEllipse");
            Storyboard.SetTargetProperty(da, new PropertyPath("StrokeThickness"));
            m_storyboard.Children.Add(da);
            Application.Current.Resources.Add(m_ellipse.Name + "_SB", m_storyboard);
        }
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="markControl">要显示的标注点控件对象</param>
 /// <param name="coordinateType">坐标类型(默认是屏幕坐标,如果是逻辑坐标,在绘图时会根据地图容器的LogicToScreen方法转换坐标)</param>
 /// <param name="mLayer">标注图层对象,为“null”时会内部自动获取</param>
 /// <remarks>
 /// 下载示例代码<br/>
 /// <a href="http://www.lbsmap.net/imsdownload/IMSMark_Demo.rar">IMSMark_Demo</a>
 /// </remarks>
 public IMSmyMark(FrameworkElement markControl, CoordinateType coordinateType = CoordinateType.Screen, MarkLayer mLayer = null) :
     base(markControl, coordinateType, mLayer)
 {
     if (markControl != null)
     {
         markControl.Cursor      = Cursors.Hand;
         markControl.MouseEnter += new MouseEventHandler(OnMouseEnter);
         markControl.MouseLeave += new MouseEventHandler(OnMouseLeave);
     }
 }