Beispiel #1
0
        private ToolStripMenuItem CreateOpenFile()
        {
            var text = _association.HasAssociation
                           ? string.Format("&Open with {0}", _association.AppName)
                           : "&Open with...";

            return(new ToolStripMenuItem(text, _association.GetProgramImage(16), OpenFile));
        }
Beispiel #2
0
        private void ShowContextMenu(Point point, Playlist playlist)
        {
            var menu = new ContextMenuStrip();

            var assoc = new FileAssociation(playlist.FullPath);

            var playItem = new ToolStripMenuItem(assoc.HasAssociation ? string.Format("&Play with {0}", assoc.AppName) : "&Play with...");

            playItem.Click  += (o, eventArgs) => FileUtils.OpenFile(playlist.FullPath, this);
            playItem.Font    = new Font(playItem.Font, FontStyle.Bold);
            playItem.Enabled = assoc.CanBeOpened;
            if (assoc.HasAssociation)
            {
                playItem.Image = assoc.GetProgramImage(16);
            }

            var showFileItem = new ToolStripMenuItem("Show in &folder", Resources.folder_open);

            showFileItem.Click += (o, eventArgs) => FileUtils.ShowInFolder(playlist.FullPath, this);

            var copyPathItem = new ToolStripMenuItem("&Copy path to clipboard", Resources.clipboard_arrow);

            copyPathItem.Click += (o, eventArgs) => Clipboard.SetText(playlist.FullPath);

            if (!File.Exists(playlist.FullPath))
            {
                playItem.Enabled     = false;
                showFileItem.Enabled = false;
                menu.Items.Add(new ToolStripMenuItem("File not found")
                {
                    Enabled = false
                });
            }

            menu.Items.Add(playItem);
            menu.Items.Add("-");
            menu.Items.Add(showFileItem);
            menu.Items.Add(copyPathItem);
            menu.Items.Add("-");

            AddCutMenuItems(menu, playlist);

            menu.Show(listView, point);
        }