예제 #1
0
 public static void Add(OwnerEntry owner)
 {
     if (_allOwners.ContainsKey(owner.Key))
     {
         return;
     }
     _allOwners.Add(owner.Key, owner);
 }
예제 #2
0
        public OwnerEntry Clone()
        {
            OwnerEntry p = new OwnerEntry();

            p.Domain    = (string)this.Domain.Clone();
            p.User      = (string)this.User.Clone();
            p.FullName  = (string)this.FullName.Clone();
            p.ShortName = (string)this.ShortName.Clone();
            p.Phone     = (string)this.Phone.Clone();

            return(p);
        }
예제 #3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            string domainUser = tboxDomainUser.Text.Trim();

            if (!OwnerEntry.VerifyDomainUser(domainUser))
            {
                yMessageBox.ShowError(this, "Your input Domain\\User is not correct!", "Error Domain\\User");
                return;
            }

            if (OwnerTranslate.Contains(domainUser))
            {
                yMessageBox.ShowError(this, "Your input Domain\\User has existed! Please input different one.");
                return;
            }

            string fullName = tboxOwnerFullName.Text.Trim();

            if (fullName.Length == 0)
            {
                yMessageBox.ShowError(this, "The full name fields should not be empty!");
                return;
            }

            string shortName = tboxOwnerShortName.Text.Trim();

            if (shortName.Length == 0)
            {
                yMessageBox.ShowError(this, "The shot name fields should not be empty!");
                return;
            }

            string phone = tboxOwnerPhone.Text.Trim();

            if (phone.Length == 0)
            {
                yMessageBox.ShowError(this, "The phone fields should not be empty!");
                return;
            }

            OwnerEntry entry = new OwnerEntry(domainUser);

            entry.FullName  = fullName;
            entry.ShortName = shortName;
            entry.Phone     = phone;

            if (_listen != null)
            {
                _listen.OnInputOwnerTranslateCompleted(_mode, entry);
            }

            this.Close();
        }
예제 #4
0
        private void EditOwnerTranslate()
        {
            if (listViewOwnerTranslate.SelectedItems.Count <= 0)
            {
                return;
            }

            string     key = listViewOwnerTranslate.SelectedItems[0].SubItems[0].Text;
            OwnerEntry own = OwnerTranslate.Get(key);

            m_selectedOwner = own;

            FormInputOwnerTranslateItem formInputTranslate =
                new FormInputOwnerTranslateItem(InputOwnerTranslateMode.Edit, this, own);

            formInputTranslate.ShowDialog();
            m_selectedOwner = null;
        }
예제 #5
0
        public static string GetOwnerShow(OwnerShowFormat fmt, string domainuser)
        {
            if (fmt == OwnerShowFormat.Default)
            {
                return(domainuser);
            }

            string lowdu = domainuser.ToLower();

            if (fmt == OwnerShowFormat.DomainUser)
            {
                return(lowdu);
            }

            if (!_allOwners.ContainsKey(lowdu))
            {
                return(domainuser);
            }

            OwnerEntry owner = _allOwners[lowdu];

            if (owner == null)
            {
                return(domainuser);
            }

            if (fmt == OwnerShowFormat.FullName)
            {
                return(owner.FullName);
            }
            else if (fmt == OwnerShowFormat.ShortName)
            {
                return(owner.ShortName);
            }
            else if (fmt == OwnerShowFormat.Phone)
            {
                return(owner.Phone);
            }
            else
            {
                return(domainuser);
            }
        }
예제 #6
0
        public static void LoadFromFile()
        {
            StreamReader fs = null;

            try
            {
                fs = File.OpenText(_path);
                fs.ReadLine(); //version number
                _allOwners.Clear();
                while (!fs.EndOfStream)
                {
                    string   line  = fs.ReadLine();
                    string[] stemp = line.Split(new char[] { '|' });
                    if (stemp.Length >= 3)
                    {
                        OwnerEntry owner = new OwnerEntry(stemp[0]);
                        owner.FullName  = stemp[1];
                        owner.ShortName = stemp[2];
                        if (stemp.Length >= 4)
                        {
                            owner.Phone = stemp[3];
                        }

                        Add(owner);
                    }
                }
            }
            catch
            {
                _allOwners.Clear();
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }
        }
예제 #7
0
        public void OnInputOwnerTranslateCompleted(InputOwnerTranslateMode mode, OwnerEntry owner)
        {
            if (mode == InputOwnerTranslateMode.Add)
            {
                OwnerTranslate.Add(owner);
                RefreshTabOwnerTranslate();
                SelectOwnerTranslateVisuable(owner.DomainUser);

                OwnerTranslate.SaveToFile();
            }
            else
            {
                if (m_selectedOwner != null)
                {
                    OwnerTranslate.Remove(m_selectedOwner.DomainUser);
                    OwnerTranslate.Add(owner);
                    RefreshTabOwnerTranslate();
                    SelectOwnerTranslateVisuable(owner.DomainUser);

                    OwnerTranslate.SaveToFile();
                }
            }
        }
예제 #8
0
 public bool Equals(OwnerEntry p, StringComparison cmp = StringComparison.InvariantCultureIgnoreCase)
 {
     return(p.Domain.Equals(this.Domain, cmp) && p.User.Equals(this.User, cmp) &&
            p.FullName.Equals(this.FullName, cmp) && p.ShortName.Equals(this.ShortName, cmp) &&
            p.Phone.Equals(this.Phone, cmp));
 }
예제 #9
0
        public FormInputOwnerTranslateItem(InputOwnerTranslateMode mode, IInputOwnerTranslate listen, OwnerEntry owner)
        {
            InitializeComponent();

            if (mode == InputOwnerTranslateMode.Add)
            {
                this.Text = "Add New Owner Translate";
                this.Icon = Properties.Resources.add_icon;
            }
            else
            {
                this.Text               = "Edit Owner Translate";
                tboxDomainUser.Text     = owner.DomainUser;
                tboxOwnerFullName.Text  = owner.FullName;
                tboxOwnerPhone.Text     = owner.Phone;
                tboxOwnerShortName.Text = owner.ShortName;
                this.Icon               = Properties.Resources.edit_icon;
            }
            _mode   = mode;
            _listen = listen;
        }