Click here to Skip to main content
15,884,177 members
Articles / Containers / Docker

SVG Artiste - An SVG Editor

Rate me:
Please Sign up or sign in to vote.
4.69/5 (23 votes)
3 Aug 2010CPOL14 min read 95.8K   15.4K   93  
A Vector based tool to create and edit SVG images
#region Header

/*  --------------------------------------------------------------------------------------------------------------
 *  I Software Innovations
 *  --------------------------------------------------------------------------------------------------------------
 *  SVG Artieste 2.0
 *  --------------------------------------------------------------------------------------------------------------
 *  File     :       DrawArea.cs
 *  Author   :       ajaysbritto@yahoo.com
 *  Date     :       21/03/2010
 *  --------------------------------------------------------------------------------------------------------------
 *  Change Log
 *  --------------------------------------------------------------------------------------------------------------
 *  Author	Comments
 */

#endregion Header

namespace SVGEditor2
{
    using System;
    using System.Drawing;
    using System.Windows.Forms;

    public partial class WorkSpaceControlBox : Form
    {
        #region Constructors

        public WorkSpaceControlBox()
        {
            InitializeComponent();
        }

        #endregion Constructors

        #region Delegates

        public delegate void OnGridOptionChange(object sender, EventArgs e);

        public delegate void OnWorkAreaOptionChange(object sender, ControlBoxEventArgs e);

        public delegate void OnZoomChange(object sender, EventArgs e);

        #endregion Delegates

        #region Events

        public event OnGridOptionChange GridOptionChange;

        public event OnWorkAreaOptionChange WorkAreaOptionChange;

        public event OnZoomChange ZoomChange;

        #endregion Events

        #region Methods

        public void SetGridOption(bool isGridOn, int minorGrid, Size drawAreaSize, String description)
        {
            checkBox_Grid.Checked = isGridOn;
            numericUpDown_minorGrids.Value = minorGrid;
            numHeight.Value = drawAreaSize.Height;
            numWidth.Value = drawAreaSize.Width;
            textBox_description.Text = description;
        }

        public void SetZoom(float f)
        {
            if((f >= trackBarZoom.Minimum) && (f <= trackBarZoom.Maximum))
            trackBarZoom.Value = (int)f;
        }

        private void ButtonNoZoomClick(object sender, EventArgs e)
        {
            trackBarZoom.Value = 1;
        }

        private void ButtonZoominClick(object sender, EventArgs e)
        {
            if (trackBarZoom.Value < 10)
                trackBarZoom.Value++;
        }

        private void ButtonZoomoutClick(object sender, EventArgs e)
        {
            if (trackBarZoom.Value > 1)
                trackBarZoom.Value--;
        }

        private void CheckBoxGridCheckedChanged(object sender, EventArgs e)
        {
            if(GridOptionChange!= null)
                GridOptionChange(sender, e);
        }

        private void FillControlboxEventArgs(ref ControlBoxEventArgs ev)
        {
            Size newSize = ev.Size;
            newSize.Height = (int)numHeight.Value;
            newSize.Width = (int)numWidth.Value;
            ev.Description = textBox_description.Text;
            ev.Size = newSize;
        }

        private void NumericUpDownMinorGridsValueChanged(object sender, EventArgs e)
        {
            if (GridOptionChange != null)
                GridOptionChange(sender, e);
        }

        private void NumHeightValueChanged(object sender, EventArgs e)
        {
            var ev = new ControlBoxEventArgs();
            FillControlboxEventArgs(ref ev);
            if (WorkAreaOptionChange != null)
                WorkAreaOptionChange(sender, ev);
        }

        private void NumWidthValueChanged(object sender, EventArgs e)
        {
            var ev = new ControlBoxEventArgs();
            FillControlboxEventArgs(ref ev);
            if(WorkAreaOptionChange != null)
                WorkAreaOptionChange(sender, ev);
        }

        private void TrackBarZoomValueChanged(object sender, EventArgs e)
        {
            label_Zoom.Text = trackBarZoom.Value + @"X";
            ZoomChange(sender, e);
        }

        private void textBox_description_TextChanged(object sender, EventArgs e)
        {
            var ev = new ControlBoxEventArgs();
            FillControlboxEventArgs(ref ev);
            if (WorkAreaOptionChange != null)
                WorkAreaOptionChange(sender, ev);
        }

        #endregion Methods

        #region Nested Types

        public class ControlBoxEventArgs : EventArgs
        {
            #region Constructors

            public ControlBoxEventArgs()
            {
                Description = String.Empty;
            }

            #endregion Constructors

            #region Properties

            public string Description
            {
                get; set;
            }

            public Size Size
            {
                get; set;
            }

            #endregion Properties
        }

        #endregion Nested Types

    }
}

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)


Written By
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.

Comments and Discussions