Beispiel #1
0
		/// <summary>
		/// Paint the box nex to the node
		/// </summary>
		private void PaintExpandBox(Node oNode, Graphics oGraphics, int nX, int nY, 
			ref Hashtable m_mapRectToItemBox, ref Hashtable m_mapItemBoxToRect)
		{
			int nAlpha = oNode.TreeView.GetNodeAlpha(oNode);
			Rectangle rect = new Rectangle(nX - 12, nY + 2, 10, 10);
		
			if (oNode.GetShowPlusMinus() == true)
			{
				if (oNode.Nodes.Count > 0 || oNode.Panel != null)
				{
					if (oNode.IsExpanded == false)
					{
						// draw the plus in the box										
						Pen oPen = null;		
			
						if (oNode.Flash == true)
							nAlpha = 255;

						Rectangle boxRect = new Rectangle(rect.Left + 1, rect.Top + 1, rect.Width - 2, rect.Height - 2);

						// if XP line style, then fade the box and paint in black the inner part
						if (oNode.GetExpandBoxShape() == ExpandBoxShape.XP)
						{
							LinearGradientBrush oBrush = new LinearGradientBrush
							(
								new Rectangle(boxRect.Left, boxRect.Top, boxRect.Width, boxRect.Height),
								Color.White,
								oNode.GetExpandBoxBackColor(),
								LinearGradientMode.Vertical						
							);  

							oGraphics.FillRectangle(oBrush, new Rectangle(boxRect.Left + 1, boxRect.Top + 1, boxRect.Width - 1, boxRect.Height - 1));						

							oPen = new Pen(Color.FromArgb(nAlpha, oNode.GetExpandBoxBorderColor()), 1);
							oGraphics.DrawLine(oPen, boxRect.Left + 1, boxRect.Bottom, boxRect.Right - 1, boxRect.Bottom);
							oGraphics.DrawLine(oPen, boxRect.Right, boxRect.Top + 1, boxRect.Right, boxRect.Bottom - 1);
							oPen.Color = Color.FromArgb(128, oPen.Color);
							oGraphics.DrawLine(oPen, boxRect.Left + 1, boxRect.Top, boxRect.Right - 1, boxRect.Top);
							oGraphics.DrawLine(oPen, boxRect.Left, boxRect.Top + 1, boxRect.Left, boxRect.Bottom - 1);
						}
						else 
						{
							oPen = new Pen(Color.FromArgb(nAlpha, oNode.GetExpandBoxBorderColor()), 1);												
							oGraphics.DrawRectangle(oPen, boxRect);

							if (oNode.GetExpandBoxShape() == ExpandBoxShape.Flat)
							{
								SolidBrush oBrush = new SolidBrush(oNode.GetExpandBoxBackColor());
								oGraphics.FillRectangle(oBrush, new Rectangle(boxRect.Left + 1, boxRect.Top + 1, boxRect.Width - 1, boxRect.Height - 1));						
							}
						}

						oPen.Color = Color.FromArgb(nAlpha, oNode.GetExpandBoxForeColor());
						oGraphics.DrawLine(oPen, nX - 9, nY + 7, nX - 5, nY + 7);
						oGraphics.DrawLine(oPen, nX - 7, nY + 9, nX - 7, nY + 5);
						oPen.Dispose();
					}
					else
					{
						// draw the minus in the box
						Pen oPen = null;

						if (oNode.Flash == true)
							nAlpha = 255;			
			
						Rectangle boxRect = new Rectangle(rect.Left + 1, rect.Top + 1, rect.Width - 2, rect.Height - 2);

						// if XP line style, then fade the box and paint in black the inner part
						if (oNode.GetExpandBoxShape() == ExpandBoxShape.XP)
						{
							LinearGradientBrush oBrush = new LinearGradientBrush
							(
								new Rectangle(boxRect.Left, boxRect.Top, boxRect.Width, boxRect.Height),
								Color.White,
								oNode.GetExpandBoxBackColor(),
								LinearGradientMode.Vertical						
							);  

							oGraphics.FillRectangle(oBrush, new Rectangle(boxRect.Left + 1, boxRect.Top + 1, boxRect.Width - 1, boxRect.Height - 1));							

							oPen = new Pen(Color.FromArgb(nAlpha, oNode.GetExpandBoxBorderColor()), 1);
							oGraphics.DrawLine(oPen, boxRect.Left + 1, boxRect.Bottom, boxRect.Right - 1, boxRect.Bottom);
							oGraphics.DrawLine(oPen, boxRect.Right, boxRect.Top + 1, boxRect.Right, boxRect.Bottom - 1);
							oPen.Color = Color.FromArgb(128, oPen.Color);
							oGraphics.DrawLine(oPen, boxRect.Left + 1, boxRect.Top, boxRect.Right - 1, boxRect.Top);
							oGraphics.DrawLine(oPen, boxRect.Left, boxRect.Top + 1, boxRect.Left, boxRect.Bottom - 1);
						}
						else 
						{
							oPen = new Pen(Color.FromArgb(nAlpha, oNode.GetExpandBoxBorderColor()), 1);												
							oGraphics.DrawRectangle(oPen, boxRect);

							if (oNode.GetExpandBoxShape() == ExpandBoxShape.Flat)
							{
								SolidBrush oBrush = new SolidBrush(oNode.GetExpandBoxBackColor());
								oGraphics.FillRectangle(oBrush, new Rectangle(boxRect.Left + 1, boxRect.Top + 1, boxRect.Width - 1, boxRect.Height - 1));						
							}
						}

						oPen.Color = Color.FromArgb(nAlpha, oNode.GetExpandBoxForeColor());
						oGraphics.DrawLine(oPen, nX - 8, nY + 7, nX - 6, nY + 7);
						oPen.Dispose();
					}					
				}
				else
				{
					// draw the dot in the box
					Pen oPen = null;

					if (oNode.Flash == true)
						nAlpha = 255;			
		
					Rectangle boxRect = new Rectangle(rect.Left + 1, rect.Top + 1, rect.Width - 2, rect.Height - 2);

					// if XP line style, then fade the box and paint in black the inner part
					if (oNode.GetExpandBoxShape() == ExpandBoxShape.XP)
					{
						LinearGradientBrush oBrush = new LinearGradientBrush
						(
							new Rectangle(boxRect.Left, boxRect.Top, boxRect.Width, boxRect.Height),
							Color.White,
							oNode.GetExpandBoxBackColor(),
							LinearGradientMode.Vertical						
						);  

						oGraphics.FillRectangle(oBrush, new Rectangle(boxRect.Left + 1, boxRect.Top + 1, boxRect.Width - 1, boxRect.Height - 1));						

						oPen = new Pen(Color.FromArgb(nAlpha, oNode.GetExpandBoxBorderColor()), 1);
						oGraphics.DrawLine(oPen, boxRect.Left + 1, boxRect.Bottom, boxRect.Right - 1, boxRect.Bottom);
						oGraphics.DrawLine(oPen, boxRect.Right, boxRect.Top + 1, boxRect.Right, boxRect.Bottom - 1);
						oPen.Color = Color.FromArgb(128, oPen.Color);
						oGraphics.DrawLine(oPen, boxRect.Left + 1, boxRect.Top, boxRect.Right - 1, boxRect.Top);
						oGraphics.DrawLine(oPen, boxRect.Left, boxRect.Top + 1, boxRect.Left, boxRect.Bottom - 1);
					}
					else 
					{
						oPen = new Pen(Color.FromArgb(nAlpha, oNode.GetExpandBoxBorderColor()), 1);											
						oGraphics.DrawRectangle(oPen, boxRect);

						if (oNode.GetExpandBoxShape() == ExpandBoxShape.Flat)
						{
							SolidBrush oBrush = new SolidBrush(oNode.GetExpandBoxBackColor());
							oGraphics.FillRectangle(oBrush, new Rectangle(boxRect.Left + 1, boxRect.Top + 1, boxRect.Width - 1, boxRect.Height - 1));						
						}
					}

					oPen.Color = Color.FromArgb(nAlpha, oNode.GetExpandBoxForeColor());
					oGraphics.DrawLine(oPen, nX - 7, nY + 7, nX - 7, nY + 8);
					oPen.Dispose();
				}
			}

			// now mask the rect into the rect holders. it is being used by the mouse handler to change statuses
			try{m_mapRectToItemBox.Add(rect, oNode);}catch{}
			try{m_mapItemBoxToRect.Add(oNode, rect);}catch{}			
		}