📄 cmirror.cs
字号:
using System;
using System.Collections;
using System.Drawing;
namespace VCSharp
{
/// <summary>
/// CMirror 的摘要说明。
/// </summary>
///
public class CMirror:ICommand
{
private int m_Step;
private PointF m_Pos1;
private PointF m_Pos2;
public CMirror()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public void LButtonDown(Graphics g,PointF aPos,ArrayList ges,ArrayList geSels)
{
m_Step+=1;
switch (m_Step)
{
case 1:
m_Pos1=aPos;
m_Pos2=aPos;
break;
case 2:
//清除最后一条橡皮线
CLine tempLine=new CLine(m_Pos1,m_Pos2);
tempLine.Draw(g,DrawMode.Drag);
tempLine=null;
//将所有被选中的图元移动到目标位置并进行绘制
if (geSels.Count>0)
{
for (int i=0;i< geSels.Count;i++)
{
//清除图元在当前位置上的图形
((CGElement)(geSels[i])).Draw(g,DrawMode.Delete);
((CGElement)(geSels[i])).Mirror(g,m_Pos1,m_Pos2);
((CGElement)(geSels[i])).Draw(g,DrawMode.Selec);
}
}
m_Step=0;
break;
}
}
public void MouseMove(Graphics g,PointF aPos)
{
switch (m_Step)
{
case 1:
PointF prePos=new PointF();
PointF curPos=new PointF();
prePos =m_Pos2;
curPos =aPos;
//清除上一条橡皮线
CLine tempLine1=new CLine(m_Pos1,prePos);
tempLine1.Draw(g,DrawMode.Drag);
tempLine1=null;
//绘当前位置的橡皮线
CLine tempLine2=new CLine(m_Pos1,curPos);
tempLine2.Draw(g,DrawMode.Drag);
tempLine2=null;
m_Pos2=aPos;
break;
}
}
//单击鼠标右键时的绘图行为
public void RButtonDown(Graphics g,PointF aPos)
{
if (m_Step==1)
{
//清除上一条橡皮线
CLine tempLine=new CLine(m_Pos1,m_Pos2);
tempLine.Draw(g,DrawMode.Drag);
tempLine=null;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -