PdnStatusBar.cs :  » GUI » Paint.net » PaintDotNet » 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 » GUI » Paint.net 
Paint.net » PaintDotNet » PdnStatusBar.cs
/////////////////////////////////////////////////////////////////////////////////
// Paint.NET                                                                   //
// Copyright (C) dotPDN LLC, Rick Brewster, Tom Jackson, and contributors.     //
// Portions Copyright (C) Microsoft Corporation. All Rights Reserved.          //
// See src/Resources/Files/License.txt for full licensing and attribution      //
// details.                                                                    //
// .                                                                           //
/////////////////////////////////////////////////////////////////////////////////

using PaintDotNet.SystemLayer;
using System;
using System.Drawing;
using System.Windows.Forms;

namespace PaintDotNet{
    internal sealed class PdnStatusBar
        : StatusStrip, 
          IStatusBarProgress
    {
        private System.Windows.Forms.ToolStripStatusLabel contextStatusLabel;
        private System.Windows.Forms.ToolStripSeparator progressStatusSeparator;
        private System.Windows.Forms.ToolStripProgressBar progressStatusBar;
        private System.Windows.Forms.ToolStripStatusLabel imageInfoStatusLabel;
        private System.Windows.Forms.ToolStripStatusLabel cursorInfoStatusLabel;

        private string progressTextFormat = PdnResources.GetString("StatusBar.Progress.Percentage.Format");
        private ImageResource contextStatusImage;

        public string ImageInfoStatusText
        {
            get
            {
                return this.imageInfoStatusLabel.Text;
            }

            set
            {
                this.imageInfoStatusLabel.Text = value;
                Update();
            }
        }

        public string ContextStatusText
        {
            get
            {
                return this.contextStatusLabel.Text;
            }

            set
            {
                this.contextStatusLabel.Text = value;
                Update();
            }
        }

        public ImageResource ContextStatusImage
        {
            get
            {
                return this.contextStatusImage;
            }

            set
            {
                this.contextStatusImage = value;

                if (this.contextStatusImage == null)
                {
                    this.contextStatusLabel.Image = null;
                }
                else
                {
                    this.contextStatusLabel.Image = this.contextStatusImage.Reference;
                }

                Update();
            }
        }

        public string CursorInfoText
        {
            get
            {
                return this.cursorInfoStatusLabel.Text;
            }

            set
            {
                this.cursorInfoStatusLabel.Text = value;
                Update();
            }
        }
        
        public void ResetProgressStatusBarAsync()
        {
            this.BeginInvoke(new Procedure(ResetProgressStatusBar));
        }

        public void EraseProgressStatusBar()
        {
            try
            {
                this.progressStatusSeparator.Visible = false;
                this.progressStatusBar.Visible = false;
                this.progressStatusBar.Value = 0;
            }

            catch (NullReferenceException)
            {
                // See bug #2212 -- appears to be a bug in the framework
            }
        }

        public void EraseProgressStatusBarAsync()
        {
            this.BeginInvoke(new Procedure(EraseProgressStatusBar));
        }

        public void ResetProgressStatusBar()
        {
            try
            {
                this.progressStatusBar.Value = 0;
                this.progressStatusSeparator.Visible = true;
                this.progressStatusBar.Visible = true;
            }

            catch (NullReferenceException nrex)
            {
                Tracing.Ping(nrex.ToString());
            }
        }

        public double GetProgressStatusBarValue()
        {
            lock (this.progressStatusBar)
            {
                return this.progressStatusBar.Value;
            }
        }

        public void SetProgressStatusBar(double percent)
        {
            lock (this.progressStatusBar)
            {
                this.progressStatusBar.Value = (int)percent;
                bool visible = (percent != 100);
                this.progressStatusBar.Visible = visible;
                this.progressStatusSeparator.Visible = visible;
            }
        }

        public PdnStatusBar()
        {
            InitializeComponent();

            this.cursorInfoStatusLabel.Image = PdnResources.GetImageResource("Icons.CursorXYIcon.png").Reference;
            this.cursorInfoStatusLabel.Text = string.Empty;

            // imageInfo (width,height info)
            this.imageInfoStatusLabel.Image = PdnResources.GetImageResource("Icons.ImageSizeIcon.png").Reference;

            // progress
            this.progressStatusBar.Visible = false;
            this.progressStatusSeparator.Visible = false;
            this.progressStatusBar.Height -= 4;
            this.progressStatusBar.ProgressBar.Style = ProgressBarStyle.Continuous;
        }

        private void InitializeComponent()
        {
            this.contextStatusLabel = new ToolStripStatusLabel();
            this.progressStatusSeparator = new ToolStripSeparator();
            this.progressStatusBar = new ToolStripProgressBar();
            this.imageInfoStatusLabel = new ToolStripStatusLabel();
            this.cursorInfoStatusLabel = new ToolStripStatusLabel();
            SuspendLayout();
            //
            // contextStatusLabel
            //
            this.contextStatusLabel.Name = "contextStatusLabel";
            this.contextStatusLabel.Width = UI.ScaleWidth(436);
            this.contextStatusLabel.Spring = true;
            this.contextStatusLabel.TextAlign = ContentAlignment.MiddleLeft;
            this.contextStatusLabel.ImageAlign = ContentAlignment.MiddleLeft;
            //
            // progressStatusBar
            //
            this.progressStatusBar.Name = "progressStatusBar";
            this.progressStatusBar.Width = 130;
            this.progressStatusBar.AutoSize = false;
            //
            // imageInfoStatusLabel
            //
            this.imageInfoStatusLabel.Name = "imageInfoStatusLabel";
            this.imageInfoStatusLabel.Width = UI.ScaleWidth(130);
            this.imageInfoStatusLabel.TextAlign = ContentAlignment.MiddleLeft;
            this.imageInfoStatusLabel.ImageAlign = ContentAlignment.MiddleLeft;
            this.imageInfoStatusLabel.AutoSize = false;
            //
            // cursorInfoStatusLabel
            //
            this.cursorInfoStatusLabel.Name = "cursorInfoStatusLabel";
            this.cursorInfoStatusLabel.Width = UI.ScaleWidth(130);
            this.cursorInfoStatusLabel.TextAlign = ContentAlignment.MiddleLeft;
            this.cursorInfoStatusLabel.ImageAlign = ContentAlignment.MiddleLeft;
            this.cursorInfoStatusLabel.AutoSize = false;
            //
            // PdnStatusBar
            //
            this.Name = "PdnStatusBar";
            this.Items.Add(this.contextStatusLabel);
            this.Items.Add(this.progressStatusSeparator);
            this.Items.Add(this.progressStatusBar);
            this.Items.Add(new ToolStripSeparator());
            this.Items.Add(this.imageInfoStatusLabel);
            this.Items.Add(new ToolStripSeparator());
            this.Items.Add(this.cursorInfoStatusLabel);
            ResumeLayout(false);
        }
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.