public ProjectFileSelectorDialog (Project project, string defaultFilterName, string defaultFilterPattern, string [] buildActions) { this.project = project; this.defaultFilter = new SelectFileDialogFilter (defaultFilterName, defaultFilterPattern ?? "*"); this.buildActions = buildActions; this.Build(); projBuf = ImageService.GetIcon (project.StockIcon, IconSize.Menu); dirClosedBuf = ImageService.GetIcon (MonoDevelop.Ide.Gui.Stock.ClosedFolder, IconSize.Menu); dirOpenBuf = ImageService.GetIcon (MonoDevelop.Ide.Gui.Stock.OpenFolder, IconSize.Menu); TreeViewColumn projectCol = new TreeViewColumn (); projectCol.Title = GettextCatalog.GetString ("Project Folders"); var pixRenderer = new CellRendererImage (); CellRendererText txtRenderer = new CellRendererText (); projectCol.PackStart (pixRenderer, false); projectCol.PackStart (txtRenderer, true); projectCol.SetCellDataFunc (pixRenderer, new TreeCellDataFunc (PixDataFunc)); projectCol.SetCellDataFunc (txtRenderer, new TreeCellDataFunc (TxtDataFunc)); projectTree.Model = dirStore; projectTree.AppendColumn (projectCol); TreeIter projectIter = dirStore.AppendValues ("", FilePath.Empty); InitDirs (projectIter); projectTree.ExpandAll (); projectTree.RowActivated += delegate { fileList.GrabFocus (); }; projectTree.KeyPressEvent += ProjectListKeyPressEvent; TreeViewColumn fileCol = new TreeViewColumn (); var filePixRenderer = new CellRendererImage (); fileCol.Title = GettextCatalog.GetString ("Files"); fileCol.PackStart (filePixRenderer, false); fileCol.PackStart (txtRenderer, true); fileCol.AddAttribute (filePixRenderer, "image", 1); fileCol.SetCellDataFunc (txtRenderer, new TreeCellDataFunc (TxtFileDataFunc)); fileList.Model = fileStore; fileList.AppendColumn (fileCol); fileList.RowActivated += delegate { TreeIter iter; if (fileList.Selection.GetSelected (out iter)) Respond (ResponseType.Ok); }; fileList.KeyPressEvent += FileListKeyPressEvent; fileList.KeyReleaseEvent += FileListKeyReleaseEvent; TreeIter root; if (dirStore.GetIterFirst (out root)) projectTree.Selection.SelectIter (root); UpdateFileList (null, null); projectTree.Selection.Changed += UpdateFileList; fileList.Selection.Changed += UpdateSensitivity; this.DefaultResponse = ResponseType.Cancel; this.Modal = true; }
public SelectFileDialogFilter AddFilter (SelectFileDialogFilter filter) { if (useDefaultFilters) throw new InvalidOperationException ("Cannot mix default filters and custom filters"); filters.Add (filter); return filter; }
public SelectFileDialogFilter AddFilter(SelectFileDialogFilter filter) { if (useDefaultFilters) { throw new InvalidOperationException("Cannot mix default filters and custom filters"); } filters.Add(filter); return(filter); }
static IEnumerable <SelectFileDialogFilter> ParseFilters(System.Collections.IEnumerable filterStrings) { if (filterStrings == null) { yield break; } foreach (string filterStr in filterStrings) { var parts = filterStr.Split('|'); var f = new SelectFileDialogFilter(parts[0], parts[1].Split(';')); yield return(f); } }
static NSOpenSavePanelUrl GetFileFilter(SelectFileDialogFilter filter) { var globRegex = filter.Patterns == null || filter.Patterns.Count == 0? null : CreateGlobRegex(filter.Patterns); var mimetypes = filter.MimeTypes == null || filter.MimeTypes.Count == 0? null : filter.MimeTypes; return((sender, url) => { //never show non-file URLs if (!url.IsFileUrl) { return false; } string path = url.Path; // According to the NSUrl documentation // If the receiver contains a file reference URL, // this property’s value provides the current path for the referenced resource, which may be nil if the resource no longer exists. if (string.IsNullOrEmpty(path)) { return false; } //always make directories selectable, unless they're app bundles if (System.IO.Directory.Exists(path)) { return !path.EndsWith(".app", StringComparison.OrdinalIgnoreCase); } if (globRegex != null && globRegex.IsMatch(path)) { return true; } if (mimetypes != null) { var mimetype = IdeServices.DesktopService.GetMimeTypeForUri(path); if (mimetype != null) { var chain = IdeServices.DesktopService.GetMimeTypeInheritanceChain(mimetype); if (mimetypes.Any(m => chain.Any(c => c == m))) { return true; } } } return false; }); }
static IEnumerable <SelectFileDialogFilter> ParseFilters(System.Collections.IEnumerable filterStrings) { if (filterStrings == null) { yield break; } var filterNames = new HashSet <string>(); foreach (string filterStr in filterStrings) { var parts = filterStr.Split('|'); var filterName = parts[0]; if (filterNames.Add(filterName)) { var f = new SelectFileDialogFilter(filterName, parts[1].Split(';')); yield return(f); } } }
static NSOpenSavePanelUrl GetFileFilter(SelectFileDialogFilter filter) { var globRegex = filter.Patterns == null || filter.Patterns.Count == 0? null : CreateGlobRegex(filter.Patterns); var mimetypes = filter.MimeTypes == null || filter.MimeTypes.Count == 0? null : filter.MimeTypes; return((sender, url) => { //never show non-file URLs if (!url.IsFileUrl) { return false; } string path = url.Path; //always make directories selectable, unless they're app bundles if (System.IO.Directory.Exists(path)) { return !path.EndsWith(".app", StringComparison.OrdinalIgnoreCase); } if (globRegex != null && globRegex.IsMatch(path)) { return true; } if (mimetypes != null) { var mimetype = IdeServices.DesktopService.GetMimeTypeForUri(path); if (mimetype != null) { var chain = IdeServices.DesktopService.GetMimeTypeInheritanceChain(mimetype); if (mimetypes.Any(m => chain.Any(c => c == m))) { return true; } } } return false; }); }
public ProjectFileSelectorDialog(Project project, string defaultFilterName, string defaultFilterPattern, string [] buildActions) { this.project = project; this.defaultFilter = new SelectFileDialogFilter(defaultFilterName, defaultFilterPattern ?? "*"); this.buildActions = buildActions; this.Build(); projBuf = ImageService.GetPixbuf(project.StockIcon, IconSize.Menu); dirClosedBuf = ImageService.GetPixbuf(MonoDevelop.Ide.Gui.Stock.ClosedFolder, IconSize.Menu); dirOpenBuf = ImageService.GetPixbuf(MonoDevelop.Ide.Gui.Stock.OpenFolder, IconSize.Menu); TreeViewColumn projectCol = new TreeViewColumn(); projectCol.Title = GettextCatalog.GetString("Project Folders"); var pixRenderer = new CellRendererPixbuf(); CellRendererText txtRenderer = new CellRendererText(); projectCol.PackStart(pixRenderer, false); projectCol.PackStart(txtRenderer, true); projectCol.SetCellDataFunc(pixRenderer, new TreeCellDataFunc(PixDataFunc)); projectCol.SetCellDataFunc(txtRenderer, new TreeCellDataFunc(TxtDataFunc)); projectTree.Model = dirStore; projectTree.AppendColumn(projectCol); TreeIter projectIter = dirStore.AppendValues("", FilePath.Empty); InitDirs(projectIter); projectTree.ExpandAll(); projectTree.RowActivated += delegate { fileList.GrabFocus(); }; projectTree.KeyPressEvent += ProjectListKeyPressEvent; TreeViewColumn fileCol = new TreeViewColumn(); var filePixRenderer = new CellRendererPixbuf(); fileCol.Title = GettextCatalog.GetString("Files"); fileCol.PackStart(filePixRenderer, false); fileCol.PackStart(txtRenderer, true); fileCol.AddAttribute(filePixRenderer, "pixbuf", 1); fileCol.SetCellDataFunc(txtRenderer, new TreeCellDataFunc(TxtFileDataFunc)); fileList.Model = fileStore; fileList.AppendColumn(fileCol); fileList.RowActivated += delegate { TreeIter iter; if (fileList.Selection.GetSelected(out iter)) { Respond(ResponseType.Ok); } }; fileList.KeyPressEvent += FileListKeyPressEvent; fileList.KeyReleaseEvent += FileListKeyReleaseEvent; TreeIter root; if (dirStore.GetIterFirst(out root)) { projectTree.Selection.SelectIter(root); } UpdateFileList(null, null); projectTree.Selection.Changed += UpdateFileList; fileList.Selection.Changed += UpdateSensitivity; this.DefaultResponse = ResponseType.Cancel; this.Modal = true; }
static NSOpenSavePanelUrl GetFileFilter (SelectFileDialogFilter filter) { var globRegex = filter.Patterns == null || filter.Patterns.Count == 0? null : CreateGlobRegex (filter.Patterns); var mimetypes = filter.MimeTypes == null || filter.MimeTypes.Count == 0? null : filter.MimeTypes; return (NSSavePanel sender, NSUrl url) => { //never show non-file URLs if (!url.IsFileUrl) return false; string path = url.Path; //always make directories selectable, unless they're app bundles if (System.IO.Directory.Exists (path)) return !path.EndsWith (".app", StringComparison.OrdinalIgnoreCase); if (globRegex != null && globRegex.IsMatch (path)) return true; if (mimetypes != null) { var mimetype = MonoDevelop.Ide.DesktopService.GetMimeTypeForUri (path); if (mimetype != null) { var chain = MonoDevelop.Ide.DesktopService.GetMimeTypeInheritanceChain (mimetype); if (mimetypes.Any (m => chain.Any (c => c == m))) return true; } } return false; }; }
static IEnumerable<SelectFileDialogFilter> ParseFilters (System.Collections.IEnumerable filterStrings) { if (filterStrings == null) yield break; foreach (string filterStr in filterStrings) { var parts = filterStr.Split ('|'); var f = new SelectFileDialogFilter (parts[0], parts[1].Split (';')); yield return f; } }