目的:增加wasd键盘移动控件功能,默认移动1像素,当按住ctrl+wasd时,移动10像素(方向键可能被其他组件监听,暂时使用wasd替代)
效果预览:
使用软件:dnSpyEx(https://github.com/dnSpyEx/dnSpy/releases/download/v6.5.1/dnSpy-netframework.zip)
修改dll:UBFStudio\Runtime\UFSoft.UBF.Report.Designer.Controls.dll
修改步骤:
0.将下列dll拖入dnspy
Runtime\UFSoft.UBF.Report.Designer.Controls.dll
Runtime\UFSoft.UBF.Report.Base.dll
Runtime\UFSoft.UBF.Report.Entity.dll
Runtime\UFSoft.UBF.Report.Designer.Propertys.dll
Runtime\UFSoft.UBF.Report.Designer.dll
Runtime\UFSoft.UBF.Report.Filter.FilterModel.dll
Runtime\UFSoft.UBF.Report.Designer.CommDialog.dll
1.找到相关类并点击编辑类UFSoft.UBF.Report.Designer.Controls.ControlSizeButton
2.找到方法public ControlSizeButton()并添加代码base.KeyDown+=this.ControlSizeButton_KeyDown;
3.添加方法ControlSizeButton_KeyDown
private void ControlSizeButton_KeyDown(object sender, KeyEventArgs e)
{
bool control = e.Control;
Keys keyCode = e.KeyCode;
// 按住 Ctrl 键时移动 10 像素,否则移动 1 像素
int moveAmount = control ? 10 : 1;
int x = 0;
int y = 0;
switch (keyCode)
{
case Keys.W:
y -= moveAmount;
break;
case Keys.A:
x -= moveAmount;
break;
case Keys.S:
y += moveAmount;
break;
case Keys.D:
x += moveAmount;
break;
}
if (x != 0 || y != 0)
{
ControlSizeButtonEventArgs controlSizeButtonEventArgs = new ControlSizeButtonEventArgs(x, y);
this.On_ControlMoving(x, y);
this.On_ControlMoved(x, y);
}
e.Handled = true;
}
4.找到方法private void ControlSizeButton_MouseDown(object sender, MouseEventArgs e)并添加base.Focus();添加完成后点击编译
5.点击:文件-全部保存-确定
6.修改已完成,打开软件进行验证