iReaperStatusStrip.cs :  » Network-Clients » iReaper » IReaper » Statues » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Network Clients » iReaper 
iReaper » IReaper » Statues » iReaperStatusStrip.cs
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace IReaper.Statues{
    /* 
     * iReaper
     *  1. 
     *  2. 
     *  3. 
     *  4. 
     * 12
     * 
     * 
     * 3
     * 
     * 4
     */
    public partial class iReaperStatusStrip : StatusStrip, IReaper.Statues.IiReaperStatusStrip
    {
        #region static
        internal static IiReaperStatusStrip statuStripInstance;
        #endregion
        volatile bool isBusy;
        bool hasNewVersion = false;
        Queue<AsyncWork> timeConsumingTaskQueue = new Queue<AsyncWork>();

        public iReaperStatusStrip()
        {
            InitializeComponent();
            statuStripInstance = this;
            LoadVersionInfo();
        }

        public iReaperStatusStrip(IContainer container) : this()
        {
            container.Add(this);
        }

        #region ()
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Work"></param>
        public void BeginAsyncWork(AsyncWork Work)
        {
            if (this.isBusy)
            {
                lock (timeConsumingTaskQueue)
                {
                    this.timeConsumingTaskQueue.Enqueue(Work);
                }
                return;
            }
            else
            {
                Work.RunWorkerCompleted += new RunWorkerCompletedEventHandler(EndAsyncWork);
                this.isBusy = true;
                Work.RunWorkerAsync(this);
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void EndAsyncWork(object sender, RunWorkerCompletedEventArgs e)
        {
            this.isBusy = false;
            lock (timeConsumingTaskQueue)
            {
                if (this.timeConsumingTaskQueue.Count > 0)
                {

                    AsyncWork work = this.timeConsumingTaskQueue.Dequeue();
                    this.BeginAsyncWork(work);
                    return;
                }
                else
                {
                    try
                    {
                        if (!this.IsDisposed)
                        {
                            this.BeginInvoke(new ThreadStart(delegate()
                            {
                                this.toolStripTaskName.Visible = false;
                            }));
                        }
                    }
                    catch
                    { }
                }
            }
        }
        #endregion

        /// <summary>
        /// 
        /// </summary>
        [Browsable(false)]
        public string TaskMessage
        {
            set
            {
                SetMessage(this.toolStripTaskName, value);
            }
        }

        /// <summary>
        /// 
        /// </summary>
        [Browsable(false)]
        public string InfomationMessage
        {
            set
            {
                SetMessage(this.toolStripPrimaryInfo, value);
            }
        }

        /// <summary>
        /// ToolStripItem
        /// </summary>
        /// <param name="item"></param>
        /// <param name="Message"></param>
        private static void SetMessage(ToolStripItem item, object Message)
        {
            if (item == null || Message == null)
            {
                return;
            }
            Control control = item.Owner;
            if (control == null)
            {
                return;
            }
            if (item is ToolStripProgressBar)
            {
                control.BeginInvoke(new ThreadStart(delegate()
                {
                    ((ToolStripProgressBar)item).Value = (int)Message;
                    item.Visible = true;
                }));
            }
            else
            {
                try
                {
                    control.BeginInvoke(new ThreadStart(delegate()
                    {
                        item.Text = Message.ToString();
                        item.Visible = true;
                    }));
                }
                catch
                { }
            }
        }

        /// <summary>
        /// Strip
        /// </summary>
        public bool IsBusy
        {
            get { return isBusy; }
            set { isBusy = value; }
        }

        private void LoadVersionInfo()
        {
            this.hasNewVersion = (bool)Core.CoreData[CoreDataType.HasNewVersion];
            if (hasNewVersion)
            { 
                this.toolStripStatusLabelVersionLabel.Text = Properties.Resources.HasNewVersion;
            }
        }

        private void OpeniReaperWebsite(object sender, EventArgs e)
        {
            Browser.BrowserManager.OpenWebsite("http://www.ireaper.net");
        }

        #region IiReaperStatusStrip 


        /// <summary>
        /// 
        ///  0 - 100
        /// </summary>
        public int Percentage
        {
            set
            {
                try
                {
                    if (value >= 100 || value == 0)
                    {
                        toolStripProgressBar.Visible = false;
                        toolStripProgressBar.Value = value;
                    }
                    else
                    {
                        toolStripProgressBar.Visible = true;
                        toolStripProgressBar.Value = value;
                    }
                }
                catch
                { }
            }
        }

        #endregion
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.