コード例 #1
0
        /// <summary>
        /// Overridden <see cref="VGElement.AddGrabHandles()"/>.
        /// Adds a grab handle for the starting and ending
        /// point of the arrow with a sizeall cursor.
        /// </summary>
        protected override void AddGrabHandles()
        {
            this.AddGrabHandles(true, false, false, false, false, false, false, false, false);

            PointF center1Pt = new PointF(
                this.firstPoint.X - GrabHandle.HANDLESIZE / 2,
                this.firstPoint.Y - GrabHandle.HANDLESIZE / 2);

            PointF center2Pt = new PointF(
                this.secondPoint.X - GrabHandle.HANDLESIZE / 2,
                this.secondPoint.Y - GrabHandle.HANDLESIZE / 2);

            GrabHandle handleFirstPoint = new GrabHandle(
                center1Pt,
                Cursors.SizeNWSE,
                GrabHandle.HandlePosition.Left);

            this.GrabHandles.Add(handleFirstPoint);

            GrabHandle handleSecondPoint = new GrabHandle(
                center2Pt,
                Cursors.SizeNWSE,
                GrabHandle.HandlePosition.Right);

            this.GrabHandles.Add(handleSecondPoint);
        }
コード例 #2
0
        /// <summary>
        /// Overridden <see cref="VGElement.GrabHandleMoved(ref GrabHandle, Point)"/>.
        /// Resets bounds of the arrow
        /// according to the movement of the given grab handle
        /// </summary>
        /// <param name="handle">GrabHandle that moved</param>
        /// <param name="handleMovement">Movement in stimulus coordinates</param>
        public override void GrabHandleMoved(ref GrabHandle handle, Point handleMovement)
        {
            if (handle.GrabHandlePosition == GrabHandle.HandlePosition.Center)
            {
                PointF newCenter = new PointF(this.Center.X - handleMovement.X, this.Center.Y - handleMovement.Y);
                this.Center = newCenter;
                this.AddGrabHandles();
            }
            else
            {
                if (VGPolyline.Distance(handle.Center, this.firstPoint) < GrabHandle.HANDLESIZE)
                {
                    this.firstPoint.X -= handleMovement.X;
                    this.firstPoint.Y -= handleMovement.Y;
                }
                else if (VGPolyline.Distance(handle.Center, this.secondPoint) < GrabHandle.HANDLESIZE)
                {
                    this.secondPoint.X -= handleMovement.X;
                    this.secondPoint.Y -= handleMovement.Y;
                }

                PointF newHandleLocation = new PointF(
                    handle.Location.X - handleMovement.X,
                    handle.Location.Y - handleMovement.Y);

                handle.Location = newHandleLocation;
            }

            this.Modified = true;
        }
コード例 #3
0
ファイル: VGPolyline.cs プロジェクト: zhjh-stack/ogama
        /// <summary>
        /// Overridden <see cref="VGElement.GrabHandleMoved(ref GrabHandle, Point)"/>.
        /// Resets bounds of the poyline according to the movement of the given grab handle.
        /// </summary>
        /// <param name="handle">GrabHandle that moved</param>
        /// <param name="handleMovement">Movement in stimulus coordinates</param>
        public override void GrabHandleMoved(ref GrabHandle handle, Point handleMovement)
        {
            if (handle.GrabHandlePosition == GrabHandle.HandlePosition.Center)
            {
                PointF newCenter = new PointF(this.Center.X - handleMovement.X, this.Center.Y - handleMovement.Y);
                this.Center = newCenter;
                this.AddGrabHandles();
            }
            else
            {
                List <PointF> currentPoints       = this.GetPoints();
                bool          recreateGrabHandles = false;
                for (int i = 0; i < currentPoints.Count; i++)
                {
                    if (Distance(handle.Center, currentPoints[i]) < GrabHandle.HANDLESIZE)
                    {
                        PointF movedPt = currentPoints[i];
                        movedPt.X       -= handleMovement.X;
                        movedPt.Y       -= handleMovement.Y;
                        currentPoints[i] = movedPt;
                        if (i == 0)
                        {
                            currentPoints[this.GetPointCount() - 1] = movedPt;
                            recreateGrabHandles = true;
                        }
                        else if (i == this.GetPointCount() - 1)
                        {
                            currentPoints[0]    = movedPt;
                            recreateGrabHandles = true;
                        }

                        break;
                    }
                }

                this.Path.Reset();
                this.Path.AddLines(currentPoints.ToArray());

                PointF newHandleLocation = new PointF(
                    handle.Location.X - handleMovement.X,
                    handle.Location.Y - handleMovement.Y);

                handle.Location = newHandleLocation;

                if (recreateGrabHandles)
                {
                    this.AddGrabHandles();
                }
            }

            this.Modified = true;
        }
コード例 #4
0
ファイル: VGPolyline.cs プロジェクト: zhjh-stack/ogama
        /// <summary>
        /// Overridden <see cref="VGElement.AddGrabHandles()"/>.
        /// Adds a grab handle for each vertex of the polyline with a sizeall cursor
        /// </summary>
        protected override void AddGrabHandles()
        {
            this.AddGrabHandles(true, false, false, false, false, false, false, false, false);

            foreach (PointF point in this.GetPoints())
            {
                Point grabHandleLocation = new Point(
                    (int)(point.X - GrabHandle.HANDLESIZE / 2),
                    (int)(point.Y - GrabHandle.HANDLESIZE / 2));

                GrabHandle handle = new GrabHandle(
                    grabHandleLocation,
                    Cursors.SizeNESW,
                    GrabHandle.HandlePosition.Top);

                this.GrabHandles.Add(handle);
            }
        }
コード例 #5
0
ファイル: VGLine.cs プロジェクト: DeSciL/Ogama
    /// <summary>
    /// Overridden <see cref="VGElement.AddGrabHandles()"/>. 
    /// Adds a grab handle for the starting and ending
    /// point of the line with a sizeall cursor.
    /// </summary>
    protected override void AddGrabHandles()
    {
      this.AddGrabHandles(true, false, false, false, false, false, false, false, false);

      PointF center1Pt = new PointF(
        this.firstPoint.X - GrabHandle.HANDLESIZE / 2,
        this.firstPoint.Y - GrabHandle.HANDLESIZE / 2);

      PointF center2Pt = new PointF(
        this.secondPoint.X - GrabHandle.HANDLESIZE / 2,
        this.secondPoint.Y - GrabHandle.HANDLESIZE / 2);

      GrabHandle handleFirstPoint = new GrabHandle(
        center1Pt,
        Cursors.SizeNWSE,
        GrabHandle.HandlePosition.Left);
      this.GrabHandles.Add(handleFirstPoint);

      GrabHandle handleSecondPoint = new GrabHandle(
        center2Pt,
        Cursors.SizeNWSE,
        GrabHandle.HandlePosition.Right);
      this.GrabHandles.Add(handleSecondPoint);
    }
コード例 #6
0
ファイル: VGLine.cs プロジェクト: DeSciL/Ogama
    /// <summary>
    /// Overridden <see cref="VGElement.GrabHandleMoved(ref GrabHandle, Point)"/>. 
    /// Resets bounds of the line
    /// according to the movement of the given grab handle
    /// </summary>
    /// <param name="handle">GrabHandle that moved</param>
    /// <param name="handleMovement">Movement in stimulus coordinates</param>
    public override void GrabHandleMoved(ref GrabHandle handle, Point handleMovement)
    {
      if (handle.GrabHandlePosition == GrabHandle.HandlePosition.Center)
      {
        PointF newCenter = new PointF(this.Center.X - handleMovement.X, this.Center.Y - handleMovement.Y);
        this.Center = newCenter;
        this.AddGrabHandles();
      }
      else
      {
        if (VGPolyline.Distance(handle.Center, this.firstPoint) < GrabHandle.HANDLESIZE)
        {
          this.firstPoint.X -= handleMovement.X;
          this.firstPoint.Y -= handleMovement.Y;
        }
        else if (VGPolyline.Distance(handle.Center, this.secondPoint) < GrabHandle.HANDLESIZE)
        {
          this.secondPoint.X -= handleMovement.X;
          this.secondPoint.Y -= handleMovement.Y;
        }

        PointF newHandleLocation = new PointF(
          handle.Location.X - handleMovement.X,
          handle.Location.Y - handleMovement.Y);

        handle.Location = newHandleLocation;
      }

      this.Modified = true;
    }
コード例 #7
0
ファイル: VGElement.cs プロジェクト: DeSciL/Ogama
    /// <summary>
    /// Adds a box with up to 8 grab handles around the rectangle.
    /// </summary>
    /// <param name="center">True, if center should me movable and shown with a grab handle.</param>
    /// <param name="topLeft">True, if top left corner should me movable and shown with a grab handle.</param>
    /// <param name="topMiddle">True, if top middle corner should me movable and shown with a grab handle.</param>
    /// <param name="topRight">True, if top right corner should me movable and shown with a grab handle.</param>
    /// <param name="middleLeft">True, if middle left corner should me movable and shown with a grab handle.</param>
    /// <param name="middleRight">True, if middle right corner should me movable and shown with a grab handle.</param>
    /// <param name="bottomLeft">True, if bottom left corner should me movable and shown with a grab handle.</param>
    /// <param name="bottomMiddle">True, if bottom middle corner should me movable and shown with a grab handle.</param>
    /// <param name="bottomRight">True, if bottom right corner should me movable and shown with a grab handle.</param>
    protected void AddGrabHandles(
      bool center,
      bool topLeft,
      bool topMiddle,
      bool topRight,
      bool middleLeft,
      bool middleRight,
      bool bottomLeft,
      bool bottomMiddle,
      bool bottomRight)
    {
      if (this.GrabHandles == null)
      {
        // Create list if has not been created yet.
        this.GrabHandles = new List<GrabHandle>();
      }
      else
      {
        // Clear eventually existing grab handles
        this.GrabHandles.Clear();
      }

      Rectangle rectBounds = this.GetSelectionFrameBounds();

      // Create grab handles in respect to given parameters and add them to the grab handle list.
      if (center)
      {
        Point location = new Point(
          rectBounds.X + rectBounds.Width / 2 - GrabHandle.HANDLESIZE / 2,
          rectBounds.Y + rectBounds.Height / 2 - GrabHandle.HANDLESIZE / 2);

        GrabHandle ctr = new GrabHandle(
          location,
          Cursors.SizeAll,
          GrabHandle.HandlePosition.Center);
        this.GrabHandles.Add(ctr);
      }

      if (topLeft)
      {
        GrabHandle tl = new GrabHandle(
          new Point(rectBounds.X, rectBounds.Y),
          Cursors.SizeNWSE,
          GrabHandle.HandlePosition.TopLeft);
        this.GrabHandles.Add(tl);
      }

      if (topMiddle)
      {
        GrabHandle tm = new GrabHandle(
          new Point(rectBounds.X + rectBounds.Width / 2 - GrabHandle.HANDLESIZE / 2, rectBounds.Y),
          Cursors.SizeNS,
          GrabHandle.HandlePosition.Top);
        this.GrabHandles.Add(tm);
      }

      if (topRight)
      {
        GrabHandle tr = new GrabHandle(
          new Point(rectBounds.X + rectBounds.Width - GrabHandle.HANDLESIZE, rectBounds.Y),
          Cursors.SizeNESW,
          GrabHandle.HandlePosition.TopRight);
        this.GrabHandles.Add(tr);
      }

      if (middleLeft)
      {
        GrabHandle ml = new GrabHandle(
          new Point(rectBounds.X, rectBounds.Y + rectBounds.Height / 2 - GrabHandle.HANDLESIZE / 2),
          Cursors.SizeWE,
          GrabHandle.HandlePosition.Left);
        this.GrabHandles.Add(ml);
      }

      if (middleRight)
      {
        Point location = new Point(
          rectBounds.X + rectBounds.Width - GrabHandle.HANDLESIZE,
          rectBounds.Y + rectBounds.Height / 2 - GrabHandle.HANDLESIZE / 2);
        GrabHandle mr = new GrabHandle(
          location,
          Cursors.SizeWE,
          GrabHandle.HandlePosition.Right);
        this.GrabHandles.Add(mr);
      }

      if (bottomLeft)
      {
        GrabHandle bl = new GrabHandle(
          new Point(rectBounds.X, rectBounds.Y + rectBounds.Height - GrabHandle.HANDLESIZE),
          Cursors.SizeNESW,
          GrabHandle.HandlePosition.BottomLeft);
        this.GrabHandles.Add(bl);
      }

      if (bottomMiddle)
      {
        Point location = new Point(
          rectBounds.X + rectBounds.Width / 2 - GrabHandle.HANDLESIZE / 2,
          rectBounds.Y + rectBounds.Height - GrabHandle.HANDLESIZE);
        GrabHandle bm = new GrabHandle(
          location,
          Cursors.SizeNS,
          GrabHandle.HandlePosition.Down);
        this.GrabHandles.Add(bm);
      }

      if (bottomRight)
      {
        Point location = new Point(
          rectBounds.X + rectBounds.Width - GrabHandle.HANDLESIZE,
          rectBounds.Y + rectBounds.Height - GrabHandle.HANDLESIZE);
        GrabHandle br = new GrabHandle(
          location,
          Cursors.SizeNWSE,
          GrabHandle.HandlePosition.BottomRight);
        this.GrabHandles.Add(br);
      }
    }
コード例 #8
0
ファイル: VGElement.cs プロジェクト: DeSciL/Ogama
    /// <summary>
    /// Virtual. An override should reinitialze the grab handles of the element. 
    /// Resets bounds of the graphic element according to the movement of the given grab handle
    /// </summary>
    /// <param name="handle">GrabHandle that moved</param>
    /// <param name="handleMovement">Movement in stimulus coordinates</param>
    public virtual void GrabHandleMoved(ref GrabHandle handle, Point handleMovement)
    {
      switch (handle.GrabHandlePosition)
      {
        case GrabHandle.HandlePosition.Top:
          this.Bounds = new RectangleF(
            this.Location.X,
            this.Location.Y - handleMovement.Y,
            this.Bounds.Width,
            this.Bounds.Height + handleMovement.Y);
          break;
        case GrabHandle.HandlePosition.Down:
          this.Bounds = new RectangleF(
            this.Location.X,
            this.Location.Y,
            this.Bounds.Width,
            this.Bounds.Height - handleMovement.Y);
          break;
        case GrabHandle.HandlePosition.Left:
          this.Bounds = new RectangleF(
            this.Location.X - handleMovement.X,
            this.Location.Y,
            this.Bounds.Width + handleMovement.X,
            this.Bounds.Height);
          break;
        case GrabHandle.HandlePosition.Right:
          this.Bounds = new RectangleF(
            this.Location.X,
            this.Location.Y,
            this.Bounds.Width - handleMovement.X,
            this.Bounds.Height);
          break;
        case GrabHandle.HandlePosition.Center:
          PointF newCenter = new PointF(
            this.Center.X - handleMovement.X,
            this.Center.Y - handleMovement.Y);
          this.Center = newCenter;
          break;
        case GrabHandle.HandlePosition.TopLeft:
          this.Bounds = new RectangleF(
            this.Location.X - handleMovement.X,
            this.Location.Y - handleMovement.Y,
            this.Bounds.Width + handleMovement.X,
            this.Bounds.Height + handleMovement.Y);
          break;
        case GrabHandle.HandlePosition.TopRight:
          this.Bounds = new RectangleF(
            this.Location.X,
            this.Location.Y - handleMovement.Y,
            this.Bounds.Width - handleMovement.X,
            this.Bounds.Height + handleMovement.Y);
          break;
        case GrabHandle.HandlePosition.BottomLeft:
          this.Bounds = new RectangleF(
            this.Location.X - handleMovement.X,
            this.Location.Y,
            this.Bounds.Width + handleMovement.X,
            this.Bounds.Height - handleMovement.Y);
          break;
        case GrabHandle.HandlePosition.BottomRight:
          this.Bounds = new RectangleF(
            this.Location.X,
            this.Location.Y,
            this.Bounds.Width - handleMovement.X,
            this.Bounds.Height - handleMovement.Y);
          break;
      }

      this.AddGrabHandles();
      this.Modified = true;
    }
コード例 #9
0
ファイル: VGPolyline.cs プロジェクト: DeSciL/Ogama
    /// <summary>
    /// Overridden <see cref="VGElement.AddGrabHandles()"/>. 
    /// Adds a grab handle for each vertex of the polyline with a sizeall cursor
    /// </summary>
    protected override void AddGrabHandles()
    {
      this.AddGrabHandles(true, false, false, false, false, false, false, false, false);

      foreach (PointF point in this.GetPoints())
      {
        Point grabHandleLocation = new Point(
          (int)(point.X - GrabHandle.HANDLESIZE / 2),
          (int)(point.Y - GrabHandle.HANDLESIZE / 2));

        GrabHandle handle = new GrabHandle(
          grabHandleLocation,
          Cursors.SizeNESW,
          GrabHandle.HandlePosition.Top);

        this.GrabHandles.Add(handle);
      }
    }
コード例 #10
0
ファイル: VGPolyline.cs プロジェクト: DeSciL/Ogama
    /// <summary>
    /// Overridden <see cref="VGElement.GrabHandleMoved(ref GrabHandle, Point)"/>. 
    /// Resets bounds of the poyline according to the movement of the given grab handle.
    /// </summary>
    /// <param name="handle">GrabHandle that moved</param>
    /// <param name="handleMovement">Movement in stimulus coordinates</param>
    public override void GrabHandleMoved(ref GrabHandle handle, Point handleMovement)
    {
      if (handle.GrabHandlePosition == GrabHandle.HandlePosition.Center)
      {
        PointF newCenter = new PointF(this.Center.X - handleMovement.X, this.Center.Y - handleMovement.Y);
        this.Center = newCenter;
        this.AddGrabHandles();
      }
      else
      {
        List<PointF> currentPoints = this.GetPoints();
        bool recreateGrabHandles = false;
        for (int i = 0; i < currentPoints.Count; i++)
        {
          if (Distance(handle.Center, currentPoints[i]) < GrabHandle.HANDLESIZE)
          {
            PointF movedPt = currentPoints[i];
            movedPt.X -= handleMovement.X;
            movedPt.Y -= handleMovement.Y;
            currentPoints[i] = movedPt;
            if (i == 0)
            {
              currentPoints[this.GetPointCount() - 1] = movedPt;
              recreateGrabHandles = true;
            }
            else if (i == this.GetPointCount() - 1)
            {
              currentPoints[0] = movedPt;
              recreateGrabHandles = true;
            }

            break;
          }
        }

        this.Path.Reset();
        this.Path.AddLines(currentPoints.ToArray());

        PointF newHandleLocation = new PointF(
          handle.Location.X - handleMovement.X,
          handle.Location.Y - handleMovement.Y);

        handle.Location = newHandleLocation;

        if (recreateGrabHandles)
        {
          this.AddGrabHandles();
        }
      }

      this.Modified = true;
    }
コード例 #11
0
ファイル: PictureModifiable.cs プロジェクト: DeSciL/Ogama
    /// <summary>
    /// Resets the selected element and its dependencies to null.
    /// If there was a selected element, invokes <see cref="ShapeDeselected"/> event.
    /// </summary>
    public void ResetSelectedElement()
    {
      if (this.selectedElement != null)
      {
        this.selectedElement.IsInEditMode = false;

        // Use property to invoke the ShapeDeselected event
        this.SelectedElement = null;
        this.activeGrabHandle = null;
        this.DrawForeground(false);
      }
    }
コード例 #12
0
ファイル: PictureModifiable.cs プロジェクト: DeSciL/Ogama
    /// <summary>
    /// Overridden <see cref="Control.MouseDown"/> event handler.
    /// Starts requested shape creation when left mouse button is pressed.
    /// Otherwise looks for elements under mouse cursor and selects them.
    /// If there is already a selected element and the mouse is over a grab
    /// handle it is selected.
    /// </summary>
    /// <remarks>Pressing the ALT key during selection iterates
    /// through the elementsUnderMouseCursor collection.</remarks>
    /// <param name="e">The <see cref="MouseEventArgs"/> with the event data (click point).</param>
    protected override void OnMouseDown(MouseEventArgs e)
    {
      // base.OnMouseDown(e);

      // Achieve focus to the picture, because otherwise it will not
      // receive input keys which are interesting as modifiers.
      this.Focus();

      if (Control.ModifierKeys != Keys.ShiftKey)
      {
        // Transform mouse down point to stimulus coordinates
        PointF mouseLocationF = this.GetTransformedMouseLocation(e.Location);
        Point mouseLocation = Point.Round(mouseLocationF);

        if (this.state != BuildState.None)
        {
          // Is creating a new shape
          // Left Mouse Button pressed, so start Logging
          if (e.Button == MouseButtons.Left)
          {
            this.state = BuildState.FirstPointSet;

            // Add the new shape to the list.
            if (!this.Elements.Contains(this.newShape))
            {
              this.Elements.Add(this.newShape);
            }

            // Select it
            this.SelectedElement = this.newShape;

            // save click point for later bounding rectangle creation
            this.firstClickPoint = mouseLocationF;

            // Special handling for polyline construction
            // every click is a polyline point
            // up to the moment the polyline is closed
            if (this.newShape is VGPolyline)
            {
              this.currentLine.FirstPoint = this.firstClickPoint;

              // Add the _CurrentLine element during polyline
              // creation
              if (!Elements.Contains(this.currentLine))
              {
                Elements.Add(this.currentLine);
              }

              // Cast newShape to polyline
              VGPolyline poly = (VGPolyline)this.newShape;

              // Check for closing polyline conditions
              if (this.PointsAreNear(poly.FirstPt, mouseLocationF) &&
                poly.GetPointCount() > 2)
              {
                // If the mouse click point is near the first point
                // close polyline.
                poly.ClosePolyline();

                this.state = BuildState.None;

                // New Graphic element created, so notify listeners.
                this.OnShapeAdded(new ShapeEventArgs(this.newShape));

                // CleanUp creation mode
                this.Elements.Remove(this.currentLine);
                this.newShape = null;
              }
              else
              {
                // Point is anywhere else, but not near the first
                // polyline point.
                // Add new polyline point and update CurrentLine.
                this.currentLine.FirstPoint = mouseLocationF;
                poly.AddPt(mouseLocationF);
              }
            }
            else if (this.newShape is VGLine)
            {
              // Cast newShape to VGLine
              VGLine line = (VGLine)this.newShape;
              line.FirstPoint = this.firstClickPoint;
            }
            else if (this.newShape is VGFlash)
            {
              // Cast newShape to VGFlash
              VGFlash flash = (VGFlash)this.newShape;
              flash.InitializeOnControl(this.Parent, false, this.StimulusToScreen);
            }
          }
        }
        else
        {
          // We are not in new shape creation mode
          if (e.Button == MouseButtons.Left)
          {
            this.mouseDownPoint = e.Location;

            // Store elements under mouse cursor.
            VGElementCollection elementsUnderMouseCursor = new VGElementCollection();
            int numberOfElements = this.Elements.Count;
            for (int i = 0; i < numberOfElements; i++)
            {
              VGElement currentElement = this.Elements[numberOfElements - i - 1];
              if (currentElement.Contains(mouseLocation))
              {
                elementsUnderMouseCursor.Add(currentElement);
                if (currentElement == this.SelectedElement)
                {
                  this.counterUnderCursor = elementsUnderMouseCursor.Count - 1;
                }
              }
            }

            if (this.selectedElement == null)
            {
              // Check whether an element lies under
              // mouse cursor. Select the next item.
              if (elementsUnderMouseCursor.Count > 0)
              {
                this.SelectedElement = elementsUnderMouseCursor[0];
                this.selectedElement.IsInEditMode = true;
              }
              else
              {
                this.SelectedElement = null;
              }
            }
            else if (this.selectedElement.Contains(mouseLocation))
            {
              // Click in selected element 
              // could be more than one, so iterate if Modifier alt is pressed.
              if (Control.ModifierKeys == Keys.Alt)
              {
                this.Cursor = Cursors.Default;
                this.counterUnderCursor++;

                // Reset counter if larger than element list size.
                if (this.counterUnderCursor >= elementsUnderMouseCursor.Count)
                {
                  this.counterUnderCursor = 0;
                }

                // Select next item if there is any
                if (elementsUnderMouseCursor.Count > 1)
                {
                  this.ResetSelectedElement();

                  // Use property to invoke Shape Selected event.
                  this.SelectedElement = elementsUnderMouseCursor[this.counterUnderCursor];
                  this.selectedElement.IsInEditMode = true;
                }
              }
              else
              {
                // No alt is pressed
                // Select grab handle, if mouse is over it
                foreach (GrabHandle handle in this.selectedElement.GrabHandles)
                {
                  if (handle.Contains(mouseLocation))
                  {
                    this.activeGrabHandle = handle;
                    break;
                  }

                  // Select center handle
                  this.activeGrabHandle = this.selectedElement.GrabHandles[0];
                }
              }
            }
            else
            {
              // Click in region outside current selected element
              // Reset selected element. And look for other element
              // under mouse cursor.
              this.ResetSelectedElement();

              // Select the first element that lies under mouse cursor.
              if (elementsUnderMouseCursor.Count > 0)
              {
                this.SelectedElement = elementsUnderMouseCursor[0];
                this.selectedElement.IsInEditMode = true;
              }
              else
              {
                this.SelectedElement = null;
              }
            }

            this.DrawForeground(false);
          }
        }
      }
    }