Esempio n. 1
0
    private void CreatePopupMenu()
    {
        // creating popup menu

        Gtk.Menu popupMenu = new Gtk.Menu();

        // Add

        Dialogs.AddImageMenuButton("Add file...", "add.png", popupMenu, OnButtonAddClicked);
        Dialogs.AddImageMenuButton("Add folder...", "add.png", popupMenu, OnButtonAddFolderClicked);

        // play and open with buttons for first selected media

        var selectedMovies = GetSelectedMediaFiles();

        if (selectedMovies.Count > 0)
        {
            popupMenu.Append(new SeparatorMenuItem());

            // getting first selected media
            var cmd = String.Empty;
            foreach (var f in selectedMovies)
            {
                cmd += "\"" + f.FileName + "\"";
                break;                 // only first
            }

            Gtk.Menu openWithSubMenu = new Gtk.Menu();

            foreach (var app in MediaConvertGUIConfiguration.OpenWithApplications)
            {
                var btn = new MenuItem(app);
                openWithSubMenu.Add(btn);
                btn.Activated += delegate { SupportMethods.Execute(app, cmd); };
            }

            MenuItem menuitemOpenWith = new MenuItem("Open with.");
            menuitemOpenWith.Submenu = openWithSubMenu;

            popupMenu.Add(menuitemOpenWith);

            Dialogs.AddImageMenuButton("Play...", "play.png", popupMenu, OnPlaySelectedInShelButtonClicked);
            Dialogs.AddImageMenuButton("Export movie screenshot", "screenshot.png", popupMenu, OnScreenShotClicked);
            Dialogs.AddImageMenuButton("Preview ffmpeg batch ...", "preview.png", popupMenu, OnPreviwButtonClicked);

            Dialogs.AddImageMenuButton("Apply", "apply.png", popupMenu, OnButtonApplyClicked);

            Dialogs.AddImageMenuButton("Go convert...", "run.png", popupMenu, OnButtonGoConvertClicked);
            Dialogs.AddImageMenuButton("Show ffmpeg log ...", "log.png", popupMenu, OnShowLogActivated);
        }


        // scheme

        if (MoviesInfo.Count > 0)
        {
            popupMenu.Append(new SeparatorMenuItem());

            var schemeSubMenu = new Gtk.Menu();

            var menuItemScheme = Dialogs.AddImageMenuButton("Scheme..", null, popupMenu, null);

            menuItemScheme.Submenu = schemeSubMenu;

            // loading schemes:
            var schemesPath = System.IO.Path.Combine(SupportMethods.AppPath, "Schemes/");
            var schemes     = Directory.GetFiles(schemesPath, "*.xml");

            foreach (var sch in schemes)
            {
                Dialogs.AddImageMenuButton(System.IO.Path.GetFileNameWithoutExtension(sch), null, schemeSubMenu, OnSchemeChange, sch);
            }

            schemeSubMenu.Append(new SeparatorMenuItem());

            Dialogs.AddImageMenuButton("Import scheme from xml", null, schemeSubMenu, OnImportShcemeActionActivated);
            Dialogs.AddImageMenuButton("Save scheme to xml", null, schemeSubMenu, OnButtonSaveSchemeActivated);
        }

        // remove

        if (MoviesInfo.Count > 0)
        {
            popupMenu.Append(new SeparatorMenuItem());

            var removeSubMenu  = new Gtk.Menu();
            var menuItemRemove = Dialogs.AddImageMenuButton("Remove", "remove.png", popupMenu, null);

            menuItemRemove.Submenu = removeSubMenu;

            if (selectedMovies.Count > 0)
            {
                Dialogs.AddImageMenuButton("Selected", null, removeSubMenu, OnButtonRemoveClicked);
            }

            Dialogs.AddImageMenuButton("All", null, removeSubMenu, OnButtonRemoveAllClicked);
        }


        popupMenu.ShowAll();
        popupMenu.Popup();
    }