Esempio n. 1
0
        /// <summary>
        /// Shows the specified annotation.
        /// </summary>
        /// <param name="annotation">The text annotation</param>
        /// <param name="text">The message text.</param>
        /// <param name="anchor">The message anchor.</param>
        private void OnShowAnnotation(MapTextAnnotation annotation, string text, IAnchor anchor)
        {
            // Get the old message bounds.
            Rectangle oldBounds = annotation.Bounds;

            // Suspend the message layout.
            annotation.SuspendLayout();
            // Set the new message properties.
            annotation.Text = text;
            annotation.Anchor = anchor;
            // Result the message layout.
            annotation.ResumeLayout();

            // Get the new message bounds.
            Rectangle newBounds = annotation.Bounds;
            // If the message is currently visible.
            if (annotation.Visible)
            {
                // Invalidate the area corresponding to the old annotation bounds.
                this.Invalidate(oldBounds);
            }
            else
            {
                // Set the annotation visibility to true.
                annotation.Visible = true;
            }
            // Invalidated the area corresponding to the new annotation bounds.
            this.Invalidate(newBounds);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new control instance.
        /// </summary>
        public MapControl()
        {
            // Set the default properties.
            this.DoubleBuffered = true;

            // Create the background bitmap.
            using (Graphics graphics = Graphics.FromImage(this.bitmapBackground))
            {
                using (SolidBrush brush = new SolidBrush(Color.LightGray))
                {
                    // Draw the gray checker board.
                    graphics.FillRectangle(brush, 0, 0, 10, 10);
                    graphics.FillRectangle(brush, 10, 10, 20, 20);
                    // Draw the white checker board.
                    brush.Color = Color.White;
                    graphics.FillRectangle(brush, 10, 0, 20, 10);
                    graphics.FillRectangle(brush, 0, 10, 10, 20);
                }
            }

            // Create the map annotations.
            this.annotationMessage = new MapTextAnnotation(MapControl.messageNoMap, this, null);
            this.annotationInfo = new MapInfoAnnotation(null, this, this);

            this.annotations = new MapAnnotation[] {
                this.annotationMessage,
                this.annotationInfo
            };

            // Create the background brush.
            this.brushBackground = new TextureBrush(this.bitmapBackground);

            // Create the spring motion event handler.
            this.scrollSpring.Tick += this.OnSpringTick;

            // Create the marker collection event handlers.
            this.markers.BeforeCleared += this.OnBeforeMarkersCleared;
            this.markers.AfterItemInserted += this.OnAfterMarkerInserted;
            this.markers.AfterItemRemoved += this.OnAfterMarkerRemoved;
            this.markers.AfterItemSet += this.OnAfterMarkerSet;

            // Create the grid font.
            this.fontGrid = new Font(Window.DefaultFont.FontFamily, 7.0f);
        }
Esempio n. 3
0
 /// <summary>
 /// Refreshes the specified text annotation.
 /// </summary>
 /// <param name="annotation">The annotation.</param>
 private void OnRefreshAnnotation(MapTextAnnotation annotation)
 {
     // If the annotation is visible.
     if (annotation.Visible)
     {
         // Invalidate the area corresponding to the old annotation bounds.
         this.Invalidate(annotation.Bounds);
         // Refresh the annotation.
         annotation.Refresh();
         // Invalidate the area corresponding to the new annotation bounds.
         this.Invalidate(annotation.Bounds);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Hides the specified text annotation.
 /// </summary>
 /// <param name="annotation">The annotation.</param>
 private void OnHideAnnotation(MapTextAnnotation annotation)
 {
     // If the annotation is visible.
     if (annotation.Visible)
     {
         // Invalidate the area corresponding to the annotation bounds.
         this.Invalidate(annotation.Bounds);
     }
     // Set the annotation visibility to false.
     annotation.Visible = false;
 }