Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » C# » General » Downloads
 
Add your own
alternative version

100% Reflective Class Diagram Creation Tool

, 14 Jun 2011
100% Reflective Class Diagram Creation Tool
Prize winner in Competition "Best C# article of Feb 2007"
autodiagramer.zip
AutoDiagramer
AutoDiagramer
AutoDiagramer.csproj.user
AutoDiagramer_TemporaryKey.pfx
bin
Debug
AutoDiagramer.application
AutoDiagramer.exe
AutoDiagramer.exe.manifest
AutoDiagramer.pdb
AutoDiagramer.publish
AutoDiagramer.application
AutoDiagramer_1_7_0_0
AutoDiagramer.exe.deploy
AutoDiagramer.exe.manifest
np.ico.deploy
setup.exe
AutoDiagramer.vshost.application
AutoDiagramer.vshost.exe
AutoDiagramer.vshost.exe.manifest
Controls
Forms
Helpers
images
about16.png
AboutImg.png
BannerImg.png
Collapse9.png
Constructors16.png
Draw16.png
edging.png
Events16.png
Exit16.png
Expand9.png
Fields16.png
help16.gif
HideTree.png
HideTree16.png
Interfaces16.png
MainCollapse13.png
MainExpand13.png
Method16.png
open16.png
print16.png
Prop16.png
Prop33.png
save16.png
SaveImg.png
Setting16.png
SettingImg.png
ShowTree.png
ShowTree16.png
Thumbs.db
TreeCode.png
TreeLeaf.png
TreeRoot.png
View16.png
np.ico
obj
Debug
AutoDiagramer.application
AutoDiagramer.csproj.GenerateResource.Cache
AutoDiagramer.exe
AutoDiagramer.exe.manifest
AutoDiagramer.frmAbout.resources
AutoDiagramer.frmMain.resources
AutoDiagramer.frmSave.resources
AutoDiagramer.frmSettings.resources
AutoDiagramer.frmZoom.resources
AutoDiagramer.InputBoxDialog.resources
AutoDiagramer.pdb
AutoDiagramer.Properties.Resources.resources
AutoDiagramer.Resource1.resources
AutoDiagramer.ucExpander.resources
ClassDiagFromAssembly.csproj.GenerateResource.Cache
Refactor
TempPE
Properties.Resources.Designer.cs.dll
Resource1.Designer.cs.dll
Printing
Properties
Settings.settings
Thumbs.db
autodiagramerdll.zip
autodiagrammer.zip
AutoDiagrammer
AutoDiagramerReflectorAddin
AutoDiagramerReflectorAddin.csproj.user
AutoDiagramer_TemporaryKey.pfx
bin
Debug
AutoDiagramer.dll
AutoDiagramer.pdb
Controls
Forms
Helpers
images
about16.png
AboutImg.png
BannerImg.png
Collapse9.png
Constructors16.png
Draw16.png
edging.png
Events16.png
Exit16.png
Expand9.png
Fields16.png
help16.gif
HideTree.png
HideTree16.png
Interfaces16.png
MainCollapse13.png
MainExpand13.png
Method16.png
open16.png
print16.png
Prop16.png
Prop33.png
save16.png
SaveImg.png
Setting16.png
SettingImg.png
ShowTree.png
ShowTree16.png
Thumbs.db
TreeCode.png
TreeLeaf.png
TreeRoot.png
View16.png
np.ico
Printing
Properties
Settings.settings
Thumbs.db
AutoDiagramerStandAlone
AutoDiagramerStandAlone.csproj.user
AutoDiagramer_TemporaryKey.pfx
bin
Debug
AutoDiagramer.application
AutoDiagramer.exe
AutoDiagramer.exe.manifest
AutoDiagramer.pdb
AutoDiagramer.publish
AutoDiagramer.application
AutoDiagramer_1_12_0_0
AutoDiagramer.exe.deploy
AutoDiagramer.exe.manifest
np.ico.deploy
setup.exe
AutoDiagramer.vshost.application
AutoDiagramer.vshost.exe
AutoDiagramer.vshost.exe.manifest
Controls
Forms
Helpers
images
about16.png
AboutImg.png
BannerImg.png
Collapse9.png
Constructors16.png
Draw16.png
edging.png
Events16.png
Exit16.png
Expand9.png
Fields16.png
help16.gif
HideTree.png
HideTree16.png
Interfaces16.png
MainCollapse13.png
MainExpand13.png
Method16.png
open16.png
print16.png
Prop16.png
Prop33.png
save16.png
SaveImg.png
Setting16.png
SettingImg.png
ShowTree.png
ShowTree16.png
Thumbs.db
TreeCode.png
TreeLeaf.png
TreeRoot.png
View16.png
np.ico
Printing
Properties
Settings.settings
Thumbs.db
autodiagrammer2.zip
AutoDiagramer
AutoDiagramer.csproj.user
AutoDiagramer_TemporaryKey.pfx
bin
Debug
AutoDiagramer.application
AutoDiagramer.exe
AutoDiagramer.exe.manifest
AutoDiagramer.pdb
AutoDiagramer.publish
AutoDiagramer.application
AutoDiagramer_1_9_0_0
AutoDiagramer.exe.deploy
AutoDiagramer.exe.manifest
np.ico.deploy
Reflector.exe.deploy
setup.exe
AutoDiagramer.vshost.exe
Reflector.cfg
Reflector.exe
Controls
Forms
Helpers
images
about16.png
AboutImg.png
BannerImg.png
Collapse9.png
Constructors16.png
Draw16.png
edging.png
Events16.png
Exit16.png
Expand9.png
Fields16.png
help16.gif
HideTree.png
HideTree16.png
Interfaces16.png
MainCollapse13.png
MainExpand13.png
Method16.png
open16.png
print16.png
Prop16.png
Prop33.png
save16.png
SaveImg.png
Setting16.png
SettingImg.png
ShowTree.png
ShowTree16.png
Thumbs.db
TreeCode.png
TreeLeaf.png
TreeRoot.png
View16.png
np.ico
obj
Printing
Properties
Settings.settings
Thumbs.db
Reflector AddIn DLL
AutoDiagramer.dll
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace AutoDiagramer
{
    #region frmSettings CLASS
    /// <summary>
    /// Partial class that creates the GUI part of the frmZoom object
    /// </summary>
    public partial class frmZoom : Form
    {
        #region Instance fields
        //instanec fields
        private Bitmap _Bitmap= null;
        private double Zoom = 1.0;
        #endregion
        #region Constructor
        /// <summary>
        /// Creates a new frmZoom object
        /// </summary>
        public frmZoom()
        {
            InitializeComponent();
        }
        #endregion
        #region Public Properties
        /// <summary>
        /// Sets the current Bitmap
        /// </summary>
        public Bitmap CurrentImage
        {
           set 
           { 
               //create a new BitMap with initial zoom of 1.0 (100%)
               _Bitmap = value; 
				this.pnlImage.AutoScroll = true;
				this.pnlImage.AutoScrollMinSize = new Size ((int)(_Bitmap.Width * Zoom), 
                    (int)(_Bitmap.Height * Zoom));
				this.Invalidate();
           }
        }
        #endregion
        #region Private Methods
        /// <summary>
        /// Zooms the current image to the required Zoom factor
        /// </summary>
        /// <param name="zFactor">The new zoom factor</param>
        private void doZoom(double zFactor)
        {
            this.pnlImage.Visible = false;
			Zoom = zFactor;
			this.pnlImage.AutoScrollMinSize = new Size ((int)(_Bitmap.Width * Zoom), 
                (int)(_Bitmap.Height * Zoom));
			this.Invalidate();
            this.pnlImage.Visible = true;
            pnlImage.Focus();
        }

        /// <summary>
        /// mnuZoom25 menu clicked, do zoom 25% 
        /// </summary>
        /// <param name="sender">mnuZoom25 menu</param>
        /// <param name="e">the events args</param>
        private void mnuZoom25_Click(object sender, EventArgs e)
        {
            doZoom(.25);
        }

        /// <summary>
        /// mnuZoom50 menu clicked, do zoom 50% 
        /// </summary>
        /// <param name="sender">mnuZoom50 menu</param>
        /// <param name="e">the events args</param>
        private void mnuZoom50_Click(object sender, EventArgs e)
        {
            doZoom(.5);
        }

        /// <summary>
        /// mnuZoom100 menu clicked, do zoom 100% 
        /// </summary>
        /// <param name="sender">mnuZoom100 menu</param>
        /// <param name="e">the events args</param>
        private void mnuZoom100_Click(object sender, EventArgs e)
        {
            doZoom(1.0);
        }

        /// <summary>
        /// mnuZoom200 menu clicked, do zoom 200% 
        /// </summary>
        /// <param name="sender">mnuZoom200 menu</param>
        /// <param name="e">the events args</param>
        private void mnuZoom200_Click(object sender, EventArgs e)
        {
            doZoom(2.0);
        }

        /// <summary>
        /// paint the image on the pnlImage panel at the right zoom
        /// </summary>
        /// <param name="sender">pnlImage panel</param>
        /// <param name="e">the events args</param>
        private void pnlImage_Paint(object sender, PaintEventArgs e)
        {
			Graphics g = e.Graphics;
			g.DrawImage(_Bitmap, new Rectangle(this.pnlImage.AutoScrollPosition.X, 
                this.pnlImage.AutoScrollPosition.Y, (int)(_Bitmap.Width*Zoom), (int)(_Bitmap.Height * Zoom)));
        }

        /// <summary>
        /// mnuEnterManualZoom menu clicked, so allow user to enter their own zoom, 
        /// but check for all possible error prior to allowing new zoom to be applied
        /// </summary>
        /// <param name="sender">mnuEnterManualZoom menu</param>
        /// <param name="e">the events args</param>
        private void mnuEnterManualZoom_Click(object sender, EventArgs e)
        {
            //allow user to enter their own zoom, but check for all possible error prior to allowing
            //new zoom to be applied
            String zoomEntered = Program.InputBox("Enter your desired zoom factor (Between 0.1 - 2.0)","Enter zoom factor","1.0");
            if (!string.IsNullOrEmpty(zoomEntered))
            {
                try 
                {
                    double dZoom = double.Parse(zoomEntered);
                    if (dZoom < 0.1 || dZoom > 2.0)
                    {
                        Program.ErrorBox("You didnt enter a valid zoom factor\r\n\r\n" +
                                        "Zoom MUST be between 0.1 - 2.0");
                    }
                    else 
                    {
                        doZoom(dZoom);
                    }
                }
                catch (Exception)
                {
                    Program.ErrorBox("You didnt enter a valid zoom factor");
                }
            }
        }

        /// <summary>
        /// btnOk button clicked, so close this form
        /// </summary>
        /// <param name="sender">btnOk button</param>
        /// <param name="e">the events args</param>
        private void btnOk_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        /// <summary>
        /// frmZoom form resized, so re-position all controls
        /// </summary>
        /// <param name="sender">frmZoom form</param>
        /// <param name="e">the events args</param>
        private void frmZoom_Resize(object sender, EventArgs e)
        {
            this.pnlImage.Width = this.Width;
            this.pnlImage.Height = this.Height - (this.pnlImage.Location.Y + 2* pnlBottom.Height);
            btnOk.Left = this.Width - 84;
        }

        /// <summary>
        /// frmZoom form shown, so set focus to main panel
        /// </summary>
        /// <param name="sender">frmZoom form</param>
        /// <param name="e">the events args</param>
        private void frmZoom_Shown(object sender, EventArgs e)
        {
            pnlImage.Focus();
        }
        #endregion
    }
    #endregion
}

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

Sacha Barber
Software Developer (Senior)
United Kingdom United Kingdom
I currently hold the following qualifications (amongst others, I also studied Music Technology and Electronics, for my sins)
 
- MSc (Passed with distinctions), in Information Technology for E-Commerce
- BSc Hons (1st class) in Computer Science & Artificial Intelligence
 
Both of these at Sussex University UK.
 
Award(s)

I am lucky enough to have won a few awards for Zany Crazy code articles over the years

  • Microsoft C# MVP 2014
  • Codeproject MVP 2014
  • Microsoft C# MVP 2013
  • Codeproject MVP 2013
  • Microsoft C# MVP 2012
  • Codeproject MVP 2012
  • Microsoft C# MVP 2011
  • Codeproject MVP 2011
  • Microsoft C# MVP 2010
  • Codeproject MVP 2010
  • Microsoft C# MVP 2009
  • Codeproject MVP 2009
  • Microsoft C# MVP 2008
  • Codeproject MVP 2008
  • And numerous codeproject awards which you can see over at my blog

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 14 Jun 2011
Article Copyright 2007 by Sacha Barber
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid