Beispiel #1
0
		/// <summary>
		/// Paint the background of the node
		/// </summary>
		/// <param name="oNode"></param>
		/// <param name="oNodeRect"></param>
		private void PaintNodeBackground(Node oNode, Graphics oGraphics, Rectangle oNodeRect)
		{
			// if the node is selected node, then draw the selection
			if (oNode.IsSelected == true && m_oTreeView.HideSelection == false)
			{								
				int nScrollWidth = 2;
				int nAdd = 0;

				if (oNode.GetCheckBoxes() == true && oNode.CheckBoxVisible == true)
				{
					//if (oNode.GetShowPlusMinus() == false)
					//	nAdd = -2;
					//else
						nAdd = -1;
				}
				
				nScrollWidth += m_oTreeView.GetScrollBarWidth();

				m_oBrush.Color = oNode.GetSelectedBorderColor();

				// if full row select
				if (m_oTreeView.Style.FullRowSelect == true || oNode.Panel != null)
				{
					oGraphics.FillRectangle(m_oBrush, oNodeRect.X + 1 + nAdd, oNodeRect.Y - 1, 
						Width - (oNodeRect.X + 3) - nScrollWidth - nAdd, oNodeRect.Height - 1);

					m_oBrush.Color = oNode.GetSelectedBackColor();

					if (oNode.GetSelectedFillStyle() == FillStyle.Flat)
					{
						oGraphics.FillRectangle(m_oBrush, oNodeRect.X + 2 + nAdd, oNodeRect.Y, 
							Width - (oNodeRect.X + 5) - nScrollWidth - nAdd, oNodeRect.Height - 3);
					}
					else 
					if (oNode.GetSelectedFillStyle() == FillStyle.HorizontalFading)
					{
						AreaPainter.PaintRectangle(oGraphics, oNodeRect.X + 2 + nAdd, oNodeRect.Y, 
							Width - (oNodeRect.X + 5) - nScrollWidth - nAdd, oNodeRect.Height - 3,
							FillStyle.HorizontalFading, m_oBrush.Color, Color.White, BorderStyle.None, 
							Color.Transparent);
					}
					else
					if (oNode.GetSelectedFillStyle() == FillStyle.VerticalFading)
					{
						AreaPainter.PaintRectangle(oGraphics, oNodeRect.X + 2 + nAdd, oNodeRect.Y, 
							Width - (oNodeRect.X + 5) - nScrollWidth - nAdd, oNodeRect.Height - 3,
							FillStyle.VerticalFading, m_oBrush.Color, Color.White, BorderStyle.None, 
							Color.Transparent);
					}
					else
					if (oNode.GetSelectedFillStyle() == FillStyle.DiagonalBackward)
					{
						AreaPainter.PaintRectangle(oGraphics, oNodeRect.X + 2 + nAdd, oNodeRect.Y, 
							Width - (oNodeRect.X + 5) - nScrollWidth - nAdd, oNodeRect.Height - 3,
							FillStyle.DiagonalBackward, m_oBrush.Color, Color.White, BorderStyle.None, 
							Color.Transparent);
					}
					else
					if (oNode.GetSelectedFillStyle() == FillStyle.DiagonalForward)
					{
						AreaPainter.PaintRectangle(oGraphics, oNodeRect.X + 2 + nAdd, oNodeRect.Y, 
							Width - (oNodeRect.X + 5) - nScrollWidth - nAdd, oNodeRect.Height - 3,
							FillStyle.DiagonalForward, m_oBrush.Color, Color.White, BorderStyle.None, 
							Color.Transparent);
					}
					else
					if (oNode.GetSelectedFillStyle() == FillStyle.VistaFading)
					{
						AreaPainter.PaintRectangle(oGraphics, oNodeRect.X + 2 + nAdd, oNodeRect.Y, 
							Width - (oNodeRect.X + 5) - nScrollWidth - nAdd, oNodeRect.Height - 3,
							FillStyle.VistaFading, m_oBrush.Color, Color.White, BorderStyle.None, 
							Color.Transparent);
					}
					else
					if (oNode.GetSelectedFillStyle() == FillStyle.VerticalCentreFading)
					{
						AreaPainter.PaintRectangle(oGraphics, oNodeRect.X + 2 + nAdd, oNodeRect.Y, 
							Width - (oNodeRect.X + 5) - nScrollWidth - nAdd, oNodeRect.Height - 3,
							FillStyle.VerticalCentreFading, m_oBrush.Color, Color.White, BorderStyle.None, 
							Color.Transparent);
					}
				}
				else
				{
					oGraphics.FillRectangle(m_oBrush, oNodeRect.X + 1 + nAdd, oNodeRect.Y - 1, 
						(int)oNodeRect.Width, oNodeRect.Height - 1);

					m_oBrush.Color = oNode.GetSelectedBackColor();

					if (oNode.GetSelectedFillStyle() == FillStyle.Flat)
					{
						oGraphics.FillRectangle(m_oBrush, oNodeRect.X + 2 + nAdd, oNodeRect.Y, 
							(int)oNodeRect.Width - 2, oNodeRect.Height - 3);
					}
					else
					if (oNode.GetSelectedFillStyle() == FillStyle.HorizontalFading)
					{
						AreaPainter.PaintRectangle(oGraphics,  oNodeRect.X + 2 + nAdd, oNodeRect.Y, 
							(int)oNodeRect.Width - 2, oNodeRect.Height - 3,
							FillStyle.HorizontalFading, m_oBrush.Color, Color.White, BorderStyle.None, 
							Color.Transparent);
					}
					else
					if (oNode.GetSelectedFillStyle() == FillStyle.VerticalFading)
					{
						AreaPainter.PaintRectangle(oGraphics,  oNodeRect.X + 2 + nAdd, oNodeRect.Y, 
							(int)oNodeRect.Width - 2, oNodeRect.Height - 3,
							FillStyle.VerticalFading, m_oBrush.Color, Color.White, BorderStyle.None, 
							Color.Transparent);
					}
					else
					if (oNode.GetSelectedFillStyle() == FillStyle.DiagonalBackward)
					{
						AreaPainter.PaintRectangle(oGraphics,  oNodeRect.X + 2 + nAdd, oNodeRect.Y, 
							(int)oNodeRect.Width - 2, oNodeRect.Height - 3,
							FillStyle.DiagonalBackward, m_oBrush.Color, Color.White, BorderStyle.None, 
							Color.Transparent);
					}
					else
					if (oNode.GetSelectedFillStyle() == FillStyle.DiagonalForward)
					{
						AreaPainter.PaintRectangle(oGraphics,  oNodeRect.X + 2 + nAdd, oNodeRect.Y, 
							(int)oNodeRect.Width - 2, oNodeRect.Height - 3,
							FillStyle.DiagonalForward, m_oBrush.Color, Color.White, BorderStyle.None, 
							Color.Transparent);
					}
					else
					if (oNode.GetSelectedFillStyle() == FillStyle.VistaFading)
					{
						AreaPainter.PaintRectangle(oGraphics,  oNodeRect.X + 2 + nAdd, oNodeRect.Y, 
							(int)oNodeRect.Width - 2, oNodeRect.Height - 3,
							FillStyle.VistaFading, m_oBrush.Color, Color.White, BorderStyle.None, 
							Color.Transparent);
					}
					else
					if (oNode.GetSelectedFillStyle() == FillStyle.VerticalCentreFading)
					{
						AreaPainter.PaintRectangle(oGraphics,  oNodeRect.X + 2 + nAdd, oNodeRect.Y, 
							(int)oNodeRect.Width - 2, oNodeRect.Height - 3,
							FillStyle.VerticalCentreFading, m_oBrush.Color, Color.White, BorderStyle.None, 
							Color.Transparent);
					}
				}
			}

			// draw the focus rectangle
			if (oNode.IsSelected == true && oNode.TreeView.m_bUserFocus == true && oNode.TreeView.FocusNode == oNode
				&& oNode.TreeView.FocusRectangle == true)
			{
				int nScrollWidth = 2;
				int nAdd = 0;

				nScrollWidth += m_oTreeView.GetScrollBarWidth();

				if (oNode.GetCheckBoxes() == true && oNode.CheckBoxVisible == true)
				{
					//if (oNode.GetShowPlusMinus() == false)
					//	nAdd = -2;
					//else
						nAdd = -1;
				}

				Pen oRectPen = new Pen(Color.Black, 1);
				oRectPen.DashStyle = DashStyle.Dot;

				if (m_oTreeView.Style.FullRowSelect == true || oNode.Panel != null)
				{
					oGraphics.DrawRectangle(oRectPen, oNodeRect.X + 2 + nAdd, oNodeRect.Y, 
						Width - (oNodeRect.X + 6) - nScrollWidth - nAdd, oNodeRect.Height - 4);	
				}
				else
				{
					oGraphics.DrawRectangle(oRectPen, oNodeRect.X + 2 + nAdd, oNodeRect.Y, 
						(int)oNodeRect.Width - 3, oNodeRect.Height - 4);	
				}

				oRectPen.Dispose();
			}

			// if not selected
			if (oNode.IsSelected == false)
			{			
				// when draging the mouse over nodes, test if the node is being highlighted
				if (oNode == oNode.TreeView.HighlightedNode)
				{
					int nScrollWidth = 2;
				
					nScrollWidth += m_oTreeView.GetScrollBarWidth();

					m_oBrush.Color = oNode.GetHighlightedBackColor();

					if (m_oTreeView.Style.FullRowSelect == true || oNode.Panel != null)
					{
						oGraphics.FillRectangle(m_oBrush, oNodeRect.X + 1, oNodeRect.Y - 1, 
							Width - (oNodeRect.X + 3) - nScrollWidth, oNodeRect.Height - 1);
					}
					else
					{
						oGraphics.FillRectangle(m_oBrush, oNodeRect.X + 1, oNodeRect.Y - 1, 
							(int)oNodeRect.Width, oNodeRect.Height - 1);
					}
				}
			}
		}