using System;
using System.Collections.Specialized;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
namespace Khendys.Controls {
#region Public Enums
// Enum for possible RTF colors
public enum RtfColor {
Black, Maroon, Green, Olive, Navy, Purple, Teal, Gray, Silver,
Red, Lime, Yellow, Blue, Fuchsia, Aqua, White
}
#endregion
public class ExRichTextBox : System.Windows.Forms.RichTextBox {
#region My Enums
// Specifies the flags/options for the unmanaged call to the GDI+ method
// Metafile.EmfToWmfBits().
private enum EmfToWmfBitsFlags {
// Use the default conversion
EmfToWmfBitsFlagsDefault = 0x00000000,
// Embedded the source of the EMF metafiel within the resulting WMF
// metafile
EmfToWmfBitsFlagsEmbedEmf = 0x00000001,
// Place a 22-byte header in the resulting WMF file. The header is
// required for the metafile to be considered placeable.
EmfToWmfBitsFlagsIncludePlaceable = 0x00000002,
// Don't simulate clipping by using the XOR operator.
EmfToWmfBitsFlagsNoXORClip = 0x00000004
};
#endregion
#region My Structs
// Definitions for colors in an RTF document
private struct RtfColorDef {
public const string Black = @"\red0\green0\blue0";
public const string Maroon = @"\red128\green0\blue0";
public const string Green = @"\red0\green128\blue0";
public const string Olive = @"\red128\green128\blue0";
public const string Navy = @"\red0\green0\blue128";
public const string Purple = @"\red128\green0\blue128";
public const string Teal = @"\red0\green128\blue128";
public const string Gray = @"\red128\green128\blue128";
public const string Silver = @"\red192\green192\blue192";
public const string Red = @"\red255\green0\blue0";
public const string Lime = @"\red0\green255\blue0";
public const string Yellow = @"\red255\green255\blue0";
public const string Blue = @"\red0\green0\blue255";
public const string Fuchsia = @"\red255\green0\blue255";
public const string Aqua = @"\red0\green255\blue255";
public const string White = @"\red255\green255\blue255";
}
// Control words for RTF font families
private struct RtfFontFamilyDef {
public const string Unknown = @"\fnil";
public const string Roman = @"\froman";
public const string Swiss = @"\fswiss";
public const string Modern = @"\fmodern";
public const string Script = @"\fscript";
public const string Decor = @"\fdecor";
public const string Technical = @"\ftech";
public const string BiDirect = @"\fbidi";
}
#endregion
#region My Constants
// Not used in this application. Descriptions can be found with documentation
// of Windows GDI function SetMapMode
private const int MM_TEXT = 1;
private const int MM_LOMETRIC = 2;
private const int MM_HIMETRIC = 3;
private const int MM_LOENGLISH = 4;
private const int MM_HIENGLISH = 5;
private const int MM_TWIPS = 6;
// Ensures that the metafile maintains a 1:1 aspect ratio
private const int MM_ISOTROPIC = 7;
// Allows the x-coordinates and y-coordinates of the metafile to be adjusted
// independently
private const int MM_ANISOTROPIC = 8;
// Represents an unknown font family
private const string FF_UNKNOWN = "UNKNOWN";
// The number of hundredths of millimeters (0.01 mm) in an inch
// For more information, see GetImagePrefix() method.
private const int HMM_PER_INCH = 2540;
// The number of twips in an inch
// For more information, see GetImagePrefix() method.
private const int TWIPS_PER_INCH = 1440;
#endregion
#region My Privates
// The default text color
private RtfColor textColor;
// The default text background color
private RtfColor highlightColor;
// Dictionary that maps color enums to RTF color codes
private HybridDictionary rtfColor;
// Dictionary that mapas Framework font families to RTF font families
private HybridDictionary rtfFontFamily;
// The horizontal resolution at which the control is being displayed
private float xDpi;
// The vertical resolution at which the control is being displayed
private float yDpi;
#endregion
#region Elements required to create an RTF document
/* RTF HEADER
* ----------
*
* \rtf[N] - For text to be considered to be RTF, it must be enclosed in this tag.
* rtf1 is used because the RichTextBox conforms to RTF Specification
* version 1.
* \ansi - The character set.
* \ansicpg[N] - Specifies that unicode characters might be embedded. ansicpg1252
* is the default used by Windows.
* \deff[N] - The default font. \deff0 means the default font is the first font
* found.
* \deflang[N] - The default language. \deflang1033 specifies US English.
* */
private const string RTF_HEADER = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033";
/* RTF DOCUMENT AREA
* -----------------
*
* \viewkind[N] - The type of view or zoom level. \viewkind4 specifies normal view.
* \uc[N] - The number of bytes corresponding to a Unicode character.
* \pard - Resets to default paragraph properties
* \cf[N] - Foreground color. \cf1 refers to the color at index 1 in
* the color table
* \f[N] - Font number. \f0 refers to the font at index 0 in the font
* table.
* \fs[N] - Font size in half-points.
* */
private const string RTF_DOCUMENT_PRE = @"\viewkind4\uc1\pard\cf1\f0\fs20";
private const string RTF_DOCUMENT_POST = @"\cf0\fs17}";
private string RTF_IMAGE_POST = @"}";
#endregion
#region Accessors
// TODO: This can be ommitted along with RemoveBadCharacters
// Overrides the default implementation of RTF. This is done because the control
// was originally developed to run in an instant messenger that uses the
// Jabber XML-based protocol. The framework would throw an exception when the
// XML contained the null character, so I filtered out.
public new string Rtf {
get {return RemoveBadChars(base.Rtf);}
set {base.Rtf = value;}
}
// The color of the text
public RtfColor TextColor {
get {return textColor;}
set {textColor = value;}
}
// The color of the highlight
public RtfColor HiglightColor {
get {return highlightColor;}
set {highlightColor = value;}
}
#endregion
#region Constructors
/// <summary>
/// Initializes the text colors, creates dictionaries for RTF colors and
/// font families, and stores the horizontal and vertical resolution of
/// the RichTextBox's graphics context.
/// </summary>
public ExRichTextBox() : base() {
// Initialize default text and background colors
textColor = RtfColor.Black;
highlightColor = RtfColor.White;
// Initialize the dictionary mapping color codes to definitions
rtfColor = new HybridDictionary();
rtfColor.Add(RtfColor.Aqua, RtfColorDef.Aqua);
rtfColor.Add(RtfColor.Black, RtfColorDef.Black);
rtfColor.Add(RtfColor.Blue, RtfColorDef.Blue);
rtfColor.Add(RtfColor.Fuchsia, RtfColorDef.Fuchsia);
rtfColor.Add(RtfColor.Gray, RtfColorDef.Gray);
rtfColor.Add(RtfColor.Green, RtfColorDef.Green);
rtfColor.Add(RtfColor.Lime, RtfColorDef.Lime);
rtfColor.Add(RtfColor.Maroon, RtfColorDef.Maroon);
rtfColor.Add(RtfColor.Navy, RtfColorDef.Navy);
rtfColor.Add(RtfColor.Olive, RtfColorDef.Olive);
rtfColor.Add(RtfColor.Purple, RtfColorDef.Purple);
rtfColor.Add(RtfColor.Red, RtfColorDef.Red);
rtfColor.Add(RtfColor.Silver, RtfColorDef.Silver);
rtfColor.Add(RtfColor.Teal, RtfColorDef.Teal);
rtfColor.Add(RtfColor.White, RtfColorDef.White);
rtfColor.Add(RtfColor.Yellow, RtfColorDef.Yellow);
// Initialize the dictionary mapping default Framework fon
没有合适的资源?快使用搜索试试~ 我知道了~
C#技术文章(零散的技术文章)
共139个文件
txt:79个
doc:54个
mht:4个
需积分: 0 1 下载量 182 浏览量
2011-07-13
18:02:34
上传
评论
收藏 2.77MB RAR 举报
温馨提示
零零散散的技术文档。关于C#的技术文档,学习的人看下吧。
资源详情
资源评论
资源推荐
收起资源包目录
C#技术文章(零散的技术文章) (139个子文件)
C#语言参考.doc 1.64MB
利用C#制作一个仿IE地址栏的文本框.doc 1.42MB
在C#中利用Excel做高级报表.doc 1.18MB
在C#中实现软件自动升级.doc 1.04MB
用C#做个带精灵的邮件通知程序.doc 281KB
运用Visual C#完成基本数字图像处理.doc 223KB
利用Visual C#处理数字图像.doc 220KB
WinForm中如何播放声音与Flash动画.doc 213KB
使用C#进行Word 2002和Excel 2002编程.doc 191KB
在Visual C#下实现图像的透明处理.doc 171KB
使用VC#制作可伸缩个性化窗体.doc 152KB
中文语音识别技术在c#中的应用.doc 138KB
实战Visual C#数据库编程.doc 110KB
Visual C#中的数据绑定.doc 109KB
NET环境下水晶报表使用总结.doc 106KB
SQL存储过程在.NET数据库中的应用.doc 103KB
Visual C#组件技巧之ComboBox美容.doc 103KB
VC# .Net中浏览Crystal Report.doc 96KB
带图标的组合框.doc 80KB
运用C#实现POP3邮件接收程序.doc 79KB
在Visual C#中用ListView显示数据记录.doc 68KB
全面掌握C#中的拖放操作.doc 67KB
Visual C#的Excel编程.doc 64KB
用C#和VB.NET实现Office XP风格的菜单.doc 60KB
wind2000无盘工作站的配置.doc 59KB
弹出广告杀手.doc 57KB
运用API函数获取系统信息.doc 53KB
C# 中操作API.doc 50KB
Excel、Exchange 和 C#.doc 50KB
在C#中使用热键隐含窗口.doc 49KB
NET中各种数据库连接大全.doc 49KB
创建不规则窗体和控件.doc 47KB
浅析C#中图形编程.doc 47KB
解读C#中的正则表达式.doc 44KB
C#基本书写规范.doc 41KB
把金额转换为大写.doc 36KB
把.NET程序部署到没有安装.NET Framwork的机器上.doc 36KB
删除注册表中的注册信息.doc 36KB
C#中改变显示器的分辨率.doc 34KB
图像的透明处理.doc 34KB
打造Win 2000无盘工作站.doc 34KB
用C#实现生成PDF文档(原码).doc 33KB
使用说明.doc 33KB
在Visual C#中访问不同数据库.doc 30KB
从数据库中得到合适的时间格式.doc 30KB
使用C#语言操作ADO数据库.doc 30KB
在Delphi中控制扫描仪.doc 30KB
C#实现网段扫描.doc 29KB
Visual C# 中的MDI编程.doc 28KB
大话XML.doc 28KB
C#处理鼠标和键盘事件.doc 26KB
C#中使用指针.doc 26KB
注册表使用.doc 23KB
随机数的使用.doc 21KB
ActiveX技术彻底研究.mht 83KB
梦幻游戏编程 第三章.mht 62KB
在对话框中显示网页,并屏蔽掉IE的弹出式菜单 --- tech521_com.mht 18KB
ActiveX技术综述.mht 16KB
DataTable,DataView和DataGrid中一些容易混淆的概念.pdf 220KB
treeview的使用小结.pdf 83KB
NET在RichTextBox控件加入图片(类似QQ).txt 28KB
C#串口操作.txt 25KB
使用 Win32 和其他库.txt 22KB
关于拖放操作.txt 13KB
在.NET中得到计算机硬件信息的一些功能.txt 12KB
打造 “浏览器”.txt 10KB
Visual C# 打造 “浏览器”.txt 10KB
如何与资源管理器互动剪切、拷贝、粘贴文件.txt 9KB
mail.txt 8KB
得到当前数据库中所有用户表信息.txt 8KB
C#编码标准.txt 8KB
如何:在 Visual C# .NET 中建立一个平滑的进度条.txt 8KB
深入理解C#编程中的组件-事件-委托.txt 7KB
C#中水晶按钮的程序生成.txt 7KB
C#中调用Windows API的要点.txt 7KB
使用 Visual C# .NET 检查 Windows 版本.txt 7KB
用C# 来捕获屏幕.txt 7KB
捕捉DataGrid的双击事件(C#版本).txt 6KB
C#如何取硬件标志.txt 6KB
C#中为DataGrid添加下拉列表框.TXT 6KB
将控件放到datagrid中以及修改列宽.TXT 6KB
用C#做ScreenSaver.TXT 6KB
在C#中利用SharpZipLib进行文件的压缩和解压缩.txt 6KB
send.txt 5KB
字幕显示屏幕保护.txt 5KB
C#里的InputBox.txt 5KB
SQL储存过程等的解密.txt 5KB
关于在WinForm里用HttpWebRequest获得某个页面,并填写页面的textbox及点击button的方法.txt 5KB
C#中利用GDI作图解决异或问题.txt 5KB
怎样检测网络中的电脑是否有安装SQL 2000.txt 4KB
画带阴影效果的文字.txt 3KB
如何用程序实现键盘和鼠标的模拟?.txt 3KB
如何用程序实现键盘和鼠标的模拟.txt 3KB
编辑字段中的word文件.txt 3KB
读取、设置系统时间日期.txt 2KB
用word填充表格.txt 2KB
C#中控制输入法.txt 2KB
模拟鼠标和键盘操作.txt 2KB
显示DataGrid序号的一个适用的方法 .txt 2KB
二进制数据保存.txt 2KB
共 139 条
- 1
- 2
亚飞正传
- 粉丝: 8
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0