Click here to Skip to main content
15,892,746 members
Articles / Web Development / HTML

Implementing WS-SecureConversation in Microsoft IssueVision

Rate me:
Please Sign up or sign in to vote.
4.61/5 (12 votes)
27 Sep 20056 min read 73.3K   776   38  
Adding secure communications to the Microsoft IssueVision sample application using WSE 2.0.
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;

namespace IssueVision
{
	public class MainForm : System.Windows.Forms.Form
	{
		[STAThread]
		static void Main() 
		{
			Application.EnableVisualStyles();
			Application.DoEvents();
			Application.Run(new MainForm());
		}
		
		#region Windows Form Designer generated code
		public MainForm() 
		{
			InitializeComponent();
		}

		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		private System.ComponentModel.IContainer components;

		//NOTE: The following procedure is required by the Windows Form Designer
		//It can be modified using the Windows Form Designer.  
		//do { not modify it using the code editor.
		private System.Windows.Forms.ToolBar tlbMain;
		private System.Windows.Forms.ToolBarButton tlbNewIssue;
		private System.Windows.Forms.StatusBarPanel sbpItemCount;
		private System.Windows.Forms.StatusBar stbMain;
		private System.Windows.Forms.ToolBarButton tlbOffline;
		private System.Windows.Forms.ImageList imagesToolbar;
		private System.Windows.Forms.ImageList imagesOnline;
		private System.Windows.Forms.Splitter splitterLeft;
		private System.Windows.Forms.Panel panelRight;
		private System.Windows.Forms.MenuItem menuFile;
		private System.Windows.Forms.MenuItem menuNew;
		private System.Windows.Forms.MenuItem menuExit;
		private System.Windows.Forms.MenuItem menuHelp;
		private System.Windows.Forms.MenuItem menuAbout;
		private System.Windows.Forms.MainMenu menuMain;
		private System.Windows.Forms.ToolBarButton tlbSendReceive;
		private System.Windows.Forms.MenuItem menuSendReceive;
		private System.Windows.Forms.Splitter Splitter1;
		private IssueVision.MiddlePane paneMiddle;
		private System.Windows.Forms.MenuItem MenuItem2;
		private IssueVision.OneIssuePane paneRight;
		private System.Windows.Forms.Panel panelLeft;
		private IssueVision.ChartPane paneChart;
		private IssueVision.StaffPane paneStaff;
		private IssueVision.ConflictPane paneConflict;
		private System.Windows.Forms.StatusBarPanel sbpIcon;
		private System.Windows.Forms.StatusBarPanel sbpOnline;
		private System.Windows.Forms.MenuItem mnuLogoutExit;

		[System.Diagnostics.DebuggerStepThrough()]
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainForm));
			this.stbMain = new System.Windows.Forms.StatusBar();
			this.sbpItemCount = new System.Windows.Forms.StatusBarPanel();
			this.sbpOnline = new System.Windows.Forms.StatusBarPanel();
			this.sbpIcon = new System.Windows.Forms.StatusBarPanel();
			this.tlbMain = new System.Windows.Forms.ToolBar();
			this.tlbNewIssue = new System.Windows.Forms.ToolBarButton();
			this.tlbSendReceive = new System.Windows.Forms.ToolBarButton();
			this.tlbOffline = new System.Windows.Forms.ToolBarButton();
			this.imagesToolbar = new System.Windows.Forms.ImageList(this.components);
			this.splitterLeft = new System.Windows.Forms.Splitter();
			this.panelRight = new System.Windows.Forms.Panel();
			this.paneConflict = new IssueVision.ConflictPane();
			this.paneRight = new IssueVision.OneIssuePane();
			this.Splitter1 = new System.Windows.Forms.Splitter();
			this.paneMiddle = new IssueVision.MiddlePane();
			this.menuMain = new System.Windows.Forms.MainMenu();
			this.menuFile = new System.Windows.Forms.MenuItem();
			this.menuNew = new System.Windows.Forms.MenuItem();
			this.menuSendReceive = new System.Windows.Forms.MenuItem();
			this.MenuItem2 = new System.Windows.Forms.MenuItem();
			this.mnuLogoutExit = new System.Windows.Forms.MenuItem();
			this.menuExit = new System.Windows.Forms.MenuItem();
			this.menuHelp = new System.Windows.Forms.MenuItem();
			this.menuAbout = new System.Windows.Forms.MenuItem();
			this.imagesOnline = new System.Windows.Forms.ImageList(this.components);
			this.panelLeft = new System.Windows.Forms.Panel();
			this.paneStaff = new IssueVision.StaffPane();
			this.paneChart = new IssueVision.ChartPane();
			((System.ComponentModel.ISupportInitialize)(this.sbpItemCount)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.sbpOnline)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.sbpIcon)).BeginInit();
			this.panelRight.SuspendLayout();
			this.panelLeft.SuspendLayout();
			this.SuspendLayout();
			// 
			// stbMain
			// 
			this.stbMain.Location = new System.Drawing.Point(0, 503);
			this.stbMain.Name = "stbMain";
			this.stbMain.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
																					   this.sbpItemCount,
																					   this.sbpOnline,
																					   this.sbpIcon});
			this.stbMain.ShowPanels = true;
			this.stbMain.Size = new System.Drawing.Size(824, 22);
			this.stbMain.TabIndex = 0;
			// 
			// sbpItemCount
			// 
			this.sbpItemCount.BorderStyle = System.Windows.Forms.StatusBarPanelBorderStyle.None;
			this.sbpItemCount.MinWidth = 40;
			this.sbpItemCount.Text = "0 Items";
			this.sbpItemCount.Width = 80;
			// 
			// sbpOnline
			// 
			this.sbpOnline.Alignment = System.Windows.Forms.HorizontalAlignment.Right;
			this.sbpOnline.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
			this.sbpOnline.BorderStyle = System.Windows.Forms.StatusBarPanelBorderStyle.None;
			this.sbpOnline.MinWidth = 100;
			this.sbpOnline.Width = 706;
			// 
			// sbpIcon
			// 
			this.sbpIcon.BorderStyle = System.Windows.Forms.StatusBarPanelBorderStyle.None;
			this.sbpIcon.MinWidth = 22;
			this.sbpIcon.Width = 22;
			// 
			// tlbMain
			// 
			this.tlbMain.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
			this.tlbMain.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																					   this.tlbNewIssue,
																					   this.tlbSendReceive,
																					   this.tlbOffline});
			this.tlbMain.DropDownArrows = true;
			this.tlbMain.ImageList = this.imagesToolbar;
			this.tlbMain.Location = new System.Drawing.Point(0, 0);
			this.tlbMain.Name = "tlbMain";
			this.tlbMain.ShowToolTips = true;
			this.tlbMain.Size = new System.Drawing.Size(824, 41);
			this.tlbMain.TabIndex = 1;
			this.tlbMain.TextAlign = System.Windows.Forms.ToolBarTextAlign.Right;
			// 
			// tlbNewIssue
			// 
			this.tlbNewIssue.ImageIndex = 0;
			this.tlbNewIssue.Text = "New";
			this.tlbNewIssue.ToolTipText = "Create a new issue";
			// 
			// tlbSendReceive
			// 
			this.tlbSendReceive.ImageIndex = 1;
			this.tlbSendReceive.Text = "Send/Receive";
			this.tlbSendReceive.ToolTipText = "Send/Receive issues";
			// 
			// tlbOffline
			// 
			this.tlbOffline.ImageIndex = 2;
			this.tlbOffline.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton;
			this.tlbOffline.Text = "Work Offline";
			this.tlbOffline.ToolTipText = "Work offline";
			// 
			// imagesToolbar
			// 
			this.imagesToolbar.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
			this.imagesToolbar.ImageSize = new System.Drawing.Size(29, 29);
			this.imagesToolbar.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imagesToolbar.ImageStream")));
			this.imagesToolbar.TransparentColor = System.Drawing.Color.Lime;
			// 
			// splitterLeft
			// 
			this.splitterLeft.Location = new System.Drawing.Point(208, 41);
			this.splitterLeft.MinSize = 200;
			this.splitterLeft.Name = "splitterLeft";
			this.splitterLeft.Size = new System.Drawing.Size(5, 462);
			this.splitterLeft.TabIndex = 14;
			this.splitterLeft.TabStop = false;
			// 
			// panelRight
			// 
			this.panelRight.AutoScroll = true;
			this.panelRight.BackColor = System.Drawing.Color.White;
			this.panelRight.Controls.Add(this.paneConflict);
			this.panelRight.Controls.Add(this.paneRight);
			this.panelRight.Controls.Add(this.Splitter1);
			this.panelRight.Controls.Add(this.paneMiddle);
			this.panelRight.Dock = System.Windows.Forms.DockStyle.Fill;
			this.panelRight.Location = new System.Drawing.Point(213, 41);
			this.panelRight.Name = "panelRight";
			this.panelRight.Size = new System.Drawing.Size(611, 462);
			this.panelRight.TabIndex = 15;
			// 
			// paneConflict
			// 
			this.paneConflict.BackColor = System.Drawing.Color.White;
			this.paneConflict.Dock = System.Windows.Forms.DockStyle.Fill;
			this.paneConflict.DockPadding.All = 1;
			this.paneConflict.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.paneConflict.Location = new System.Drawing.Point(333, 0);
			this.paneConflict.Name = "paneConflict";
			this.paneConflict.Size = new System.Drawing.Size(278, 462);
			this.paneConflict.TabIndex = 2;
			this.paneConflict.Visible = false;
			// 
			// paneRight
			// 
			this.paneRight.BackColor = System.Drawing.Color.White;
			this.paneRight.Dock = System.Windows.Forms.DockStyle.Fill;
			this.paneRight.DockPadding.All = 1;
			this.paneRight.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.paneRight.Location = new System.Drawing.Point(333, 0);
			this.paneRight.Name = "paneRight";
			this.paneRight.Size = new System.Drawing.Size(278, 462);
			this.paneRight.TabIndex = 2;
			// 
			// Splitter1
			// 
			this.Splitter1.BackColor = System.Drawing.SystemColors.Control;
			this.Splitter1.Location = new System.Drawing.Point(328, 0);
			this.Splitter1.Name = "Splitter1";
			this.Splitter1.Size = new System.Drawing.Size(5, 462);
			this.Splitter1.TabIndex = 1;
			this.Splitter1.TabStop = false;
			// 
			// paneMiddle
			// 
			this.paneMiddle.AutoScroll = true;
			this.paneMiddle.BackColor = System.Drawing.SystemColors.Window;
			this.paneMiddle.Dock = System.Windows.Forms.DockStyle.Left;
			this.paneMiddle.DockPadding.All = 1;
			this.paneMiddle.Location = new System.Drawing.Point(0, 0);
			this.paneMiddle.Name = "paneMiddle";
			this.paneMiddle.Size = new System.Drawing.Size(328, 462);
			this.paneMiddle.TabIndex = 0;
			// 
			// menuMain
			// 
			this.menuMain.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.menuFile,
																					 this.menuHelp});
			// 
			// menuFile
			// 
			this.menuFile.Index = 0;
			this.menuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.menuNew,
																					 this.menuSendReceive,
																					 this.MenuItem2,
																					 this.mnuLogoutExit,
																					 this.menuExit});
			this.menuFile.Text = "&File";
			// 
			// menuNew
			// 
			this.menuNew.Index = 0;
			this.menuNew.Shortcut = System.Windows.Forms.Shortcut.CtrlN;
			this.menuNew.Text = "&New";
			// 
			// menuSendReceive
			// 
			this.menuSendReceive.Index = 1;
			this.menuSendReceive.Shortcut = System.Windows.Forms.Shortcut.CtrlS;
			this.menuSendReceive.Text = "&Send/Receive";
			// 
			// MenuItem2
			// 
			this.MenuItem2.Index = 2;
			this.MenuItem2.Text = "-";
			// 
			// mnuLogoutExit
			// 
			this.mnuLogoutExit.Index = 3;
			this.mnuLogoutExit.Text = "&Logout and Exit";
			// 
			// menuExit
			// 
			this.menuExit.Index = 4;
			this.menuExit.Text = "E&xit";
			// 
			// menuHelp
			// 
			this.menuHelp.Index = 1;
			this.menuHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.menuAbout});
			this.menuHelp.Text = "&Help";
			// 
			// menuAbout
			// 
			this.menuAbout.Index = 0;
			this.menuAbout.Text = "&About";
			// 
			// imagesOnline
			// 
			this.imagesOnline.ImageSize = new System.Drawing.Size(16, 16);
			this.imagesOnline.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imagesOnline.ImageStream")));
			this.imagesOnline.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// panelLeft
			// 
			this.panelLeft.BackColor = System.Drawing.SystemColors.Window;
			this.panelLeft.Controls.Add(this.paneStaff);
			this.panelLeft.Controls.Add(this.paneChart);
			this.panelLeft.Dock = System.Windows.Forms.DockStyle.Left;
			this.panelLeft.Location = new System.Drawing.Point(0, 41);
			this.panelLeft.Name = "panelLeft";
			this.panelLeft.Size = new System.Drawing.Size(208, 462);
			this.panelLeft.TabIndex = 13;
			// 
			// paneStaff
			// 
			this.paneStaff.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.paneStaff.BackColor = System.Drawing.SystemColors.Window;
			this.paneStaff.DockPadding.All = 1;
			this.paneStaff.Location = new System.Drawing.Point(0, 0);
			this.paneStaff.Name = "paneStaff";
			this.paneStaff.Size = new System.Drawing.Size(208, 296);
			this.paneStaff.TabIndex = 2;
			// 
			// paneChart
			// 
			this.paneChart.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.paneChart.BackColor = System.Drawing.SystemColors.Window;
			this.paneChart.Location = new System.Drawing.Point(0, 300);
			this.paneChart.Name = "paneChart";
			this.paneChart.Size = new System.Drawing.Size(208, 160);
			this.paneChart.TabIndex = 1;
			// 
			// MainForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(824, 525);
			this.Controls.Add(this.panelRight);
			this.Controls.Add(this.splitterLeft);
			this.Controls.Add(this.panelLeft);
			this.Controls.Add(this.tlbMain);
			this.Controls.Add(this.stbMain);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Menu = this.menuMain;
			this.MinimumSize = new System.Drawing.Size(800, 559);
			this.Name = "MainForm";
			this.Text = "IssueVision";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.MainForm_Closing);
			this.Load += new System.EventHandler(this.MainForm_Load);
			((System.ComponentModel.ISupportInitialize)(this.sbpItemCount)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.sbpOnline)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.sbpIcon)).EndInit();
			this.panelRight.ResumeLayout(false);
			this.panelLeft.ResumeLayout(false);
			this.ResumeLayout(false);

		}

	#endregion

		// Internal members
		private IssueSubject m_issueSubject = null;
		private Command m_workOfflineCommand = null;
		private Command m_sendReceiveCommand = null;
		private Command m_newIssueCommand = null;
		private Command m_logoutExitCommand = null;
		private Command m_exitCommand = null;
		private Command m_aboutCommand = null;
		private bool m_saveUserSettings = true;

	#region StatusIcon enum

		// Holds icons that are displayed in the statusbar
		private Icon[] m_statusIcons = new Icon[3];

		// Maps to the icons in the image list
		private enum StatusIcon : int
		{
			Offline = 0,
			Online = 1,
			Sync = 2
		}

	#endregion

	#region Application Initialization

		private void MainForm_Load(object sender,  System.EventArgs e)
		{
			this.Visible = false;
			this.Cursor = Cursors.WaitCursor;
	        
			// Configure MainForm UI
			ResizeRedraw = true;
	        
			// get the user's credentials
			Login();
			
			if (UserSettings.Instance != null ) 
			{
				this.Visible = true;
				this.Show();
				this.Refresh();
				tlbMain.Buttons[2].Pushed = UserSettings.Instance.WorkOffline;
				
				// Load icon resources that are displayed in the statusbar
				LoadStatusIcons();
				
				// Setup the Command pattern
				InitializeCommands();
				
				// Finally, initialize the Subject
				ConfigureSubject();
			} 
			else 
			{
				Application.Exit();
			}        

			this.Cursor = Cursors.Default;
		}

		private void InitializeCommands() 
		{
			// Wire up menus and toolbar buttons
			//Command pattern: File | Send & Receive
			m_sendReceiveCommand = new Command(new Command.Action(this.SendReceive_Action));
			MenuItemCommander.Connect(menuSendReceive, m_sendReceiveCommand);
			ToolBarButtonCommander.Connect(tlbSendReceive, m_sendReceiveCommand);

			// Toolbar | Work Offline
			m_workOfflineCommand = new Command(new Command.Action(this.WorkOffline_Action));
			ToolBarButtonCommander.Connect(tlbOffline, m_workOfflineCommand);

			// File | new
			m_newIssueCommand = new Command(new Command.Action(this.NewIssue_Action));
			MenuItemCommander.Connect(this.menuNew, m_newIssueCommand);
			ToolBarButtonCommander.Connect(this.tlbNewIssue, m_newIssueCommand);

			// File | Logout and Exit
			m_logoutExitCommand = new Command(new Command.Action(this.LogoutExit_Action));
			MenuItemCommander.Connect(this.mnuLogoutExit, m_logoutExitCommand);

			// File | Exit
			m_exitCommand = new Command(new Command.Action(this.Exit_Action));
			MenuItemCommander.Connect(this.menuExit, m_exitCommand);

			// Help | About
			m_aboutCommand = new Command(new Command.Action(this.About_Action));
			MenuItemCommander.Connect(this.menuAbout, m_aboutCommand);
		}	

		private void Login() 
		{
			// do we have an existing, valid settings file in AppData?
			if (UserSettings.Instance != null ) 
			{
				if ( UserSettings.Instance.WorkOffline ) 
				{
					// login successful, show mainform
					return;
				} 
				else 
				{
					ShowLoginForm();
				}			
			} 
			else 
			{
				UserSettings.Delete();
				ShowLoginForm();
			}
		}	

		private void ShowLoginForm() 
		{
			LoginForm login = new LoginForm();
			login.Visible = false;
			login.ShowDialog();
			login.Close();
		}

		private void ConfigureSubject() 
		{
			if (m_issueSubject != null) 
			{
				m_issueSubject.SaveIssueData();
			}

			m_issueSubject = new IssueSubject(this.components);

			paneStaff.Subject = m_issueSubject;
			paneMiddle.Subject = m_issueSubject;
			paneRight.Subject = m_issueSubject;
			paneChart.Subject = m_issueSubject;
			paneConflict.Subject = m_issueSubject;

			m_issueSubject.Parent = this;
			m_issueSubject.Synchronization_Started += new IssueSubject.Synchronization_StartedEventHandler(IssueSubject_Synchronization_Started);
			m_issueSubject.Synchronization_Finished += new IssueSubject.Synchronization_FinishedEventHandler(IssueSubject_Synchronization_Finished);
			m_issueSubject.IssueDataChanged += new IssueSubject.IssueDataChangedEventHandler(IssueSubject_IssueDataChanged);
			
			m_issueSubject.Initialize();

			UpdateOnlineStatus();

			// If login was successful, set the titlebar
			this.Text = "IssueVision - " + UserSettings.Instance.Username;
		}

	#endregion

	#region Command Actions

		private void SendReceive_Action() 
		{
			this.Cursor = Cursors.WaitCursor;
			this.m_issueSubject.SendReceiveIssueData(SyncThread.MainThread);
			this.Cursor = Cursors.Default;
		}

		private void WorkOffline_Action() 
		{
			UpdateOnlineStatus();
		}

		private void About_Action() 
		{
			// Display the About dialog
			AboutForm form = new AboutForm();

			form.Visible = false;
			form.ShowDialog(this);
		}

		private void NewIssue_Action() 
		{
			// Display the new Issue dialog
			IssueNewForm form = new IssueNewForm(this);
			form.Subject = m_issueSubject;
			form.Show();
		}

		private void LogoutExit_Action() 
		{
			// Delete settings file and exit
			UserSettings.Delete();
			m_saveUserSettings = false;
			this.Close();
		}

		private void Exit_Action() 
		{
			this.Close();
		}

	#endregion

	#region Status Icons

		// Load icons that are displayed in the statusbar
		private void LoadStatusIcons() 
		{
			m_statusIcons[(int)StatusIcon.Offline] = Icon.FromHandle(new Bitmap(imagesOnline.Images[(int)StatusIcon.Offline]).GetHicon());

			m_statusIcons[(int)StatusIcon.Online] = Icon.FromHandle(new Bitmap(imagesOnline.Images[(int)StatusIcon.Online]).GetHicon());

			m_statusIcons[(int)StatusIcon.Sync] = Icon.FromHandle(new Bitmap(imagesOnline.Images[(int)StatusIcon.Sync]).GetHicon());
		}

		// update the online / offline status in the statusbar
		private void UpdateOnlineStatus() 
		{
			UserSettings.Instance.WorkOffline = tlbMain.Buttons[2].Pushed;
			m_issueSubject.IsOnline = !(tlbMain.Buttons[2].Pushed);

			if ( tlbMain.Buttons[2].Pushed ) 
			{
				m_sendReceiveCommand.IsEnabled = true;
				sbpOnline.Text = "Working Offline";
				sbpIcon.Icon = m_statusIcons[(int)StatusIcon.Offline];
			} 
			else 
			{
				// set to online
				m_sendReceiveCommand.IsEnabled = false;
				sbpOnline.Text = "Working Online";
				sbpIcon.Icon = m_statusIcons[(int)StatusIcon.Online];
			}
		}

		// These events are raised by the Subject to permit the main form to show
		// the current status of data synchronization with the server
		private void IssueSubject_Synchronization_Started(object sender, System.EventArgs e)
		{
			sbpOnline.Text = "Sending and Receiving...";
			sbpIcon.Icon = m_statusIcons[(int)StatusIcon.Sync];
		}

		private void IssueSubject_Synchronization_Finished(object sender, System.EventArgs e)
		{
			UpdateOnlineStatus();
		}

		// The IssueDataChanged event is handled by all of the observers, including MainForm
		// to ensure current information is displayed.  In the case of MainForm, the 
		// count of issue for the current view is displayed in the status bar.
		private void IssueSubject_IssueDataChanged(object sender, System.EventArgs e)
		{
			int count = m_issueSubject.CurrentView.Count;

			this.sbpItemCount.Text = count.ToString() + " item";
			if ( count != 1 ) 
			{ 
				sbpItemCount.Text += "s";
			}
		}

	#endregion

	#region Application Shutdown
		private void MainForm_Closing( object sender,  System.ComponentModel.CancelEventArgs e)
		{
			if (m_issueSubject != null ) 
			{
				m_issueSubject.SaveIssueData();
			}
	        
			if (UserSettings.Instance != null && m_saveUserSettings) 
			{
				UserSettings.Instance.Serialize();
			}
		}
	#endregion
	}
}

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
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

Comments and Discussions