コード例 #1
0
ファイル: BookmarkTools.cs プロジェクト: rdterner/fcmd
        private void ParseBookmarkNode(XmlNode XN, Bookmark UpperBookmark = null)
        {
            try
            {
                //overall
                Bookmark bm = new Bookmark();
                bm.title = XN.Attributes.GetNamedItem("title").Value;
                if (XN.OuterXml.IndexOf("icon=", StringComparison.Ordinal) > 0)
                    bm.Icon = XN.Attributes.GetNamedItem("icon").Value;

                //if the bookmark is container
                if (XN.HasChildNodes)
                {
                    bm.SubMenu = new List<Bookmark>();
                    foreach (XmlNode SubXN in XN.ChildNodes)
                    {
                        ParseBookmarkNode(SubXN, bm);
                    }
                }
                //if it is not a container
                else
                {
                    bm.url = XN.Attributes.GetNamedItem("url").Value;
                }

                if(UpperBookmark == null)
                bookmarks.Add(bm);
                else
                UpperBookmark.SubMenu.Add(bm);
            }
            catch
            {
                Console.WriteLine("WARNING: Invalid bookmark declaration: " + XN.OuterXml);
            }
        }
コード例 #2
0
ファイル: BookmarkTools.cs プロジェクト: rdterner/fcmd
        /// <summary>Add bookmarks of mounted medias (Windows)</summary>
        private List<Bookmark> AddSysDrives()
        {
            List<Bookmark> bms = new List<Bookmark>();
            foreach (DriveInfo di in DriveInfo.GetDrives())
            {
                Bookmark bm = new Bookmark();
                bm.title=di.Name;
                bm.url = "file://" + di.Name;
                /*if (di.IsReady)
                {
                    NewBtn.TooltipText = di.VolumeLabel + " (" + di.DriveFormat + ")";
                }*/

                switch (di.DriveType)
                {
                    case DriveType.Fixed:
                        bm.Icon = "(internal)drive-harddisk.png";
                        break;
                    case DriveType.CDRom:
                        bm.Icon = "(internal)drive-optical.png";
                        break;
                    case DriveType.Removable:
                        bm.Icon = "(internal)drive-removable-media.png";
                        break;
                    case DriveType.Network:
                        bm.Icon = "(internal)network-server.png";
                        break;
                    case DriveType.Ram:
                        bm.Icon = "(internal)emblem-system.png";
                        break;
                    case DriveType.Unknown:
                        bm.Icon = "(internal)image-missing.png";
                        break;
                }

                string d = di.Name;
                //OS-specific icons
                if (d.StartsWith("A:")) bm.Icon = "(internal)media-floppy.png";
                if (d.StartsWith("B:")) bm.Icon = "(internal)media-floppy.png";
                if (d.StartsWith("/dev")) bm.Icon = "(internal)preferences-desktop-peripherals.png";
                if (d.StartsWith("/proc")) bm.Icon = "(internal)emblem-system.png";
                if (d == "/") bm.Icon = "(internal)root-folder.png";
                bms.Add(bm);
            }
            return bms;
        }
コード例 #3
0
ファイル: BookmarkTools.cs プロジェクト: rdterner/fcmd
        private Menu GetBookmarkSubmenu(Bookmark bookmark, Action<string> OnClick)
        {
            Menu mnu = new Menu();
            if (bookmark.SubMenu == null) throw new ArgumentException("The bookmark should have a submenu", "bookmark");

            List<Bookmark> lbm = bookmark.SubMenu;
            foreach (Bookmark b in lbm)
            {
                MenuItem mi = new MenuItem();
                mi.Label = b.title;
                mi.Image = b.GetIcon();

                if (b.SubMenu == null)
                {
                    string url = b.url;
                    mi.Clicked += (o, ea) => OnClick(url);

                }
                else
                {
                    mi.SubMenu = GetBookmarkSubmenu(b, OnClick);
                }
                mnu.Items.Add(mi);
            }

            return mnu;
        }
コード例 #4
0
ファイル: BookmarkTools.cs プロジェクト: rdterner/fcmd
        /// <summary>Add bookmarks of mounted medias (*nix)</summary>
        private List<Bookmark> AddLinuxMounts()
        {
            List<Bookmark> bms = new List<Bookmark>();

            if (Directory.Exists(@"/mnt"))
            {
                foreach (string dir in Directory.GetDirectories(@"/mnt/"))
                {
                    Bookmark bm = new Bookmark();
                    bm.url="file://" + dir;
                    bm.title=dir.Replace(@"/mnt/", "");
                    bm.Icon = "(internal)drive-removable-media.png";
                    bms.Add(bm);
                }
            }
            else return AddSysDrives(); //fallback for Windows

            return bms;
        }