/// <summary> /// Gets the current ambience. /// This method is thread-safe. /// </summary> /// <returns>Returns a new ambience object (ambience objects are never reused to ensure their thread-safety). /// Never returns null, in case of errors the <see cref="NetAmbience"/> is used.</returns> public static IAmbience GetCurrentAmbience() { IAmbience ambience; if (UseProjectAmbienceIfPossible) { ICSharpCode.SharpDevelop.Project.IProject p = ICSharpCode.SharpDevelop.Project.ProjectService.CurrentProject; if (p != null) { ambience = p.GetAmbience(); if (ambience != null) { return(ambience); } } } string language = DefaultAmbienceName; try { ambience = (IAmbience)AddInTree.BuildItem("/SharpDevelop/Workbench/Ambiences/" + language, null); } catch (TreePathNotFoundException) { ambience = null; } if (ambience == null && Gui.WorkbenchSingleton.MainWin32Window != null) { MessageService.ShowError("${res:ICSharpCode.SharpDevelop.Services.AmbienceService.AmbienceNotFoundError}"); } return(ambience ?? new NetAmbience()); }
static Action <FileTemplateOptions> ReadAction(XmlElement el) { switch (el.Name) { case "RunCommand": if (el.HasAttribute("path")) { try { ICommand command = (ICommand)AddInTree.BuildItem(el.GetAttribute("path"), null); return(fileCreateInformation => { command.Owner = fileCreateInformation; command.Run(); }); } catch (TreePathNotFoundException ex) { MessageService.ShowWarning(ex.Message + " - in " + el.OwnerDocument.DocumentElement.GetAttribute("fileName")); return(null); } } else { ProjectTemplate.WarnAttributeMissing(el, "path"); return(null); } default: ProjectTemplate.WarnObsoleteNode(el, "Unknown action element is ignored"); return(null); } }
private void ActivateView(ActivateViewMessage message) { var viewName = message.ViewName; if (_views.ContainsKey(viewName)) { var view = (Control)_views[viewName]; if (Controls.Contains(view)) { view.BringToFront(); ActiveView = _views[viewName]; UpdateRibbonItems(); } } else { var viewPath = BasePath + "/DockPanels/" + viewName; if (!AddInTree.ExistsTreeNode(viewPath)) { return; } var viewDescriptor = (DockPanelDescriptor)AddInTree.BuildItem(viewPath, null); if (viewDescriptor == null) { throw new Exception(string.Format("{0} doesn't exist in addin file, please check it.", viewPath)); } var controller = ControllerFactory.CreateController(viewDescriptor.ControllerId); this._controllers[viewDescriptor.ControllerId] = controller; var result = new ActionInvoker().Invoke(controller, null, message.Parameters) as IPartialViewResult; if (result != null) { result.View.ViewName = viewDescriptor.Codon.Id; AddView(result.View); var view = (Control)result.View; view.Dock = DockStyle.Fill; this.Controls.Add(view); view.BringToFront(); ActiveView = result.View; InitObjectWidget(controller); UpdateRibbonItems(); } } }
static Action <ProjectCreateInformation> ReadAction(XmlElement el) { switch (el.Name) { case "Open": if (el.HasAttribute("filename")) { string fileName = el.GetAttribute("filename"); return(projectCreateInformation => { string parsedFileName = StringParser.Parse(fileName, new string[, ] { { "ProjectName", projectCreateInformation.ProjectName } }); string path = Path.Combine(projectCreateInformation.ProjectBasePath, parsedFileName); FileService.OpenFile(path); }); } else { WarnAttributeMissing(el, "filename"); return(null); } case "RunCommand": if (el.HasAttribute("path")) { ICommand command = (ICommand)AddInTree.BuildItem(el.GetAttribute("path"), null); return(projectCreateInformation => { command.Owner = projectCreateInformation; command.Run(); }); } else { WarnAttributeMissing(el, "path"); return(null); } default: WarnObsoleteNode(el, "Unknown action element is interpreted as <Open>"); goto case "Open"; } }
static Action <IProject> ReadAction(XmlElement el) { switch (el.Name) { case "RunCommand": if (el.HasAttribute("path")) { ICommand command = (ICommand)AddInTree.BuildItem(el.GetAttribute("path"), null); return(project => { command.Owner = project; command.Run(); }); } else { ProjectTemplate.WarnAttributeMissing(el, "path"); return(null); } default: throw new TemplateLoadException("Unknown node in <CreateActions>: " + el.Name); } }
static Action <IProject> ReadAction(XmlElement el) { switch (el.Name) { case "RunCommand": if (el.HasAttribute("path")) { string path = el.GetAttribute("path"); #if DEBUG ICommand command = (ICommand)AddInTree.BuildItem(path, null); if (command == null) { throw new TemplateLoadException("Unknown create action " + path); } #endif return(project => { #if !DEBUG ICommand command = (ICommand)AddInTree.BuildItem(path, null); #endif if (command != null) { command.Owner = project; command.Run(); } }); } else { ProjectTemplate.WarnAttributeMissing(el, "path"); return(null); } default: throw new TemplateLoadException("Unknown node in <CreateActions>: " + el.Name); } }