当前位置: 首页>>代码示例>>C#>>正文


C# Widget.AddEvents方法代码示例

本文整理汇总了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));
        }
开发者ID:bvssvni,项目名称:csharp-sketch,代码行数:101,代码来源:CanvasHelper.cs


注:本文中的Gtk.Widget.AddEvents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。