Ejemplo n.º 1
0
        internal static void PopulateOpenWithViewers(CommandArrayInfo info, Project project, string filePath)
        {
            var viewers = DisplayBindingService.GetFileViewers(filePath, project).ToList();

            //show the default viewer first
            var def = viewers.FirstOrDefault(v => v.CanUseAsDefault) ?? viewers.FirstOrDefault(v => v.IsExternal);

            if (def != null)
            {
                CommandInfo ci = info.Add(def.Title, def);
                ci.Description = GettextCatalog.GetString("Open with '{0}'", def.Title);
                if (viewers.Count > 1)
                {
                    info.AddSeparator();
                }
            }

            //then the builtins, followed by externals
            FileViewer prev = null;

            foreach (FileViewer fv in viewers)
            {
                if (def != null && fv.Equals(def))
                {
                    continue;
                }
                if (prev != null && fv.IsExternal != prev.IsExternal)
                {
                    info.AddSeparator();
                }
                CommandInfo ci = info.Add(fv.Title, fv);
                ci.Description = GettextCatalog.GetString("Open with '{0}'", fv.Title);
                prev           = fv;
            }
        }
Ejemplo n.º 2
0
        static bool FillViewers(CustomCommonFileDialogComboBox combo, string fileName)
        {
            combo.Items.Clear();

            if (String.IsNullOrEmpty(fileName) || Directory.Exists(fileName))
            {
                combo.Enabled = false;
                return(false);
            }

            bool hasBench       = false;
            var  projectService = IdeApp.Services.ProjectService;

            if (projectService.IsWorkspaceItemFile(fileName) || projectService.IsSolutionItemFile(fileName))
            {
                hasBench = true;
                combo.Items.Add(new ViewerComboItem(null, GettextCatalog.GetString("Solution Workbench")));
            }

            foreach (var vw in DisplayBindingService.GetFileViewers(fileName, null))
            {
                if (!vw.IsExternal)
                {
                    combo.Items.Add(new ViewerComboItem(vw, vw.Title));
                }
            }

            combo.Enabled = combo.Items.Count >= 1;
            return(hasBench);
        }
Ejemplo n.º 3
0
        // Sort of ported from the MacSupport addin
        static void FillViewers(List <FileViewer> currentViewers, ComboBox viewerBox, string fileName)
        {
            currentViewers.Clear();
            viewerBox.Items.Clear();

            if (String.IsNullOrEmpty(fileName) || Directory.Exists(fileName))
            {
                viewerBox.Enabled = false;
                return;
            }

            var projectService = IdeApp.Services.ProjectService;

            if (projectService.IsWorkspaceItemFile(fileName) || projectService.IsSolutionItemFile(fileName))
            {
                viewerBox.Items.Add(GettextCatalog.GetString("Solution Workbench"));
                currentViewers.Add(null);
            }

            foreach (var vw in DisplayBindingService.GetFileViewers(fileName, null))
            {
                if (!vw.IsExternal)
                {
                    viewerBox.Items.Add(vw.Title);
                    currentViewers.Add(vw);
                }
            }

            viewerBox.Enabled       = currentViewers.Count > 1;
            viewerBox.SelectedIndex = 0;
        }
Ejemplo n.º 4
0
        void FillViewers()
        {
            ((Gtk.ListStore)viewerSelector.Model).Clear();
            currentViewers.Clear();

            if (Filenames.Length == 0 || Filename.Length == 0 || System.IO.Directory.Exists(Filename))
            {
                return;
            }

            if (IdeApp.Services.ProjectService.IsWorkspaceItemFile(Filename) || IdeApp.Services.ProjectService.IsSolutionItemFile(Filename))
            {
                viewerSelector.AppendText(GettextCatalog.GetString("Solution Workbench"));
                currentViewers.Add(null);
            }
            foreach (FileViewer vw in DisplayBindingService.GetFileViewers(Filename, null))
            {
                if (!vw.IsExternal)
                {
                    viewerSelector.AppendText(vw.Title);
                    currentViewers.Add(vw);
                }
            }
            viewerSelector.Active = 0;
            viewerLabel.Sensitive = viewerSelector.Sensitive = currentViewers.Count > 1;
        }
Ejemplo n.º 5
0
        static bool FillViewers(CustomCommonFileDialogComboBox combo, string fileName)
        {
            combo.Items.Clear();

            if (String.IsNullOrEmpty(fileName) || Directory.Exists(fileName))
            {
                combo.Enabled = false;
                return(false);
            }

            int  selected       = -1;
            int  i              = 0;
            bool hasBench       = false;
            var  projectService = IdeApp.Services.ProjectService;

            if (projectService.IsWorkspaceItemFile(fileName) || projectService.IsSolutionItemFile(fileName))
            {
                hasBench = true;
                combo.Items.Add(new ViewerComboItem(null, GettextCatalog.GetString("Solution Workbench")));
                if (!CanBeOpenedInAssemblyBrowser(fileName))
                {
                    selected = 0;
                }
                i++;
            }

            foreach (var vw in DisplayBindingService.GetFileViewers(fileName, null))
            {
                if (!vw.IsExternal)
                {
                    combo.Items.Add(new ViewerComboItem(vw, vw.Title));

                    if (vw.CanUseAsDefault && selected == -1)
                    {
                        selected = i;
                    }

                    i++;
                }
            }

            if (selected == -1)
            {
                selected = 0;
            }

            combo.Enabled = combo.Items.Count >= 1;
            if (selected > 0)
            {
                // Unable to set SelectedIndex until ApplyControlPropertyChange called for Items
                // which causes the combo box selection to visibly change selection twice. Instead just
                // make the default item the first one in the combo.
                var item = combo.Items[selected];
                combo.Items.RemoveAt(selected);
                combo.Items.Insert(0, item);
            }
            return(hasBench);
        }
Ejemplo n.º 6
0
        void FillViewers()
        {
            ((Gtk.ListStore)viewerSelector.Model).Clear();
            currentViewers.Clear();

            if (Filenames.Length == 0 || Filename.Length == 0 || System.IO.Directory.Exists(Filename))
            {
                return;
            }

            int selected = -1;
            int i        = 0;

            if (IdeApp.Services.ProjectService.IsWorkspaceItemFile(Filename) || IdeApp.Services.ProjectService.IsSolutionItemFile(Filename))
            {
                viewerSelector.AppendText(GettextCatalog.GetString("Solution Workbench"));
                currentViewers.Add(null);

                if (closeWorkspaceCheck.Visible)
                {
                    closeWorkspaceCheck.Active = true;
                }

                // Default exe/dll to AssemblyBrowser, solutions/projects to Solution Workbench.
                // HACK: Couldn't make it a generic SolutionItemFile based conditional, .csproj fits under this category also.
                if (!(Filename.EndsWith(".exe", StringComparison.OrdinalIgnoreCase) || Filename.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)))
                {
                    selected = 0;
                }
                i++;
            }

            foreach (FileViewer vw in DisplayBindingService.GetFileViewers(Filename, null))
            {
                if (!vw.IsExternal)
                {
                    viewerSelector.AppendText(vw.Title);
                    currentViewers.Add(vw);

                    if (vw.CanUseAsDefault && selected == -1)
                    {
                        selected = i;
                    }

                    i++;
                }
            }

            if (selected == -1)
            {
                selected = 0;
            }

            viewerSelector.Active = selected;
            viewerLabel.Sensitive = viewerSelector.Sensitive = currentViewers.Count > 1;
        }
        void FillViewers()
        {
            ((Gtk.ListStore)viewerSelector.Model).Clear();
            currentViewers.Clear();

            if (Filenames.Length == 0 || Filename.Length == 0 || System.IO.Directory.Exists(Filename))
            {
                return;
            }

            int selected = -1;
            int i        = 0;

            if (IdeApp.Services.ProjectService.IsWorkspaceItemFile(Filename) || IdeApp.Services.ProjectService.IsSolutionItemFile(Filename))
            {
                viewerSelector.AppendText(GettextCatalog.GetString("Solution Workbench"));
                currentViewers.Add(null);

                if (closeWorkspaceCheck.Visible)
                {
                    closeWorkspaceCheck.Active = true;
                }

                selected = 0;
                i++;
            }

            foreach (FileViewer vw in DisplayBindingService.GetFileViewers(Filename, null))
            {
                if (!vw.IsExternal)
                {
                    viewerSelector.AppendText(vw.Title);
                    currentViewers.Add(vw);

                    if (vw.CanUseAsDefault && selected == -1)
                    {
                        selected = i;
                    }

                    i++;
                }
            }

            if (selected == -1)
            {
                selected = 0;
            }

            viewerSelector.Active = selected;
            viewerLabel.Sensitive = viewerSelector.Sensitive = currentViewers.Count > 1;
        }
Ejemplo n.º 8
0
        static void FillViewers(List <FileViewer> currentViewers, NSPopUpButton button, FilePath[] filenames)
        {
            button.Menu.RemoveAllItems();
            currentViewers.Clear();

            if (filenames == null || filenames.Length == 0)
            {
                button.Enabled = false;
                return;
            }

            var filename = filenames[0];

            if (System.IO.Directory.Exists(filename))
            {
                return;
            }

            if (IdeApp.Services.ProjectService.IsWorkspaceItemFile(filename) || IdeApp.Services.ProjectService.IsSolutionItemFile(filename))
            {
                button.Menu.AddItem(new NSMenuItem()
                {
                    Title = GettextCatalog.GetString("Solution Workbench")
                });
                currentViewers.Add(null);
            }
            foreach (var vw in DisplayBindingService.GetFileViewers(filename, null))
            {
                if (!vw.IsExternal)
                {
                    button.Menu.AddItem(new NSMenuItem()
                    {
                        Title = vw.Title
                    });
                    currentViewers.Add(vw);
                }
            }
            button.Enabled = currentViewers.Count > 1;
            button.SelectItem(0);
        }
Ejemplo n.º 9
0
        static void FillViewers(List <FileViewer> currentViewers, NSPopUpButton button, NSButton closeSolutionButton, FilePath[] filenames)
        {
            button.Menu.RemoveAllItems();
            currentViewers.Clear();

            if (filenames == null || filenames.Length == 0)
            {
                button.Enabled = false;
                return;
            }

            var filename = filenames[0];

            if (System.IO.Directory.Exists(filename))
            {
                return;
            }

            int selected = -1;
            int i        = 0;

            if (IdeApp.Services.ProjectService.IsWorkspaceItemFile(filename) || IdeApp.Services.ProjectService.IsSolutionItemFile(filename))
            {
                button.Menu.AddItem(new NSMenuItem()
                {
                    Title = GettextCatalog.GetString("Solution Workbench")
                });
                currentViewers.Add(null);

                if (closeSolutionButton != null)
                {
                    closeSolutionButton.State = NSCellStateValue.On;
                }

                selected = 0;
                i++;
            }

            foreach (var vw in DisplayBindingService.GetFileViewers(filename, null))
            {
                if (!vw.IsExternal)
                {
                    button.Menu.AddItem(new NSMenuItem()
                    {
                        Title = vw.Title
                    });
                    currentViewers.Add(vw);

                    if (vw.CanUseAsDefault && selected == -1)
                    {
                        selected = i;
                    }

                    i++;
                }
            }

            if (selected == -1)
            {
                selected = 0;
            }

            button.Enabled = currentViewers.Count > 1;
            button.SelectItem(selected);
        }