private void Defaults() { CodeSnippets.Add(CodeSnippet.TrashcanSnippet()); CodeSnippets.Add(CodeSnippet.ClipboardMonitorSnippet()); var _root = CodeSnippet.NewRoot("", CodeType.Folder, Constants.SNIPPETS); CodeSnippets.Add(_root); }
public static CodeSnippet TrashcanSnippet() { var _snip = new CodeSnippet() { Code = string.Empty, CodeType = CodeType.System, Id = Constants.TRASHCAN, Name = Constants.TRASHCAN_TITLE }; _snip.SetPath(Constants.TRASHCAN_TITLE, out bool _changed); return(_snip); }
public static CodeSnippet NewRoot(string text, CodeType codetype, string name) { var _snip = new CodeSnippet() { CodeType = codetype, Locked = false, Name = name }; _snip.SetCode(text, out bool _changed); _snip.SetRtf("", out _changed); _snip.SetPath(name, out _changed); return(_snip); }
public static CodeSnippet ClipboardMonitorSnippet() { var _snip = new CodeSnippet() { CodeType = CodeType.System, Name = Constants.CLIPBOARDMONITOR_TITLE, Id = Constants.CLIPBOARDMONITOR }; _snip.SetCode("", out bool _changed); _snip.SetRtf("", out _changed); _snip.SetPath(Constants.CLIPBOARDMONITOR_TITLE, out _changed); return(_snip); }
public CodeSnippet Clone() { CodeSnippet _clone = new CodeSnippet(); _clone.AlarmActive = AlarmActive; _clone.AlarmDate = AlarmDate; if (Blob != null) { Blob.CopyTo(_clone.Blob, 0); } _clone.CacheCode = null; _clone.CacheDefaultChildCode = null; _clone.CacheDefaultChildRtf = null; _clone.CachePath = null; _clone.CacheRTF = null; _clone.Code = Code; _clone.CodeLastModificationDate = CodeLastModificationDate; _clone.CodeType = CodeType; _clone.CreationDate = CreationDate; _clone.CurrentLine = CurrentLine; _clone.DefaultChildCode = DefaultChildCode; _clone.DefaultChildCodeType = DefaultChildCodeType; _clone.DefaultChildCodeTypeEnabled = DefaultChildCodeTypeEnabled; _clone.DefaultChildName = DefaultChildName; _clone.DefaultChildRtf = DefaultChildRtf; _clone.Expanded = Expanded; _clone.Flag = Flag; _clone.HtmlPreview = HtmlPreview; _clone.Id = Guid.NewGuid().ToString(); _clone.Name = _clone.Id; _clone.Important = Important; _clone.Locked = Locked; _clone.Order = Order; _clone.Path = Path; _clone.ReferenceLinkId = ReferenceLinkId; _clone.RTF = RTF; _clone.RTFAlwaysWhite = RTFAlwaysWhite; _clone.RTFOwnTheme = RTFOwnTheme; _clone.RTFTheme = RTFTheme; _clone.ShortCutKeys = ShortCutKeys; _clone.Wordwrap = Wordwrap; return(_clone); }
public CodeSnippetCollection() { Items = new List <CodeSnippet> { CodeSnippet.TrashcanSnippet() }; }
public void LoadLegacy(CodeSnippetCollectionOld collection) { BeginUpdate(); Cleanup(collection); Counter = collection.Counter; CodeSnippetCollection _newCollection = new CodeSnippetCollection(); _newCollection.Items.Clear(); foreach (CodeSnippetOld _old in collection.Items) { if (string.IsNullOrWhiteSpace(_old.Path)) { _old.Path = Constants.UNNAMED; } CodeSnippet _new = new CodeSnippet() { DefaultChildCodeType = _old.DefaultChildCodeType, DefaultChildCodeTypeEnabled = _old.DefaultChildCodeTypeEnabled, DefaultChildName = _old.DefaultChildName, Name = _old.Name, Blob = _old.Blob, AlarmActive = _old.AlarmActive, AlarmDate = _old.AlarmDate, CodeLastModificationDate = _old.CodeLastModificationDate, CodeType = _old.CodeType, CreationDate = _old.CreationDate, CurrentLine = _old.CurrentLine, Expanded = _old.Expanded, Flag = _old.Flag, HtmlPreview = _old.HtmlPreview, Id = _old.Id, Important = _old.Important, Locked = _old.Locked, Order = _old.Order, ReferenceLinkId = _old.ReferenceLinkId, RTFAlwaysWhite = _old.RTFAlwaysWhite, RTFOwnTheme = _old.RTFOwnTheme, RTFTheme = _old.RTFTheme, ShortCutKeys = _old.ShortCutKeys, Wordwrap = _old.Wordwrap }; if (_old.Path.Equals(@"Trashcan")) { } if (_old.Path.Equals(@"C#\Classes\VersionNumber")) { } bool _changed = false; _new.SetPath(_old.Path, out _changed); _new.SetCode(_old.Code, out _changed); _new.SetRtf(_old.RTF, out _changed); _new.SetDefaultChildCode(_old.DefaultChildCode, out _changed); _new.SetDefaultChildRtf(_old.DefaultChildRtf, out _changed); _newCollection.Items.Add(_new); } TreeNodes.Clear(); CodeSnippets.Clear(); CodeSnippets.AddRange(_newCollection.Items); if (Counter < collection.Items.Count) { Counter = collection.Items.Count; } if (ClipboardMonitor != null) { ClipboardMonitor.Order = -1; ClipboardMonitor.SetPath("Clipboard Monitor", out bool _changed); } if (Trashcan != null) { Trashcan.Order = -2; Trashcan.SetPath("Trashcan", out bool _changed); } DocumentId = Guid.NewGuid(); // Legacy always new DocumentId EndUpdate(); }