Beispiel #1
0
        // #LEGACY
        public void Cleanup(CodeSnippetCollectionOld collection)
        {
            if (collection == null)
            {
                return;
            }

            foreach (var _snip in collection.Items)
            {
                if (_snip == null)
                {
                    continue;
                }

                if (!string.IsNullOrEmpty(_snip.Code))
                {
                    if (_snip.Code.Contains("Ã"))
                    {
                        _snip.Code = "";
                    }
                }
                if (_snip.RTF != null)
                {
                    if (_snip.RTF.Contains("Ã"))
                    {
                        _snip.RTF = "";
                    }
                }
                if (!string.IsNullOrEmpty(_snip.Name))
                {
                    if (_snip.Name.Contains("Ã"))
                    {
                        _snip.Name = "";
                    }
                }
                if (!string.IsNullOrEmpty(_snip.Path))
                {
                    if (_snip.Path.Contains("Ã"))
                    {
                        _snip.Path = "";
                    }
                }
            }

            // Ã
        }
Beispiel #2
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();
        }