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

📄 umlshow.cs

📁 UML设计相关的源码。作UML相关开发的不容错过。
💻 CS
📖 第 1 页 / 共 5 页
字号:
					if( ((FunctionData)itemData).FunctionType == enumFunctionType.functionTypePropertyGet )
					{
						showString = "<<"+"Get"+">>" + showString;
					}
					else if( ((FunctionData)itemData).FunctionType == enumFunctionType.functionTypePropertySet )
					{
						showString = "<<"+"Set"+">>" + showString;
					}
					else if( ((FunctionData)itemData).FunctionType == enumFunctionType.functionTypePropertyLet )
					{
						showString = "<<"+"Let"+">>" + showString;
					}
				}

				return showString;
			}
			
			
			
			/// <summary>
			/// Help function
			/// Help to auto calculate the graphics element's size
			/// </summary>
			/// <param name="g"></param>
			/// <param name="elementData"></param>
			public void AutoCalculateElementSize( Graphics g, ElementData elementData )
			{
				switch( elementData.ElementType )
				{
					case enumElementType.elementTypeClass:
					case enumElementType.elementTypeStruct:
						AutoCalculateClassElementSize( g, elementData );
						break;

					case enumElementType.elementTypeNameSpace:
						AutoCalculateNameSpaceElementSize( g, elementData );
						break;

					case enumElementType.elementTypeInterface:
						AutoCalculateInterfaceElementSize( g, elementData );
						break;
				}

			}
			/// <summary>
			/// Help function
			/// Help to auto calculate the interface graphics element's size
			/// The Only different between class and interface is the head graphics
			/// element. The interface element is  a cirlce
			/// </summary>
			/// <param name="g"></param>
			/// <param name="elementData"></param>
			/// <param name="drawState"></param>
			private void AutoCalculateClassElementSize( Graphics g, ElementData elementData )
			{
				
				ElementData drawData	= elementData;
				ItemDrawState itemState = (ItemDrawState) drawData.ExtendDataObject;
				// Check the itemState object exist or not
				if( itemState == null ) return;

				const int heightSpaceCount = 6;

				// Used to calculate the element's width
				int itemMaxWidth = 0;
				// ******  first name  ***** //
				// Calculate item size
				SizeF sizeFontItem = new SizeF();
				sizeFontItem       = g.MeasureString( drawData.Name, itemState.ItemFont );
				SizeF nameAreaSize = new SizeF( 0, sizeFontItem.Height + heightSpaceCount );

				// Store the max width				
				itemMaxWidth =(int)sizeFontItem.Width > itemMaxWidth ? (int)sizeFontItem.Width : itemMaxWidth;

					
				// ****** Calculate Variable ***** //
				SizeF variableAreaSize = new SizeF( 0, 0 );  // default height 0 units
				Point variableStartPosition = new Point( (int)itemState.Position.X, (int)itemState.Position.Y + (int)nameAreaSize.Height );
				Point variablePosition = new Point( variableStartPosition.X, variableStartPosition.Y );
				if( ! ( (int)( itemState.DrawState & enumDrawState.drawStateSuppressAttributes ) > 0 ) )
				{
					if( (int)( itemState.DrawState & enumDrawState.drawStateShowAttributes ) > 0 )
					{
						if( drawData.Element.Count > 0 )
						{
							for( int i = 0 ; i < drawData.Element.Count ; i ++ )
							{
								ElementData itemData = (ElementData) drawData.Element[i];
								if( itemData.ElementType == enumElementType.elementTypeVariable ||
									itemData.ElementType == enumElementType.elementTypeProperty )
								{
									// Prepare string...
									String showString = itemData.Name + " : " + 
										itemData.PhotoType.phototypeType.Split(' ')[0];
							
									// Draw String
									sizeFontItem = g.MeasureString( showString, itemState.ItemFont );
									variablePosition.Y += (int)sizeFontItem.Height;

									// Store the max width				
									itemMaxWidth =(int)sizeFontItem.Width > itemMaxWidth ? (int)sizeFontItem.Width : itemMaxWidth;
							
								}
							}
							variableAreaSize.Height = variablePosition.Y - variableStartPosition.Y;
						}
					}
					variableAreaSize.Height += heightSpaceCount;
				}

				// Calculate operation
				// ****** Calculate operation ***** //
				SizeF operationsAreaSize = new SizeF( 0, 0 );  // default height 0 units
				Point operationsStartPosition = new Point( (int)itemState.Position.X, (int)itemState.Position.Y + (int)nameAreaSize.Height + (int) variableAreaSize.Height );
				Point operationsPosition = new Point( operationsStartPosition.X, operationsStartPosition.Y );
				if( ! ( (int)( itemState.DrawState & enumDrawState.drawStateSuppressOperations ) > 0 ) )
				{
					if( (int)( itemState.DrawState & enumDrawState.drawStateShowOperations ) > 0 )
					{
						if( drawData.Element.Count > 0 )
						{
							for( int i = 0 ; i < drawData.Element.Count ; i ++ )
							{
								ElementData itemData = (ElementData) drawData.Element[i];
								if( itemData.ElementType == enumElementType.elementTypeFunction ||
									itemData.ElementType == enumElementType.elementTypeDelegate )
								{
									// Prepare string...
									String showString = GetOperationShowString( itemData, itemState.DrawState );
								
									// Draw String
									sizeFontItem = g.MeasureString( showString, itemState.ItemFont );
									operationsPosition.Y += (int)sizeFontItem.Height;

									// Store the max width				
									itemMaxWidth =(int)sizeFontItem.Width > itemMaxWidth ? (int)sizeFontItem.Width : itemMaxWidth;
								}
							}
						}
						operationsAreaSize.Height = operationsPosition.Y - operationsStartPosition.Y;
					}
					operationsAreaSize.Height += heightSpaceCount;
				}

				// Calculate the last Max Width
				if( (int)( itemState.DrawState & enumDrawState.drawStateShowVisibility ) > 0 )
				{
					itemMaxWidth += 30; // here 30 units are the icon's width
				}

				// Finally...
				// FontSize
				itemState.nameSize.Height        = nameAreaSize.Height;
				itemState.variablesSize.Height   = variableAreaSize.Height;
				itemState.operationsSize.Height  = operationsAreaSize.Height;

				itemState.nameSize.Width        = itemMaxWidth;
				itemState.variablesSize.Width   = itemMaxWidth;
				itemState.operationsSize.Width  = itemMaxWidth;

			}
			
			/// <summary>
			/// Automatic set the namespace element size
			/// 
			///************************* NOTICE *********************//
			/// Check the minium size of the body
			///       get the experience result by using rose
			///       the size.height must be 18 and the
			///           namesize.height must no less than 60
			///******************************************************//
			/// </summary>
			/// <param name="g"></param>
			/// <param name="elementData"></param>
			private void AutoCalculateNameSpaceElementSize( Graphics g, ElementData elementData )
			{
				//************************* NOTICE *********************//
				// Check the minium size of the body
				//       get the experience result by using rose
				//       the size.height must be 18 and the
				//           namesize.height must no less than 60
				//******************************************************//
				ElementData drawData	= elementData;
				ItemDrawState itemState = (ItemDrawState) drawData.ExtendDataObject;
				// Check the itemState object exist or not
				if( itemState == null ) return;
				
				// Header size
                itemState.headSize.Height = 18;
				itemState.headSize.Width  = 0;

				// Body Size
				// 3 * 2 scale might better
				//SizeF sizeItem = g.MeasureString( drawData.Name, itemState.ItemFont );
				itemState.nameSize.Height = 60; // Initialize height
				itemState.nameSize.Width  = 90;
	
			}

			/// <summary>
			/// 
			/// </summary>
			/// <param name="g"></param>
			/// <param name="elementData"></param>
			private void AutoCalculateInterfaceElementSize( Graphics g, ElementData elementData )
			{
				ElementData drawData	= elementData;
				ItemDrawState itemState = (ItemDrawState) drawData.ExtendDataObject;
				// Check the itemState object exist or not
				if( itemState == null ) return;

				const int heightSpaceCount = 6;

				// Used to calculate the element's width
				int itemMaxWidth = 0;
				// ******  first name  ***** //
				// Calculate item size
				SizeF sizeFontItem = new SizeF();
				sizeFontItem       = g.MeasureString( drawData.Name, itemState.ItemFont );
				SizeF nameAreaSize = new SizeF( 0, sizeFontItem.Height + heightSpaceCount );
				// Because Interface has a fixed size circle.
				// ********************** FIXED SIZE CIRCLE DEFINE HERE *******************
				// Plus circle size is : radius:10units
				itemState.headSize.Height = 20;
				itemState.headSize.Width  = 20;

				// Store the max width				
				itemMaxWidth =(int)sizeFontItem.Width > itemMaxWidth ? (int)sizeFontItem.Width : itemMaxWidth;

					
				// ****** Calculate Variable ***** //
				SizeF variableAreaSize = new SizeF( 0, 0 );  // default height 0 units
				Point variableStartPosition = new Point( (int)itemState.Position.X, (int)itemState.Position.Y + (int)nameAreaSize.Height );
				Point variablePosition = new Point( variableStartPosition.X, variableStartPosition.Y );
				if( ! ( (int)( itemState.DrawState & enumDrawState.drawStateSuppressAttributes ) > 1 ) )
				{
					if( (int)( itemState.DrawState & enumDrawState.drawStateShowAttributes ) > 1 )
					{
						if( drawData.Element.Count > 0 )
						{
							for( int i = 0 ; i < drawData.Element.Count ; i ++ )
							{
								ElementData itemData = (ElementData) drawData.Element[i];
								if( itemData.ElementType == enumElementType.elementTypeVariable ||
									itemData.ElementType == enumElementType.elementTypeProperty )
								{
									// Prepare string...
									String showString = itemData.Name + " : " + 
										itemData.PhotoType.phototypeType.Split(' ')[0];
							
									// Draw String
									sizeFontItem = g.MeasureString( showString, itemState.ItemFont );
									variablePosition.Y += (int)sizeFontItem.Height;

									// Store the max width				
									itemMaxWidth =(int)sizeFontItem.Width > itemMaxWidth ? (int)sizeFontItem.Width : itemMaxWidth;
							
								}
							}
							variableAreaSize.Height = variablePosition.Y - variableStartPosition.Y;
						}
					}
					variableAreaSize.Height += heightSpaceCount;
				}

				// Calculate operation
				// ****** Calculate operation ***** //
				SizeF operationsAreaSize = new SizeF( 0, 0 );  // default height 0 units
				Point operationsStartPosition = new Point( (int)itemState.Position.X, (int)itemState.Position.Y + (int)nameAreaSize.Height + (int) variableAreaSize.Height );
				Point operationsPosition = new Point( operationsStartPosition.X, operationsStartPosition.Y );
				if( ! ( (int)( itemState.DrawState & enumDrawState.drawStateSuppressOperations ) > 1 ) )
				{
					if( (int)( itemState.DrawState & enumDrawState.drawStateShowOperations ) > 1 )
					{
						if( drawData.Element.Count > 0 )
						{
							for( int i = 0 ; i < drawData.Element.Count ; i ++ )
							{
								ElementData itemData = (ElementData) drawData.Element[i];
								if( itemData.ElementType == enumElementType.elementTypeFunction ||
									itemData.ElementType == enumElementType.elementTypeDelegate )
								{
									// Prepare string...
									String showString = GetOperationShowString( itemData, itemState.DrawState );
								
									// Draw String
									sizeFontItem = g.MeasureString( showString, itemState.ItemFont );
									operationsPosition.Y += (int)sizeFontItem.Height;

									// Store the max width				
									itemMaxWidth =(int)sizeFontItem.Width > itemMaxWidth ? (int)sizeFontItem.Width : itemMaxWidth;
								}
							}
						}
						operationsAreaSize.Height = operationsPosition.Y - operationsStartPosition.Y;
					}
					operationsAreaSize.Height += heightSpaceCount;
				}

				// Calculate the last Max Width
				if( (int)( itemState.DrawState & enumDrawState.drawStateShowVisibility ) > 0 )
				{
					itemMaxWidth += 30; // here 30 units are the icon's width
				}

				// Finally...
				// FontSize
				itemState.nameSize.Height        = nameAreaSize.Height;
				itemState.variablesSize.Height   = variableAreaSize.Height;
				itemState.operationsSize.Height  = operationsAreaSize.Height;

				itemState.nameSize.Width        = itemMaxWidth;
				itemState.variablesSize.Width   = itemMaxWidth;
				itemState.operationsSize.Width  = itemMaxWidth;

			}

			public void Draw( Graphics g, Point ptOffset )
			{
				// Store it into
				if( this.codeData == null ) return;
				if( currentDisplayPackage == null ) currentDisplayPackage = this.codeData;
				if( currentDisplayElementList.Count <= 0 ) return;
				
				//
				DrawRelationShip( g, ptOffset );

				// Top Level display
				// Prevent draw the same object
				ElementData itemData;

⌨️ 快捷键说明

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