コード例 #1
0
ファイル: PhoneBlock.cs プロジェクト: mo5h/omeo
        public override void Save()
        {
            StringCollection oldPhones = new StringCollection();

            oldPhones.AddRange(_contact.GetPhoneNames());
            foreach (HashMap.Entry E in _phoneControls)
            {
                string phoneNumber = ((TextBox)E.Value).Text.Trim();
                string phoneName   = ((Label)E.Key).Text;
                if (phoneName.Length > 0)
                {
                    phoneName = phoneName.Substring(0, phoneName.Length - 1);
                    if (!String.IsNullOrEmpty(phoneNumber.Trim()))
                    {
                        _contact.SetPhoneNumber(phoneName, phoneNumber);
                    }
                    else
                    {
                        _contact.DeletePhone(phoneName);
                    }
                    oldPhones.Remove(phoneName);
                }
            }
            foreach (string remainedPhone in oldPhones)
            {
                _contact.DeletePhone(remainedPhone);
            }
        }
コード例 #2
0
ファイル: PhoneBlock.cs プロジェクト: mo5h/omeo
        public override void EditResource(IResource contact)
        {
            _contact = new ContactBO(contact);
            string[] phonesNames = _contact.GetPhoneNames();
            foreach (HashMap.Entry e in _phoneControls)
            {
                ((Label)e.Key).Tag = false;    //  set unused
            }
            _origPhones.Clear();

            //  Display the list of phones. Two conditions are to be satisfied:
            //  1. Three standard phone labels: "Home", "Mobile" and "Work"
            //     must be present independently of their content
            //  2. Order of the phone labels above must be kept.
            AddPhone("Home", (Array.IndexOf(phonesNames, "Home") == -1) ? "" : _contact.GetPhoneNumber("Home"), false);
            AddPhone("Mobile", (Array.IndexOf(phonesNames, "Mobile") == -1) ? "" : _contact.GetPhoneNumber("Mobile"), false);
            AddPhone("Work", (Array.IndexOf(phonesNames, "Work") == -1) ? "" : _contact.GetPhoneNumber("Work"), false);
            foreach (string name in phonesNames)
            {
                _origPhones[name] = _contact.GetPhoneNumber(name);
                if (name != "Home" && name != "Mobile" && name != "Work")
                {
                    AddPhone(name, _contact.GetPhoneNumber(name), false);
                }
            }

            //  Remove all phone controls from previous "EditResource".
            //  Thus we remove only unused phones => reduce flickering.
            bool      changed  = false;
            ArrayList toRemove = new ArrayList();

            foreach (HashMap.Entry e in _phoneControls)
            {
                if ((bool)((Label)e.Key).Tag == false)
                {
                    changed = true;
                    Controls.Remove((Label)e.Key);
                    Controls.Remove((Control)e.Value);
                    toRemove.Add((Label)e.Key);
                }
            }
            foreach (Label label in toRemove)
            {
                _phoneControls.Remove(label);
            }

            if (changed)
            {
                RedrawPhones();
            }
            UpdateHeight();
        }
コード例 #3
0
ファイル: PhoneBlock.cs プロジェクト: mo5h/omeo
        public override string  HtmlContent(IResource contact)
        {
            string result = string.Empty;

            ContactBO bo = new ContactBO(contact);

            string[] phoneNames = bo.GetPhoneNames();

            result += AddPhoneText("Home", phoneNames, bo);
            result += AddPhoneText("Mobile", phoneNames, bo);
            result += AddPhoneText("Work", phoneNames, bo);

            foreach (string phoneName in phoneNames)
            {
                if (phoneName != "Home" && phoneName != "Mobile" && phoneName != "Work")
                {
                    result += "\t<tr><td>" + phoneName + "</td><td>" + bo.GetPhoneNumber(phoneName) + "</td></tr>";
                }
            }
            return(result);
        }