Esempio n. 1
0
        internal void UpdateStyle(BaseStyle activeStyle, StylePropertyType stylePropertyType, object value)
        {
            LevelStyle      levelStyle  = activeStyle as LevelStyle;
            InlineNoteStyle inlineStyle = activeStyle as InlineNoteStyle;

            WalkRecursively(__FakeRootNote,
                            delegate(OutlinerNote note, out bool shouldWalkSubnotes, out bool shouldContinue)
            {
                shouldContinue     = true;
                shouldWalkSubnotes = true;

                if (activeStyle.StyleType == StyleType.Inline)
                {
                    if (!note.HasInlineNote)
                    {
                        return;
                    }

                    TextRange range = new TextRange(note.InlineNoteDocument.ContentStart, note.InlineNoteDocument.ContentEnd);

                    UndoManager.PushUndoAction(new Undo.UndoFlowDocumentFormatting(note, 0, true, false));
                    LevelStyle.ApplyPropertyToRange(range, stylePropertyType, value);
                    LevelStyle.ApplyPropertyToFlowDocument(note.InlineNoteDocument, stylePropertyType, value);
                }
                else    // if (activeStyle.StyleType == StyleType.Level)
                {
                    if (note.Level == levelStyle.Level || levelStyle.Level == -1)
                    {
                        ApplyStylePropertyForAllColumns(stylePropertyType, value, levelStyle, note);
                    }
                }
            });
        }
Esempio n. 2
0
        private void ApplyStylePropertyForAllColumns(StylePropertyType stylePropertyType, object value, LevelStyle levelStyle, OutlinerNote note)
        {
            for (int i = 0; i < note.Columns.Count; i++)
            {
                if (note.Columns[i].DataType != ColumnDataType.RichText)
                {
                    continue;
                }

                FlowDocument flowDocument = (FlowDocument)note.Columns[i].ColumnData;
                TextRange    range        = new TextRange(flowDocument.ContentStart, flowDocument.ContentEnd);

                UndoManager.PushUndoAction(new Undo.UndoFlowDocumentFormatting(note, i, false, false));
                LevelStyle.ApplyPropertyToRange(range, stylePropertyType, value);
                LevelStyle.ApplyPropertyToFlowDocument(flowDocument, stylePropertyType, value);

                // If document style gets modified, level style should be applied afterwards
                if (levelStyle.Level == -1)
                {
                    LevelStyle currentLevelStyle = note.Document.Styles.GetStyleForLevel(note.Level);
                    for (int si = 0; si < currentLevelStyle.Properties.Count; si++)
                    {
                        if (currentLevelStyle.Properties[si].PropertyType == stylePropertyType)
                        {
                            LevelStyle.ApplyPropertyToRange(range,
                                                            stylePropertyType,
                                                            currentLevelStyle.Properties[si].Value);

                            LevelStyle.ApplyPropertyToFlowDocument(
                                flowDocument,
                                stylePropertyType,
                                currentLevelStyle.Properties[si].Value);
                        }
                    }
                }
            }
        }