Click here to Skip to main content
15,895,557 members
Articles / Programming Languages / C#

Hello UIPAB

Rate me:
Please Sign up or sign in to vote.
4.76/5 (27 votes)
24 Mar 2005CPOL14 min read 118.1K   230   84  
A primer to Microsoft's User Interface Process Application Block.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Microsoft.ApplicationBlocks.UIProcess;

namespace SimpleWinUIPAB
{
	/// <summary>
	/// Summary description for Start.
	/// </summary>
	public class Start : System.Windows.Forms.Form, IShutdownUIP
	{
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.Label label2;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Start()
		{
            // The classes that implement the shutdown interface must be registered 
            // with the UIPManager class
            UIPManager.RegisterShutdown(this);
            
            InitializeComponent();
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.label1 = new System.Windows.Forms.Label();
            this.button1 = new System.Windows.Forms.Button();
            this.label2 = new System.Windows.Forms.Label();
            this.SuspendLayout();
            // 
            // label1
            // 
            this.label1.ForeColor = System.Drawing.Color.Maroon;
            this.label1.Location = new System.Drawing.Point(8, 16);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(312, 32);
            this.label1.TabIndex = 0;
            this.label1.Text = "Typically, the initial page would contain a login mechanism.";
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(96, 80);
            this.button1.Name = "button1";
            this.button1.TabIndex = 1;
            this.button1.Text = "Start UIPAB";
            this.button1.Click += new System.EventHandler(this.button1_Click);
            // 
            // label2
            // 
            this.label2.ForeColor = System.Drawing.Color.Maroon;
            this.label2.Location = new System.Drawing.Point(8, 144);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(312, 24);
            this.label2.TabIndex = 2;
            this.label2.Text = "This page is not contained in the \'views\' or \'navigationgraph\' sections contained" +
                " in the configuration file.";
            // 
            // Start
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(328, 222);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.label1);
            this.Name = "Start";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Start";
            this.ResumeLayout(false);

        }
		#endregion
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main() 
        {
            Application.Run(new Start());
        }

        private void button1_Click(object sender, System.EventArgs e)
        {
            // This view can be hidden because it started the task 
            // and its lifetime isn�t controlled
            // by the UIPManager class
            this.Visible = false;

            // Create a task and start the UIPAB block
            UIPManager.StartNavigationTask("SimpleWinUIPAB");
        }	
       
        // When the last UIP form closes, UIP detects that the windows have
        // been closed and the registered classes' Shutdown method is invoked. 
        public void Shutdown()
        {
            this.Close();
        }    
    }
}

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
United States United States
Roy is a software developer who digs all aspects of software development, from design and architecture to implementation.

Comments and Discussions