⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 umlshow.cs

📁 UML设计相关的源码。作UML相关开发的不容错过。
💻 CS
📖 第 1 页 / 共 5 页
字号:
/* ---------------------------------------------------------------------------------------------------
 *  
 *                          PocketUML v0.01.0016
 *  
 *        
 *    Written by Jie Tang.
 *    Bug report : jiet@msn.com
 *  
 *
 * Copyright 2002 James <jiet@msn.com>
 * All rights reserved.
 *
 * This source file(s) may be redistributed unmodified by any means
 * PROVIDING they are not sold for profit without the authors expressed
 * written consent, and providing that this notice and the authors name
 * and all copyright notices remain intact.
 *
 * Any use of the software in source or binary forms, with or without
 * modification, must include, in the user documentation ("About" box and
 * printed documentation) and internal comments to the code, notices to
 * the end user as follows:
 *
 * "Portions Copyright 2002 Tang Jie
 *
 * An email letting me know that you are using it would be nice as well.
 * That's not much to ask considering the amount of work that went into
 * this.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
 * EXPRESS OR IMPLIED. USE IT AT YOUT OWN RISK. THE AUTHOR ACCEPTS NO
 * LIABILITY FOR ANY DATA DAMAGE/LOSS THAT THIS PRODUCT MAY CAUSE.
 *
 */
//-----------------------------------------------------------------------------------------------------
//										Update Information.
//-----------------------------------------------------------------------------------------------------

///
/// PocketUML Namespace
/// Display uml data in a control
/// 
/// PocketUML v0.1
/// Created by Jie Tang  04/10/2002.
///
namespace PocketUML
{
	///
	/// This namespace contain display data class
	/// 
	namespace DataUI
	{
		using System;
		using System.Drawing;
		using System.Drawing.Drawing2D;
		using System.Collections;
		using PocketUML.Data;
		using System.Reflection;
		using System.Resources;
		using System.Diagnostics;

		/// *********************************************************** ///
		///                    UPDATE    RECORD                         ///
		/// *********************************************************** ///
		/// Created 07/10/2002. James Tang                              ///
		/// *********************************************************** ///
		/// Modifyed 08/10/2002 James Tang
		/// Change display functions , only display one same name namespace
		/// *********************************************************** ///
		
		[Flags]
		public enum enumDrawState
		{
			/// <summary>
			/// Default value
			/// show visibility and attributes and operations
			/// </summary>
			drawStateDefault                = drawStateShowVisibility | drawStateShowAttributes | drawStateShowOperations ,
			/// <summary>
			/// Draw all elements
			/// </summary>
			drawStateNoElements				= 1,

			/// <summary>
			/// Only draw it's visibility
			/// </summary>
			drawStateShowVisibility			= 2,

			/// <summary>
			/// Show all attributes
			/// </summary>
			drawStateShowAttributes			= 4,
	
			/// <summary>
			/// Show all operations
			/// </summary>
			drawStateShowOperations			= 8,

			/// <summary>
			/// Show operation's signature
			/// </summary>
			drawStateShowOperationSignature = 16,

			/// <summary>
			/// Suppress attributes
			/// </summary>
			drawStateSuppressAttributes     = 32,

			/// <summary>
			/// Suppress Operations
			/// </summary>
			drawStateSuppressOperations     = 64
		}
		
		/// <summary>
		/// This calss used to store item draw state: position, color, ect...
		/// attach this class to class data
		/// </summary>
		public class ItemDrawState
		{
			public ItemDrawState ()
			{
				Position     = new Point( 0, 0 );
				headSize     = new Size( 0, 0 );
				backColor    = new Color();
				frontColor   = new Color();
				itemFont     = new Font("Arial", 9 );
				drawState    = enumDrawState.drawStateDefault;
				backColor    = Color.Yellow;
				frontColor   = Color.Black;

				
				operationsSize = new SizeF( 0, 0 );
				variablesSize  = new SizeF( 0, 0 );
				nameSize       = new SizeF( 0, 0 );
			}

			#region Basic Graphics Data
			/// <summary>
			/// This control's position
			/// </summary>
			public System.Drawing.Point Position;

			/// <summary>
			/// Three area size
			/// ********************* NOTIFY *******************************
			///Here I use three variable to keep the object's 
			///position data.
			///
			///For Class & Struct:
			///    Entire Size = nameSize + variablesSize + operationsSize
			///
			///For Interface:
			///    Entire Size = headSize + nameSize + variablesSize + operationsSize
			///           headSize used to store the circle graphic element size
			///
			///For Namespace ( Package )
			///    Entire Size = Size + nameSize
			///           ItemDrawState.headSize : the head size of the package graphic
			///           nameSize : Body part Size
			///           
			/// ************************************************************
			/// </summary>
			public System.Drawing.SizeF  headSize;
			public System.Drawing.SizeF  nameSize;
			public System.Drawing.SizeF  operationsSize;
			public System.Drawing.SizeF  variablesSize;

			/// <summary>
			/// This control's background color
			/// </summary>
			private System.Drawing.Color backColor;
			public System.Drawing.Color BackColor
			{
				get
				{
					return this.backColor;
				}
				set
				{
					this.backColor = value;
				}
			}

			/// <summary>
			/// This control's front color
			/// </summary>
			private System.Drawing.Color frontColor;
			public System.Drawing.Color FrontColor
			{
				get
				{
					return this.frontColor;
				}
				set
				{
					this.frontColor = value;
				}
			}

			/// <summary>
			/// Desicribe how to draw the elements
			/// </summary>
			private enumDrawState drawState;
			public enumDrawState DrawState
			{
				get
				{
					return this.drawState;
				}
				set
				{
					this.drawState = value;
				}
			}

			/// <summary>
			/// Element's text font
			/// </summary>
			private System.Drawing.Font itemFont;
			public System.Drawing.Font ItemFont
			{
				get
				{
					return itemFont;
				}
				set
				{
					itemFont = value;
				}
			}

			/// <summary>
			/// Get the element total size(rectangle size)
			/// </summary>
			/// <param name="elementType"></param>
			/// <returns></returns>
			public SizeF GetSize( enumElementType elementType )
			{
				SizeF sizeItem = new SizeF( 0, 0 );

				if( elementType == enumElementType.elementTypeClass ||
					elementType == enumElementType.elementTypeStruct )
				{
					sizeItem.Height = nameSize.Height + variablesSize.Height + operationsSize.Height;
					sizeItem.Width  = nameSize.Width;
				}
				else if( elementType == enumElementType.elementTypeNameSpace )
				{
					sizeItem.Height = headSize.Height + nameSize.Height;
					sizeItem.Width  = nameSize.Width;
				}
				else if ( elementType == enumElementType.elementTypeInterface )
				{
					sizeItem.Height = headSize.Height + nameSize.Height + variablesSize.Height + operationsSize.Height;
					sizeItem.Width  = nameSize.Width;
				}

				return sizeItem;
			}

			#endregion // Basic graphics data
		}


		/// <summary>
		/// Draw UML elements
		/// </summary>
		public class UMLShow
		{
			public UMLShow( System.Windows.Forms.ContainerControl parent )
			{
				//
				// TODO: Add constructor logic here
				//
				
				parentForm = parent;

				// ****** Load all icon ***** //
				
				// ****** I don't know why i can't add those resource to the main assembly ******/
				/*
				Assembly thisAssembly = Assembly.GetAssembly(Type.GetType("PocketUML.UMLViewer"));
				ResourceManager resManager = new ResourceManager( "AccessTypeIcon", thisAssembly);
				Icon iconVariablePrv = (Icon)resManager.GetObject( "VariablePrv");
				Icon iconVariablePub = (Icon)resManager.GetObject( "variablePub" );
				Icon iconProperty    = (Icon)resManager.GetObject( "Property" );
				Icon iconFunctionPrv = (Icon)resManager.GetObject( "FunctionPrv" );
				Icon iconFunctionPub = (Icon)resManager.GetObject( "FunctionPub" );
				*/
				//*********************************************************************
				Assembly thisAssembly = Assembly.GetExecutingAssembly();
				string strName = thisAssembly.Location;
				string sfullpath = strName;
				string[] tmp = sfullpath.Split( "\\".ToCharArray() );
				string temp = tmp[tmp.Length -1];
				sfullpath = sfullpath.TrimEnd( temp.ToCharArray() );
				
				iconVariablePrv = new Icon( sfullpath + "Variableprv.ico" );
				iconVariablePub = new Icon( sfullpath + "variablepub.ico" );
				iconProperty    = new Icon( sfullpath + "Property.ico" );
				iconFunctionPrv = new Icon( sfullpath + "FunctionPrv.ico" );
				iconFunctionPub = new Icon( sfullpath + "FunctionPub.ico" );
			}

			/// <summary>
			/// prepare to show the root elements
			/// </summary>
			public void Initialize( )
			{
				Graphics g = parentForm.CreateGraphics();
				// Used to calculate the autoscroll size
				int nMaxX = 0;
				int nMaxY = 0;
				if( codeData != null )
				{
					currentDisplayElementList.RemoveRange( 0, currentDisplayElementList.Count );

					for( int nSolutionIndex = 0; nSolutionIndex < codeData.SolutionList.Count; nSolutionIndex ++ )
					{
						SolutionData sluData = (SolutionData)codeData.SolutionList[nSolutionIndex];
						for( int nProjectIndex = 0; nProjectIndex < sluData.Element.Count ; nProjectIndex ++ )
						{
							ProjectData prjData = (ProjectData)sluData.Element[nProjectIndex];
							for( int nProjectItemIndex = 0; nProjectItemIndex < prjData.Element.Count; nProjectItemIndex ++ )
							{
								ProjectItemData prjItemData = (ProjectItemData)prjData.Element[nProjectItemIndex];
								CodeModelData codeModelData = (CodeModelData)prjItemData.Element[0];
								CodeElementsData codeElementsData = (CodeElementsData)codeModelData.Element[0];

								for( int nElementIndex = 0; nElementIndex < codeElementsData.Element.Count; nElementIndex ++ )

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -