Click here to Skip to main content
15,895,746 members
Articles / Desktop Programming / Windows Forms

Crystal Image Toolkit: thumbnail image control and picture viewing.

Rate me:
Please Sign up or sign in to vote.
4.68/5 (21 votes)
11 May 2011LGPL37 min read 110K   8.3K   95  
Thumbnail and image viewing controls for Windows Forms, using C#.
using System;
using System.Windows.Forms;

namespace WaitFormPictureShow
{
    /// <summary>
    /// Demonstrates how to call WaitPictureShowForm.
    /// </summary>
    public partial class Form1 : Form
    {
        private WaitPictureShowForm _waitForm = null;

        /// <summary>
        /// Default constructor.
        /// </summary>
        public Form1()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Show the wait form when this main form is loaded.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Event arguments.</param>
        private void Form1_Load(object sender, EventArgs e)
        {
            ShowWaitForm();
        }

        /// <summary>
        /// Creates the wait form and ties into the WaitTerminated event handles.
        /// </summary>
        /// <returns>WaitPictureShowForm object.</returns>
        private WaitPictureShowForm GetWaitForm()
        {
            if (_waitForm == null)
            {
                _waitForm = new WaitPictureShowForm();
                _waitForm.WaitTerminated += new EventHandler(_waitForm_Terminated);
            }

            return _waitForm;
        }

        /// <summary>
        /// Handles the terminated event by closing the form.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Event arguments.</param>
        void _waitForm_Terminated(object sender, EventArgs e)
        {
            HideWaitForm();
        }

        /// <summary>
        /// Shows the Wait form over this main form.
        /// </summary>
        private void ShowWaitForm()
        {
            WaitPictureShowForm waitForm = GetWaitForm();
            waitForm.Show(this);
        }

        /// <summary>
        /// Hides the wait form by closing it.
        /// </summary>
        private void HideWaitForm()
        {
            if (_waitForm != null)
            {
                _waitForm.Hide();
                _waitForm.Close();
                _waitForm = null;
            }
        }

        /// <summary>
        /// Shows the wait form when the button is pressed.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Event arguments.</param>
        private void button1_Click(object sender, EventArgs e)
        {
            if (_waitForm == null)
                ShowWaitForm();
        }
    }
}

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 GNU Lesser General Public License (LGPLv3)


Written By
Software Developer (Senior)
United States United States
Richard has been working with Windows software since 1991. He has worked for Borland, Microsoft, Oracle, and various startup companies such as Livescribe. Currently he is developing projects in C#, Windows Forms, and Net Framework. Visit his blog Attilan (www.attilan.com) to learn more about his tools, projects and discoveries.

Comments and Discussions