本文整理汇总了C#中System.Windows.Documents.TextRange.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# TextRange.Remove方法的具体用法?C# TextRange.Remove怎么用?C# TextRange.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.TextRange
的用法示例。
在下文中一共展示了TextRange.Remove方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FormatExisting
private void FormatExisting()
{
IEnumerator<Block> paras = MainTextArea.Document.Blocks.GetEnumerator();
string currentText;
Paragraph newPara;
List<Block> newBlocks = new List<Block>();
for (int i = 0; i < MainTextArea.Document.Blocks.Count; i++)
{
paras.MoveNext();
if (paras.Current.Tag == null)
{
currentText = new TextRange(paras.Current.ContentStart, paras.Current.ContentEnd).Text;
newPara = new Paragraph();
foreach (string symbol in StyleSymbol)
{
if (currentText.StartsWith(symbol))
{
currentText = currentText.Remove(0, symbol.Length);
newPara.Tag = StyleName[Array.IndexOf(StyleSymbol, symbol)];
break;
}
}
newPara.Inlines.Add(new Run(currentText));
ChangeParagraphStyle((Paragraph)newPara, newPara.Tag.ToString());
}
else
{
newPara = (Paragraph)paras.Current;
}
newBlocks.Add(newPara);
}
MainTextArea.Document.Blocks.Clear();
MainTextArea.Document.Blocks.AddRange(newBlocks);
}
示例2: tw_MouseDoubleClick
private void tw_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
TextWorker tw = sender as TextWorker;
string newText = new TextRange(Modification.tb.Document.ContentStart, Modification.tb.Document.ContentEnd).Text;
string textToInsert = ((string)tw.Content).Remove(0, 2);
newText = newText.Remove(tw.startIndex, (tw.endIndex - tw.startIndex));
newText = newText.Insert(tw.startIndex, textToInsert);
FlowDocument doc = new FlowDocument();
Paragraph paragraph = new Paragraph();
paragraph.Inlines.Add(new Run(newText));
doc.Blocks.Add(paragraph);
Modification.tb.Document = doc;
Data = newText;
FindErrors();
Modification.sp.Children.Remove((UIElement)tw.Parent);
Update();
}
示例3: rtbEdit_PreviewKeyDown
private void rtbEdit_PreviewKeyDown(object sender, KeyEventArgs e)
{
timer.Interval = COUNTDOWN;
if (e.Key == Key.V && (Keyboard.Modifiers & (ModifierKeys.Control)) == (ModifierKeys.Control))
{
if (Clipboard.ContainsImage())
{
e.Handled = true;
BitmapSource bitmap = Clipboard.GetImage();
PngBitmapEncoder pE = new PngBitmapEncoder();
string tempFile = Path.GetTempFileName();
pE.Frames.Add(BitmapFrame.Create(bitmap));
using (Stream stream = File.Create(tempFile))
{
pE.Save(stream);
}
Helper.ImageHelper.InsertImg(rtbEdit, tempFile);
File.Delete(tempFile);
}
}
else
{
string strText = new TextRange(rtbEdit.Document.ContentStart, rtbEdit.Document.ContentEnd).Text;
if (strText.LastIndexOf("\r\n") > 0)
{
strText = strText.Remove(strText.LastIndexOf("\r\n"));
}
if (strText.Length <= 0) return;
int titleEnd = strText.IndexOf("\r\n");
if (titleEnd > 31 || titleEnd < 0) titleEnd = 0;
strText = strText.Remove(0, titleEnd);
int count = Regex.Matches(strText, @"[^\s]").Count;
if (count <= 0) return;
tbCount.Text = count + "";
if (count > countAll + 10 || count < countAll - 10)
{
countAll = count;
SaveAndUpdate();
}
}
}