public void SetAddin(AddIn addin) { author.Text = "Author: " + addin.Author; description.Text = "Description: " + addin.Description; copyright.Text = "Copyright: " + addin.Copyright; url.Text = "Url: " + addin.Url; }
public static string GetStockId(AddIn addin, string filename) { if (addin != null && filename.StartsWith ("res:")) return GetStockIdFromResource (addin, filename); string s = (string) stockMappings [filename]; if (s != null) return s; return filename; }
public FileTemplate(AddIn addin, string filename) { Stream stream = addin.GetResourceStream (filename); if (stream == null) throw new ApplicationException ("Template " + filename + " not found"); XmlDocument doc = new XmlDocument(); try { doc.Load(stream); } finally { stream.Close (); } XmlElement config = doc.DocumentElement["TemplateConfiguration"]; originator = doc.DocumentElement.Attributes["Originator"].InnerText; created = doc.DocumentElement.Attributes["Created"].InnerText; lastmodified = doc.DocumentElement.Attributes["LastModified"].InnerText; name = GettextCatalog.GetString (config["_Name"].InnerText); category = config["Category"].InnerText; languagename = config["LanguageName"].InnerText; if (config["_Description"] != null) { description = GettextCatalog.GetString (config["_Description"].InnerText); } if (config["Icon"] != null) { icon = ResourceService.GetStockId (addin, config["Icon"].InnerText); } if (config["Wizard"] != null) { wizardpath = config["Wizard"].Attributes["path"].InnerText; } fileoptions = doc.DocumentElement["FileOptions"]; // load the files XmlElement files = doc.DocumentElement["TemplateFiles"]; XmlNodeList nodes = files.ChildNodes; foreach (XmlElement filenode in nodes) { FileDescriptionTemplate template = new FileDescriptionTemplate(filenode.Attributes["DefaultName"].InnerText + filenode.Attributes["DefaultExtension"].InnerText, filenode.InnerText); this.files.Add(template); } }
public static string GetStockIdFromResource(AddIn addin, string id) { if (!id.StartsWith ("res:")) return id; id = id.Substring (4); int aid = addins.IndexOf (addin); Hashtable hash; if (aid == -1) { aid = addins.Add (addin); hash = new Hashtable (); addinIcons.Add (hash); } else { hash = (Hashtable) addinIcons [aid]; } string sid = "__asm" + aid + "__" + id; if (!hash.Contains (sid)) { foreach (Assembly asm in addin.RuntimeLibraries.Values) { try { Gdk.Pixbuf pix = new Gdk.Pixbuf (asm, id); AddToIconFactory (sid, pix, Gtk.IconSize.Invalid); break; } catch {} } hash [sid] = sid; } return sid; }
void AddExtensions(AddIn.Extension extension) { DefaultAddInTreeNode localRoot = CreatePath(root, extension.Path); foreach (ICodon codon in extension.CodonCollection) { DefaultAddInTreeNode localPath = CreatePath(localRoot, codon.ID); if (localPath.Codon != null) { throw new DuplicateCodonException(codon.GetType().Name, codon.ID); } localPath.Codon = codon; localPath.ConditionCollection = (ConditionCollection)extension.Conditions[codon.ID]; } }
/// <summary> /// Removes an AddIn from the AddInTree. /// </summary> public void RemoveAddIn(AddIn addIn) { // TODO : Implement the RemoveAddInMethod throw new ApplicationException("Implement ME!"); }
/// <summary> /// Add a <see cref="AddIn"/> object to the tree, inserting all it's extensions. /// </summary> public void InsertAddIn(AddIn addIn) { addIns.Add(addIn); foreach (AddIn.Extension extension in addIn.Extensions) { AddExtensions(extension); } }
static StringCollection InsertAddIns(StringCollection addInFiles, out AddinError[] errors) { StringCollection retryList = new StringCollection(); ArrayList list = new ArrayList (); foreach (string addInFile in addInFiles) { AddIn addIn = new AddIn(); try { addIn.Initialize (addInFile); addInTree.InsertAddIn (addIn); } catch (CodonNotFoundException ex) { retryList.Add (addInFile); list.Add (new AddinError (addInFile, ex, false)); } catch (ConditionNotFoundException ex) { retryList.Add (addInFile); list.Add (new AddinError (addInFile, ex, false)); } catch (MissingDependencyException ex) { // Try to load the addin later. Maybe it depends on an // addin that has not yet been loaded. retryList.Add(addInFile); list.Add (new AddinError (addInFile, ex, false)); } catch (InvalidAssemblyVersionException ex) { retryList.Add (addInFile); list.Add (new AddinError (addInFile, ex, false)); } catch (Exception ex) { retryList.Add (addInFile); list.Add (new AddinError (addInFile, ex, false)); } } errors = (AddinError[]) list.ToArray (typeof(AddinError)); return retryList; }
static void LoadFileTemplate(AddIn addin, string filename) { FileTemplates.Add(new FileTemplate (addin, filename)); }
protected ProjectTemplate(AddIn addin, string fileName) { Stream stream = addin.GetResourceStream (fileName); if (stream == null) throw new ApplicationException ("Template " + fileName + " not found"); XmlDocument doc = new XmlDocument(); try { doc.Load(stream); } finally { stream.Close (); } originator = doc.DocumentElement.Attributes["originator"].InnerText; created = doc.DocumentElement.Attributes["created"].InnerText; lastmodified = doc.DocumentElement.Attributes["lastModified"].InnerText; XmlElement config = doc.DocumentElement["TemplateConfiguration"]; if (config["Wizard"] != null) { wizardpath = config["Wizard"].InnerText; } name = GettextCatalog.GetString (config["_Name"].InnerText); category = config["Category"].InnerText; if (config["LanguageName"] != null) languagename = config["LanguageName"].InnerText; if (config["_Description"] != null) { description = GettextCatalog.GetString (config["_Description"].InnerText); } if (config["Icon"] != null) { icon = ResourceService.GetStockId (addin, config["Icon"].InnerText); } if (doc.DocumentElement["Combine"] != null) { combineDescriptor = CombineDescriptor.CreateCombineDescriptor(doc.DocumentElement["Combine"]); } // Read Actions; if (doc.DocumentElement["Actions"] != null) { foreach (XmlElement el in doc.DocumentElement["Actions"]) { actions.Add(new OpenFileAction(el.Attributes["filename"].InnerText)); } } }
/// <summary> /// <para>Gets a value indicating whether the /// <see cref="AddInCollection"/> contains the specified <see cref="AddIn"/>.</para> /// </summary> /// <param name="value">The <see cref="AddIn"/> to locate.</param> /// <returns> /// <para><see langword="true"/> if the <see cref="AddIn"/> is contained in the collection; /// otherwise, <see langword="false"/>.</para> /// </returns> /// <seealso cref="AddInCollection.IndexOf"/> public bool Contains(AddIn value) { return List.Contains(value); }
/// <summary> /// <para>Adds a <see cref="AddIn"/> with the specified value to the /// <see cref="AddInCollection"/> .</para> /// </summary> /// <param name="value">The <see cref="AddIn"/> to add.</param> /// <returns> /// <para>The index at which the new element was inserted.</para> /// </returns> public int Add(AddIn value) { return List.Add(value); }
/// <summary> /// <para> Removes a specific <see cref="AddIn"/> from the /// <see cref="AddInCollection"/> .</para> /// </summary> /// <param name="value">The <see cref="AddIn"/> to remove from the <see cref="AddInCollection"/> .</param> /// <returns><para>None.</para></returns> /// <exception cref="System.ArgumentException"><paramref name="value"/> is not found in the Collection. </exception> public void Remove(AddIn value) { List.Remove(value); }
/// <summary> /// <para>Returns the index of a <see cref="AddIn"/> in /// the <see cref="AddInCollection"/> .</para> /// </summary> /// <param name="value">The <see cref="AddIn"/> to locate.</param> /// <returns> /// <para>The index of the <see cref="AddIn"/> of <paramref name="value"/> in the /// <see cref="AddInCollection"/>, if found; otherwise, -1.</para> /// </returns> /// <seealso cref="AddInCollection.Contains"/> public int IndexOf(AddIn value) { return List.IndexOf(value); }