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();
}
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();
}
相关文章推荐
- [VB.NET]找不到指定的模組。 (Exception from HRESULT: 0x8007007E) (System.Windows.Forms)
- How to Uninstall AVG Programs from A Windows System
- Hot Potato: Porting the System from Windows to Solaris
- How to register a keyboard shortcut (hot key) in a .NET Windows Forms Application
- System.Windows.Forms.Timer和System.Timers.Timer的区别
- System.Timers.Timer与System.Windows.Forms.Timer比较
- Refresh parent window from child window without having to press the refresh button
- System.Windows.Forms.Timer与System.Timers.Timer的区别
- System.Windows.Forms.Control : Component, IOleControl, IOleObject, IOleInPlaceObject, IOleInPlaceActiveObject....
- PDA 程序(附工程代码)System.Windows.Forms.Form._SetVisibleNotify() UnSupportedExpection 异常
- java.sql.SQLException: 内部错误: Unable to construct a Datum from the specified input
- Connect to a Windows Desktop from Ubuntu via Remote Desktop Connection
- To get the View matrix from the rotation,translation,scale
- Application.Run() 和 System.Windows.Forms.Form.Show() 方法的区别
- Powershell script to install Windows Updates (msu) from folder
- Why the volume so big after coping file from Linux to Windows?
- Windows Streams - An Introduction to File System Streams
- vi tips -- how to copy to / paste from system clipboard
- using System.Windows.Forms;引用不成功
- How to move a datafile from a file system to ASM (Doc ID 390274.1)