/*********************************************************************************************
 * Copyright 2004 - Volian Enterprises, Inc. All rights reserved.
 * Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
 * ------------------------------------------------------------------------------
 * $Workfile: LockRlsDlg.cs $     $Revision: 2 $
 * $Author: Jsj $   $Date: 8/17/04 12:54p $
 *
 * $History: LockRlsDlg.cs $
 * 
 * *****************  Version 2  *****************
 * User: Jsj          Date: 8/17/04    Time: 12:54p
 * Updated in $/LibSource/VENetwork
 * Needed to assign an Icon to the form.  It was bombing with a resource
 * error otherwise.
 * 
 * *****************  Version 1  *****************
 * User: Kathy        Date: 7/27/04    Time: 8:44a
 * Created in $/LibSource/VENetwork
 *********************************************************************************************/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace VENetwork
{
	/// 
	/// Allows user to Release Locks on exit.
	/// 
	public class LockRlsDlg : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Button btnOK;
		private System.Windows.Forms.Button btnCancel;
		private System.Windows.Forms.CheckBox cbSystem;
		private System.Windows.Forms.CheckBox cbPlant;
		private System.Windows.Forms.CheckBox cbProcSet;
		private System.ComponentModel.Container components = null;
		private VELock LSystem;
		private VELock LPlant;
		private VELock LProcSet;
		public LockRlsDlg(VELock lsys, VELock lplt, VELock lps)
		{
			LSystem = lsys;
			LPlant = lplt;
			LProcSet = lps;
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			// Set checkboxes depending on whether a lock exists. Note
			// that the input locks will be null if not locked by this user.
			if (lsys != null)
				cbSystem.Checked = true;
			else
				cbSystem.Enabled = false;
			if (lplt != null)
			{
				cbPlant.Text = lplt.Path.Substring(0,lplt.Path.LastIndexOf("\\"));
				cbPlant.Checked = true;
			}
			else
				cbPlant.Enabled = false;
			if (lps != null)
			{
				cbProcSet.Text = lps.Path.Substring(0,lps.Path.LastIndexOf("\\"));
				cbProcSet.Checked = true;
			}
			else
				cbProcSet.Enabled = false;
		}
		/// 
		/// Clean up any resources being used.
		/// 
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}
		#region Windows Form Designer generated code
		/// 
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// 
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(LockRlsDlg));
			this.label1 = new System.Windows.Forms.Label();
			this.btnOK = new System.Windows.Forms.Button();
			this.btnCancel = new System.Windows.Forms.Button();
			this.cbSystem = new System.Windows.Forms.CheckBox();
			this.cbPlant = new System.Windows.Forms.CheckBox();
			this.cbProcSet = new System.Windows.Forms.CheckBox();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label1.Location = new System.Drawing.Point(29, 9);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(451, 56);
			this.label1.TabIndex = 0;
			this.label1.Text = "The Following Locks Have Been Detected.  Please Click The Appropriate Box To Rele" +
				"ase The Lock.";
			// 
			// btnOK
			// 
			this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
			this.btnOK.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.btnOK.Location = new System.Drawing.Point(173, 194);
			this.btnOK.Name = "btnOK";
			this.btnOK.Size = new System.Drawing.Size(77, 28);
			this.btnOK.TabIndex = 1;
			this.btnOK.Text = "OK";
			this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
			// 
			// btnCancel
			// 
			this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnCancel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.btnCancel.Location = new System.Drawing.Point(288, 194);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.Size = new System.Drawing.Size(77, 28);
			this.btnCancel.TabIndex = 2;
			this.btnCancel.Text = "Cancel";
			// 
			// cbSystem
			// 
			this.cbSystem.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.cbSystem.Location = new System.Drawing.Point(86, 74);
			this.cbSystem.Name = "cbSystem";
			this.cbSystem.Size = new System.Drawing.Size(375, 28);
			this.cbSystem.TabIndex = 3;
			this.cbSystem.Text = "System";
			// 
			// cbPlant
			// 
			this.cbPlant.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.cbPlant.Location = new System.Drawing.Point(86, 111);
			this.cbPlant.Name = "cbPlant";
			this.cbPlant.Size = new System.Drawing.Size(375, 27);
			this.cbPlant.TabIndex = 4;
			this.cbPlant.Text = "Plant";
			// 
			// cbProcSet
			// 
			this.cbProcSet.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.cbProcSet.Location = new System.Drawing.Point(86, 148);
			this.cbProcSet.Name = "cbProcSet";
			this.cbProcSet.Size = new System.Drawing.Size(375, 27);
			this.cbProcSet.TabIndex = 5;
			this.cbProcSet.Text = "Data";
			// 
			// LockRlsDlg
			// 
			this.AccessibleRole = System.Windows.Forms.AccessibleRole.TitleBar;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
			this.ClientSize = new System.Drawing.Size(537, 228);
			this.Controls.Add(this.cbProcSet);
			this.Controls.Add(this.cbPlant);
			this.Controls.Add(this.cbSystem);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.btnOK);
			this.Controls.Add(this.label1);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "LockRlsDlg";
			this.Text = "Release Locks";
			this.ResumeLayout(false);
		}
		#endregion
		private void btnOK_Click(object sender, System.EventArgs e)
		{
			// unlock any where the check was removed (kind of backwards but duplicates
			// functionality from vfw.
			if (this.cbSystem.Visible && this.cbSystem.Enabled && !this.cbSystem.Checked)
				LSystem.UnLock(false);
			if (this.cbPlant.Visible && this.cbPlant.Enabled && !this.cbPlant.Checked)
				LPlant.UnLock(false);
			if (this.cbProcSet.Visible && this.cbProcSet.Enabled && !this.cbProcSet.Checked)
				LProcSet.UnLock(false);
		}
	}
}