Today, I continue do some search for Wpf, I found something misunderstand before.
For example, MouseEventArgs.GetPostion(), at last article, I pass in (IInputElement)this, but it's wrong, it should pass
(UIElement)sender.
Also, I found new differnces:
1, MouseDown and MouseUp use MouseButtonEventArgs instead of MouseEventArgs, it different from MouseMove.
And e.Button == MouseButtons.Left should change to e.ChangeButton == MouseButton.Left
namespace System.Windows.Input
{
// Summary:
// Defines values that specify the buttons on a mouse device.
public enum MouseButton
{
// Summary:
// The left mouse button.
Left = 0,
//
// Summary:
// The middle mouse button.
Middle = 1,
//
// Summary:
// The right mouse button.
Right = 2,
//
// Summary:
// The first extended mouse button.
XButton1 = 3,
//
// Summary:
// The second extended mouse button.
XButton2 = 4,
}
}
But original one is lile:
using System;
using System.Runtime.InteropServices;
namespace System.Windows.Forms
{
// Summary:
// Specifies constants that define which mouse button was pressed.
[Flags]
[ComVisible(true)]
public enum MouseButtons
{
// Summary:
// No mouse button was pressed.
None = 0,
//
// Summary:
// The left mouse button was pressed.
Left = 1048576,
//
// Summary:
// The right mouse button was pressed.
Right = 2097152,
//
// Summary:
// The middle mouse button was pressed.
Middle = 4194304,
//
// Summary:
// The first XButton was pressed.
XButton1 = 8388608,
//
// Summary:
// The second XButton was pressed.
XButton2 = 16777216,
}
}
2, Point changes a lot, I will write detail thing for it later. Also contains Size, Vector..
3, use DrawingContext replace Graphics,
use OnRender(DrawingContext) replace OnPaint(PaintEventArgs)
I will write detail thing later.
4, ColorPickerCustomControl
This sample shows how to create a custom control and display it in a dialog window. This sample defines a custom color picker control that enables users to browse colors by their hue, saturation, and brightness. The control also enables the user to enter RGB, scRGB, and hexadecimal values directly.