Click here to Skip to main content
15,878,814 members
Articles / Desktop Programming / Windows Forms

BookStore

Rate me:
Please Sign up or sign in to vote.
4.61/5 (25 votes)
24 Apr 2012CPOL5 min read 134.4K   17.8K   98  
A project for managing the digital books (HTML, DOCX, ODF, PDF, EPUB, TXT, etc.) of the user using db4o
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;


namespace BookStoreGUI
{

    /// <summary>
    /// Form rendering a modal progress window, that is shown as long as the required
    /// background (separate thread) operation is running.
    /// </summary>
    partial class WorkInProgressForm : Form
    {

        /// <summary>
        /// Delegate for a cross-thread operation, that uses invocation to
        /// ensure control integrity.
        /// </summary>
        private delegate void FormOperation();
        
        
        /// <summary>
        /// The message displayed by the progress form. 
        /// </summary>
        private string explanationText;

        private int isFull;


        /// <summary>
        /// WorkInProgressForm constructor.
        /// </summary>
        /// <param name="explanationText">The message displayed by the progress form</param>
        public WorkInProgressForm(string explanationText)
        {
            InitializeComponent();
            this.explanationText = explanationText;
            this.isFull = 0;
        }


        private void WorkInProgressForm_FormClosing(object sender, CancelEventArgs e)
        {
            e.Cancel = true;
        }


        private void CloseProgressFormHelper()
        {
            this.FormClosing -= WorkInProgressForm_FormClosing;
            this.Close();
        }

        /// <summary>
        /// Closes the form.
        /// </summary>
        public void CloseProgressForm()
        {
            if (this.InvokeRequired == true)
                this.Invoke(new FormOperation(CloseProgressFormHelper));
            else
                CloseProgressFormHelper();
        }


        private void WorkInProgressForm_Load(object sender, EventArgs e)
        {
            lbExplanation.Text = explanationText;
            this.FormClosing += new FormClosingEventHandler(WorkInProgressForm_FormClosing);
        }


        private void timerAnimation_Tick(object sender, EventArgs e)
        {
            if (isFull == 4)
            {
                pbOperationProgress.Value = 0;
                isFull = 0;
            }
            else if (pbOperationProgress.Value < pbOperationProgress.Maximum)
            {
                pbOperationProgress.PerformStep();
            }
            else if (pbOperationProgress.Value == pbOperationProgress.Maximum)
            {
                pbOperationProgress.PerformStep();
                isFull += 1;
            }
        }

    }

}

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)



Comments and Discussions