Beispiel #1
0
        void DecorateClassificationTypes()
        {
            if (_ClassificationFormatMap.IsInBatchUpdate)
            {
                return;
            }
            _ClassificationFormatMap.BeginBatchUpdate();
            var defaultSize = _ClassificationFormatMap.DefaultTextProperties.FontRenderingEmSize;

            foreach (var item in _ClassificationFormatMap.CurrentPriorityOrder)
            {
                StyleBase style;
                TextFormattingRunProperties textFormatting;
                if (item == null ||
                    (style = FormatStore.GetStyle(item.Classification)) == null ||
                    (textFormatting = FormatStore.GetBackupFormatting(item.Classification)) == null)
                {
                    continue;
                }
                _ClassificationFormatMap.SetTextProperties(item, SetProperties(textFormatting, style, defaultSize));
            }
            _ClassificationFormatMap.EndBatchUpdate();
            Debug.WriteLine("Decorated");
        }
Beispiel #2
0
        void DecorateClassificationTypes(IEnumerable <IClassificationType> classifications, bool fullUpdate)
        {
            if (_ClassificationFormatMap.IsInBatchUpdate)
            {
                return;
            }
            var       defaultSize = _ClassificationFormatMap.DefaultTextProperties.FontRenderingEmSize;
            var       updated     = new Dictionary <IClassificationType, TextFormattingRunProperties>();
            StyleBase style;
            TextFormattingRunProperties textFormatting;

            foreach (var item in classifications)
            {
                if (item == null ||
                    (style = FormatStore.GetOrCreateStyle(item)) == null ||
                    (textFormatting = FormatStore.GetOrSaveBackupFormatting(item, _Initialized == false)) == null)
                {
                    continue;
                }
                var p = SetProperties(textFormatting, style, defaultSize);
                if (p != textFormatting || fullUpdate)
                {
                    updated[item] = p;
                }
            }
            var refreshList = new List <(IClassificationType type, TextFormattingRunProperties property)>();

            foreach (var item in updated)
            {
                foreach (var subType in item.Key.GetSubTypes())
                {
                    if (updated.ContainsKey(subType) == false)
                    {
                        if ((style = FormatStore.GetOrCreateStyle(subType)) == null ||
                            (textFormatting = FormatStore.GetBackupFormatting(subType)) == null)
                        {
                            continue;
                        }
                        refreshList.Add((subType, SetProperties(textFormatting, style, defaultSize)));
                    }
                }
            }
            if (refreshList.Count > 0)
            {
                foreach (var item in refreshList)
                {
                    updated[item.type] = item.property;
                }
            }
            if (updated.Count > 0)
            {
                _ClassificationFormatMap.BeginBatchUpdate();
                foreach (var item in updated)
                {
                    _ClassificationFormatMap.SetTextProperties(item.Key, item.Value);
                    Debug.WriteLine("Update format: " + item.Key.Classification);
                }
                _ClassificationFormatMap.EndBatchUpdate();
                Debug.WriteLine($"Decorated {updated.Count} formats");
            }
        }