您的位置:首页 > 其它

Mouse translation from System.Windows.Forms.MouseButtons to System.Windows.Input.MouseButton

2012-06-15 14:57 423 查看
In the UI world, there are two system, the Winforms and the WPF.   The WPF ones come later and have a face lift on the overall classes and designs. 

The team has made tremendous effort to bridge the two world. However, situation exists that you have to convert between the two of them , for example the MouseButton class.

System.Windows.Forms.MouseButtons
System.Windows.Input.MouseButton

Below shows the conversion code that does the code between the two.

private static MouseButton ToMouseButton(Forms.MouseButtons button)
{
switch (button)
{
case Forms.MouseButtons.Left:
return MouseButton.Left;
case Forms.MouseButtons.Right:
return MouseButton.Right;
case Forms.MouseButtons.Middle:
return MouseButton.Middle;
case Forms.MouseButtons.XButton1:
return MouseButton.XButton1;
case Forms.MouseButtons.XButton2:
return MouseButton.XButton2;
}

throw new InvalidOperationException();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息