internal void InitFromNode(LanguageBindingExtensionNode node) { Language = node.Id; if (!string.IsNullOrEmpty(node.SingleLineCommentTag)) { SingleLineCommentTag = node.SingleLineCommentTag; } if (!string.IsNullOrEmpty(node.BlockCommentStartTag)) { BlockCommentStartTag = node.BlockCommentStartTag; } if (!string.IsNullOrEmpty(node.BlockCommentEndTag)) { BlockCommentEndTag = node.BlockCommentEndTag; } if (node.SupportedExtensions != null && node.SupportedExtensions.Length > 0) { fileExtensions = node.SupportedExtensions; } if (!string.IsNullOrEmpty(node.CodeDomType)) { codeDomTypeName = node.CodeDomType; addin = node.Addin; } }
//static void AddToAnimatedIconFactory (string stockId, AnimatedIcon aicon) //{ // animationFactory [stockId] = aicon; //} #if false static string InternalGetStockIdFromResource(RuntimeAddin addin, string id, Gtk.IconSize size) { if (!id.StartsWith("res:")) { return(id); } id = id.Substring(4); int addinId = GetAddinId(addin); Dictionary <string, string> hash = addinIcons[addinId]; string stockId = "__asm" + addinId + "__" + id + "__" + size; if (!hash.ContainsKey(stockId)) { System.IO.Stream stream = addin.GetResource(id); if (stream != null) { using (stream) { AddToIconFactory(stockId, new Gdk.Pixbuf(stream), size); } } hash[stockId] = stockId; } return(stockId); }
public void RegisterProperty(RuntimeAddin addin, string targetType, string name, string propertyType, bool isExternal, bool skipEmpty) { TypeRef tr; if (!pendingTypesByTypeName.TryGetValue(targetType, out tr)) { tr = new TypeRef(addin, targetType); pendingTypesByTypeName [targetType] = tr; } if (tr.DataType != null) { RegisterProperty(addin.GetType(targetType, true), name, addin.GetType(propertyType, true), isExternal, skipEmpty); return; } PropertyRef prop = new PropertyRef(addin, targetType, name, propertyType, isExternal, skipEmpty); if (tr.Properties == null) { tr.Properties = prop; } else { PropertyRef plink = tr.Properties; while (plink.Next != null) { plink = plink.Next; } plink.Next = prop; } }
public void IncludeType(RuntimeAddin addin, string typeName, string itemName) { if (string.IsNullOrEmpty(itemName)) { int i = typeName.LastIndexOf('.'); if (i >= 0) { itemName = typeName.Substring(i + 1); } else { itemName = typeName; } } TypeRef tr; if (!pendingTypesByTypeName.TryGetValue(typeName, out tr)) { tr = new TypeRef(addin, typeName); pendingTypesByTypeName [typeName] = tr; } else { tr.Addin = addin; } pendingTypes [itemName] = tr; }
static string InternalGetStockIdFromAnimation(RuntimeAddin addin, string id, Gtk.IconSize size) { if (!id.StartsWith("animation:", StringComparison.Ordinal)) { return(id); } id = id.Substring(10); Dictionary <string, string> hash; int addinId; if (addin != null) { addinId = GetAddinId(addin); hash = addinIcons[addinId]; } else { addinId = -1; hash = iconSpecToStockId; } string stockId = "__asm" + addinId + "__" + id + "__" + size; if (!hash.ContainsKey(stockId)) { var aicon = new AnimatedIcon(addin, id, size); AddToAnimatedIconFactory(stockId, aicon); hash[stockId] = stockId; icons [stockId] = aicon.FirstFrame; } return(stockId); }
public AnimatedIcon(RuntimeAddin addin, string animationSpec, Gtk.IconSize size) { this.addin = addin; this.size = size; this.animationSpec = animationSpec; Parse(animationSpec); }
public IAddinLocalizer CreateLocalizer(RuntimeAddin addin, NodeElement element) { foreach (NodeElement nloc in element.ChildNodes) { if (nloc.NodeName != "Locale") { throw new InvalidOperationException("Invalid element found: '" + nloc.NodeName + "'. Expected: 'Locale'"); } string ln = nloc.GetAttribute("id"); if (ln.Length == 0) { throw new InvalidOperationException("Locale id not specified"); } ln = ln.Replace('_', '-'); Hashtable messages = new Hashtable(); foreach (NodeElement nmsg in nloc.ChildNodes) { if (nmsg.NodeName != "Msg") { throw new InvalidOperationException("Locale '" + ln + "': Invalid element found: '" + nmsg.NodeName + "'. Expected: 'Msg'"); } string id = nmsg.GetAttribute("id"); if (id.Length == 0) { throw new InvalidOperationException("Locale '" + ln + "': Message id not specified"); } messages [id] = nmsg.GetAttribute("str"); } locales [ln] = messages; } return(this); }
protected SolutionItemDescriptor(RuntimeAddin addin, XmlElement element) { this.addin = addin; name = element.GetAttribute("name"); // relativePath = element.GetAttribute ("directory"); typeName = element.GetAttribute("type"); template = element; }
static string PrivGetStockId(RuntimeAddin addin, string filename, Gtk.IconSize size) { if (addin != null && filename.StartsWith("res:")) { return(InternalGetStockIdFromResource(addin, filename, size)); } return(filename); }
/// <summary> /// The addin may be null if the file template is loaded by a unit test. /// </summary> static string Localize(RuntimeAddin addin, string s) { if (addin != null) { return(addin.Localizer.GetString(s)); } return(GettextCatalog.GetString(s)); }
public PropertyRef(RuntimeAddin addin, string targetType, string name, string propertyType, bool isExternal, bool skipEmpty) { this.Addin = addin; this.TargetType = targetType; this.Name = name; this.PropertyType = propertyType; this.IsExternal = isExternal; this.SkipEmpty = skipEmpty; }
static Stream GetResource2x(this RuntimeAddin addin, string id) { var stream = addin.GetResource(Path.GetFileNameWithoutExtension(id) + "@2x" + Path.GetExtension(id)); if (stream == null) { stream = addin.GetResource(id + "@2x"); } return(stream); }
public static SolutionDescriptor CreateSolutionDescriptor(RuntimeAddin addin, XmlElement xmlElement, FilePath baseDirectory) { SolutionDescriptor solutionDescriptor = new SolutionDescriptor(); solutionDescriptor.addin = addin; if (xmlElement.Attributes["name"] != null) { solutionDescriptor.name = xmlElement.Attributes["name"].Value; } else { throw new InvalidOperationException("Attribute 'name' not found"); } if (xmlElement.Attributes["type"] != null) { solutionDescriptor.type = xmlElement.Attributes["type"].Value; } if (xmlElement.Attributes["directory"] != null) { solutionDescriptor.directory = xmlElement.Attributes["directory"].Value; } if (xmlElement["Options"] != null && xmlElement["Options"]["StartupProject"] != null) { solutionDescriptor.startupProject = xmlElement["Options"]["StartupProject"].InnerText; } foreach (XmlNode xmlNode in xmlElement.ChildNodes) { if (xmlNode is XmlElement) { XmlElement xmlNodeElement = (XmlElement)xmlNode; switch (xmlNodeElement.Name) { case "Project": solutionDescriptor.entryDescriptors.Add( ProjectDescriptor.CreateProjectDescriptor(xmlNodeElement, baseDirectory)); break; case "CombineEntry": case "SolutionItem": solutionDescriptor.entryDescriptors.Add( SolutionItemDescriptor.CreateDescriptor(addin, xmlNodeElement)); break; } } } return(solutionDescriptor); }
static Xwt.Drawing.Image LoadStockIcon(RuntimeAddin addin, string stockId, string resource, string imageFile, string iconId, Gtk.IconSize iconSize, string animation, bool forceWildcard) { try { AnimatedIcon animatedIcon = null; Func <Stream[]> imageLoader = null; Xwt.Drawing.Image img = null; if (!string.IsNullOrEmpty(resource) || !string.IsNullOrEmpty(imageFile)) { if (resource != null) { CustomImageLoader loader; if (!imageLoaders.TryGetValue(addin, out loader)) { loader = imageLoaders [addin] = new CustomImageLoader(addin); } img = Xwt.Drawing.Image.FromCustomLoader(loader, resource); } else { img = Xwt.Drawing.Image.FromFile(addin.GetFilePath(imageFile)); } } else if (!string.IsNullOrEmpty(iconId)) { var id = GetStockIdForImageSpec(addin, iconId, iconSize); img = GetIcon(id, iconSize); // This may be an animation, get it animationFactory.TryGetValue(id, out animatedIcon); } else if (!string.IsNullOrEmpty(animation)) { string id = GetStockIdForImageSpec(addin, "animation:" + animation, iconSize); img = GetIcon(id, iconSize); // This *should* be an animation animationFactory.TryGetValue(id, out animatedIcon); } if (animatedIcon != null) { AddToAnimatedIconFactory(stockId, animatedIcon); } if (imageLoader != null) { img.SetStreamSource(imageLoader); } return(img); } catch (Exception ex) { LoggingService.LogError(string.Format("Error loading icon '{0}'", stockId), ex); return(null); } }
static int GetAddinId(RuntimeAddin addin) { int result = addins.IndexOf(addin); if (result == -1) { result = addins.Count; addinIcons.Add(new Dictionary <string, string> ()); } return(result); }
static string PrivGetStockId(RuntimeAddin addin, string filename, Gtk.IconSize size) { if (addin != null && filename.StartsWith("res:", StringComparison.Ordinal)) { return(InternalGetStockIdFromResource(addin, filename, size)); } if (filename.StartsWith("animation:", StringComparison.Ordinal)) { return(InternalGetStockIdFromAnimation(addin, filename, size)); } return(filename); }
//static string GetStockIdForImageSpec (string filename, Gtk.IconSize size) //{ // return GetStockIdForImageSpec (null, filename, size); //} #if false static string GetStockIdForImageSpec(RuntimeAddin addin, string filename, Gtk.IconSize size) { if (filename.IndexOf('|') == -1) { return(PrivGetStockId(addin, filename, size)); } string[] parts = filename.Split('|'); for (int n = 0; n < parts.Length; n++) { parts[n] = PrivGetStockId(addin, parts[n], size); } return(GetComposedIcon(parts, size)); }
public IAddinLocalizer CreateLocalizer(RuntimeAddin addin, NodeElement element) { string pkg = element.GetAttribute("catalog"); if (pkg.Length == 0) { pkg = addin.Id; } string dir = element.GetAttribute("location"); if (dir.Length == 0) { dir = "locale"; } dir = addin.GetFilePath(dir); domain = new GettextDomain(); domain.Init(pkg, dir); return(this); }
static string InternalGetStockIdFromResource(RuntimeAddin addin, string id, Gtk.IconSize size) { if (!id.StartsWith("res:", StringComparison.Ordinal)) { return(id); } id = id.Substring(4); int addinId = GetAddinId(addin); Dictionary <string, string> hash = addinIcons[addinId]; string stockId = "__asm" + addinId + "__" + id + "__" + size; if (!hash.ContainsKey(stockId)) { icons[stockId] = LoadStockIcon(addin, stockId, id, null, null, size, null, false); hash[stockId] = stockId; } return(stockId); }
public static Xwt.Drawing.Image GetImageResource(this RuntimeAddin addin, string resource) { using (var s = addin.GetResource(resource)) { var img = Xwt.Drawing.Image.FromStream(s); int i = resource.LastIndexOf('.'); if (i != -1) { var resource2x = resource.Substring(0, i) + "@2x" + resource.Substring(i); var s2x = addin.GetResource(resource2x); if (s2x != null) { using (s2x) { var img2x = Xwt.Drawing.Image.FromStream(s2x); return(Xwt.Drawing.Image.CreateMultiSizeIcon(new Xwt.Drawing.Image[] { img, img2x })); } } } return(img); } }
public void UnregisterProperty(RuntimeAddin addin, string targetType, string name) { TypeRef tr; if (!pendingTypesByTypeName.TryGetValue(targetType, out tr)) { return; } if (tr.DataType != null) { Type t = addin.GetType(targetType, false); if (t != null) { UnregisterProperty(t, name); } return; } PropertyRef prop = tr.Properties; PropertyRef prev = null; while (prop != null) { if (prop.Name == name) { if (prev != null) { prev.Next = prop.Next; } else { tr.Properties = null; } break; } prev = prop; prop = prop.Next; } }
static string InternalGetStockIdFromAnimation(RuntimeAddin addin, string id, Gtk.IconSize size) { if (!id.StartsWith ("animation:")) return id; id = id.Substring (10); Dictionary<string, string> hash; int addinId; if (addin != null) { addinId = GetAddinId (addin); hash = addinIcons[addinId]; } else { addinId = -1; hash = iconSpecToStockId; } string stockId = "__asm" + addinId + "__" + id + "__" + size; if (!hash.ContainsKey (stockId)) { var aicon = new AnimatedIcon (addin, id, size); AddToIconFactory (stockId, aicon.FirstFrame, size); AddToAnimatedIconFactory (stockId, aicon); hash[stockId] = stockId; } return stockId; }
public static string GetStockId(RuntimeAddin addin, string filename, Gtk.IconSize iconSize) { return(GetStockIdForImageSpec(addin, filename, iconSize)); }
public static string GetStockId(RuntimeAddin addin, string filename) { return(GetStockId(addin, filename, Gtk.IconSize.Invalid)); }
public static Xwt.Drawing.Image GetImageResource(this RuntimeAddin addin, string resource) { var loader = new CustomImageLoader(addin); return(Xwt.Drawing.Image.FromCustomLoader(loader, resource)); }
protected ProjectTemplate(RuntimeAddin addin, string id, ProjectTemplateCodon codon, string overrideLanguage) { XmlDocument xmlDocument = codon.GetTemplate(); XmlElement xmlConfiguration = xmlDocument.DocumentElement ["TemplateConfiguration"]; // Get legacy category. if (xmlConfiguration ["_Category"] != null) { category = xmlConfiguration ["_Category"].InnerText; } if (xmlConfiguration ["Category"] != null) { category = xmlConfiguration ["Category"].InnerText; } else if (category == null) { LoggingService.LogWarning(string.Format("Category missing in project template {0}", codon.Id)); } if (!string.IsNullOrEmpty(overrideLanguage)) { this.languagename = overrideLanguage; this.category = overrideLanguage + "/" + this.category; } else if (xmlConfiguration ["LanguageName"] != null) { List <string> listLanguages = new List <string> (); foreach (string item in xmlConfiguration["LanguageName"].InnerText.Split(',')) { listLanguages.Add(item.Trim()); } ExpandLanguageWildcards(listLanguages); this.languagename = listLanguages [0]; if (listLanguages.Count > 1 && !String.IsNullOrEmpty(languagename) && !category.StartsWith(languagename + "/")) { category = languagename + "/" + category; } for (int i = 1; i < listLanguages.Count; i++) { string language = listLanguages[i]; try { ProjectTemplates.Add(new ProjectTemplate(addin, id, codon, language)); } catch (Exception e) { LoggingService.LogError(GettextCatalog.GetString("Error loading template {0} for language {1}", codon.Id, language), e); } } } this.id = id; this.originator = xmlDocument.DocumentElement.GetAttribute("originator"); this.created = xmlDocument.DocumentElement.GetAttribute("created"); this.lastModified = xmlDocument.DocumentElement.GetAttribute("lastModified"); if (xmlConfiguration ["Wizard"] != null) { this.wizardPath = xmlConfiguration ["Wizard"].InnerText; } if (xmlConfiguration ["_Name"] != null) { this.nonLocalizedName = xmlConfiguration ["_Name"].InnerText; this.name = addin.Localizer.GetString(this.nonLocalizedName); } if (xmlConfiguration ["_Description"] != null) { this.description = addin.Localizer.GetString(xmlConfiguration ["_Description"].InnerText); } if (xmlConfiguration ["Icon"] != null) { this.icon = ImageService.GetStockId(addin, xmlConfiguration ["Icon"].InnerText, Gtk.IconSize.Dnd); } if (xmlConfiguration ["GroupId"] != null) { this.groupId = xmlConfiguration ["GroupId"].InnerText; this.condition = xmlConfiguration ["GroupId"].GetAttribute("condition"); } if (xmlConfiguration ["FileExtension"] != null) { this.fileExtension = xmlConfiguration ["FileExtension"].InnerText; } if (xmlConfiguration ["SupportedParameters"] != null) { this.supportedParameters = xmlConfiguration ["SupportedParameters"].InnerText; } if (xmlConfiguration ["DefaultParameters"] != null) { this.defaultParameters = xmlConfiguration ["DefaultParameters"].InnerText; } if (xmlConfiguration ["Image"] != null) { XmlElement imageElement = xmlConfiguration ["Image"]; imageId = imageElement.GetAttribute("id"); imageFile = imageElement.GetAttribute("file"); if (!String.IsNullOrEmpty(imageFile)) { imageFile = Path.Combine(codon.BaseDirectory, imageFile); } } if (xmlConfiguration ["Visibility"] != null) { visibility = xmlConfiguration ["Visibility"].InnerText; } if (xmlDocument.DocumentElement ["Combine"] == null) { throw new InvalidOperationException("Combine element not found"); } else { solutionDescriptor = SolutionDescriptor.CreateSolutionDescriptor(addin, xmlDocument.DocumentElement ["Combine"], codon.BaseDirectory); } if (xmlDocument.DocumentElement ["Actions"] != null) { foreach (XmlNode xmlElement in xmlDocument.DocumentElement["Actions"]) { if (xmlElement is XmlElement && xmlElement.Attributes ["filename"] != null) { actions.Add(xmlElement.Attributes ["filename"].Value); } } } }
//static string GetStockIdForImageSpec (string filename, Gtk.IconSize size) //{ // return GetStockIdForImageSpec (null, filename, size); //} static string GetStockIdForImageSpec(RuntimeAddin addin, string filename, Gtk.IconSize size) { if (filename.IndexOf ('|') == -1) return PrivGetStockId (addin, filename, size); string[] parts = filename.Split ('|'); for (int n = 0; n < parts.Length; n++) { parts[n] = PrivGetStockId (addin, parts[n], size); } return GetComposedIcon (parts, size); }
static string PrivGetStockId(RuntimeAddin addin, string filename, Gtk.IconSize size) { if (addin != null && filename.StartsWith ("res:")) return InternalGetStockIdFromResource (addin, filename, size); if (filename.StartsWith ("animation:")) return InternalGetStockIdFromAnimation (addin, filename, size); return filename; }
internal static FileTemplate LoadFileTemplate(RuntimeAddin addin, XmlDocument xmlDocument, FilePath baseDirectory = new FilePath(), string templateId = "") { //Configuration XmlElement xmlNodeConfig = xmlDocument.DocumentElement ["TemplateConfiguration"]; FileTemplate fileTemplate; if (xmlNodeConfig ["Type"] != null) { Type configType = addin.GetType(xmlNodeConfig ["Type"].InnerText); if (typeof(FileTemplate).IsAssignableFrom(configType)) { fileTemplate = (FileTemplate)Activator.CreateInstance(configType); } else { throw new InvalidOperationException(string.Format("The file template class '{0}' must be a subclass of MonoDevelop.Ide.Templates.FileTemplate", xmlNodeConfig ["Type"].InnerText)); } } else { fileTemplate = new FileTemplate(); } fileTemplate.Originator = xmlDocument.DocumentElement.GetAttribute("Originator"); fileTemplate.Created = xmlDocument.DocumentElement.GetAttribute("Created"); fileTemplate.LastModified = xmlDocument.DocumentElement.GetAttribute("LastModified"); if (xmlNodeConfig ["_Name"] != null) { fileTemplate.Name = xmlNodeConfig ["_Name"].InnerText; } else { throw new InvalidOperationException(string.Format("Missing element '_Name' in file template: {0}", templateId)); } if (xmlNodeConfig ["LanguageName"] != null) { fileTemplate.LanguageName = xmlNodeConfig ["LanguageName"].InnerText; } if (xmlNodeConfig ["ProjectType"] != null) { var projectTypeList = new List <string> (); foreach (var item in xmlNodeConfig["ProjectType"].InnerText.Split(',')) { projectTypeList.Add(item.Trim()); } fileTemplate.ProjectTypes = projectTypeList; } fileTemplate.Categories = new Dictionary <string, string> (); if (xmlNodeConfig ["_Category"] != null) { foreach (XmlNode xmlNode in xmlNodeConfig.GetElementsByTagName("_Category")) { if (xmlNode is XmlElement) { string projectType = ""; if (xmlNode.Attributes ["projectType"] != null) { projectType = xmlNode.Attributes ["projectType"].Value; } if (!string.IsNullOrEmpty(projectType) && fileTemplate.ProjectTypes.Contains(projectType)) { fileTemplate.Categories.Add(projectType, xmlNode.InnerText); } else if (!fileTemplate.Categories.ContainsKey(DefaultCategoryKey)) { fileTemplate.Categories.Add(DefaultCategoryKey, xmlNode.InnerText); } } } } else { throw new InvalidOperationException(string.Format("Missing element '_Category' in file template: {0}", templateId)); } if (xmlNodeConfig ["_Description"] != null) { fileTemplate.Description = xmlNodeConfig ["_Description"].InnerText; } if (xmlNodeConfig ["Icon"] != null) { fileTemplate.Icon = ImageService.GetStockId(addin, xmlNodeConfig ["Icon"].InnerText, IconSize.Dnd); } if (xmlNodeConfig ["Wizard"] != null) { fileTemplate.Icon = xmlNodeConfig ["Wizard"].Attributes ["path"].InnerText; } if (xmlNodeConfig ["DefaultFilename"] != null) { fileTemplate.DefaultFilename = xmlNodeConfig ["DefaultFilename"].InnerText; string isFixed = xmlNodeConfig ["DefaultFilename"].GetAttribute("IsFixed"); if (isFixed.Length > 0) { bool bFixed; if (bool.TryParse(isFixed, out bFixed)) { fileTemplate.IsFixedFilename = bFixed; } else { throw new InvalidOperationException("Invalid value for IsFixed in template."); } } } //Template files XmlNode xmlNodeTemplates = xmlDocument.DocumentElement ["TemplateFiles"]; if (xmlNodeTemplates != null) { foreach (XmlNode xmlNode in xmlNodeTemplates.ChildNodes) { var xmlElement = xmlNode as XmlElement; if (xmlElement != null) { fileTemplate.Files.Add( FileDescriptionTemplate.CreateTemplate(xmlElement, baseDirectory)); } } } //Conditions XmlNode xmlNodeConditions = xmlDocument.DocumentElement ["Conditions"]; if (xmlNodeConditions != null) { foreach (XmlNode xmlNode in xmlNodeConditions.ChildNodes) { var xmlElement = xmlNode as XmlElement; if (xmlElement != null) { fileTemplate.Conditions.Add(FileTemplateCondition.CreateCondition(xmlElement)); } } } return(fileTemplate); }
static FileTemplate LoadFileTemplate(RuntimeAddin addin, ProjectTemplateCodon codon) { return(LoadFileTemplate(addin, codon.GetTemplate(), codon.BaseDirectory, codon.Id)); }
private static FileTemplate LoadFileTemplate(RuntimeAddin addin, ProjectTemplateCodon codon) { XmlDocument xmlDocument = codon.GetTemplate(); FilePath baseDirectory = codon.BaseDirectory; //Configuration XmlElement xmlNodeConfig = xmlDocument.DocumentElement["TemplateConfiguration"]; FileTemplate fileTemplate = null; if (xmlNodeConfig["Type"] != null) { Type configType = addin.GetType(xmlNodeConfig["Type"].InnerText); if (typeof(FileTemplate).IsAssignableFrom(configType)) { fileTemplate = (FileTemplate)Activator.CreateInstance(configType); } else { throw new InvalidOperationException(string.Format("The file template class '{0}' must be a subclass of MonoDevelop.Ide.Templates.FileTemplate", xmlNodeConfig["Type"].InnerText)); } } else { fileTemplate = new FileTemplate(); } fileTemplate.originator = xmlDocument.DocumentElement.GetAttribute("Originator"); fileTemplate.created = xmlDocument.DocumentElement.GetAttribute("Created"); fileTemplate.lastModified = xmlDocument.DocumentElement.GetAttribute("LastModified"); if (xmlNodeConfig["_Name"] != null) { fileTemplate.name = xmlNodeConfig["_Name"].InnerText; } else { throw new InvalidOperationException(string.Format("Missing element '_Name' in file template: {0}", codon.Id)); } if (xmlNodeConfig["_Category"] != null) { fileTemplate.category = xmlNodeConfig["_Category"].InnerText; } else { throw new InvalidOperationException(string.Format("Missing element '_Category' in file template: {0}", codon.Id)); } if (xmlNodeConfig["LanguageName"] != null) { fileTemplate.languageName = xmlNodeConfig["LanguageName"].InnerText; } if (xmlNodeConfig["ProjectType"] != null) { fileTemplate.projecttype = xmlNodeConfig["ProjectType"].InnerText; } if (xmlNodeConfig["_Description"] != null) { fileTemplate.description = xmlNodeConfig["_Description"].InnerText; } if (xmlNodeConfig["Icon"] != null) { fileTemplate.icon = ImageService.GetStockId(addin, xmlNodeConfig["Icon"].InnerText, IconSize.Dnd); //xmlNodeConfig["_Description"].InnerText; } if (xmlNodeConfig["Wizard"] != null) { fileTemplate.icon = xmlNodeConfig["Wizard"].Attributes["path"].InnerText; } if (xmlNodeConfig["DefaultFilename"] != null) { fileTemplate.defaultFilename = xmlNodeConfig["DefaultFilename"].InnerText; string isFixed = xmlNodeConfig["DefaultFilename"].GetAttribute("IsFixed"); if (isFixed.Length > 0) { bool bFixed; if (bool.TryParse(isFixed, out bFixed)) { fileTemplate.isFixedFilename = bFixed; } else { throw new InvalidOperationException("Invalid value for IsFixed in template."); } } } //Template files XmlNode xmlNodeTemplates = xmlDocument.DocumentElement["TemplateFiles"]; if (xmlNodeTemplates != null) { foreach (XmlNode xmlNode in xmlNodeTemplates.ChildNodes) { if (xmlNode is XmlElement) { fileTemplate.files.Add( FileDescriptionTemplate.CreateTemplate((XmlElement)xmlNode, baseDirectory)); } } } //Conditions XmlNode xmlNodeConditions = xmlDocument.DocumentElement["Conditions"]; if (xmlNodeConditions != null) { foreach (XmlNode xmlNode in xmlNodeConditions.ChildNodes) { if (xmlNode is XmlElement) { fileTemplate.conditions.Add(FileTemplateCondition.CreateCondition((XmlElement)xmlNode)); } } } return(fileTemplate); }
static int GetAddinId(RuntimeAddin addin) { int result = addins.IndexOf (addin); if (result == -1) { result = addins.Count; addinIcons.Add (new Dictionary<string, string> ()); } return result; }
public CustomImageLoader(RuntimeAddin addin) { this.addin = addin; }
public static string GetStockId(RuntimeAddin addin, string filename, Gtk.IconSize iconSize) { return GetStockIdForImageSpec (addin, filename, iconSize); }
//static void AddToAnimatedIconFactory (string stockId, AnimatedIcon aicon) //{ // animationFactory [stockId] = aicon; //} static string InternalGetStockIdFromResource(RuntimeAddin addin, string id, Gtk.IconSize size) { if (!id.StartsWith ("res:")) return id; id = id.Substring (4); int addinId = GetAddinId (addin); Dictionary<string, string> hash = addinIcons[addinId]; string stockId = "__asm" + addinId + "__" + id + "__" + size; if (!hash.ContainsKey (stockId)) { System.IO.Stream stream = addin.GetResource (id); if (stream != null) { using (stream) { AddToIconFactory (stockId, new Gdk.Pixbuf (stream), size); } } hash[stockId] = stockId; } return stockId; }
protected ProjectTemplate(RuntimeAddin addin, string id, ProjectTemplateCodon codon) : this(addin, id, codon, null) { }
//public static string GetStockId (string filename) //{ // return GetStockId (filename, Gtk.IconSize.Invalid); //} //public static string GetStockId (string filename, Gtk.IconSize iconSize) //{ //return GetStockIdForImageSpec (filename, iconSize); //} public static string GetStockId(RuntimeAddin addin, string filename) { return GetStockId (addin, filename, Gtk.IconSize.Invalid); }