internal static void Save(OpenedFile file) { Debug.Assert(file != null); using (SaveFileDialog fdiag = new SaveFileDialog()) { fdiag.OverwritePrompt = true; fdiag.AddExtension = true; string[] fileFilters = (string[])(AddInTree.GetTreeNode("/SharpDevelop/Workbench/FileFilter").BuildChildItems(null)).ToArray(typeof(string)); fdiag.Filter = String.Join("|", fileFilters); for (int i = 0; i < fileFilters.Length; ++i) { if (fileFilters[i].IndexOf(Path.GetExtension(file.FileName)) >= 0) { fdiag.FilterIndex = i + 1; break; } } if (fdiag.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) { string fileName = fdiag.FileName; if (!FileService.CheckFileName(fileName)) { return; } if (FileUtility.ObservedSave(new NamedFileOperationDelegate(file.SaveToDisk), fileName) == FileOperationResult.OK) { FileService.RecentOpen.AddLastFile(fileName); MessageService.ShowMessage(fileName, "${res:ICSharpCode.SharpDevelop.Commands.SaveFile.FileSaved}"); } } } }
public override void Run() { if (System.Windows.Forms.Form.ActiveForm.Modal) { return; } IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow; if (window != null) { if (window.ViewContent.IsViewOnly) { return; } if (window.ViewContent is ICustomizedCommands) { if (((ICustomizedCommands)window.ViewContent).SaveAsCommand()) { return; } } using (SaveFileDialog fdiag = new SaveFileDialog()) { fdiag.OverwritePrompt = true; fdiag.AddExtension = true; string[] fileFilters = (string[])(AddInTree.GetTreeNode("/SharpDevelop/Workbench/FileFilter").BuildChildItems(this)).ToArray(typeof(string)); fdiag.Filter = String.Join("|", fileFilters); for (int i = 0; i < fileFilters.Length; ++i) { if (fileFilters[i].IndexOf(Path.GetExtension(window.ViewContent.FileName == null ? window.ViewContent.UntitledName : window.ViewContent.FileName)) >= 0) { fdiag.FilterIndex = i + 1; break; } } if (fdiag.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) { string fileName = fdiag.FileName; if (!FileService.CheckFileName(fileName)) { return; } if (FileUtility.ObservedSave(new NamedFileOperationDelegate(window.ViewContent.Save), fileName) == FileOperationResult.OK) { FileService.RecentOpen.AddLastFile(fileName); MessageService.ShowMessage(fileName, "${res:ICSharpCode.SharpDevelop.Commands.SaveFile.FileSaved}"); } } } } }
public void ListCodons(string path) { CodonLV.Items.Clear(); if (path == null) { ExtTextBox.Text = "Extension : "; return; } ExtTextBox.Text = "Extension : " + path; AddInTreeNode node = AddInTree.GetTreeNode(path, false); if (node == null) { return; } foreach (Codon c in node.Codons) { ListViewItem lvi = new ListViewItem(c.Name); lvi.Tag = c; lvi.SubItems.Add(c.Id); lvi.SubItems.Add(c.Properties.Contains("class") ? c.Properties["class"] : ""); lvi.SubItems.Add(string.Join(";", c.Conditions.Select(a => a.Name + ": " + a.Action))); lvi.SubItems.Add(c.Properties.Contains("label") ? c.Properties["label"] : ""); CodonLV.Items.Add(lvi); } }
public static string BrowseForStylesheetFile() { using (OpenFileDialog dialog = new OpenFileDialog()) { dialog.AddExtension = true; dialog.Multiselect = false; dialog.CheckFileExists = true; dialog.Title = ResourceService.GetString("ICSharpCode.XmlEditor.AssignXSLT.Title"); AddInTreeNode node = AddInTree.GetTreeNode("/SharpDevelop/Workbench/FileFilter"); if (node != null) { string xmlFileFilter = GetFileFilter(node, "Xml"); string allFilesFilter = GetFileFilter(node, "AllFiles"); string xslFileFilter = GetFileFilter(node, "Xsl"); dialog.Filter = String.Join("|", xslFileFilter, xmlFileFilter, allFilesFilter); dialog.FilterIndex = 1; } if (dialog.ShowDialog(WorkbenchSingleton.MainWin32Window) == DialogResult.OK) { return(dialog.FileName); } } return(null); }
static IconService() { try { InitializeIcons(AddInTree.GetTreeNode("/Workspace/Icons")); } catch (TreePathNotFoundException) { } }
/// <summary> /// Returns a File Dialog filter that can be used to filter on all registered project formats /// </summary> public static string GetAllProjectsFilter(object caller) { AddInTreeNode addinTreeNode = AddInTree.GetTreeNode("/SharpDevelop/Workbench/Combine/FileFilter"); StringBuilder b = new StringBuilder(StringParser.Parse("${res:SharpDevelop.Solution.AllKnownProjectFormats}|")); bool first = true; foreach (Codon c in addinTreeNode.Codons) { string ext = c.Properties.Get("extensions", ""); if (ext != "*.*" && ext.Length > 0) { if (!first) { b.Append(';'); } else { first = false; } b.Append(ext); } } foreach (string entry in addinTreeNode.BuildChildItems(caller)) { b.Append('|'); b.Append(entry); } return(b.ToString()); }
static void LoadThread() { try { InitializeIcons(AddInTree.GetTreeNode("/Workspace/Icons")); } catch (TreePathNotFoundException) { } }
public void ListCodons(string path) { CodonLV.Items.Clear(); if (path == null) { ExtLabel.Text = "Extension : "; return; } ExtLabel.Text = "Extension : " + path; AddInTreeNode node = AddInTree.GetTreeNode(path, false); if (node == null) { return; } foreach (Codon c in node.Codons) { ListViewItem lvi = new ListViewItem(c.Name); lvi.Tag = c; lvi.SubItems.Add(c.Id); lvi.SubItems.Add(c.Properties.Contains("class") ? c.Properties["class"] : ""); foreach (ICondition condition in c.Conditions) { lvi.SubItems.Add(condition.Name + ", " + condition.Action); } CodonLV.Items.Add(lvi); } }
public static void SaveFileAs(IWorkbenchWindow window) { using (SaveFileDialog fdiag = new SaveFileDialog()) { fdiag.OverwritePrompt = true; fdiag.AddExtension = true; fdiag.Filter = String.Join("|", (string[])(AddInTree.GetTreeNode("/SharpDevelop/Workbench/FileFilter").BuildChildItems(null)).ToArray(typeof(string))); string[] fileFilters = (string[])(AddInTree.GetTreeNode("/SharpDevelop/Workbench/FileFilter").BuildChildItems(null)).ToArray(typeof(string)); fdiag.Filter = String.Join("|", fileFilters); for (int i = 0; i < fileFilters.Length; ++i) { if (fileFilters[i].IndexOf(Path.GetExtension(window.ViewContent.FileName == null ? window.ViewContent.UntitledName : window.ViewContent.FileName)) >= 0) { fdiag.FilterIndex = i + 1; break; } } if (fdiag.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) { string fileName = fdiag.FileName; // currently useless, because the fdiag.FileName can't // handle wildcard extensions :( if (Path.GetExtension(fileName).StartsWith("?") || Path.GetExtension(fileName) == "*") { fileName = Path.ChangeExtension(fileName, ""); } window.ViewContent.Save(fileName); MessageService.ShowMessage(fileName, "${res:ICSharpCode.SharpDevelop.Commands.SaveFile.FileSaved}"); } } }
public void Initialize() { UpdateRenderer(); ReadMaxViewContentCount(); MenuComplete += new EventHandler(SetStandardStatusBar); SetStandardStatusBar(null, null); try { ArrayList contents = AddInTree.GetTreeNode(viewContentPath).BuildChildItems(this); foreach (PadDescriptor content in contents) { if (content != null) { ShowPad(content); } } } catch (TreePathNotFoundException) { } CreateMainMenu(); CreateToolBars(); toolbarUpdateTimer = new System.Windows.Forms.Timer(); toolbarUpdateTimer.Tick += new EventHandler(UpdateMenu); toolbarUpdateTimer.Tick += new EventHandler(ClearMemory); toolbarUpdateTimer.Interval = 500; toolbarUpdateTimer.Start(); RightToLeftConverter.Convert(this); }
void CreateMainMenu() { TopMenu = new MenuStrip(); TopMenu.Items.Clear(); try { ToolStripItem[] items = (ToolStripItem[])(AddInTree.GetTreeNode(mainMenuPath).BuildChildItems(this)).ToArray(typeof(ToolStripItem)); TopMenu.Items.AddRange(items); UpdateMenus(); } catch (TreePathNotFoundException) {} }
public override void Run() { using (TreeViewOptions optionsDialog = new TreeViewOptions((Properties)PropertyService.Get("ICSharpCode.TextEditor.Document.Document.DefaultDocumentAggregatorProperties", new Properties()), AddInTree.GetTreeNode("/SharpDevelop/Dialogs/OptionsDialog"))) { optionsDialog.FormBorderStyle = FormBorderStyle.FixedDialog; optionsDialog.Owner = (Form)WorkbenchSingleton.Workbench; optionsDialog.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm); } }
private static List <SearchItem> BuildSearchItems(SearchPathDescriptor descriptor) { List <SearchItem> result = new List <SearchItem>(); AddInTreeNode node = AddInTree.GetTreeNode(descriptor.Path); foreach (Codon codon in node.Codons) { result.AddRange(HandleMenuCodon(descriptor, codon, descriptor.Path, new List <string>())); } return(result); }
public override void Run() { bool?result = ShowTreeOptions( "test", AddInTree.GetTreeNode("/FrameWork/OptionPanel/SystemOptions")); if (result == true) { // save properties after changing options PropertyService.Save(); } }
public override void Run() { using (TreeViewOptions optionsDialog = new TreeViewOptions(AddInTree.GetTreeNode("/SharpDevelop/Dialogs/OptionsDialog"))) { optionsDialog.FormBorderStyle = FormBorderStyle.FixedDialog; optionsDialog.Owner = WorkbenchSingleton.MainForm; if (optionsDialog.ShowDialog(WorkbenchSingleton.MainForm) == DialogResult.OK) { PropertyService.Save(); } } }
public override void Run() { bool?result = ShowTreeOptions( ResourceService.GetString("Dialog.Options.TreeViewOptions.DialogName"), AddInTree.GetTreeNode("/SharpDevelop/Dialogs/OptionsDialog")); if (result == true) { // save properties after changing options PropertyService.Save(); } }
public void Initialize() { try { ArrayList contents = AddInTree.GetTreeNode(viewContentPath).BuildChildItems(this); foreach (PadDescriptor content in contents) { if (content != null) { padDescriptors.Add(content); } } } catch (TreePathNotFoundException) {} }
public void InitializeFormatter() { string formatterPath = formatingStrategyPath + "/" + Document.HighlightingStrategy.Name; if (AddInTree.ExistsTreeNode(formatterPath)) { IFormattingStrategy[] formatter = (IFormattingStrategy[])(AddInTree.GetTreeNode(formatterPath).BuildChildItems(this)).ToArray(typeof(IFormattingStrategy)); if (formatter != null && formatter.Length > 0) { Document.FormattingStrategy = formatter[0]; } } }
public void Execute(object parameter) { var colorSets = AddInTree.GetTreeNode("/Altaxo/ApplicationColorSets").BuildChildItems <Tuple <IColorSet, bool> >(this); foreach (var entry in colorSets) { ColorSetManager.Instance.TryRegisterList(entry.Item1, ItemDefinitionLevel.Application, out var storedList); if (entry.Item2) { ColorSetManager.Instance.DeclareAsPlotColorList(storedList); } } }
/// <summary> /// Returns if a project loader exists for the given file. This method works even in early /// startup (before service initialization) /// </summary> public static bool HasProjectLoader(string fileName) { AddInTreeNode addinTreeNode = AddInTree.GetTreeNode("/SharpDevelop/Workbench/Combine/FileFilter"); foreach (Codon codon in addinTreeNode.Codons) { string pattern = codon.Properties.Get("extensions", ""); if (FileUtility.MatchesPattern(fileName, pattern) && codon.Properties.Contains("class")) { return(true); } } return(false); }
static private IConnection CreateConnectionObject(string connectionstring) { try { AddInTreeNode AddinNode = AddInTree.GetTreeNode("/SharpQuery/Connection"); IConnection conn = (IConnection)AddinNode.BuildChildItem("ConnectionWrapper", null, null); conn.ConnectionString = connectionstring; return(conn); } catch (System.Exception e) { throw new ConnectionStringException(e.Message); } }
public void Initialize() { SynchronizingObject = new WpfSynchronizeInvoke(mainWindow.Dispatcher); try { List <PadDescriptor> contents = AddInTree.GetTreeNode(viewContentPath).BuildChildItems <PadDescriptor>(this); foreach (PadDescriptor content in contents) { if (content != null) { padDescriptors.Add(content); } } } catch (TreePathNotFoundException) {} }
public static ToolBar[] CreateToolBars(UIElement inputBindingOwner, object owner, string addInTreePath) { List <ToolBar> toolBars = new List <ToolBar>(); AddInTreeNode treeNode; try { treeNode = AddInTree.GetTreeNode(addInTreePath); } catch (TreePathNotFoundException) { return(toolBars.ToArray()); } foreach (AddInTreeNode childNode in treeNode.ChildNodes.Values) { ToolBar toolBar = null; if (childNode.PathProperties != null) { if (childNode.PathProperties.Contains("showInTray")) { string showInTray = childNode.PathProperties["showInTray"]; if (showInTray.ToUpper().Equals("TRUE")) { if (childNode.PathProperties.Contains("isLocked")) { string isLocked = childNode.PathProperties["isLocked"]; if (isLocked.ToUpper().Equals("TRUE")) { toolBar = CreateToolBar(inputBindingOwner, owner, childNode, true, true); } else { toolBar = CreateToolBar(inputBindingOwner, owner, childNode, true, false); } } else { toolBar = CreateToolBar(inputBindingOwner, owner, childNode, true, false); } } else { toolBar = CreateToolBar(inputBindingOwner, owner, childNode); } } } toolBars.Add(toolBar); } return(toolBars.ToArray()); }
protected override void OnOwnerChanged(EventArgs e) { base.OnOwnerChanged(e); dropDownButton = (ToolBarDropDownButton)Owner; ToolStripItem[] items = (ToolStripItem[])(AddInTree.GetTreeNode("/SharpDevelop/Pads/ClassBrowser/Toolbar/SelectFilter").BuildChildItems(this)).ToArray(typeof(ToolStripItem)); foreach (ToolStripItem item in items) { if (item is IStatusUpdate) { ((IStatusUpdate)item).UpdateStatus(); } } dropDownButton.DropDownItems.AddRange(items); }
public static IProjectLoader GetProjectLoader(string fileName) { AddInTreeNode addinTreeNode = AddInTree.GetTreeNode("/SharpDevelop/Workbench/Combine/FileFilter"); foreach (Codon codon in addinTreeNode.Codons) { string pattern = codon.Properties.Get("extensions", ""); if (FileUtility.MatchesPattern(fileName, pattern) && codon.Properties.Contains("class")) { object binding = codon.AddIn.CreateObject(codon.Properties["class"]); return(binding as IProjectLoader); } } return(null); }
public override void Run() { Altaxo.Current.SetResourceService(new ResourceServiceWrapper()); Altaxo.Current.SetProjectService(new Altaxo.Main.ProjectService()); Altaxo.Current.SetGUIFactoryService(new Altaxo.Main.Services.GUIFactoryService()); Altaxo.Current.SetPrintingService(new Altaxo.Main.PrintingService()); Altaxo.Current.ProjectService.ProjectChanged += new ProjectEventHandler(((AltaxoSDWorkbench)Altaxo.Current.Workbench).EhProjectChanged); // we construct the main document (for now) Altaxo.Current.ProjectService.CurrentOpenProject = new AltaxoDocument(); // less important services follow now Altaxo.Main.Services.FitFunctionService fitFunctionService = new Altaxo.Main.Services.FitFunctionService(); Altaxo.Current.SetFitFunctionService(fitFunctionService); AddInTree.GetTreeNode("/Altaxo/BuiltinTextures").BuildChildItems(this); }
public static void SaveAll() { foreach (IViewContent content in WorkbenchSingleton.Workbench.ViewContentCollection.ToArray()) { if (content.IsViewOnly) { continue; } if (content.FileName == null) { if (content is ICustomizedCommands) { if (((ICustomizedCommands)content).SaveAsCommand()) { continue; } } else { using (SaveFileDialog fdiag = new SaveFileDialog()) { fdiag.OverwritePrompt = true; fdiag.AddExtension = true; fdiag.Filter = String.Join("|", (string[])(AddInTree.GetTreeNode("/SharpDevelop/Workbench/FileFilter").BuildChildItems(null)).ToArray(typeof(string))); if (fdiag.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) { string fileName = fdiag.FileName; // currently useless, because the fdiag.FileName can't // handle wildcard extensions :( if (Path.GetExtension(fileName).StartsWith("?") || Path.GetExtension(fileName) == "*") { fileName = Path.ChangeExtension(fileName, ""); } if (FileUtility.ObservedSave(new NamedFileOperationDelegate(content.Save), fileName) == FileOperationResult.OK) { MessageService.ShowMessage(fileName, "${res:ICSharpCode.SharpDevelop.Commands.SaveFile.FileSaved}"); } } } } } else { FileUtility.ObservedSave(new FileOperationDelegate(content.Save), content.FileName); } } }
public override void Run() { using (OpenFileDialog fdiag = new OpenFileDialog()) { fdiag.AddExtension = true; string[] fileFilters = (string[])(AddInTree.GetTreeNode("/SharpDevelop/Workbench/FileFilter").BuildChildItems(this)).ToArray(typeof(string)); fdiag.Filter = String.Join("|", fileFilters); bool foundFilter = false; // search filter like in the current open file if (!foundFilter) { IViewContent content = WorkbenchSingleton.Workbench.ActiveViewContent; if (content != null) { string extension = Path.GetExtension(content.PrimaryFileName); if (string.IsNullOrEmpty(extension) == false) { for (int i = 0; i < fileFilters.Length; ++i) { if (fileFilters[i].IndexOf(extension) >= 0) { fdiag.FilterIndex = i + 1; foundFilter = true; break; } } } } } if (!foundFilter) { fdiag.FilterIndex = fileFilters.Length; } fdiag.Multiselect = true; fdiag.CheckFileExists = true; if (fdiag.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) { foreach (string name in fdiag.FileNames) { FileService.OpenFile(name); } } } }
/// <summary> /// Gets the keyboard shortcut for the menu item with the given addin tree /// path and given codon id. /// </summary> Keys GetKeyboardShortcut(string path, string id) { AddInTreeNode node = AddInTree.GetTreeNode(path); if (node != null) { foreach (Codon codon in node.Codons) { if (codon.Id == id) { return(MenuCommand.ParseShortcut(codon.Properties["shortcut"])); } } } return(Keys.None); }
/// <summary> /// Gets the keyboard shortcut for the menu item with the given addin tree /// path and given codon id. /// </summary> Keys GetKeyboardShortcut(string path, string id) { AddInTreeNode node = AddInTree.GetTreeNode(path); if (node != null) { foreach (Codon codon in node.Codons) { if (codon.Id == id) { return((Keys) new KeysConverter().ConvertFromInvariantString(codon.Properties["shortcut"].Replace('|', '+'))); } } } return(Keys.None); }