本文整理汇总了C#中System.Windows.Forms.RichTextBox.Copy方法的典型用法代码示例。如果您正苦于以下问题:C# RichTextBox.Copy方法的具体用法?C# RichTextBox.Copy怎么用?C# RichTextBox.Copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.RichTextBox
的用法示例。
在下文中一共展示了RichTextBox.Copy方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportToRtf
/// <summary>
/// Take each chapter's RTF output and string it together
/// to create the book.
/// </summary>
/// <returns></returns>
public string ExportToRtf()
{
RichTextBox working = new RichTextBox(); // Holds running sum
RichTextBox temp = new RichTextBox(); // Holds individual scene
foreach (Chapter cp in Chapters)
{
temp.Rtf = cp.ExportToRtf();
if (temp.Text == "")
continue;
temp.SelectAll();
temp.Copy();
working.Paste();
}
return working.Rtf;
}
示例2: downloadChangeLog
public static void downloadChangeLog(bool calledFromConfig)
{
// sort the list of patches with the newest first, this correctly display the change log
updateCheck.patchList.Sort(delegate(updateCheck.patches p1, updateCheck.patches p2) { return p2.patchVersion.CompareTo(p1.patchVersion); });
RichTextBox richTextBoxInput = new RichTextBox();
RichTextBox richTextBoxOutput = new RichTextBox();
//
// Download the change logs
//
foreach (updateCheck.patches thePatch in updateCheck.patchList)
{
if (thePatch.patchChangeLog.StartsWith("C:\\"))
{
System.IO.File.Copy(thePatch.patchChangeLog, Path.Combine(Path.GetTempPath(), "ChangeLog.rtf"), true);
return;
}
WebClient client = new WebClient();
try
{
client.DownloadFile(thePatch.patchChangeLog, Path.Combine(Path.GetTempPath(), "ChangeLog-" + thePatch.patchVersion.MinorRevision.ToString() + ".rtf"));
}
catch (Exception e)
{
if (calledFromConfig)
MessageBox.Show("Unable to access ChangeLog-" + thePatch.patchVersion.MinorRevision.ToString() + ".rtf\n\n" + e.Message, "ChangeLog access issue");
//smcLog.WriteLog("Unable to access ChangeLog-" + thePatch.patchVersion.MinorRevision.ToString() + ".rtf > " + e.Message, LogLevel.Error);
return;
}
// smcLog.WriteLog("Downloaded File : " + Path.Combine(Path.GetTempPath(), "ChangeLog-" + thePatch.patchVersion.MinorRevision.ToString() + ".rtf"), LogLevel.Info);
}
//
// And combine them into a single change log
//
if (File.Exists(Path.Combine(Path.GetTempPath(), "ChangeLog.rtf")))
File.Delete(Path.Combine(Path.GetTempPath(), "ChangeLog.rtf"));
//smcLog.WriteLog("Processing Change Log...", LogLevel.Info);
try
{
// Add each file and save as ChangeLog.rtf
int patchCnt = 1;
AvalonGUIConfig.theRevisions = "Patch: ";
foreach (updateCheck.patches thePatch in updateCheck.patchList)
{
richTextBoxInput.LoadFile(Path.Combine(Path.GetTempPath(), "ChangeLog-" + thePatch.patchVersion.MinorRevision.ToString() + ".rtf"));
richTextBoxInput.SelectAll();
richTextBoxInput.Copy();
richTextBoxOutput.Paste();
System.IO.File.Delete(Path.Combine(Path.GetTempPath(), "ChangeLog-" + thePatch.patchVersion.MinorRevision.ToString() + ".rtf"));
if (patchCnt < updateCheck.patchList.Count)
AvalonGUIConfig.theRevisions = AvalonGUIConfig.theRevisions + thePatch.patchVersion.ToString() + " / ";
else
AvalonGUIConfig.theRevisions = AvalonGUIConfig.theRevisions + thePatch.patchVersion.ToString();
patchCnt++;
}
richTextBoxOutput.SaveFile(Path.Combine(Path.GetTempPath(), "ChangeLog.rtf"));
richTextBoxInput.Dispose();
richTextBoxOutput.Dispose();
}
catch (Exception ex)
{
Log.Error("Exception Reading Change Logs: " + ex.Message + "\\n" + ex.StackTrace);
}
}
示例3: RichTextBoxContextMenu
private void RichTextBoxContextMenu(RichTextBox richTextBox)
{
ContextMenu cm = new ContextMenu();
MenuItem mi = new MenuItem("Cut");
mi.Click += (a, b) => { richTextBox.Cut(); };
cm.MenuItems.Add(mi);
mi = new MenuItem("Copy");
mi.Click += (a, b) =>
{
richTextBox.Copy();
};
cm.MenuItems.Add(mi);
mi = new MenuItem("Paste");
mi.Click += (a, b) =>
{
richTextBox.Paste(DataFormats.GetFormat(DataFormats.UnicodeText));
};
cm.MenuItems.Add(mi);
richTextBox.ContextMenu = cm;
}
示例4: copyToolStripMenuItem_Click
private void copyToolStripMenuItem_Click(object sender, EventArgs e)
{
RichTextBox textBox = new RichTextBox();
foreach (ListViewItem item in listView1.Items)
{
textBox.Text += item.Text + ": " + item.SubItems[1].Text + "\n";
}
textBox.SelectAll();
textBox.Copy();
MessageBox.Show(Program.ResourceManager.GetString("Message_InfoCopiedIntoTheClipboard"));
}
示例5: button2_Click
// Copy to clipboard
private void button2_Click(object sender, EventArgs e)
{
ListView listView1 = (ListView)tabControl1.TabPages[tabControl1.SelectedIndex].Controls[0];
RichTextBox textBox = new RichTextBox();
foreach (ListViewItem item in listView1.Items)
{
textBox.Text += item.Text + ": " + item.SubItems[1].Text + "\n";
}
textBox.SelectAll();
textBox.Copy();
ManagedMessageBox.ShowMessage(Program.ResourceManager.GetString("Message_Done"));
}
示例6: ExportToRtf
public string ExportToRtf()
{
RichTextBox working = new RichTextBox(); // Holds running sum
RichTextBox temp = new RichTextBox(); // Holds individual scene
foreach (Scene sc in Scenes)
{
temp.Rtf = sc.ExportToRtf();
if (temp.Text == "")
continue;
temp.SelectAll();
temp.Copy();
working.Paste();
working.AppendText(Constant.LF + Constant.LF);
}
return working.Rtf;
}
示例7: imgProcessing
/// <summary>
/// 发送前处理图片
/// </summary>
void imgProcessing()
{
string stamp = timeUtil.GetTimeStamp();
//图片序号
int imgNum=0;
//缓存剪贴板中现有内容
RichTextBox clipboardTmp = new RichTextBox();
clipboardTmp.Paste();
for (int i = 0; i < chatBoxSend.TextLength; i++)
{
chatBoxSend.Select(i, 1); //依次选中
RichTextBoxSelectionTypes rt = chatBoxSend.SelectionType; //获取当前选中 内容的类型
if (rt == RichTextBoxSelectionTypes.Object) //图片是object
{
chatBoxSend.Copy(); //复制到剪贴板
Image img = Clipboard.GetImage(); //从剪贴板中建立Img对象
string serialNumber = string.Format("{0}{1:d6}", stamp,imgNum); //格式化生成图片序列号
if (img != null)
{
ImageUtil.ImgSave(serialNumber, img); //存储图片,并加入后缀
img.Tag=serialNumber;
SendImage(img, serialNumber, contactInfo.ID.ToString()); //发送图片
img.Dispose();
}
chatBoxSend.SelectedText = "<img>" + serialNumber + "</img>";
imgNum++;
}
}
//将原来剪贴板中的内容放回去
clipboardTmp.SelectAll();
clipboardTmp.Copy();
}
示例8: GetCurrentRichTextBox
public void 复制ToolStripMenuItem_Click(object sender, EventArgs e)
{
r = GetCurrentRichTextBox();
if (r.SelectedText == "")
return;
else
r.Copy();
}