FeedStep.cs :  » Installers-Generators » WiX » Microsoft » Tools » WindowsInstallerXml » Extensions » ClickThrough » 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 » Installers Generators » WiX 
WiX » Microsoft » Tools » WindowsInstallerXml » Extensions » ClickThrough » FeedStep.cs
// <copyright file="FeedStep.cs" company="Microsoft">
//    Copyright (c) Microsoft Corporation.  All rights reserved.
//    
//    The use and distribution terms for this software are covered by the
//    Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
//    which can be found in the file CPL.TXT at the root of this distribution.
//    By using this software in any fashion, you are agreeing to be bound by
//    the terms of this license.
//    
//    You must not remove this notice, or any other, from this software.
// </copyright>
// 
// <summary>
// Feed step.
// </summary>

namespace Microsoft.Tools.WindowsInstallerXml.Extensions.ClickThrough{
    using System;
    using System.ComponentModel;
    using System.Windows.Forms;

    /// <summary>
    /// Feed step.
    /// </summary>
    public sealed partial class FeedStep : UserControl
    {
        private readonly int[] rates = { 10080, 4320, 1440, 720, 360, 60, 1 };
        private Fabricator fabricator;
        private string updateUri;
        private int updateRate;
        ////private bool externalChange;
        ////private bool updateChanged;
        ////private bool previousPathChanged;

        /// <summary>
        /// Creates a new FeedStep.
        /// </summary>
        public FeedStep()
        {
            this.InitializeComponent();
        }

        /// <summary>
        /// Event fired any time a change is made to the step's properties.
        /// </summary>
        public event PropertyChangedEventHandler Changed;

        /// <summary>
        /// Gets and sets the fabricator for this step.
        /// </summary>
        /// <value>Fabricator.</value>
        public Fabricator Fabricator
        {
            get { return this.fabricator; }
            set { this.fabricator = value; }
        }

        /// <summary>
        /// Gets and sets the update uri for this step.
        /// </summary>
        /// <value>String update uri.</value>
        public string UpdateUri
        {
            get
            {
                return this.updateUri;
            }

            set
            {
                if (this.updateUri != value)
                {
                    this.updateUri = value;
                    this.updateTextBox.Text = value;
                }
            }
        }

        /// <summary>
        /// Gets and sets the update rate in minutes for this step.
        /// </summary>
        /// <value>Update rate (in minutes).</value>
        public int UpdateRate
        {
            get
            {
                return this.updateRate;
            }

            set
            {
                if (this.updateRate != value)
                {
                    this.updateRate = value;
                    if (0 == this.updateRate)
                    {
                        this.updateRateComboBox.SelectedIndex = -1;
                    }
                    else
                    {
                        bool found = false;
                        for (int i = 0; i < this.rates.Length; ++i)
                        {
                            if (this.rates[i] == this.updateRate)
                            {
                                this.updateRateComboBox.SelectedIndex = i;
                                found = true;
                                break;
                            }
                        }

                        if (!found)
                        {
                            this.updateRateComboBox.SelectedIndex = -1;
                        }
                    }

                }
            }
        }

        /// <summary>
        /// Event handler for when the update text box is validating
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event data.</param>
        private void UpdateTextBox_Validating(object sender, CancelEventArgs e)
        {
            if (this.updateTextBox.Text != null && this.updateTextBox.Text != String.Empty)
            {
                try
                {
                    Uri uri = new Uri(this.updateTextBox.Text);
                }
                catch (UriFormatException)
                {
                    e.Cancel = true;
                }
                finally
                {
                    if (e.Cancel)
                    {
                        MessageBox.Show("Invalid Update URL.", this.fabricator.Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }

        /// <summary>
        /// Event handler for when the update text box is validated.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event data.</param>
        private void UpdateTextBox_Validated(object sender, EventArgs e)
        {
            if (this.updateTextBox.Text == null || this.updateTextBox.Text == String.Empty)
            {
                this.updateUri = null;
                if (this.Changed != null)
                {
                    this.Changed(this, new PropertyChangedEventArgs("UpdateUri"));
                }
            }
            else
            {
                this.updateUri = this.updateTextBox.Text;
                if (this.Changed != null)
                {
                    this.Changed(this, new PropertyChangedEventArgs("UpdateUri"));
                }

                if (this.updateRate == 0)
                {
                    this.updateRateComboBox.SelectedIndex = 0;
                }
            }
        }


        /// <summary>
        /// Event handler for when the update rate combo box is validated.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event data.</param>
        private void UpdateRateComboBox_Validated(object sender, EventArgs e)
        {
            if (this.updateRateComboBox.SelectedIndex == -1)
            {
                this.updateRate = 0;
            }
            else
            {
                this.updateRate = this.rates[this.updateRateComboBox.SelectedIndex];
            }

            if (this.Changed != null)
            {
                this.Changed(this, new PropertyChangedEventArgs("UpdateRate"));
            }
        }
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.