本文整理汇总了C#中System.Windows.Forms.RichTextBox.Paste方法的典型用法代码示例。如果您正苦于以下问题:C# RichTextBox.Paste方法的具体用法?C# RichTextBox.Paste怎么用?C# RichTextBox.Paste使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.RichTextBox
的用法示例。
在下文中一共展示了RichTextBox.Paste方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Message1
public Message1(string content, Font temp)
{
InitializeComponent();
//lbl_content.Font = temp;
////lbl_user.Text = user;
//lbl_content.Text = content;
//Size size = TextRenderer.MeasureText(lbl_content.Text, lbl_content.Font);
//if (size.Width > 300)
//{
// int count = size.Width / 300;
// int lenght = content.Length / (count + 1);
// int tile = size.Width / content.Length;
// int sizeText = 300 / tile;
// for (int i = 0; i < count; i++)
// {
// content = content.Insert((i + 1) * sizeText , "\n");
// }
// this.Width = 300 + 30;
// lbl_content.Text = content;
// Size size1 = TextRenderer.MeasureText(lbl_content.Text, lbl_content.Font);
// this.Height = size1.Height/(count+1)*count + 15+Math.Abs(size.Height/2-size1.Height/(count+1));
//}
//else
//{
// if (size.Width+30 > this.Width)
// {
// this.Width = size.Width+30;
// }
// lbl_content.Text = content;
//}
////////////////
RichTextBox rtb = new RichTextBox();
Size size = TextRenderer.MeasureText(content, temp);
if (size.Width > 300)
{
int count = size.Width / 300;
int lenght = content.Length / (count + 1);
int tile = size.Width / content.Length;
int sizeText = 300 / tile;
for (int i = 0; i < count; i++)
{
content = content.Insert((i + 1) * sizeText + i * 2, "\n");
}
this.Width = 300 + 50;
//rtb.Text = content;
Size size1 = TextRenderer.MeasureText(content, temp);
this.Height = size1.Height + 25 + (size.Height / 2 - size1.Height / (count + 1));
}
else
{
if (size.Width + 30 > this.Width)
{
this.Width = size.Width + 50;
}
else
{
this.Height += 10;
}
//rtb.Text = content;
}
rtb.BorderStyle = BorderStyle.None;
rtb.Multiline = true;
int _width = this.Size.Width;
this.Size = new System.Drawing.Size(this.Width,this.Height);
rtb.Height = this.Height;
rtb.Width = this.Width;
rtb.Font = temp;
string chuoi_tam;
for (int i = 0; i < content.Length; i++)
{
chuoi_tam = "";
if (content[i] == ':' && i + 2 < content.Length)
{
chuoi_tam += content[i + 1];
chuoi_tam += content[i + 2];
if (image_name(chuoi_tam))
{
rtb.Height += 50;
this.Height += 10;
Bitmap myBitmap = new Bitmap(_image_icon);
//// Copy bitmap vào clipboard.
Clipboard.SetDataObject(myBitmap);
// Lấy định dạng của đối tượng ảnh
DataFormats.Format myFormat = DataFormats.GetFormat(DataFormats.Bitmap);
// Kiểm tra xem có thể copy định dạng ảnh vào RichTextBox
if (rtb.CanPaste(myFormat))
{
//nếu được thì "add" vào
rtb.Paste(myFormat);
rtb.Show();
}
i += 2;
}
else
{
//.........这里部分代码省略.........
示例3: 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);
}
}
示例4: 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;
}
示例5: 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;
}
示例6: convertTextToSmilleys
public void convertTextToSmilleys(RichTextBox box)
{
foreach(KeyValuePair<String, Image> data in emoticons)
{
while(box.Text.Contains(data.Key))
{
//TODO: add Label with a image when the text has been set ;-)
Image img = new Bitmap(data.Value, 23, 23);
int id = box.Text.IndexOf(data.Key);
box.Select(id, data.Key.Length);
Clipboard.SetDataObject(img);
box.Paste();
}
}
}
示例7: GetLinkData
public override string GetLinkData()
{
string returnvalue = this.Data1;
try {
// now add custom stuff to front/top of it.
System.Windows.Forms.RichTextBox box = new RichTextBox ();
box.Rtf = this.Data1;
string gender = String.Format ("Gender: {0}\n", this.gender);
string color = String.Format ("Color: {0}\n", this.colorName);
string priority = String.Format ("Priority: {0}\n", this.priority);
string alias = String.Format ("Alias: {0}\n", this.alias);
box.SelectionStart = 0;
Clipboard.SetText (gender + color + priority + alias);
box.Paste ();
box.SelectedText = "\n";
returnvalue = box.Rtf;
} catch (Exception ex) {
NewMessage.Show (ex.ToString ());
}
return returnvalue;
}
示例8: AppendText
//add đoạn message vào richtextbox
void AppendText( RichTextBox box, Color color, string text)
{
Image img;
img = BinaryToImage(ChatUsers.avarta);
Size size = new Size();
size.Width = 50;
size.Height = 50;
img = resizeImage(img, size);
Clipboard.SetDataObject(img);
DataFormats.Format df;
df = DataFormats.GetFormat(DataFormats.Bitmap);
if (box.CanPaste(df))
{
box.Paste(df);
}
int start = box.TextLength;
box.AppendText(text);
int end = box.TextLength;
box.Select(start, end-start);
box.SelectionColor = color;
box.SelectionLength = 0;
}
示例9: 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();
}
示例10: GetCurrentRichTextBox
public void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e)
{
r = GetCurrentRichTextBox();
r.Paste();
}
示例11: InsertImage
public static void InsertImage(RichTextBox MainBox, MemoryStream ms, int RecordButton)
{
//chart_basic.SaveImage(ms, ChartImageFormat.Jpeg);
Bitmap m = new Bitmap(ms);
//复制到粘贴板
Clipboard.SetImage(m);
//这种做法会使得粘帖板上原有内容丢失
if (RecordButton == 0)
{
MainBox.AppendText("\r\n");
MainBox.Select();//让RichTextBox获得焦点
MainBox.Select(MainBox.TextLength, 0);//将插入符号置于文本结束处
MainBox.ScrollToCaret();
MainBox.Paste();
}
else
{
try
{
MainBox.Rtf = Report.ReportText.richTextBox1.Rtf;
MainBox.AppendText("\r\n");
MainBox.Select();//让RichTextBox获得焦点
MainBox.Select(MainBox.TextLength, 0);//将插入符号置于文本结束处
MainBox.ScrollToCaret();
MainBox.Paste();
Report.ReportText.richTextBox1.Rtf = MainBox.Rtf;
}
catch (Exception ex)
{
}
}
}