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

namespace PrintPreview
{
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
        private System.Windows.Forms.PictureBox pictureBox1;
        private System.Windows.Forms.Label label1;
        private AxSftDirectoryLib25.AxSftDirectory axSftDirectory1;
        private AxSftPrintPreviewLib10.AxSftPrintPreview axSftPrintPreview1;
        private System.Windows.Forms.MainMenu mainMenu1;
        private System.Windows.Forms.MenuItem menuExit;
        private System.Windows.Forms.MenuItem menuDirectory;
        private System.Windows.Forms.MenuItem menuPreview;
        private System.Windows.Forms.Label label2;
        private IContainer components;

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

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }

        /// <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.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.pictureBox1 = new System.Windows.Forms.PictureBox();
            this.label1 = new System.Windows.Forms.Label();
            this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
            this.menuExit = new System.Windows.Forms.MenuItem();
            this.menuDirectory = new System.Windows.Forms.MenuItem();
            this.menuPreview = new System.Windows.Forms.MenuItem();
            this.label2 = new System.Windows.Forms.Label();
            this.axSftPrintPreview1 = new AxSftPrintPreviewLib10.AxSftPrintPreview();
            this.axSftDirectory1 = new AxSftDirectoryLib25.AxSftDirectory();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.axSftPrintPreview1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.axSftDirectory1)).BeginInit();
            this.SuspendLayout();
            // 
            // pictureBox1
            // 
            this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
            this.pictureBox1.Location = new System.Drawing.Point(323, 306);
            this.pictureBox1.Name = "pictureBox1";
            this.pictureBox1.Size = new System.Drawing.Size(229, 60);
            this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
            this.pictureBox1.TabIndex = 2;
            this.pictureBox1.TabStop = false;
            this.pictureBox1.Visible = false;
            // 
            // label1
            // 
            this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label1.Location = new System.Drawing.Point(16, 328);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(296, 48);
            this.label1.TabIndex = 3;
            this.label1.Text = "Click on the SftDirectory control above and hit F1 to access help information for" +
                " SftDirectory 2.5";
            this.label1.Visible = false;
            // 
            // mainMenu1
            // 
            this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.menuExit,
            this.menuDirectory,
            this.menuPreview});
            // 
            // menuExit
            // 
            this.menuExit.Index = 0;
            this.menuExit.Text = "E&xit";
            this.menuExit.Click += new System.EventHandler(this.menuExit_Click);
            // 
            // menuDirectory
            // 
            this.menuDirectory.Index = 1;
            this.menuDirectory.Text = "View Sft&Directory";
            this.menuDirectory.Click += new System.EventHandler(this.menuDirectory_Click);
            // 
            // menuPreview
            // 
            this.menuPreview.Index = 2;
            this.menuPreview.Text = "&PrintPreview";
            this.menuPreview.Click += new System.EventHandler(this.menuPreview_Click);
            // 
            // label2
            // 
            this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label2.Location = new System.Drawing.Point(16, 264);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(536, 48);
            this.label2.TabIndex = 6;
            this.label2.Text = "This sample requires the SftPrintPreview/OCX 1.0 Product or Demo, so it can be mo" +
                "dified and compiled.";
            this.label2.Visible = false;
            // 
            // axSftPrintPreview1
            // 
            this.axSftPrintPreview1.Location = new System.Drawing.Point(288, 8);
            this.axSftPrintPreview1.Name = "axSftPrintPreview1";
            this.axSftPrintPreview1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axSftPrintPreview1.OcxState")));
            this.axSftPrintPreview1.Size = new System.Drawing.Size(264, 240);
            this.axSftPrintPreview1.TabIndex = 5;
            this.axSftPrintPreview1.PageSetupWanted += new System.EventHandler(this.axSftPrintPreview1_PageSetupWanted);
            this.axSftPrintPreview1.CloseWanted += new System.EventHandler(this.axSftPrintPreview1_CloseWanted);
            this.axSftPrintPreview1.HelpWanted += new AxSftPrintPreviewLib10._ISftPrintPreviewEvents_HelpWantedEventHandler(this.axSftPrintPreview1_HelpWanted);
            // 
            // axSftDirectory1
            // 
            this.axSftDirectory1.Location = new System.Drawing.Point(8, 8);
            this.axSftDirectory1.Name = "axSftDirectory1";
            this.axSftDirectory1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axSftDirectory1.OcxState")));
            this.axSftDirectory1.Size = new System.Drawing.Size(272, 240);
            this.axSftDirectory1.TabIndex = 4;
            // 
            // Form1
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(560, 369);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.axSftPrintPreview1);
            this.Controls.Add(this.axSftDirectory1);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.pictureBox1);
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Menu = this.mainMenu1;
            this.Name = "Form1";
            this.Text = "PrintPreview Sample - Softel vdm, Inc.";
            this.Load += new System.EventHandler(this.Form1_Load);
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.axSftPrintPreview1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.axSftDirectory1)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }
        #endregion

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main() 
        {
            Application.Run(new Form1());
        }
        //--locate-marker--

        private void Form1_Load(object sender, System.EventArgs e)
        {
            // Connect the directory control to the print preview control
            axSftPrintPreview1.ContentProvider = axSftDirectory1.Window;
            // display directory
            ShowDirectory();
            axSftPrintPreview1.ZoomFactor = 100;
            // maximize window
            WindowState = FormWindowState.Maximized;
        }

        private void ShowDirectory()
        {
            // Show the SftDirectory control
            axSftDirectory1.Visible = true;
            axSftDirectory1.Enabled = true;
            axSftDirectory1.Dock = DockStyle.Fill;
            PerformLayout();
            axSftDirectory1.Focus();
            // Disable & hide the print preview control
            axSftPrintPreview1.Visible = false;
            axSftPrintPreview1.Enabled = false;
        }

        private void ShowPreview()
        {
            // Show the print preview control
            axSftPrintPreview1.Visible = true;
            axSftPrintPreview1.Enabled = true;
            axSftPrintPreview1.Dock = DockStyle.Fill;
            PerformLayout();
            axSftPrintPreview1.Focus();
            // Disable & hide the SftDirectory control
            axSftDirectory1.Visible = false;
            axSftDirectory1.Enabled = false;
        }

        private void axSftPrintPreview1_PageSetupWanted(object sender, System.EventArgs e)
        {
            axSftPrintPreview1.PageSetup(0);
        }

        private void axSftPrintPreview1_HelpWanted(object sender, AxSftPrintPreviewLib10._ISftPrintPreviewEvents_HelpWantedEvent e)
        {
            MessageBox.Show("Sorry, this sample doesn't offer a help file");
        }

        private void axSftPrintPreview1_CloseWanted(object sender, System.EventArgs e)
        {
            ShowDirectory();        
        }

        private void menuExit_Click(object sender, System.EventArgs e)
        {
            Application.Exit();
        }

        private void menuDirectory_Click(object sender, System.EventArgs e)
        {
            ShowDirectory();
        }

        private void menuPreview_Click(object sender, System.EventArgs e)
        {
            ShowPreview();
        }

    }
}