﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication3
{
    public partial class Form1 : Form
    {



        void Form1_Load(object sender, EventArgs e)
        {
            var obsMouse = Observable.FromEvent<MouseEventArgs>(this, "MouseMove");
            var deltas = obsMouse.Zip(obsMouse.Skip(1),(a,b) => new AtoB(a.EventArgs, b.EventArgs));
            deltas.Subscribe(x => this.CreateGraphics().DrawLine(new Pen(Brushes.Black), x.from, x.to));
        }

        private class AtoB
        {
            public Point from;
            public Point to;
            public AtoB(MouseEventArgs a, MouseEventArgs b)
            {
                from = new Point(a.X, a.Y);
                to = new Point(b.X, b.Y);

            }
        }

        public Form1()
        {
            InitializeComponent();
            this.Load += new EventHandler(Form1_Load);
        }

     }
}
