Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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();
        }