本文整理汇总了C#中Gtk.Widget.AddEvents方法的典型用法代码示例。如果您正苦于以下问题:C# Widget.AddEvents方法的具体用法?C# Widget.AddEvents怎么用?C# Widget.AddEvents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.Widget
的用法示例。
在下文中一共展示了Widget.AddEvents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Step1_SetControl
//.........这里部分代码省略.........
m_modifierState |= MouseToolAction.ModifierKey.Shift;
}
if (ctrl) {
m_modifierState |= MouseToolAction.ModifierKey.Control;
}
// Change mouse button state.
var button = args.Event.Button;
switch (button) {
case 1: m_mouseState |= MouseToolAction.MouseButton.Left; break;
case 2: m_mouseState |= MouseToolAction.MouseButton.Middle; break;
case 3: m_mouseState |= MouseToolAction.MouseButton.Right; break;
}
var viewTransform = this.CurrentViewTransform;
m_mouseDownViewTransform = viewTransform;
// Set mouse down locations.
var px = args.Event.X;
var py = args.Event.Y;
this.m_mouseDownControlPosition = new Cairo.PointD (px, py);
var inv = viewTransform.Clone () as Matrix;
inv.Invert ();
inv.TransformPoint (ref px, ref py);
this.m_mouseDownViewPosition = new Cairo.PointD (px, py);
// If pressing a mouse button, complete the previous mouse tool action.
if (this.m_currentMouseToolAction != null) {
if (this.m_currentMouseToolAction.MouseUp != null) {
this.m_currentMouseToolAction.MouseUp (px, py);
}
}
// Find the mouse tool action that matches the current state.
m_currentMouseToolAction = null;
foreach (var mouseToolAction in m_mouseToolActions) {
if (mouseToolAction.Button == m_mouseState &&
mouseToolAction.Modifier == m_modifierState) {
this.m_currentMouseToolAction = mouseToolAction;
if (this.m_currentMouseToolAction.MouseDown != null) {
this.m_currentMouseToolAction.MouseDown (px, py);
}
return;
}
}
};
m_control.ButtonReleaseEvent += delegate(object o, Gtk.ButtonReleaseEventArgs args) {
// Change keyboard modifier state.
var shift = (args.Event.State & ModifierType.ShiftMask) == ModifierType.ShiftMask;
var ctrl = (args.Event.State & ModifierType.ControlMask) == ModifierType.ControlMask;
if (shift) {
m_modifierState &= ~MouseToolAction.ModifierKey.Shift;
}
if (ctrl) {
m_modifierState &= ~MouseToolAction.ModifierKey.Control;
}
// Change mouse button state.
var button = args.Event.Button;
switch (button) {
case 1: m_mouseState &= ~MouseToolAction.MouseButton.Left; break;
case 2: m_mouseState &= ~MouseToolAction.MouseButton.Middle; break;
case 3: m_mouseState &= ~MouseToolAction.MouseButton.Right; break;
}
var px = args.Event.X;
var py = args.Event.Y;
var inv = this.m_mouseDownViewTransform.Clone () as Matrix;
inv.Invert ();
inv.TransformPoint (ref px, ref py);
if (this.m_currentMouseToolAction != null) {
if (this.m_currentMouseToolAction.MouseUp != null) {
this.m_currentMouseToolAction.MouseUp (px, py);
}
}
this.m_currentMouseToolAction = null;
};
m_control.MotionNotifyEvent += delegate(object o, Gtk.MotionNotifyEventArgs args) {
if (ReferenceEquals (this.m_mouseDownViewTransform, null)) {return;}
var px = args.Event.X;
var py = args.Event.Y;
var inv = this.m_mouseDownViewTransform.Clone () as Matrix;
inv.Invert ();
inv.TransformPoint (ref px, ref py);
if (this.m_currentMouseToolAction != null) {
if (this.m_currentMouseToolAction.MouseMove != null) {
this.m_currentMouseToolAction.MouseMove (px, py);
}
}
};
m_control.AddEvents ((int)(
EventMask.ButtonPressMask
| EventMask.ButtonReleaseMask
| EventMask.PointerMotionMask));
}