コード例 #1
0
        private void ParseShortcuts(XmlReader _xmlReader)
        {
            m_ShortcutFolders.Clear();

            while (_xmlReader.Read())
            {
                if (_xmlReader.IsStartElement())
                {
                    if (_xmlReader.Name == "Shortcut")
                    {
                        ShortcutFolder sf = ShortcutFolder.FromXml(_xmlReader);
                        if (sf != null)
                        {
                            m_ShortcutFolders.Add(sf);
                        }
                    }
                    else
                    {
                        // forward compatibility : ignore new fields.
                    }
                }
                else if (_xmlReader.Name == "Shortcuts")
                {
                    break;
                }
                else
                {
                    // Fermeture d'un tag interne.
                }
            }
        }
コード例 #2
0
        private void ParseShortcuts(XmlReader reader)
        {
            shortcutFolders.Clear();
            bool empty = reader.IsEmptyElement;

            reader.ReadStartElement();

            if (empty)
            {
                return;
            }

            while (reader.NodeType == XmlNodeType.Element)
            {
                if (reader.Name == "Shortcut")
                {
                    ShortcutFolder shortcut = new ShortcutFolder(reader);
                    if (Directory.Exists(shortcut.Location))
                    {
                        shortcutFolders.Add(shortcut);
                    }
                }
                else
                {
                    reader.ReadOuterXml();
                }
            }

            reader.ReadEndElement();

            shortcutFolders.Sort();
        }
コード例 #3
0
        public void AddShortcut(ShortcutFolder shortcut)
        {
            bool known = shortcutFolders.Any(s => s.Location == shortcut.Location);

            if (!known)
            {
                shortcutFolders.Add(shortcut);
                shortcutFolders.Sort();
            }
        }
コード例 #4
0
        public int CompareTo(object obj)
        {
            ShortcutFolder sf = obj as ShortcutFolder;

            if (sf != null)
            {
                String path1 = Path.GetFileName(this.location);
                String path2 = Path.GetFileName(sf.Location);
                return(path1.CompareTo(path2));
            }
            else
            {
                throw new ArgumentException("Impossible comparison");
            }
        }
コード例 #5
0
ファイル: ShortcutFolder.cs プロジェクト: kschallitz/Kinovea
        public static ShortcutFolder FromXml(XmlReader _xmlReader)
        {
            // When we land in this method we MUST already be at the "Shortcut" node.

            string friendlyName = "";
            string location     = "";

            while (_xmlReader.Read())
            {
                if (_xmlReader.IsStartElement())
                {
                    if (_xmlReader.Name == "FriendlyName")
                    {
                        friendlyName = _xmlReader.ReadString();
                    }
                    else if (_xmlReader.Name == "Location")
                    {
                        location = _xmlReader.ReadString();
                    }
                }
                else if (_xmlReader.Name == "Shortcut")
                {
                    break;
                }
                else
                {
                    // Fermeture d'un tag interne.
                }
            }

            ShortcutFolder sf = null;

            if (location.Length > 0)
            {
                sf = new ShortcutFolder(friendlyName, location);
            }

            return(sf);
        }
コード例 #6
0
 public void RemoveShortcut(ShortcutFolder shortcut)
 {
     shortcutFolders.RemoveAll(s => s.Location == shortcut.Location);
 }