summaryrefslogtreecommitdiff
path: root/IvyControl/IvyDomain.cs
blob: 36e749aef816a289405ecab4dfa8245eecbd0eac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Windows.Forms;

namespace IvyBus
{
    public partial class IvyDomain : UserControl
    {
        private string domain = string.Empty;
        public event EventHandler DomainChanged;
#if (!PocketPC)
        [Category("Ivy")]
        [DefaultValue("")]
        [Bindable(true)]
#endif
        public string Domain
        {
            get { return domain; }
            set {
                if (domain != value)
                {
                    domain = value;
                    ivybus.Text = domain;
                    if (DomainChanged != null) DomainChanged(this, EventArgs.Empty);
                }
            }
        }       

        public IvyDomain()
        {
            InitializeComponent();
            SetDefault();
        }
        public void SetDefault()
        {
            if (IsEmpty())
            {
                domain = Ivy.GetDomain(domain);
                ivybus.Text = domain;
            }
        }
        public bool IsEmpty()
        {
            return String.IsNullOrEmpty( domain );
        }

        private void ivybus_Validating(object sender, CancelEventArgs e)
        {
            e.Cancel = !Ivy.ValidatingDomain(ivybus.Text);
        }

        private void ivybus_Validated(object sender, EventArgs e)
        {
            if ( domain != ivybus.Text )
                Domain = ivybus.Text;
        }

    }
}