public static IViewContent CreateViewContent(string fileName) { if (items == null) { items = AddInTree.BuildItems <IDisplayBinding>("/Workspace/DisplayBindings", null, true); } foreach (IDisplayBinding binding in items) { IViewContent content = binding.OpenFile(fileName); if (content != null) { return(content); } } return(null); }
public StartPageControl() { InitializeComponent(); List <object> items = AddInTree.BuildItems <object>("/SharpDevelop/ViewContent/StartPage/Items", this, false); // WPF does not use DataTemplates if the item already is a UIElement; so we 'box' it. List <BoxEntry> entries = items.ConvertAll(control => new BoxEntry { Control = control }); startPageItems.ItemsSource = entries; var aca = (AssemblyCopyrightAttribute)typeof(CommonAboutDialog).Assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0]; copyrightText.Text = aca.Copyright; versionTextBlock.Text = "SharpDevelop " + RevisionClass.FullVersion; }
public static IEnumerable <string> FindAdditionalFiles(string fileName) { List <string> list = new List <string>(); // HACK: find a different way to support .Designer.XYZ StringParserPropertyContainer.FileCreation["Extension"] = Path.GetExtension(fileName); string prefix = Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName)); foreach (string ext in AddInTree.BuildItems <string>("/SharpDevelop/Workbench/DependentFileExtensions", null, false)) { if (File.Exists(prefix + ext)) { list.Add(prefix + ext); } } return(list); }
/// <summary> /// Initializes this instance /// </summary> public override void Initialize() { _singletonInstances = new List <IViewContent>(); _singletonViewContentTypes = new Dictionary <string, Type>(); List <IViewContent> views = AddInTree.BuildItems <IViewContent>("/Maestro/Shell/SingleViewContent", null); _singletonInstances.AddRange(views); foreach (var v in views) { var type = v.GetType(); _singletonViewContentTypes.Add(type.Name, type); } LoggingService.Info(Strings.Service_Init_ViewContent_Manager); }
internal void InitializeServicesSubsystem(string servicePath) { List <IService> services = AddInTree.BuildItems <IService>(servicePath, null, false); if (services != null && services.Count > 0) { AddServices(services); } foreach (IService service in _services) { if (!service.IsInitialized) { service.InitializeService(); } } }
/// <summary> /// Initializes from the AddIn registry /// </summary> /// <param name="callback"></param> public static void Initialize(Action callback) { if (_init) { return; } _services = AddInTree.BuildItems <ServiceBase>("/Maestro/ApplicationServices", null); //NOXLATE foreach (var svc in _services) { svc.Initialize(); svc.Load(); } _init = true; EventWatcher.Initialize(); callback?.Invoke(); }
public static void RequestToolTip(ToolTipRequestEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } if (!CodeCompletionOptions.EnableCodeCompletion) { return; } if (!CodeCompletionOptions.TooltipsEnabled) { return; } if (CodeCompletionOptions.TooltipsOnlyWhenDebugging) { if (!DebuggerService.IsDebuggerLoaded) { return; } if (!DebuggerService.CurrentDebugger.IsDebugging) { return; } } // Query all registered tooltip providers using the AddInTree. // The first one that does not return null will be used. foreach (ITextAreaToolTipProvider toolTipProvider in AddInTree.BuildItems <ITextAreaToolTipProvider>(ToolTipProviderAddInTreePath, null, false)) { toolTipProvider.HandleToolTipRequest(e); if (e.Handled) { break; } } EventHandler <ToolTipRequestEventArgs> eh = ToolTipRequested; if (eh != null) { eh(null, e); } }
internal static void Initialize() { customToolList = AddInTree.BuildItems <CustomToolDescriptor>("/SharpDevelop/CustomTools", null, false); toolDict = new Dictionary <string, CustomToolDescriptor>(StringComparer.OrdinalIgnoreCase); foreach (CustomToolDescriptor desc in customToolList) { toolDict[desc.Name] = desc; } if (!initialized) { initialized = true; FileUtility.FileSaved += OnFileSaved; } beforeBuildCustomToolRunner = new BeforeBuildCustomToolRunner(); }
public static string GetFileFilter(string addInTreePath) { StringBuilder b = new StringBuilder(); b.Append("All known file types|"); foreach (string filter in AddInTree.BuildItems <string>(addInTreePath, null, true)) { b.Append(filter.Substring(filter.IndexOf('|') + 1)); b.Append(';'); } foreach (string filter in AddInTree.BuildItems <string>(addInTreePath, null, true)) { b.Append('|'); b.Append(filter); } b.Append("|All files|*.*"); return(b.ToString()); }
public void OverrideCommands(string path) { bool exist = ICSharpCode.Core.AddInTree.ExistsTreeNode(path); if (!exist) { //throw new Exception("Command Not Config:" + path); return; } List <MenuItemDescriptor> descriptors = AddInTree.BuildItems <MenuItemDescriptor>(path, this, false); foreach (MenuItemDescriptor item in descriptors) { Codon codon = item.Codon; this.OverrideCommand(codon, item); } }
public static List <SearchItem> BuildSearchItems() { List <SearchItem> result = new List <SearchItem>(); if (!AddInTree.ExistsTreeNode(SDSearchPath)) { return(result); } List <SearchPathDescriptor> descriptors = AddInTree.BuildItems <SearchPathDescriptor>(SDSearchPath, null); foreach (SearchPathDescriptor descriptor in descriptors) { List <SearchItem> descriptorList = BuildSearchItems(descriptor); result.AddRange(descriptorList); } return(result); }
static void ReadFileCategorySortOrderFiles() { fileCategorySortOrderFiles = new List <TemplateCategorySortOrderFile>(); string dataTemplateDir = Path.Combine(PropertyService.DataDirectory, "templates", "file"); List <string> files = FileUtility.SearchDirectory(dataTemplateDir, FileCategorySortOrderFileName); foreach (string templateDirectory in AddInTree.BuildItems <string>(ProjectTemplate.TemplatePath, null, false)) { files.AddRange(FileUtility.SearchDirectory(templateDirectory, FileCategorySortOrderFileName)); } foreach (string fileName in files) { try { fileCategorySortOrderFiles.Add(new TemplateCategorySortOrderFile(fileName)); } catch (Exception ex) { LoggingService.Debug("Failed to load project category sort order file: " + fileName + " : " + ex.ToString()); } } }
/// <summary> /// This method builds a ClassBrowserNode Tree out of a given combine. /// </summary> public static TreeNode AddClassNode(ExtTreeView classBrowser, IProject project, IClass c) { IClassNodeBuilder classNodeBuilder = null; foreach (IClassNodeBuilder nodeBuilder in AddInTree.BuildItems <IClassNodeBuilder>("/SharpDevelop/Views/ClassBrowser/ClassNodeBuilders", null, true)) { if (nodeBuilder.CanBuildClassTree(c)) { classNodeBuilder = nodeBuilder; break; } } if (classNodeBuilder != null) { return(classNodeBuilder.AddClassNode(classBrowser, project, c)); } throw new NotImplementedException("Can't create node builder for class " + c.Name); }
public void LoadViews(ActionParameters parameters) { var dockPath = BasePath + "/DockPanels"; if (AddInTree.ExistsTreeNode(dockPath)) { LoadMainView(dockPath, parameters); var descriptors = AddInTree.BuildItems <object>(dockPath, this, false).OfType <DockPanelDescriptor>().ToList(); foreach (var descriptor in descriptors) { bool isLazy = false; bool.TryParse(descriptor.Codon.Properties["lazy"], out isLazy); if (isLazy) { continue; } var controller = ControllerFactory.CreateController(descriptor.ControllerId); controller.WorkSpaceID = this.ID; controller.Context = this._workspaceContext; _controllers[descriptor.ControllerId] = controller; InitObjectWidget(controller); var result = new ActionInvoker().Invoke(controller, null, parameters) as IPartialViewResult; if (result != null) { result.View.ViewName = descriptor.Codon.Id; AddView(result.View); CreateDockPanel(descriptor, result.View); } } } else { throw new Exception("Config path not found:" + dockPath); } WorkSpaceTextLoader txtLoader = new WorkSpaceTextLoader(); string mainText = string.Empty; Title = txtLoader.GetListWorkSpaceTitle(ObjectName, out mainText); this.UpdateRibbonItems(); }
public void Initialize() { UpdateFlowDirection(); var padDescriptors = AddInTree.BuildItems <PadDescriptor>(viewContentPath, this, false); ((SharpDevelopServiceContainer)SD.Services).AddFallbackProvider(new PadServiceProvider(padDescriptors)); foreach (PadDescriptor content in padDescriptors) { ShowPad(content); } mainMenu.ItemsSource = MenuService.CreateMenuItems(this, this, mainMenuPath, activationMethod: "MainMenu", immediatelyExpandMenuBuildersForShortcuts: true); toolBars = ToolBarService.CreateToolBars(this, this, "/SharpDevelop/Workbench/ToolBar"); foreach (ToolBar tb in toolBars) { DockPanel.SetDock(tb, Dock.Top); dockPanel.Children.Insert(1, tb); } DockPanel.SetDock(statusBar, Dock.Bottom); dockPanel.Children.Insert(dockPanel.Children.Count - 2, statusBar); Core.WinForms.MenuService.ExecuteCommand = ExecuteCommand; Core.WinForms.MenuService.CanExecuteCommand = CanExecuteCommand; UpdateMenu(); AddHandler(Hyperlink.RequestNavigateEvent, new RequestNavigateEventHandler(OnRequestNavigate)); Project.ProjectService.CurrentProjectChanged += SetProjectTitle; SharpDevelop.FileService.FileRemoved += CheckRemovedOrReplacedFile; SharpDevelop.FileService.FileReplaced += CheckRemovedOrReplacedFile; SharpDevelop.FileService.FileRenamed += CheckRenamedFile; SharpDevelop.FileService.FileRemoved += ((RecentOpen)SD.FileService.RecentOpen).FileRemoved; SharpDevelop.FileService.FileRenamed += ((RecentOpen)SD.FileService.RecentOpen).FileRenamed; requerySuggestedEventHandler = new EventHandler(CommandManager_RequerySuggested); CommandManager.RequerySuggested += requerySuggestedEventHandler; SD.ResourceService.LanguageChanged += OnLanguageChanged; SD.StatusBar.SetMessage("${res:MainWindow.StatusBar.ReadyMessage}"); }
/// <summary> /// This method builds a ProjectBrowserNode Tree out of a given combine. /// </summary> public static TreeNode AddProjectNode(TreeNode motherNode, IProject project) { IProjectNodeBuilder projectNodeBuilder = null; foreach (IProjectNodeBuilder nodeBuilder in AddInTree.BuildItems <IProjectNodeBuilder>("/SharpDevelop/Views/ProjectBrowser/NodeBuilders", null, true)) { if (nodeBuilder.CanBuildProjectTree(project)) { projectNodeBuilder = nodeBuilder; break; } } if (projectNodeBuilder != null) { return(projectNodeBuilder.AddProjectNode(motherNode, project)); } throw new NotImplementedException("can't create node builder for project type " + project.Language); }
public override void Run() { IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow; if (window == null || !(window.ViewContent is ITextEditorControlProvider)) { return; } TextEditorControl textEditorControl = ((ITextEditorControlProvider)window.ViewContent).TextEditorControl; ParseInformation parseInformation; if (window.ViewContent.IsUntitled) { parseInformation = ParserService.ParseFile(textEditorControl.FileName, textEditorControl.Document.TextContent); } else { parseInformation = ParserService.GetParseInformation(textEditorControl.FileName); } if (parseInformation == null) { return; } ICompilationUnit cu = parseInformation.MostRecentCompilationUnit as ICompilationUnit; if (cu == null) { return; } IClass currentClass = GetCurrentClass(textEditorControl, cu, textEditorControl.FileName); if (currentClass != null) { ArrayList categories = new ArrayList(); ArrayList generators = AddInTree.BuildItems("/AddIns/DefaultTextEditor/CodeGenerator", this, true); using (CodeGenerationForm form = new CodeGenerationForm(textEditorControl, (CodeGeneratorBase[])generators.ToArray(typeof(CodeGeneratorBase)), currentClass)) { form.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm); } } }
public override void Run() { IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveViewContent; if (viewContent == null || !(viewContent is ITextEditorControlProvider)) { return; } TextEditorControl textEditorControl = ((ITextEditorControlProvider)viewContent).TextEditorControl; ParseInformation parseInformation; if (viewContent.PrimaryFile.IsUntitled) { parseInformation = ParserService.ParseFile(textEditorControl.FileName, textEditorControl.Document.TextContent); } else { parseInformation = ParserService.GetParseInformation(textEditorControl.FileName); } if (parseInformation == null) { return; } ICompilationUnit cu = parseInformation.MostRecentCompilationUnit as ICompilationUnit; if (cu == null) { return; } IClass currentClass = GetCurrentClass(textEditorControl, cu, textEditorControl.FileName); if (currentClass != null) { var generators = AddInTree.BuildItems <CodeGeneratorBase>("/AddIns/DefaultTextEditor/CodeGenerator", this, true); using (CodeGenerationForm form = new CodeGenerationForm(textEditorControl, generators.ToArray(), currentClass)) { form.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm); } } }
public override void Initialize() { base.Initialize(); _templates = new Dictionary <string, List <ItemTemplate> >(); var tpls = AddInTree.BuildItems <ItemTemplate>("/Maestro/NewItemTemplates", this); //NOXLATE foreach (var tp in tpls) { if (!_templates.ContainsKey(tp.Category)) { _templates[tp.Category] = new List <ItemTemplate>(); } _templates[tp.Category].Add(tp); LoggingService.Info($"Registered default template: {tp.GetType()}"); //NOXLATE } LoggingService.Info("Initialized: New Item Template Service"); //NOXLATE }
private static void RunWorkbenchInitializedCommands() { if (Current.ComManager != null && Current.ComManager.ApplicationWasStartedWithEmbeddingArg) { Current.ComManager.StartLocalServer(); } foreach (ICommand command in AddInTree.BuildItems <ICommand>(StringParser.Parse("/${AppName}/Workbench/AutostartAfterWorkbenchInitialized"), null, false)) { try { command.Execute(null); } catch (Exception ex) { // allow startup to continue if some commands fail MessageService.ShowException(ex); } } }
public void InitializeAdvancedHighlighter() { if (advancedHighlighter != null) { advancedHighlighter.Dispose(); advancedHighlighter = null; } string highlighterPath = advancedHighlighterPath + "/" + Document.HighlightingStrategy.Name; if (AddInTree.ExistsTreeNode(highlighterPath)) { IList <IAdvancedHighlighter> highlighter = AddInTree.BuildItems <IAdvancedHighlighter>(highlighterPath, this); if (highlighter != null && highlighter.Count > 0) { advancedHighlighter = highlighter[0]; advancedHighlighter.Initialize(this); Document.HighlightingStrategy = new AdvancedHighlightingStrategy((DefaultHighlightingStrategy)Document.HighlightingStrategy, advancedHighlighter); } } }
public void Initialize(object mainWindow) { var startupSettings = Current.GetRequiredService <StartupSettings>(); string appNamePrefix = "/" + startupSettings.ApplicationName; _mainWindow = mainWindow; // Initialize main menu items MainMenuItemsSource = MenuService.CreateMenuItems((System.Windows.UIElement)_mainWindow, this, appNamePrefix + mainMenuPathPostFix, activationMethod: "MainMenu", immediatelyExpandMenuBuildersForShortcuts: true); // Initialize toolbars ToolBarTrayItemsSource = ToolBarService.CreateToolBars(_mainWindow, this, appNamePrefix + toolBarPathPostFix); // Initialize context menu of document tabs DocumentContextMenuItemsSource = MenuService.CreateMenuItems((System.Windows.UIElement)_mainWindow, this, appNamePrefix + documentContextMenuPathPostFix, activationMethod: "ContextMenu", immediatelyExpandMenuBuildersForShortcuts: true); // Initialize pads (tool windows) var padDescriptors = AddInTree.BuildItems <PadDescriptor>(appNamePrefix + padContentPathPostFix, this, false); _padContentCollection.AddRange(padDescriptors.Select(x => x.PadContent)); // Initialize status bar var statusBarService = Current.GetService <IStatusBarService>(); if (statusBarService is IMVCController statusBarController) { if (statusBarController.ViewObject == null) { Current.Gui.FindAndAttachControlTo(statusBarController); } _statusBarView = statusBarController.ViewObject; } // Initialize Icon IconSource = "Icons." + startupSettings.ApplicationName + "ApplicationIcon"; Current.IProjectService.ProjectChanged += EhProjectChanged; Title = Current.IProjectService.GetMainWindowTitle(); WorkbenchServices.StatusBar.SetMessage("${res:MainWindow.StatusBar.ReadyMessage}"); }
public static bool NavigateTo(string assemblyFile, string typeName, string entityTag, int lineNumber = 0, bool updateMarker = true) { if (string.IsNullOrEmpty(assemblyFile)) { throw new ArgumentException("assemblyFile is null or empty"); } if (string.IsNullOrEmpty(typeName)) { throw new ArgumentException("typeName is null or empty"); } foreach (var item in AddInTree.BuildItems <INavigateToMemberService>("/SharpDevelop/Services/NavigateToEntityService", null, false)) { if (item.NavigateToMember(assemblyFile, typeName, entityTag, lineNumber, updateMarker)) { return(true); } } return(false); }
/// <inheritdoc cref="ISearchResultFactory.CreateSearchResult(string,IObservable{SearchResultMatch})"/> public static ISearchResult CreateSearchResult(string title, IObservable <SearchedFile> matches) { if (title == null) { throw new ArgumentNullException("title"); } if (matches == null) { throw new ArgumentNullException("matches"); } foreach (ISearchResultFactory factory in AddInTree.BuildItems <ISearchResultFactory>("/SharpDevelop/Pads/SearchResultPad/Factories", null, false)) { ISearchResult result = factory.CreateSearchResult(title, matches); if (result != null) { return(result); } } return(new DummySearchResult { Text = title }); }
/// <summary> /// Gets an exporter that can be used to export an image of the provided project item. /// </summary> /// <param name="item">The item to export, for instance an item of type <see cref="Altaxo.Graph.Gdi.GraphDocument"/> or <see cref="Altaxo.Graph.Graph3D.GraphDocument"/>.</param> /// <returns>The image exporter class that can be used to export the item in graphical form, or null if no exporter could be found.</returns> public IProjectItemImageExporter GetProjectItemImageExporter(IProjectItem item) { IProjectItemImageExporter result = null; foreach (IProjectItemExportBindingDescriptor descriptor in AddInTree.BuildItems <IProjectItemExportBindingDescriptor>("/Altaxo/Workbench/ProjectItemExportBindings", this, false)) { if (descriptor.ProjectItemType == item.GetType()) { System.Reflection.ConstructorInfo cinfo; if (null != (cinfo = descriptor.GraphicalExporterType.GetConstructor(new Type[0]))) { result = cinfo.Invoke(new object[0]) as IProjectItemImageExporter; if (null != result) { break; } } } } return(result); }
public void InitializeService() { List <ISymbolSource> symbolSources = new List <ISymbolSource>(); symbolSources.Add(PdbSymbolSource); symbolSources.AddRange(AddInTree.BuildItems <ISymbolSource>("/SharpDevelop/Services/DebuggerService/SymbolSource", null, false)); // init NDebugger CurrentDebugger = new NDebugger(); CurrentDebugger.Options = DebuggingOptions.Instance; CurrentDebugger.SymbolSources = symbolSources; foreach (BreakpointBookmark b in SD.BookmarkManager.Bookmarks.OfType <BreakpointBookmark>()) { AddBreakpoint(b); } SD.BookmarkManager.BookmarkAdded += (sender, e) => { BreakpointBookmark bm = e.Bookmark as BreakpointBookmark; if (bm != null) { AddBreakpoint(bm); } }; SD.BookmarkManager.BookmarkRemoved += (sender, e) => { BreakpointBookmark bm = e.Bookmark as BreakpointBookmark; if (bm != null) { Breakpoint bp = bm.InternalBreakpointObject as Breakpoint; CurrentDebugger.RemoveBreakpoint(bp); } }; if (Initialize != null) { Initialize(this, null); } }
public static bool NavigateTo(IEntity entity) { if (entity == null) { throw new ArgumentNullException("entity"); } var region = entity.Region; if (region.IsEmpty || string.IsNullOrEmpty(region.FileName)) { foreach (var item in AddInTree.BuildItems <INavigateToEntityService>("/SharpDevelop/Services/NavigateToEntityService", null, false)) { if (item.NavigateToEntity(entity)) { return(true); } } return(false); } return(FileService.JumpToFilePosition(region.FileName, region.BeginLine, region.BeginColumn) != null); }
public static ContextMenuStrip CreateContextMenu(object owner, string addInTreePath) { if (addInTreePath == null) { return(null); } try { List <MenuItemDescriptor> descriptors = AddInTree.BuildItems <MenuItemDescriptor>(addInTreePath, owner, true); ContextMenuStrip contextMenu = new ContextMenuStrip(); contextMenu.Items.Add(new ToolStripMenuItem("dummy")); contextMenu.Opening += delegate { contextMenu.Items.Clear(); AddItemsToMenu(contextMenu.Items, descriptors); }; contextMenu.Opened += ContextMenuOpened; contextMenu.Closed += ContextMenuClosed; return(contextMenu); } catch (TreePathNotFoundException) { MessageService.ShowError("Warning tree path '" + addInTreePath + "' not found."); return(null); } }
public void InitializeService() { if (useRemotingForThreadInterop) { // This needs to be called before instance of NDebugger is created string path = RemotingConfigurationHelpper.GetLoadedAssemblyPath("Debugger.Core.dll"); new RemotingConfigurationHelpper(path).Configure(); } // get decompiler service var items = AddInTree.BuildItems <IDebuggerDecompilerService>("/SharpDevelop/Services/DebuggerDecompilerService", null, false); if (items.Count > 0) { debuggerDecompilerService = items[0]; } // init NDebugger debugger = new NDebugger(); debugger.Options = DebuggingOptions.Instance; debugger.DebuggerTraceMessage += debugger_TraceMessage; debugger.Processes.Added += debugger_ProcessStarted; debugger.Processes.Removed += debugger_ProcessExited; DebuggerService.BreakPointAdded += delegate(object sender, BreakpointBookmarkEventArgs e) { AddBreakpoint(e.BreakpointBookmark); }; foreach (BreakpointBookmark b in DebuggerService.Breakpoints) { AddBreakpoint(b); } if (Initialize != null) { Initialize(this, null); } }
public static bool NavigateTo(Dom.IEntity entity) { if (entity == null) { throw new ArgumentNullException("entity"); } var cu = entity.CompilationUnit; Dom.DomRegion region; if (entity is Dom.IClass) { region = ((Dom.IClass)entity).Region; } else if (entity is Dom.IMember) { region = ((Dom.IMember)entity).Region; } else { region = Dom.DomRegion.Empty; } if (cu == null || string.IsNullOrEmpty(cu.FileName) || region.IsEmpty) { foreach (var item in AddInTree.BuildItems <INavigateToEntityService>("/SharpDevelop/Services/NavigateToEntityService", null, false)) { if (item.NavigateToEntity(entity)) { return(true); } } return(false); } else { return(FileService.JumpToFilePosition(cu.FileName, region.BeginLine, region.BeginColumn) != null); } }