Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

SVG Artiste - An SVG Editor

, 3 Aug 2010 CPOL
A Vector based tool to create and edit SVG images
SVGArtiste2_exe.zip
SvgArtiste.exe
SvgArtiste.vshost.exe.manifest
SVGLib.dll
Crom.Controls.dll
Draw.dll
SVGArtiste2_SampleSVGDrawings.zip
mercialago18.svg
SVGArtiste.svg
SVGArtiste2_src.zip
SVGLib
SVGLib.csproj.user
SVGLib.ndoc
SvgArtiste2.suo
Crom.Controls
Dock16x16.bmp
Internal
Docking
ControlCollections
Controls
DockButtons
Forms
Engine
Enums
EventArgs
Helpers
SharedHelpers
Properties
Public
Docking
Enums
EventArgs
Helpers
Renderers
TabbedDocument
Controls
Enums
Helpers
Renderers
Base
Draw
Command
Draw.csproj.user
RulerControl
Ruler.bmp
SvgArtiste2
Properties
Settings.settings
Resources
cancel.png
Ellipse.cur
exit.png
exit1.png
Line.cur
new.png
new_page.png
open.png
open1.png
pan.cur
pan_close.cur
Pencil.cur
Rectangle.cur
save.png
save_as.png
save_as1.png
Text.cur
SVGArtiste.csproj.user
Tools
Forms
UserControls
/***************************************************************************
 *   CopyRight (C) 2009 by Cristinel Mazarine                              *
 *   Author:   Cristinel Mazarine                                          *
 *   Contact:  cristinel@osec.ro                                           *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the Crom Free License as published by           *
 *   the SC Crom-Osec SRL; version 1 of the License                        *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   Crom Free License for more details.                                   *
 *                                                                         *
 *   You should have received a copy of the Crom Free License along with   *
 *   this program; if not, write to the contact@osec.ro                    *
 ***************************************************************************/

using System;
using System.Drawing;
using System.Windows.Forms;

namespace Crom.Controls.Docking
{
   /// <summary>
   /// Implementation of control positioner
   /// </summary>
   internal class ControlPositioner : Disposable
   {
      #region Fields

      private Control               _control          = null;
      private bool                  _canSizeLeft      = true;
      private bool                  _canSizeRight     = true;
      private bool                  _canSizeTop       = true;
      private bool                  _canSizeBottom    = true;
      private bool                  _canMove          = true;

      #endregion Fields

      #region Instance

      /// <summary>
      /// Constructor
      /// </summary>
      /// <param name="control">control</param>
      public ControlPositioner(Control control)
      {
         _control = control;
      }

      #endregion Instance

      #region Public section

      /// <summary>
      /// Begin move by mouse
      /// </summary>
      public event EventHandler BeginMoveByMouse;

      /// <summary>
      /// Move by mouse
      /// </summary>
      public event EventHandler MoveByMouse;

      /// <summary>
      /// End move by mouse
      /// </summary>
      public event EventHandler EndMoveByMouse;


      /// <summary>
      /// Occurs when CanSizeBottom property was changed
      /// </summary>
      public event EventHandler CanMoveChanged;

      /// <summary>
      /// Occurs when CanSizeLeft property was changed
      /// </summary>
      public event EventHandler CanSizeLeftChanged;

      /// <summary>
      /// Occurs when CanSizeRight property was changed
      /// </summary>
      public event EventHandler CanSizeRightChanged;

      /// <summary>
      /// Occurs when CanSizeTop property was changed
      /// </summary>
      public event EventHandler CanSizeTopChanged;

      /// <summary>
      /// Occurs when CanSizeBottom property was changed
      /// </summary>
      public event EventHandler CanSizeBottomChanged;


      /// <summary>
      /// Can Move flag
      /// </summary>
      public bool CanMove
      {
         get 
         {
            ValidateNotDisposed();

            return _canMove; 
         }
         set 
         {
            ValidateNotDisposed();

            if (_canMove != value)
            {
               _canMove = value;

               EventHandler handler = CanMoveChanged;
               if (handler != null)
               {
                  handler(this, EventArgs.Empty);
               }
            }
         }
      }

      /// <summary>
      /// Can Size-Left flag
      /// </summary>
      public bool CanSizeLeft
      {
         get
         {
            ValidateNotDisposed();

            return _canSizeLeft;
         }
         set
         {
            ValidateNotDisposed();

            if (_canSizeLeft != value)
            {
               _canSizeLeft = value;

               EventHandler handler = CanSizeLeftChanged;
               if (handler != null)
               {
                  handler(this, EventArgs.Empty);
               }
            }
         }
      }

      /// <summary>
      /// Can Size-Right flag
      /// </summary>
      public bool CanSizeRight
      {
         get
         {
            ValidateNotDisposed();

            return _canSizeRight;
         }
         set
         {
            ValidateNotDisposed();

            if (_canSizeRight != value)
            {
               _canSizeRight = value;

               EventHandler handler = CanSizeRightChanged;
               if (handler != null)
               {
                  handler(this, EventArgs.Empty);
               }
            }
         }
      }

      /// <summary>
      /// Can Size-Top flag
      /// </summary>
      public bool CanSizeTop
      {
         get
         {
            ValidateNotDisposed();

            return _canSizeTop;
         }
         set
         {
            ValidateNotDisposed();

            if (_canSizeTop != value)
            {
               _canSizeTop = value;

               EventHandler handler = CanSizeTopChanged;
               if (handler != null)
               {
                  handler(this, EventArgs.Empty);
               }
            }
         }
      }

      /// <summary>
      /// Can Size-Bottom flag
      /// </summary>
      public bool CanSizeBottom
      {
         get
         {
            ValidateNotDisposed();

            return _canSizeBottom;
         }
         set
         {
            ValidateNotDisposed();

            if (_canSizeBottom != value)
            {
               _canSizeBottom = value;

               EventHandler handler = CanSizeBottomChanged;
               if (handler != null)
               {
                  handler(this, EventArgs.Empty);
               }
            }
         }
      }

      /// <summary>
      /// Location
      /// </summary>
      public Point Location
      {
         get
         {
            ValidateNotDisposed();

            return _control.Location;
         }
         set
         {
            ValidateNotDisposed();

            _control.Location = value;
         }
      }

      /// <summary>
      /// Size
      /// </summary>
      public Size Size
      {
         get
         {
            ValidateNotDisposed();

            return _control.Size;
         }
         set
         {
            ValidateNotDisposed();

            _control.Size = value;
         }
      }

      /// <summary>
      /// Bounds
      /// </summary>
      public Rectangle Bounds
      {
         get
         {
            ValidateNotDisposed();

            return _control.Bounds;
         }
         set
         {
            ValidateNotDisposed();

            _control.Bounds = value;
         }
      }



      /// <summary>
      /// Start move by mouse
      /// </summary>
      public void StartMoveByMouse()
      {
         ValidateNotDisposed();

         if (BeginMoveByMouse != null)
         {
            BeginMoveByMouse(_control, EventArgs.Empty);
         }
      }

      /// <summary>
      /// Perform move by mouse
      /// </summary>
      /// <param name="x">x</param>
      /// <param name="y">y</param>
      public void PerformMoveByMouse(int x, int y)
      {
         ValidateNotDisposed();

         Location = new Point(x, y);

         if (MoveByMouse != null)
         {
            MoveByMouse(_control, EventArgs.Empty);
         }
      }

      /// <summary>
      /// Stop move by mouse
      /// </summary>
      public void StopMoveByMouse()
      {
         ValidateNotDisposed();

         if (EndMoveByMouse != null)
         {
            EndMoveByMouse(_control, EventArgs.Empty);
         }
      }


      #endregion Public section

      #region Protected section

      /// <summary>
      /// Dispose the current instance
      /// </summary>
      /// <param name="fromIDisposableDispose">dispose was called from IDisposable.Dispose</param>
      protected override void Dispose(bool fromIDisposableDispose)
      {
         if (fromIDisposableDispose)
         {
            _control = null;
         }
      }

      #endregion Protected section
   }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Ajay Britto
Engineer
Singapore Singapore
He is a Microsoft technology enthusiast, who wish to create applications which others find useful.He loves making small tools and getting involved in architecting bigger systems.

He is currently working as a professional developer in a software development firm in .Net technologies.
 
He likes reading technical blogs, contributing to opensource and most importantly, enjoying life.
 
His ambition is to be an impressive software maker.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141216.1 | Last Updated 3 Aug 2010
Article Copyright 2010 by Ajay Britto
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid