Ejemplo n.º 1
0
        private void btnAddToFavorites_Click(object sender, EventArgs e)
        {
            // Check if we are in a root folder.
            // Root folders are shown anyways.
            if (PathUtils.IsRootPath(lvExplorer.Path))
            {
                return;
            }

            if (AddToFavoriteFolders != null)
            {
                if (AddToFavoriteFolders(lvExplorer.Path))
                {
                    try
                    {
                        string             title = Path.GetFileName(lvExplorer.Path);
                        OPMToolStripButton btn   = new OPMToolStripButton(title);
                        btn.Name        = title;
                        btn.Image       = ImageProvider.GetIcon(lvExplorer.Path, true);
                        btn.ToolTipText = lvExplorer.Path;

                        btn.ImageAlign            = System.Drawing.ContentAlignment.TopCenter;
                        btn.ImageScaling          = System.Windows.Forms.ToolStripItemImageScaling.SizeToFit;
                        btn.ImageTransparentColor = System.Drawing.Color.Magenta;
                        btn.AutoSize          = true;
                        btn.Tag               = lvExplorer.Path;
                        btn.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;

                        tsSpecialFolders.Items.Add(btn);
                    }
                    catch { }
                }
            }
        }
Ejemplo n.º 2
0
        public DriveInfoItem(DriveInfo di)
        {
            _di = di;

            base.Image   = ImageProvider.GetIcon(di.Name.ToUpperInvariant(), false);
            _displayText = BuildDisplayText();
        }
Ejemplo n.º 3
0
        public static TreeNode CreateTreeNode(string dir, ImageList imageList, bool getIcons)
        {
            TreeNode tn = new TreeNode();

            tn.Text = PathUtils.GetDirectoryTitle(dir);
            tn.Tag  = dir;

            if (getIcons)
            {
                try
                {
                    imageList.Images.Add(ImageProvider.GetIcon(dir, false)); // normal icon
                    tn.ImageIndex = imageList.Images.Count - 1;
                    imageList.Images.Add(ImageProvider.GetIcon(dir, true));  // selected icon
                    tn.SelectedImageIndex = imageList.Images.Count - 1;
                }
                catch                 // use default
                {
                    tn.ImageIndex         = 1;
                    tn.SelectedImageIndex = 2;
                }
            }
            else             // use default
            {
                tn.ImageIndex         = 1;
                tn.SelectedImageIndex = 2;
            }
            return(tn);
        }
        private int GetIcon(string path)
        {
            System.Drawing.Image icon = ImageProvider.GetIcon(path, false);
            if (icon != null)
            {
                ilImages.Images.Add(icon);
                return(ilImages.Images.Count - 1);
            }

            return(0);
        }
Ejemplo n.º 5
0
        private void FillDriveList()
        {
            try
            {
                if (!Directory.Exists(this.InitialDirectory))
                {
                    this.InitialDirectory =
                        Environment.GetFolderPath(Environment.SpecialFolder.Desktop, Environment.SpecialFolderOption.Create);
                }

                System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives();

                foreach (System.IO.DriveInfo di in drives)
                {
                    try
                    {
                        string path = di.RootDirectory.FullName.ToUpperInvariant();

                        string title = di.Name;
                        if (di.IsReady)
                        {
                            title += $" [{di.VolumeLabel}]";
                        }

                        OPMToolStripButton btn = new OPMToolStripButton(title);
                        btn.Name                  = title;
                        btn.Image                 = ImageProvider.GetIcon(path, true);
                        btn.ToolTipText           = path;
                        btn.TextAlign             = ContentAlignment.MiddleLeft;
                        btn.ImageAlign            = System.Drawing.ContentAlignment.TopCenter;
                        btn.ImageScaling          = System.Windows.Forms.ToolStripItemImageScaling.SizeToFit;
                        btn.ImageTransparentColor = System.Drawing.Color.Magenta;
                        btn.AutoSize              = true;
                        btn.Tag = path;
                        btn.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;

                        tsSpecialFolders.Items.Add(btn);
                    }
                    catch (Exception ex)
                    {
                        Logger.LogException(ex);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorDispatcher.DispatchError(ex, false);
            }
        }
        private void UpdateFileType()
        {
            Image img = null;

            if (_pli != null)
            {
                img = _pli.GetImageEx(true);
            }

            if (img == null)
            {
                img = ImageProvider.GetIcon(_pli.Path, true);
            }

            tslFileType.Image = img;
            tslFileType.Tag   = _pli;
        }
Ejemplo n.º 7
0
        private void DisplayCurrentPath()
        {
            _prevPath = opmShellList.Path;

            Image  img  = null;
            string text = null;

            try
            {
                img  = ImageProvider.GetIcon(opmShellList.Path, false);
                text = Translator.Translate("TXT_CURRENT_PATH", opmShellList.Path);
            }
            catch
            {
                img  = null;
                text = null;
            }

            EventDispatch.DispatchEvent(EventNames.SetMainStatusBar, text, img);
        }
Ejemplo n.º 8
0
        private void FillFavoriteFolders()
        {
            if (FillFavoriteFoldersEvt != null)
            {
                List <string> favorites = FillFavoriteFoldersEvt();
                if (favorites != null)
                {
                    foreach (string fav in favorites)
                    {
                        try
                        {
                            string title = "";
                            if (PathUtils.IsRootPath(fav))
                            {
                                DriveInfo di = new DriveInfo(fav);
                                title = $"{di.VolumeLabel} [{di.DriveType}]";
                            }
                            else
                            {
                                title = Path.GetFileName(fav);
                            }

                            OPMToolStripButton btn = new OPMToolStripButton(title);
                            btn.Name        = title;
                            btn.Image       = ImageProvider.GetIcon(fav, true);
                            btn.ToolTipText = fav;

                            btn.ImageAlign            = System.Drawing.ContentAlignment.TopCenter;
                            btn.ImageScaling          = System.Windows.Forms.ToolStripItemImageScaling.SizeToFit;
                            btn.ImageTransparentColor = System.Drawing.Color.Magenta;
                            btn.AutoSize          = true;
                            btn.Tag               = fav;
                            btn.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;

                            tsSpecialFolders.Items.Add(btn);
                        }
                        catch { }
                    }
                }
            }
        }
Ejemplo n.º 9
0
        public SpecialFolderButton(Environment.SpecialFolder sf)
            : base(GetDisplayName(sf))
        {
            _sf = sf;

            if (string.IsNullOrEmpty(Path))
            {
                throw new ArgumentException();
            }

            base.Name = GetDisplayName(sf);

            base.ImageAlign            = System.Drawing.ContentAlignment.TopCenter;
            base.ImageScaling          = System.Windows.Forms.ToolStripItemImageScaling.SizeToFit;
            base.ImageTransparentColor = System.Drawing.Color.Magenta;
            base.AutoSize          = true;
            base.Tag               = _sf;
            base.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;

            base.Image = ImageProvider.GetIcon(Path, true);
        }
        public Image GetImage(bool large)
        {
            Image img = null;

            if (mi != null)
            {
                if (mi.IsDVDVolume)
                {
                    img = ImageProvider.GetShell32Icon(Shell32Icon.DvdDisk, large);
                }
                else
                {
                    switch (mi.MediaType.ToUpperInvariant())
                    {
                    case "URL":
                        img = ImageProvider.GetShell32Icon(Shell32Icon.URL, large);
                        break;

                    case "CDA":
                        img = ImageProvider.GetShell32Icon(Shell32Icon.CompactDisk, large);
                        break;

                    default:
                        img = ImageProvider.GetIcon(mi.Path, large);
                        break;
                    }
                }
            }

            if (img == null)
            {
                img = ImageProvider.GetShell32Icon(Shell32Icon.BlankFile, large);
            }

            return(img);
        }
        public GalleryPackageCardView()
        {
            InitializeComponent();

            var imageProvider = new ImageProvider();

            this.WhenActivated(d =>
            {
                d(this.OneWayBind(ViewModel, vm => vm.Title, v => v.Title.Text));
                d(this.OneWayBind(ViewModel, vm => vm.Description, v => v.Description.Text));
                d(this.OneWayBind(ViewModel, vm => vm.DownloadCount, v => v.DownloadCount.Text));
                d(this.OneWayBind(ViewModel, vm => vm.PublishedDate, v => v.PublishedDate.Text));
                d(this.OneWayBind(ViewModel, vm => vm.Authors, v => v.Authors.Text));
                d(this.OneWayBind(ViewModel, vm => vm.LatestVersion, v => v.LatestVersion.Text));
                d(this.OneWayBind(ViewModel, vm => vm.IconUrl, v => v.Icon.Source, uri => imageProvider.GetIcon(uri)));
            });
        }