Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » XML » Web Services » Downloads
 
Add your own
alternative version

Implementing WS-SecureConversation in Microsoft IssueVision

, 27 Sep 2005
Adding secure communications to the Microsoft IssueVision sample application using WSE 2.0.
issuevisionwsesmartclient.zip
Database
IssueVision
Controls
Outlook
Images
statusbar
toolbar
types
Libraries
ThreadHelper Documentation
Panes
Patterns
Web References
localhost
IssueVisionWebWseCS
Libraries
App.ico
IssueVision.csproj.user
IssueVision.snk
IssueVisionServices.disco
IssueVisionServices.wsdl
Reference.map
AppUpdater.dll
ThreadHelper.dll
About BackgroundWorker.doc
Async Windows Forms Programming with BackgroundWorker.doc
IssueVision-about-banner.png
mosaic-light.png
Signin.png
all_staffers.png
all_types.png
computer.png
environmental.png
help_desk.png
network.png
none.png
printer.png
staff.png
technicians.png
technicians_group.png
telecom.png
new_task.png
synchronize.png
work_offline.png
StatusConnected.ico
StatusDisconnected.ico
StatusSynchronizing.ico
IssueVisionWebWseCS.csproj.webinfo
IVDataSet.xsx
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Text;
using System.Windows.Forms;

namespace IssueVision
{
	// Label control that supports ellipsis and antialias.
	public class EllipsisLabel : UserControl
	{
		// internal members
		private bool m_antiAlias = false;
		private StringFormat m_format = new StringFormat();
		private SolidBrush m_brush = new SolidBrush(SystemColors.WindowText);
		private int m_padding = 0;
		private ContentAlignment m_alignment = ContentAlignment.TopLeft;
		private IContainer components = null;
		
		public EllipsisLabel()
		{
			InitializeComponent();
			
			// default the text to the control's name
			Text = Name;
			
			// init format
			m_format.FormatFlags = StringFormatFlags.NoWrap;
			m_format.Trimming = StringTrimming.EllipsisCharacter;
			
			// turn on double buffering and transparency
			SetStyle(	ControlStyles.UserPaint | 
						ControlStyles.ResizeRedraw | 
						ControlStyles.SupportsTransparentBackColor | 
						ControlStyles.AllPaintingInWmPaint | 
						ControlStyles.DoubleBuffer, 
						true);
		}
		
		protected override void Dispose(bool disposing)
		{
			if (disposing && components != null)
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}

		[DebuggerStepThroughAttribute()]
		private void InitializeComponent()
		{
			Name = "EllipsisLabel";
			Size = new Size(100, 23);
		}
		
		[DefaultValueAttribute(1)]
		[DescriptionAttribute("Specifies the alignment of the text.")]
		[CategoryAttribute("Appearance")]
		public ContentAlignment Alignment
		{
			get
			{
				return m_alignment;
			}

			set
			{
				m_alignment = value;
				
				// set the horz format based on the new alignment
				m_format.Alignment = StringAlignment.Near;
				
				if (m_alignment == ContentAlignment.BottomCenter || m_alignment == ContentAlignment.MiddleCenter || m_alignment == ContentAlignment.TopCenter)
				{
					m_format.Alignment = StringAlignment.Center;
				}
				
				if (m_alignment == ContentAlignment.BottomRight || m_alignment == ContentAlignment.MiddleRight || m_alignment == ContentAlignment.TopRight)
				{
					m_format.Alignment = StringAlignment.Far;
				}
				
				// set the vert format based on the new alignment
				m_format.LineAlignment = StringAlignment.Near;
				
				if (m_alignment == ContentAlignment.BottomCenter || m_alignment == ContentAlignment.BottomCenter || m_alignment == ContentAlignment.BottomCenter)
				{
					m_format.LineAlignment = StringAlignment.Far;
				}
				
				if (m_alignment == ContentAlignment.MiddleCenter || m_alignment == ContentAlignment.MiddleLeft || m_alignment == ContentAlignment.MiddleRight)
				{
					m_format.LineAlignment = StringAlignment.Center;
				}
				
				Invalidate();
			}
		}

		[CategoryAttribute("Appearance")]
		[DescriptionAttribute("Text that is displayed in the label.")]
		[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
		[BrowsableAttribute(true)]
		new public string Text
		{
			get
			{
				return base.Text;
			}

			set
			{
				base.Text = value;
				Invalidate();
			}
		}

		[DescriptionAttribute("Specifies how to trim characters from a string that does not completely fit into a layout shape.")]
		[DefaultValueAttribute(3)]
		[CategoryAttribute("Appearance")]
		public StringTrimming Ellipsis
		{
			get
			{
				return m_format.Trimming;
			}

			set
			{
				m_format.Trimming = value;
				Invalidate();
			}
		}

		[DescriptionAttribute("If the text should be drawn antialiased.")]
		[CategoryAttribute("Appearance")]
		[DefaultValueAttribute(false)]
		public bool AntiAlias
		{
			get
			{
				return m_antiAlias;
			}

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

		[CategoryAttribute("Appearance")]
		[DescriptionAttribute("Amount of space to leave around the text.")]
		[DefaultValueAttribute(0)]
		public int Padding
		{
			get
			{
				return m_padding;
			}

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

		// paint the label
		protected override void OnPaint(PaintEventArgs e)
		{
			// calculate the bounding area, required when drawing ellipsis
			RectangleF rc = new RectangleF(m_padding, m_padding, (Width - m_padding * 2), (Height - m_padding * 2));
			
			// see if want to draw antialias
			if (m_antiAlias)
			{
				e.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
			}
			
			// draw the text
			e.Graphics.DrawString(Text, Font, m_brush, rc, m_format);
		}

		// create new brush when the fore color changes
		protected override void OnForeColorChanged(EventArgs e)
		{
			base.OnForeColorChanged(e);
			m_brush.Dispose();
			m_brush = new SolidBrush(ForeColor);
		}

		// update the brush when the system colors change
		protected override void OnSystemColorsChanged(EventArgs e)
		{
			base.OnSystemColorsChanged(e);
			OnForeColorChanged(EventArgs.Empty);
		}

		// update the format if the right-to-left property changes
		protected override void OnRightToLeftChanged(EventArgs e)
		{
			base.OnRightToLeftChanged(e);
			
			if (RightToLeft == RightToLeft.Yes)
			{
				m_format.FormatFlags = m_format.FormatFlags | StringFormatFlags.DirectionRightToLeft;
			}
			
			if (RightToLeft == RightToLeft.No)
			{
				m_format.FormatFlags = m_format.FormatFlags & (StringFormatFlags)(-2);
			}
			
			Invalidate();
		}
	}
}

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

Share

About the Author

Weidong Shen
Software Developer (Senior)
United States United States
Weidong has been an information system professional since 1990. He has a Master's degree in Computer Science, and is currently a MCSD .NET

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150224.1 | Last Updated 27 Sep 2005
Article Copyright 2005 by Weidong Shen
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid