本文整理汇总了C#中System.Windows.Forms.RichTextBox.CanPaste方法的典型用法代码示例。如果您正苦于以下问题:C# RichTextBox.CanPaste方法的具体用法?C# RichTextBox.CanPaste怎么用?C# RichTextBox.CanPaste使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.RichTextBox
的用法示例。
在下文中一共展示了RichTextBox.CanPaste方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanPasteTest
public void CanPasteTest ()
{
RichTextBox rTextBox = new RichTextBox ();
Bitmap myBitmap = new Bitmap ("M.gif");
Clipboard.SetDataObject (myBitmap);
DataFormats.Format myFormat = DataFormats.GetFormat (DataFormats.Bitmap);
Assert.AreEqual (true, rTextBox.CanPaste (myFormat), "#Mtd1");
}
示例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: 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;
}