public TmNode(TmNodeType nodeType, string name, TmNode parent, ThemeData data, Metadata metadata, string desc, DateTime? pubDate) { _type = nodeType; _name = name; Parent = parent; _pubDate = pubDate.HasValue ? pubDate.Value : DefaultPubDate; //_readonly = (Parent == null) ? false : Parent._readonly; _description = desc; // Always create a data and Metadata object, else data binding in properties form won't work. _data = data ?? new ThemeData(); _data.PropertyChanged += Data_PropertyChanged; Metadata = metadata ?? new Metadata(); Metadata.PropertyChanged += Metadata_PropertyChanged; if (_type == TmNodeType.ThemeList) { Author = new ThemeListAuthor(); _status = ThemeListStatus.Created; _dataStore = TryToGetDataStore(); // TryToGetDataStore() will set _readonly for theme ThemeList = this; } }
private bool _issueUpdates = true; //Should this object issue update events or not, inherited from parent. public TmNode(TmNodeType nodeType) : this(nodeType, null, null, null, null, null, null) { }
public TmNode(TmNodeType nodeType, string name) : this(nodeType, name, null, null, null, null, null) { }
// FIXME - work needs to be done on the UI to put this new node in the Themelist treeview private void SaveAs(string path, string version) { Debug.Assert(IsThemeList, "SaveAs... is only valid for a themelist"); //Debug.Assert(HasData, "Theme List has no data object"); // create backup of current settings in case save doesn't work. ThemeData oldData = (ThemeData)Data.Clone(); TmNodeType oldKind = Type; Store oldDatastore = _dataStore; ThemeListStatus oldStatus = _status; string ext = Path.GetExtension(path); if (ext != null) ext = ext.ToLower(); switch (ext) { case ".tmz": throw new NotImplementedException(); case ".tml": case ".xml": _dataStore = XmlStore.CreateNew(path, version); break; case ".mdb": _dataStore = MdbStore.CreateNew(path, version); break; default: throw new ArgumentException(path + " is not a supported theme list file type."); } if (_dataStore == null) { _dataStore = oldDatastore; throw new ArgumentException("Unable to create a Theme List at " + path); } Data.Path = path; Data.Type = ext.Substring(1, 3); Data.Version = version; _type = TmNodeType.ThemeList; _status = ThemeListStatus.Dirty; try { Save(); } catch (Exception) { Data = oldData; _type = oldKind; _dataStore = oldDatastore; _status = oldStatus; throw; } IsReadOnly = false; }