📄 ctext.cs
字号:
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace VCSharp
{
/// <summary>
/// CText 的摘要说明。
/// </summary>
public class CText:CGElement
{
private Font m_Font;
private PointF m_Pos;
private string m_Content;
private float m_Size;
private float m_Angle;
private Color m_Color;
private FontStyle m_Style;
Module m=new Module();
//字体属性
public Font Font
{
get{return m_Font;}
set{m_Font = value;}
}
//位置属性
public PointF Pos
{
get{return m_Pos;}
set{m_Pos = value;}
}
//大小属性
public float Size
{
get{return m_Size;}
set{m_Size = value;}
}
//内容属性
public string Content
{
get{return m_Content;}
set{m_Content = value;}
}
//旋转角度属性
public float Angle
{
get{return m_Angle;}
set{m_Angle = value;}
}
//颜色属性
new public Color Color
{
get{return m_Color;}
set{m_Color = value;}
}
//字体模式
new public FontStyle Style
{
get{return m_Style;}
set{m_Style = value;}
}
//无参构造函数
public CText(){
Init();
}
//构造函数,用已知的字符串进行构造
public CText(string str, PointF aPos){
Init();
m_Content = str;
m_Pos = aPos;
}
//构造函数
public CText(string str, Font f,float size,
PointF aPos, float ang,
Color c, FontStyle sty){
m_Content = str;
m_Font = f;
m_Size = size;
m_Pos = aPos;
m_Angle = ang;
m_Color = c;
m_Style = sty;
}
//构造函数,用已知的文本进行构造
public CText(CText text)
{
m_Content =text.Content;
m_Font =text.Font;
m_Pos =text.Pos;
m_Size =text.Size;
m_Angle =text.Angle;
m_Color =text.Color;
m_Style =text.Style;
}
//初始化文本
private new void Init()
{
m_Content = " ";
m_Size = 20;
m_Font = new Font("宋体", m_Size, m_Style, GraphicsUnit.Pixel);
m_Pos = new PointF(0, 0);
m_Angle = 0;
m_Color = Color.Black;
m_Style=FontStyle.Regular;
}
//绘文本
override public void Draw(Graphics g,DrawMode aDrawMode)
{
switch(aDrawMode){
case DrawMode.Normal:
m_Color = Color.Black;
break;
case DrawMode.Selec:
m_Color = Color.Red;
break;
case DrawMode.Delete:
m_Color = Color.White;
break;
}
PointF Pos= m.WorldtoPage(m_Pos);
StringFormat sf=new StringFormat(StringFormatFlags.NoWrap);
g.DrawString(m_Content, m_Font, new SolidBrush(m_Color), Pos.X, Pos.Y, sf);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -