using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace PDFCreatorApp
{
	/// <summary>
	/// Summary description for PropertiesForm.
	/// </summary>
	public class PropertiesForm : System.Windows.Forms.Form
	{
		private Amyuni.PDFCreator.acPropertiesCtrl propertiesCtrl;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public PropertiesForm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			propertiesCtrl.OnObjectChanged += new Amyuni.PDFCreator.acPropertiesCtrl.ObjectChangedDelegate( propertiesCtrl_OnObjectChanged );
		}

		/// <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.propertiesCtrl = new Amyuni.PDFCreator.acPropertiesCtrl();
			this.SuspendLayout();
			// 
			// propertiesCtrl
			// 
			this.propertiesCtrl.AlwaysVisible = false;
			this.propertiesCtrl.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.propertiesCtrl.Location = new System.Drawing.Point(0, 0);
			this.propertiesCtrl.Name = "propertiesCtrl";
			this.propertiesCtrl.Size = new System.Drawing.Size(491, 378);
			this.propertiesCtrl.TabIndex = 0;
			// 
			// PropertiesForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(491, 374);
			this.Controls.Add(this.propertiesCtrl);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
			this.Name = "PropertiesForm";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
			this.Text = "Object Properties...";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.PropertiesForm_Closing);
			this.Load += new System.EventHandler(this.PropertiesForm_Load);
			this.Deactivate += new System.EventHandler(this.PropertiesForm_Deactivate);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void PropertiesForm_Load(object sender, System.EventArgs e)
		{
		
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void PropertiesForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			e.Cancel = true;
			this.Hide();
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void PropertiesForm_Deactivate(object sender, System.EventArgs e)
		{
			if ( !propertiesCtrl.AlwaysVisible )
				this.Hide();
		}

		/// <summary>
		/// 
		/// </summary>
		public Amyuni.PDFCreator.IacPropertiesCtrl PropertiesCtrlInterface
		{
			get
			{
				return propertiesCtrl as Amyuni.PDFCreator.IacPropertiesCtrl;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public Amyuni.PDFCreator.acPropertiesCtrl PropertiesCtrl
		{
			get
			{
				return propertiesCtrl;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void propertiesCtrl_OnObjectChanged( object sender, Amyuni.PDFCreator.acPropertiesCtrl.acPropertiesCtrlEventArgs e )
		{
			string newObjectName = "";

			if ( /*e.ObjectChangeOrignatedFromPropertiesCtrl &&*/ e.acObject != null )
			{
				if ( e.acObject.Name != null )
					newObjectName = e.acObject.Name;
			}

			this.Text = ( newObjectName.Length != 0 ? "Object Properties - " + newObjectName : "Object Properties" );
		}
	}
}
