public static void Add(OwnerEntry owner)
 {
     if (_allOwners.ContainsKey(owner.Key))
     {
         return;
     }
     _allOwners.Add(owner.Key, owner);
 }
        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);
        }
Example #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();
        }
Example #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;
        }
        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);
            }
        }
        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();
                }
            }
        }
Example #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();
                }
            }
        }
 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));
 }
Example #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;
        }