Click here to Skip to main content
11,411,840 members (51,775 online)
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.Windows.Forms;

namespace IssueVision
{
	// Commander-derived classes exist to hook up Windows Forms UI elements to 
	// Command objects using an adapter pattern.  The adapter approach permits a 
	// single Command object to sink events from dissimilar ui elements, and to set
	// state on dissimilar ui elements.
	//
	// This implementation provides Commanders for 
	// -menu items
	// -toolbar buttons
	//
	// Commanders exhibit the Adapter pattern in two ways:
	// - They adapt the different kinds of events fired by Clients (e.g. menu
	//   items and tool bar buttons) to invoke the Execute methods of their
	//   Commands.
	// - They adapt the EnableChanged events fired by Commands to set the
	//   Enabled property of their Clients.
	
	// base Commander class
	public abstract class Commander
	{
		protected Command m_command;
		protected abstract void HandleEnableChangedEvent(object sender, Command.EnableChangedEventArgs e);

		protected Commander(Command command)
		{
			m_command = command;
			m_command.EnableChanged += new Command.EnableChangedEventHandler(this.HandleEnableChangedEvent);
		}
	}
	
	// MenuItemCommander class
	public class MenuItemCommander : Commander
	{
		private MenuItem m_item;

		protected MenuItemCommander(MenuItem item, Command command) : base(command)
		{
			m_item = item;
			m_item.Click += new EventHandler(this.HandleUIEvent);
		}

		protected override void HandleEnableChangedEvent(object sender, Command.EnableChangedEventArgs e)
		{
			m_item.Enabled = e.IsEnabled;
		}

		private void HandleUIEvent(object sender, EventArgs e)
		{
			m_command.Execute();
		}

		// Connect is a shared (static) method that performs the task of adapting a menu
		// item to a command.  The commander exists only to wire up the two objects -- 
		// it is not used further
		public static void Connect(MenuItem item, Command command)
		{
			MenuItemCommander unused = new MenuItemCommander(item, command);
		}
	}
	
	public class ToolBarButtonCommander : Commander
	{
		private ToolBarButton m_button;

		protected ToolBarButtonCommander(ToolBarButton button, Command command) : base(command)
		{
			m_button = button;
			button.Parent.ButtonClick += new ToolBarButtonClickEventHandler(this.HandleUIEvent);
		}

		protected override void HandleEnableChangedEvent(object sender, Command.EnableChangedEventArgs e)
		{
			m_button.Enabled = e.IsEnabled;
		}

		private void HandleUIEvent(object sender, ToolBarButtonClickEventArgs e)
		{
			if (m_button == e.Button)
			{
				m_command.Execute();
			}
		}

		// Connect is a shared (static) method that performs the task of adapting a toolbar
		// button to a command.  The commander exists only to wire up the two objects -- 
		// it is not used further
		public static void Connect(ToolBarButton button, Command command)
		{
			ToolBarButtonCommander unused = new ToolBarButtonCommander(button, command);
		}
	}
}

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
Web01 | 2.8.150414.5 | Last Updated 27 Sep 2005
Article Copyright 2005 by Weidong Shen
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid