protected static void FireRecordDeleted(object sender, BaseRecord rec) { if (!HoldUpdates && RecordDeleted != null) { RecordDeleted(sender, new RecordChangeEventArgs(rec)); } }
public override bool DeleteRecord(BaseRecord br) { var sr = br as SubRecord; if (sr == null) { return false; } return this.SubRecords.Remove(sr); }
public override void AddRecord(BaseRecord br) { var p = br as Plugin; if (p != null) { p.Parent = this; this.pluginList.Add(p); } FireRecordListUpdate(this, null); }
public override void InsertRecord(int idx, BaseRecord br) { var sr = br as SubRecord; if (sr == null) { throw new TESParserException("Record to add was not of the correct type." + Environment.NewLine + "Records can only hold Subrecords."); } sr.Parent = this; this.SubRecords.Insert(idx, sr); }
public override void InsertRecord(int idx, BaseRecord br) { var r = br as Plugin; r.Parent = this; if (idx < 0 || idx > this.pluginList.Count) { idx = this.pluginList.Count; } this.pluginList.Insert(idx, r); FireRecordListUpdate(this, null); }
public override void AddRecord(BaseRecord br) { var r = br as Rec; if (r == null) { throw new TESParserException("Record to add was not of the correct type." + Environment.NewLine + "Groups can only hold records or other groups."); } r.Parent = this; this.records.Add(r); FireRecordListUpdate(this, this); }
public override bool DeleteRecord(BaseRecord br) { var p = br as Plugin; if (p != null) { p.Parent = null; bool ok = this.pluginList.Remove(p); FireRecordListUpdate(this, this); return(ok); } return(false); }
public Plugin GetPlugin() { BaseRecord tn = Parent; while (!(tn is Plugin) && tn != null) { tn = tn.Parent; } if (tn != null) { return(tn as Plugin); } return(null); }
public override void InsertRecord(int idx, BaseRecord br) { var r = br as Rec; if (r == null) { throw new TESParserException("Record to add was not of the correct type." + Environment.NewLine + "Groups can only hold records or other groups."); } r.Parent = this; if (idx < 0 || idx > this.records.Count) { idx = this.records.Count; } this.records.Insert(idx, r); FireRecordListUpdate(this, this); }
public void UpdateRecord(BaseRecord record) { if (record == null) { this.UpdateText(string.Empty); return; } try { string html = TESVSnip.UI.Rendering.HtmlRenderer.GetDescription(record); UpdateText(html); } catch (Exception ex) { MessageBox.Show(ex.Message, Resources.WarningText); } }
public void UpdateRecord(BaseRecord sc) { if (sc == null) { this.UpdateText(string.Empty); return; } FontLangInfo defLang; if (!Encoding.TryGetFontInfo(Domain.Properties.Settings.Default.LocalizationName, out defLang)) { defLang = new FontLangInfo(1252, 1033, 0); } var rb = new RTFBuilder(RTFFont.Arial, 16, defLang.lcid, defLang.charset); sc.GetFormattedHeader(rb); sc.GetFormattedData(rb); this.rtfInfo.Rtf = rb.ToString(); }
public static Plugin GetPluginFromNode(BaseRecord node) { BaseRecord tn = node; if (tn is Plugin) { return (Plugin)tn; } while (!(tn is Plugin) && tn != null) { tn = tn.Parent; } if (tn != null) { return tn as Plugin; } return null; }
public override bool DeleteRecord(BaseRecord br) { var r = br as Rec; if (r == null) { return(false); } bool ok = this.records.Remove(r); if (ok) { r.Parent = null; } FireRecordListUpdate(this, this); FireRecordDeleted(this, r); return(ok); }
public override void AddRecord(BaseRecord br) { try { var r = br as Rec; if (r == null) { throw new TESParserException("Record to add was not of the correct type." + Environment.NewLine + "Plugins can only hold Groups or Records."); } r.Parent = this; this.records.Add(r); this.InvalidateCache(); FireRecordListUpdate(this, this); } catch (Exception) { throw; } }
public override bool DeleteRecord(BaseRecord br) { var r = br as Rec; if (r == null) { return(false); } bool result = this.records.Remove(r); if (result) { r.Parent = null; } this.InvalidateCache(); FireRecordDeleted(this, r); FireRecordListUpdate(this, this); return(result); }
public static string GetDescription(BaseRecord rec) { if (rendererImpl == null) { var sb = new StringBuilder(); Extensions.StringRenderer.GetFormattedData(rec, sb); return sb.ToString(); } try { var kwargs = new Dictionary<string, object>(StringComparer.InvariantCultureIgnoreCase); kwargs["title"] = "Record"; kwargs["css"] = new string[] {Path.ChangeExtension(RendererPyPath, ".css")}; return rendererImpl.Render(rec, kwargs); } catch (Exception ex) { return ex.ToString(); //return Extensions.StringRenderer.GetDesc(rec); } }
public virtual int IndexOf(BaseRecord br) { return(-1); }
public abstract void AddRecord(BaseRecord br);
public abstract bool DeleteRecord(BaseRecord br);
private Plugin GetPluginFromNode(BaseRecord node) { var tn = node; var pluginFromNode = tn as Plugin; if (pluginFromNode != null) { return pluginFromNode; } while (!(tn is Plugin) && tn != null) { tn = tn.Parent; } if (tn != null) { return tn as Plugin; } return null; }
public virtual void InsertRecord(int index, BaseRecord br) { this.AddRecord(br); }
protected static void FireRecordListUpdate(object sender, BaseRecord rec) { if (!HoldUpdates && ChildListChanged != null) { ChildListChanged(sender, new RecordChangeEventArgs(rec)); } }
public static void giveBaseRecordNewFormID(BaseRecord rec, bool updateReference, ref uint formCount, ref uint refCount) { if (rec is Record) { giveRecordNewFormID((Record)rec, updateReference, ref formCount, ref refCount); } else if (rec is GroupRecord) { foreach (BaseRecord rec2 in ((GroupRecord)rec).Records) { giveBaseRecordNewFormID(rec2, updateReference, ref formCount, ref refCount); } } }
/// <summary> /// Actually perform the copy /// </summary> /// <param name="src"></param> /// <returns></returns> public int CopyRecordsTo(BaseRecord[] src) { int count = 0; PrepMasters(src); var dstRec = this.Clone(src.Where(x => !LooseGroups.Contains(x.Name)), true).ToArray(); if (dstRec.All(x => x is Record)) { // put records into appropriate groups var groups = plugin.Records.OfType<GroupRecord>().ToList(); var lookup = dstRec.GroupBy(r => r.Name) .Select(g => new { key = g.Key, value = g.ToArray() }) .ToLookup(k => k.key, v => v.value); foreach (var kvp in lookup) { if (LooseGroups.Contains(kvp.Key)) { plugin.AddRecords(dstRec); } else { var gr = groups.FirstOrDefault(x => x.ContentsType == kvp.Key); if (gr == null) { gr = new GroupRecord(kvp.Key); plugin.AddRecord(gr); } foreach (var list in kvp) { gr.AddRecords(list); } } } } else { plugin.AddRecords(dstRec); } // handle loose groups by creating copy of parent groups foreach (var srcRec in src.Where(x => LooseGroups.Contains(x.Name))) { var dstnodes = new Stack<BaseRecord>(); dstnodes.Push(this.Clone(srcRec, true)); for (var n = srcRec.Parent; n is GroupRecord; n = n.Parent) { dstnodes.Push(n.Clone(recursive: false)); } var par = plugin as IGroupRecord; foreach (var baseRecord in dstnodes) { if (par == null) { break; } if (baseRecord is GroupRecord) { var gr = baseRecord as GroupRecord; var pargr = par.Records.OfType<GroupRecord>().FirstOrDefault(x => x.IsEquivalent(gr)); if (pargr != null) { par = pargr; continue; } } par.AddRecord(baseRecord); par = baseRecord as IGroupRecord; } count += dstnodes.Count; } return count; }
/// <summary> /// Copy Records to new plugin. By default make as overrides /// </summary> /// <param name="src"></param> /// <param name="dst"></param> /// <param name="bOverride">Make record an override in the new location</param> /// <returns></returns> public static int CopyRecordsTo(BaseRecord[] src, IGroupRecord dst, bool bOverride = true) { int count = 0; if (src != null && dst != null) { if (dst is Plugin) { var plugin = (Plugin)dst; count = new CloneTool(plugin, bOverride).CopyRecordsTo(src); } else { var dstRec = src.Select(x => x.Clone()).ToArray(); dst.AddRecords(dstRec); count += dstRec.Count(); } } return count; }
public static void giveBaseRecordNewFormID(BaseRecord rec, bool updateReference) { uint formCount = 0, refCount = 0; giveBaseRecordNewFormID(rec, updateReference, ref formCount, ref refCount); }
private bool findDuplicateFormIDs(BaseRecord tn, Dictionary<uint, Record> ids) { if (tn is Record) { var r2 = (Record) tn; if (ids.ContainsKey(r2.FormID)) { this.PluginTree.SelectedRecord = tn; MessageBox.Show("Record duplicates " + ids[r2.FormID].DescriptiveName); ids.Clear(); return true; } else { ids.Add(r2.FormID, r2); } } else { foreach (BaseRecord tn2 in tn.Records) { this.findDuplicateFormIDs(tn2, ids); } } return false; }
public override int IndexOf(BaseRecord br) { return this.records.IndexOf(br as Rec); }
public override bool DeleteRecord(BaseRecord br) { var r = br as Rec; if (r == null) { return false; } bool result = this.records.Remove(r); if (result) { r.Parent = null; } this.InvalidateCache(); FireRecordDeleted(this, r); FireRecordListUpdate(this, this); return result; }
public override bool DeleteRecord(BaseRecord br) { var r = br as Rec; if (r == null) { return false; } bool ok = this.records.Remove(r); if (ok) { r.Parent = null; } FireRecordListUpdate(this, this); FireRecordDeleted(this, r); return ok; }
public RecordChangeEventArgs(BaseRecord rec) { this.record = rec; }
BaseRecord Clone(BaseRecord record, bool bRecursive) { var p = GetPluginFromNode(record); PluginInfo info; if (!pluginMap.TryGetValue(p, out info)) pluginMap.Add(p, info = new PluginInfo() { Masters = p.GetMasters() }); var result = record.Clone(recursive: bRecursive); foreach (var rec in result.Enumerate().OfType<Record>()) { uint newid; if (info.References.TryGetValue(rec.FormID, out newid) && rec.FormID != newid) rec.FormID = newid; // now handle child references rec.MatchRecordStructureToRecord(); foreach (var elem in rec.SubRecords .SelectMany(sr => sr.EnumerateElements()) .Where(elem => elem.Structure != null && elem.Structure.type == ElementValueType.FormID) ) { var value = elem.GetValue<uint>(); if (info.References.TryGetValue(value, out newid) && value != newid) elem.AssignValue<uint>(newid); } } return result; }
public void RefreshObject(BaseRecord record) { this.PluginTree.RefreshObject(record); }
public override int IndexOf(BaseRecord br) { return(this.records.IndexOf(br as Rec)); }
public override bool DeleteRecord(BaseRecord br) { var p = br as Plugin; if (p != null) { p.Parent = null; bool ok = this.pluginList.Remove(p); FireRecordListUpdate(this, this); return ok; } return false; }
public override void AddRecord(BaseRecord br) { throw new TESParserException("Subrecords cannot contain additional data."); }
public override int IndexOf(BaseRecord br) { return(this.pluginList.IndexOf(br as Plugin)); }
public override bool DeleteRecord(BaseRecord br) { return(false); }
public override int IndexOf(BaseRecord br) { return this.pluginList.IndexOf(br as Plugin); }
public virtual int IndexOf(BaseRecord br) { return -1; }