次のコードスニペットは、書式設定機能に使用されるコードを示しています。
C# |
コードのコピー
|
---|---|
rtb.Selection.Foreground = newSolidColorBrush(Colors.Red); Highlight (background) color rtb.Selection.InlineBackground = newSolidColorBrush(Colors.Yellow); Toggle Bold if(rtb.Selection.FontWeight != null&& rtb.Selection.FontWeight.Value.Weight == FontWeights.Bold.Weight) { rtb.Selection.FontWeight = FontWeights.Normal; } else { rtb.Selection.FontWeight = FontWeights.Bold; } |
C# |
コードのコピー
|
---|---|
if(rtb.Selection.FontStyle != null&& rtb.Selection.FontStyle == FontStyle.Italic) { rtb.Selection.FontStyle = FontStyle.Normal; } else { rtb.Selection.FontStyle = FontStyle.Italic; } |
C# |
コードのコピー
|
---|---|
var range = rtb.Selection; var collection = new C1TextDecorationCollection(); if (range.TextDecorations == null) { collection.Add(C1TextDecorations.Underline[0]); } else if (!range.TextDecorations.Contains(C1TextDecorations.Underline[0])) { foreach (var decoration in range.TextDecorations) collection.Add(decoration); collection.Add(C1TextDecorations.Underline[0]); } else { foreach (var decoration in range.TextDecorations) collection.Add(decoration); collection.Remove(C1TextDecorations.Underline[0]); if (collection.Count == 0) collection = null; } range.TextDecorations = collection; |
C# |
コードのコピー
|
---|---|
rtb.Selection.InlineBackground = null; rtb.Selection.Foreground = rtb.Foreground; rtb.Selection.FontWeight = FontWeights.Normal; rtb.Selection.FontStyle = FontStyle.Normal; rtb.Selection.TextDecorations = null; |