ButtonStatuMonitor.cs :  » Network-Clients » iReaper » IReaper » CommonGui » 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 » CommonGui » ButtonStatuMonitor.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using IReaper;
using IReaper.CourseData;
using IReaper.FileData;

namespace IReaper.CommonGui{
    public static class ButtonStatuMonitor
    {
        static bool download, open, remove, canProperty,canExport;
        static CoreDataType dataType = CoreDataType.CurrentSelectedCourses;
        static Course course;
        static IList<Course> privateCollection = new List<Course>();

        /// <summary>
        /// 
        /// </summary>
        public static Course CurrentCourse
        {
            set 
            {
                course = value;
                UpdateByCourse();
            }
            get { return course; }
        }
        /// <summary>
        /// 
        /// </summary>
        public static CoreDataType DataType
        {
            get { return dataType; }
            set 
            {
                dataType = value;
                UpdateByType();
            }
        }
     
        /// <summary>
        /// Remove
        /// </summary>
        public static bool CanRemove
        {
            get { return ButtonStatuMonitor.remove; }
        }

        /// <summary>
        /// Opem
        /// </summary>
        public static bool CanOpen
        {
            get { return ButtonStatuMonitor.open; }
        }

        /// <summary>
        /// Download
        /// </summary>
        public static bool CanDownload
        {
            get { return ButtonStatuMonitor.download; }
        }

        /// <summary>
        /// Property
        /// </summary>
        public static bool CanProperty
        {
            get { return ButtonStatuMonitor.canProperty; }
        }

        /// <summary>
        /// Export
        /// </summary>
        public static bool CanExport
        {
            get { return ButtonStatuMonitor.canExport; }
        }

        public static void Init()
        {
            Core.CoreData.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(CoreData_PropertyChanged);
            UpdateByType();
        }

        private static void CoreData_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == dataType.ToString())
            {
                UpdateByType();
            }
        }

        /// <summary>
        /// 
        /// </summary>
        private static void UpdateByCourse()
        {
            privateCollection.Clear();
            privateCollection.Add(course);
            Update(privateCollection);
        }

        /// <summary>
        /// 
        /// </summary>
        private static void UpdateByType()
        {
            IList<Course> courses = Core.CoreData[dataType] as IList<Course>;
            Update(courses);
        }

        private static void Update(IList<Course> courses)
        {
            download = false;
            open = false;
            remove = false;
            canProperty = false;
            canExport = false;
            if (courses == null)
            {
                return;
            }
            foreach (Course c in courses)
            {
                if (!download)
                {
                    download |= Course.CanDownload(c);
                }
                if (!remove)
                {
                    remove |= Course.CanRemove(c);
                }
                if (!canExport)
                {
                    canExport |= Course.CanOpen(c);
                }
            }
            if (courses.Count != 1)
            {
                open = false;
                canProperty = false;
            }
            else
            {
                Course c = courses[0];
                canProperty = true;
                open = Course.CanOpen(c);
            }
        }
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.