本文整理汇总了C#中System.Windows.Documents.Paragraph.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Paragraph.SetValue方法的具体用法?C# Paragraph.SetValue怎么用?C# Paragraph.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.Paragraph
的用法示例。
在下文中一共展示了Paragraph.SetValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Clone
private Block Clone(Block block)
{
var paragraph = block as Paragraph;
if (paragraph != null)
{
var newParagraph = new Paragraph();
if (DependencyPropertyHelper.GetValueSource(paragraph, Paragraph.PaddingProperty).BaseValueSource != BaseValueSource.Default)
newParagraph.SetValue(Paragraph.PaddingProperty, paragraph.Padding);
if (DependencyPropertyHelper.GetValueSource(paragraph, Paragraph.MarginProperty).BaseValueSource != BaseValueSource.Default)
newParagraph.SetValue(Paragraph.MarginProperty, paragraph.Margin);
if (DependencyPropertyHelper.GetValueSource(paragraph, Paragraph.TextAlignmentProperty).BaseValueSource != BaseValueSource.Default)
newParagraph.SetValue(Paragraph.TextAlignmentProperty, paragraph.TextAlignment);
CopyProperties(paragraph, newParagraph);
foreach (var inline in paragraph.Inlines)
newParagraph.Inlines.Add(Clone(inline));
return newParagraph;
}
throw new NotSupportedException();
}
示例2: GetSearchResultParagraph
protected static Paragraph GetSearchResultParagraph(string source, string key, Brush keyColor, double fontSize, Boolean ignoreCase = false)
{
if (String.IsNullOrEmpty(key))
{
Paragraph p = new Paragraph();
p.SetValue(TextElement.FontSizeProperty, fontSize);
Run run = new Run {Text = source};
p.Inlines.Add(run);
return p;
}
string pattern = GetRegexPattern(key);
Regex regex = ignoreCase ? new Regex(pattern, RegexOptions.IgnoreCase) : new Regex(pattern);
string[] collection = regex.Split(source);
Paragraph _paragraph = new Paragraph();
_paragraph.SetValue(TextElement.FontSizeProperty, fontSize);
foreach (string t in collection)
{
if (String.IsNullOrEmpty(t))
continue;
bool isKey = IsKey(key, t, ignoreCase);
Run run = new Run {Text = t};
if (isKey)
{
run.Foreground = keyColor;
}
_paragraph.Inlines.Add(run);
}
return _paragraph;
}
示例3: AddCellCopy
// Creates a new cell copying all its properties from a currentRow.
// RowSpan property is not copied; it's set to default value of 1.
// The new cell as added to a newRow (at the endPosition of its Cells collection).
private static TableCell AddCellCopy(TableRow newRow, TableCell currentCell, int cellInsertionIndex, bool copyRowSpan, bool copyColumnSpan)
{
Invariant.Assert(currentCell != null, "null check: currentCell");
TableCell newCell = new TableCell();
// Add the cell to a newRow's cell collection
// It's good to do it here before inserting inline formatting elements
// to avoid unnecessary TextContainer creation and content copying.
if (cellInsertionIndex < 0)
{
newRow.Cells.Add(newCell);
}
else
{
newRow.Cells.Insert(cellInsertionIndex, newCell);
}
// Copy all properties
LocalValueEnumerator properties = currentCell.GetLocalValueEnumerator();
while (properties.MoveNext())
{
LocalValueEntry propertyEntry = properties.Current;
if (propertyEntry.Property == TableCell.RowSpanProperty && !copyRowSpan ||
propertyEntry.Property == TableCell.ColumnSpanProperty && !copyColumnSpan)
{
// Skipping table structuring properties when requested
continue;
}
// Copy a property if it is not ReadOnly
if (!propertyEntry.Property.ReadOnly)
{
newCell.SetValue(propertyEntry.Property, propertyEntry.Value);
}
}
// Copy a paragraph for a cell
if (currentCell.Blocks.FirstBlock != null)
{
Paragraph newParagraph = new Paragraph();
// Transfer all known formatting properties that a locally set on a sourceBlock
Paragraph sourceParagraph = currentCell.Blocks.FirstBlock as Paragraph;
if (sourceParagraph != null)
{
DependencyProperty[] inheritableProperties = TextSchema.GetInheritableProperties(typeof(Paragraph));
DependencyProperty[] nonInheritableProperties = TextSchema.GetNoninheritableProperties(typeof(Paragraph));
for (int i = 0; i < nonInheritableProperties.Length; i++)
{
DependencyProperty property = nonInheritableProperties[i];
object value = sourceParagraph.ReadLocalValue(property);
if (value != DependencyProperty.UnsetValue)
{
newParagraph.SetValue(property, value);
}
}
for (int i = 0; i < inheritableProperties.Length; i++)
{
DependencyProperty property = inheritableProperties[i];
object value = sourceParagraph.ReadLocalValue(property);
if (value != DependencyProperty.UnsetValue)
{
newParagraph.SetValue(property, value);
}
}
}
// Add paragraph to a cell
newCell.Blocks.Add(newParagraph);
}
return newCell;
}