/// <summary> /// Creates a new Theme List Node based on the contents of the current Category Node /// </summary> /// <param name="path">File system location for the new theme list.</param> /// <returns>A new theme list node</returns> /// <exception cref="System.IO.IOException">Path is not valid, or cannot be written to</exception> public ThemeListNode ToThemeList(string path) { var newNode = new ThemeListNode(this.Name, path, this.Metadata.DeepCopy(), this.Description); var author = new ThemeListAuthor(); author["Name"] = Environment.UserName; newNode.Author = author; foreach (var child in Children) newNode.Add(child.DeepCopy()); newNode.SaveAs(path); return newNode; }
private void ValidatePathToTarget(IThemeListLoader loader, ThemeListNode themeList) { IsInitialized = false; Target = loader.LoadedNode(themeList, PathToNode); IsInitialized = true; if (Target == null) { State = ShortcutState.Broken; loader.ShortcutIsBroken(this); } else { State = ShortcutState.Verified; } }
private static bool TryToLoadThemeList(ThemeListNode node) { //FIXME - need to load as much as possible on exception. if (node == null) return false; Trace.TraceInformation("{0}: Start building node {1}", DateTime.Now, node.Name); Stopwatch time = Stopwatch.StartNew(); try { //FIXME: do I need to do any locking on this node? node.Build(); } catch (Exception ex) { string msg = string.Format("Error Loading Theme\nMessage: {0}\nMethod: {1}", ex.Message, ex.TargetSite); MessageBox.Show(msg, "oh, no!"); return false; } time.Stop(); Trace.TraceInformation("{0}: Done building node {1} - Elapsed Time: {2}", DateTime.Now, node.Name, time.Elapsed); return true; }
private void LoadTreeFromXML(XElement xele, TmTreeView tv) { TmNode node; foreach (XElement xnode in xele.Elements(ThemeListNode.TypeString)) { node = new ThemeListNode(); node.Load(xnode, false); // Add only the first node tv.Add(node); } foreach (XElement xnode in xele.Elements(CategoryNode.TypeString)) { node = new CategoryNode(); node.BeginUpdate(); node.Load(xnode, true); // Add entire branch node.UpdateAge(); node.EndUpdate(); tv.Add(node); } foreach (XElement xnode in xele.Elements(ThemeNode.TypeString)) { node = new ThemeNode(); node.BeginUpdate(); node.Load(xnode, true); // Add entire branch node.UpdateAge(); node.EndUpdate(); tv.Add(node); } tv.TextSortInit((string)xele.Attribute("sortorder")); }
private void PopulateThemeListPropertyPanel(PropertiesForm form, ThemeListNode node) { Debug.Assert(node.Author != null, "Themelist node has no author object"); Debug.Assert(node.Metadata != null, "TMNode node has no metadata object"); form.themelistFile.Text = node.FilePath; form.themelistName.DataBindings.Clear(); form.themelistMetadata.DataBindings.Clear(); form.themelistDescription.DataBindings.Clear(); form.themelistName.DataBindings.Add(new Binding("Text", node, "Name")); form.themelistMetadata.DataBindings.Add(new Binding("Text", node.Metadata, "Path")); form.themelistDescription.DataBindings.Add(new Binding("Text", node, "Description")); if (node.Author != null) { string value; node.Author.TryGetValue("Name", out value); form.themelistAuthorName.Text = value; node.Author.TryGetValue("Title", out value); form.themelistAuthorTitle.Text = value; node.Author.TryGetValue("Organization", out value); form.themelistAuthorOrg.Text = value; node.Author.TryGetValue("Address1", out value); form.themelistAuthorAddress1.Text = value; node.Author.TryGetValue("Address2", out value); form.themelistAuthorAddress2.Text = value; node.Author.TryGetValue("Phone", out value); form.themelistAuthorPhone.Text = value; node.Author.TryGetValue("Email", out value); form.themelistAuthorEmail.Text = value; } }
private void Save(ThemeListNode node) { try { node.Save(); } catch (Exception ex) { MessageBox.Show(string.Format("Unable to save themelist '{0}'\n in file '{1}'\n{2}", node.Name, node.FilePath, ex.Message), "Oh no!"); } }