Пример #1
0
        public ManagedVideoControl()
        {
            lastMouseCoordinate = new Point(0, 0);
            Child             = new VideoControlWrapper();
            Child.MouseEnter += (sender, args) =>
            {
                var e = new MouseEventArgs(Mouse.PrimaryDevice, (int)DateTime.Now.Ticks)
                {
                    RoutedEvent = Mouse.MouseEnterEvent
                };
                RaiseEvent(e);
            };

            Child.MouseLeave += delegate(object sender, EventArgs args)
            {
                MouseEventArgs e = new MouseEventArgs(Mouse.PrimaryDevice, (int)DateTime.Now.Ticks)
                {
                    RoutedEvent = Mouse.MouseLeaveEvent
                };
                RaiseEvent(e);
            };

            Child.MouseMove += (sender, args) =>
            {
                if (lastMouseCoordinate.X == args.X && lastMouseCoordinate.Y == args.Y)
                {
                    return;
                }
                lastMouseCoordinate.X = args.X;
                lastMouseCoordinate.Y = args.Y;

                MouseEventArgs e = new MouseEventArgs(Mouse.PrimaryDevice, (int)DateTime.Now.Ticks)
                {
                    RoutedEvent = Mouse.MouseMoveEvent,
                };
                RaiseEvent(e);
            };

            Child.MouseDown += delegate(object sender, System.Windows.Forms.MouseEventArgs args)
            {
                MouseButtonEventArgs e = new MouseButtonEventArgs(Mouse.PrimaryDevice, (int)DateTime.Now.Ticks,
                                                                  MouseButton.Left)
                {
                    RoutedEvent = Mouse.MouseDownEvent
                };
                RaiseEvent(e);
            };
        }
        public ManagedVideoControl()
        {
            lastMouseCoordinate = new Point(0,0);
            Child = new VideoControlWrapper();
            Child.MouseEnter += (sender, args) =>
            {
                var e = new MouseEventArgs(Mouse.PrimaryDevice, (int) DateTime.Now.Ticks)
                {
                    RoutedEvent = Mouse.MouseEnterEvent
                };
                RaiseEvent(e);
            };

            Child.MouseLeave += delegate(object sender, EventArgs args)
            {
                MouseEventArgs e = new MouseEventArgs(Mouse.PrimaryDevice, (int)DateTime.Now.Ticks)
                {
                    RoutedEvent = Mouse.MouseLeaveEvent
                };
                RaiseEvent(e);
            };

            Child.MouseMove += (sender, args) =>
            {
                if (lastMouseCoordinate.X == args.X && lastMouseCoordinate.Y == args.Y)
                    return;
                lastMouseCoordinate.X = args.X;
                lastMouseCoordinate.Y = args.Y;

                MouseEventArgs e = new MouseEventArgs(Mouse.PrimaryDevice, (int)DateTime.Now.Ticks)
                {
                    RoutedEvent = Mouse.MouseMoveEvent,
                };
                RaiseEvent(e);
            };

            Child.MouseDown += delegate(object sender, System.Windows.Forms.MouseEventArgs args)
            {
                MouseButtonEventArgs e = new MouseButtonEventArgs(Mouse.PrimaryDevice, (int)DateTime.Now.Ticks,
                   MouseButton.Left)
                {
                    RoutedEvent = Mouse.MouseDownEvent
                };
                RaiseEvent(e);
            };
        }