Exemple #1
0
        /// <summary>
        /// Read the xml profile and return its content.
        /// </summary>
        /// <param name="path">File path</param>
        /// <returns></returns>
        public XElement ImportProfile(out XmlPhone xmlPhone, out XmlMenu xmlMenu)
        {
            xmlPhone = ReadPhoneValues(_profileFile);
            xmlMenu  = ReadMenuValues(_profileFile);

            return(_profileFile);
        }
Exemple #2
0
        private XElement GetKeysElement(XmlPhone item)
        {
            XElement keysItem = new XElement("Keys");

            foreach (string key in item.Keys)
            {
                keysItem.Add(new XElement("Key", key));
            }

            return(keysItem);
        }
Exemple #3
0
        private XmlPhone ReadPhoneValues(XElement profile)
        {
            if (profile?.Element("Phone") != null)
            {
                XElement phone = profile.Element("Phone");

                XmlPhone xmlphone = new XmlPhone();
                xmlphone.ContactName  = phone.Element("ContactName")?.Value ?? XmlPhone.DefaultName;
                xmlphone.ContactIcon  = phone.Element("ContactIcon")?.Value ?? XmlPhone.DefaultIcon;
                xmlphone.DialTimeout  = int.Parse(phone.Element("DialTimeout")?.Value ?? XmlPhone.DefaultDialTimeout.ToString());
                xmlphone.Bold         = bool.Parse(phone.Element("Bold")?.Value ?? XmlPhone.DefaultBold.ToString());
                xmlphone.Sound        = ReadXmlSound(phone);
                xmlphone.Notification = ReadXmlNotification(phone);

                xmlphone.Keys = new List <string>();

                try
                {
                    List <string> shortcut = new List <string>();

                    if (phone.Element("Keys") != null)
                    {
                        foreach (XElement key in phone.Element("Keys").Elements("Key"))
                        {
                            shortcut.Add(key.Value);
                        }
                    }
                    else
                    {
                        foreach (XElement key in phone.Elements("Key"))
                        {
                            shortcut.Add(key.Value);
                        }
                    }

                    xmlphone.Keys.AddRange(shortcut);
                }
                catch (Exception e)
                {
                    // If no menu, then there should be keys
                    if (profile?.Element("Menu") == null)
                    {
                        MessageBox.Show("Cannot find a <Key> entry in the <Phone> section: " + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                return(xmlphone);
            }
            else
            {
                return(null);
            }
        }
Exemple #4
0
 public XmlProfile(XmlPhone xmlPhone, XmlMenu xmlMenu)
 {
     _phone = xmlPhone;
     _menu  = xmlMenu;
 }
Exemple #5
0
 private XElement GetNotificationElement(XmlPhone xmlphone)
 {
     return(NotificationToXElement(xmlphone.Notification));
 }
Exemple #6
0
 private XElement GetSoundElement(XmlPhone xmlphone)
 {
     return(MenuSoundToXElement(xmlphone.Sound));
 }