Click here to Skip to main content
15,886,095 members
Articles / Web Development / ASP.NET

Developing Next Generation Smart Clients using .NET 2.0 working with Existing .NET 1.1 SOA-based XML Web Services

Rate me:
Please Sign up or sign in to vote.
4.96/5 (134 votes)
16 Aug 200540 min read 1.2M   3.9K   462  
Comprehensive guide to development of .NET 2.0 Smart Clients working with existing Service Oriented Architecture based XML web services, fully utilizing the Enterprise Library
#region Using directives

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.ComponentModel;

#endregion

namespace SmartInstitute.Client.Controls
{
	public class SectionHeader : Panel
	{
		// const values
		private class Consts
		{
			public static Color ColorLow = Color.FromArgb(175, 200, 245);
			public static Color ColorHigh = Color.FromArgb(205, 225, 250);
			public static Pen PenTop = new Pen(Color.FromArgb(180, 210, 245));
			public static Pen PenBottom = new Pen(SystemColors.InactiveCaption);
			public const int PosOffset = 4;
		}

		// internal members
		private LinearGradientBrush m_brush;
		private string m_text = string.Empty;

		[DefaultValueAttribute("")]
		[CategoryAttribute("Appearance")]
		[DescriptionAttribute("Header text.")]
		public string HeaderText
		{
			get
			{
				return m_text;
			}

			set
			{
				m_text = value;
				Invalidate();
			}
		}

		public SectionHeader()
		{
			SetStyle(ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);

		}

		// the caption needs to be drawn
		protected override void OnPaint(PaintEventArgs e)
		{
			Draw(e.Graphics);
			base.OnPaint(e);
		}

		// draw the caption
		private void Draw(Graphics g)
		{
			if (Width != 0 && Height != 0)
			{
				if( null == m_brush )
					this.CreateFillBrush();

				// background
				g.FillRectangle(m_brush, DisplayRectangle);
				
				// header text
				g.DrawString(m_text, Font, SystemBrushes.ControlText, Consts.PosOffset, ((Height - Font.Height) / 2));
				
				// top and bottom lines
				g.DrawLine(Consts.PenTop, 0, 0, Width - 1, 0);
				g.DrawLine(Consts.PenBottom, 0, Height - 1, Width - 1, Height - 1);
			}
		}

		protected override void OnSizeChanged(EventArgs e)
		{
			base.OnSizeChanged(e);

			this.CreateFillBrush();
		}
		private void CreateFillBrush()
		{
			if (Width > 0 && Height > 0)
			{
				// create the gradient brush when the control is resized
				m_brush = new LinearGradientBrush(DisplayRectangle, Consts.ColorHigh, Consts.ColorLow, LinearGradientMode.Vertical);
			}
		}

	}
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect BT, UK (ex British Telecom)
United Kingdom United Kingdom

Comments and Discussions