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
A Vector based tool to create and edit SVG images
SVGArtiste2_exe.zip
SVGArtiste2_SampleSVGDrawings.zip
SVGArtiste2_src.zip
SVGLib
SVGLib.csproj.user
SVGLib.ndoc
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
#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.Windows.Forms;

    using UserControls;

    public partial class WorkArea : Form
    {
        #region Constructors

        public WorkArea()
        {
            InitializeComponent();
        }

        #endregion Constructors

        #region Delegates

            public delegate void OnItemsInSelection(object sender, MouseEventArgs e);

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

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

        #endregion Delegates

        #region Events

            public event OnItemsInSelection ItemsSelected;

            public event OnTabPageChanged PageChanged;

            public event OnToolDone ToolDone;

        #endregion Events

        #region Methods

            public void AddNewPage(String fileName)
            {
                var svgForm = new WorkspaceHolder {Dock = DockStyle.Fill, Name = fileName};
                svgForm.svgDrawForm.ToolDone += OnToolDoneComplete;
                svgForm.svgDrawForm.ItemsSelected += SvgDrawFormItemsSelected;
                tabbedView.Add(svgForm);
            }

            public void CloseActiveDocument()
            {
                if (tabbedView.Count > 0)
                {
                    var svgForm = (WorkspaceHolder)tabbedView.GetPageAt(tabbedView.SelectedIndex);
                    if (!svgForm.svgDrawForm.CheckDirty())
                    {
                        tabbedView.Remove(svgForm);
                    }
                    else
                    {
                        if ((MessageBox.Show(@"Changes have been made. Exit without Saving?", @"SVG Editor", MessageBoxButtons.YesNo) == DialogResult.Yes))
                        {
                            tabbedView.Remove(svgForm);
                        }
                    }
                }
            }

            public bool CloseAll()
            {
                bool retVal = true;
                int count = tabbedView.Count;
                if (tabbedView.Count > 0)
                {
                    for (int i = 0; i < count; i++)
                    {
                        var svgForm = (WorkspaceHolder)tabbedView.GetPageAt(0);
                        if (!svgForm.svgDrawForm.CheckDirty())
                        {
                            tabbedView.Remove(svgForm);
                        }
                        else
                        {
                            if ((MessageBox.Show(@"Changes have been made. Exit without Saving?", @"SVG Editor", MessageBoxButtons.YesNo) == DialogResult.Yes))
                            {
                                tabbedView.SelectedIndex = 0;
                                tabbedView.Remove(svgForm);
                            }
                            else
                            {
                                tabbedView.SelectedIndex = 0;
                                retVal = false;
                            }
                        }
                    }
                }
                return retVal;
            }

            public DrawTools.DrawArea.DrawToolType GetCurrentTool()
            {
                var svgForm = (WorkspaceHolder)tabbedView.GetPageAt(tabbedView.SelectedIndex);
                return svgForm.svgDrawForm.GetCurrentTool();
            }

            public WorkspaceHolder GetCurrentWorkForm()
            {
                return (WorkspaceHolder)tabbedView.GetPageAt(tabbedView.SelectedIndex);
            }

            public bool GetGridOption()
            {
                var svgForm = (WorkspaceHolder)tabbedView.GetPageAt(tabbedView.SelectedIndex);
                return svgForm.svgDrawForm.GetGridOption();
            }

            public int GetMinorGrids()
            {
                return GetCurrentForm().GetMinorGrids();
            }

            public WorkSpace GetCurrentForm()
            {
                return ((WorkspaceHolder)tabbedView.GetPageAt(tabbedView.SelectedIndex)).svgDrawForm;
            }

            public int GetWorkAreaSize()
            {
                return GetCurrentForm().GetMinorGrids();
            }

            public int GetZoom()
            {
                return (int)(GetCurrentForm().GetCurrentZoom());
            }

            public void GridOptionChanges(object sender, EventArgs e)
            {
                GetCurrentForm().GridOptionChanged(sender, e);
            }

            public void OnZoomChange(object sender, EventArgs e)
            {
                var tb = (TrackBar)sender;
                if (tb != null)
                {
                    GetCurrentForm().SetZoom(tb.Value);
                }
            }

            public void OpenDocument(String fileName)
            {
                var svgForm = new WorkspaceHolder {Dock = DockStyle.Fill, Name = fileName};
                svgForm.svgDrawForm.ToolDone += OnToolDoneComplete;
                svgForm.svgDrawForm.ItemsSelected += SvgDrawFormItemsSelected;
                svgForm.svgDrawForm.OpenFile(fileName);
                tabbedView.Add(svgForm);
                svgForm.Refresh();
            }

            public void PropertyChanged(GridItem itemChanged, object oldVal)
            {
                GetCurrentForm().PropertyChanged(itemChanged, oldVal);
            }

            public void SaveDocument(String fileName)
            {
                GetCurrentForm().SaveFile(fileName);
            }

            public void SetTool(String tool)
            {
                GetCurrentForm().SetTool(tool);
            }

            private void OnToolDoneComplete(object sender, EventArgs e)
            {
                ToolDone(sender, e);
            }

            void SvgDrawFormItemsSelected(object sender, MouseEventArgs e)
            {
                if (ItemsSelected != null)
                    ItemsSelected(sender, e);
            }

            private void TabbedViewPageSelectionMade(object sender, EventArgs e)
        {
            PageChanged(sender, e);
        }

        #endregion Methods
    }
}

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)

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 | Mobile
Web02 | 2.8.140718.1 | Last Updated 3 Aug 2010
Article Copyright 2010 by Ajay Britto
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid