using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using Microsoft.Ink;
namespace tabletSnip
{
///
/// Summary description for MySnip.
///
public class MySnip : System.Windows.Forms.Form
{
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public MySnip()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(288, 280);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
this.pictureBox1.DoubleClick += new System.EventHandler(this.pictureBox1_DoubleClick);
//
// MySnip
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(288, 280);
this.Controls.Add(this.pictureBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "MySnip";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.TopMost = true;
this.Load += new System.EventHandler(this.MySnip_Load);
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new MySnip());
}
private System.Windows.Forms.PictureBox pictureBox1;
InkOverlay io = null;
private void MySnip_Load(object sender, System.EventArgs e)
{
this.Location = new Point(0, 0);
this.Size = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
this.Opacity = .1;
//io = new InkOverlay(this.Handle);
io = new InkOverlay(pictureBox1.Handle);
io.Stroke += new InkCollectorStrokeEventHandler(StrokeEvent);
io.Enabled = true;
}
private Rectangle InkToPixelRectangle(Rectangle inkRect)
{
Rectangle pixelRect;
Point upperLeft = new Point(inkRect.Left, inkRect.Top);
Point lowerRight = new Point(inkRect.Right, inkRect.Bottom);
io.Renderer.InkSpaceToPixel(io.Handle, ref upperLeft);
io.Renderer.InkSpaceToPixel(io.Handle, ref lowerRight);
int iWidth = lowerRight.X - upperLeft.X;
int iHeight = lowerRight.Y - upperLeft.Y;
pixelRect = new Rectangle(upperLeft.X, upperLeft.Y, iWidth, iHeight);
return pixelRect;
}
private Point [] ZeroPointArray(Rectangle r, Point [] pa)
{
int x, y;
for(int i=0; i