private System.ComponentModel.Container components = null;
  private Microsoft.Ink.InkOverlay m_InkOverlay;
  private System.Windows.Forms.GroupBox groupBox1;
  private System.Windows.Forms.RadioButton InkIt;
  private System.Windows.Forms.RadioButton DelIt;
  private System.Windows.Forms.RadioButton SelectIt;
  private System.Windows.Forms.RadioButton PointErase;
  private enum InkDrawStateEnum {Ink,Select,Delete,PointErase};
  private int InkDrawState = (int) InkDrawStateEnum.Ink;
        private Button btnSave;
        private PictureBox pictureBox1;
        Microsoft.Ink.InkCollector theInkCollector;

public Form1()
  {

InitializeComponent();    // Instantiate the InkOverlay.

m_InkOverlay = new Microsoft.Ink.InkOverlay(this.Handle);

m_InkOverlay.Enabled = true;

// Hook up the InkOverlay object's Stroke event handler.

m_InkOverlay.Stroke += new InkCollectorStrokeEventHandler( InkStrokeAdded );                    // Hook up to the InkOverlay object's Painted event handler.    m_InkOverlay.Painted += new InkOverlayPaintedEventHandler(InkPainted);

}

private void InkStrokeAdded( object sender, InkCollectorStrokeEventArgs e)
  {
   // Invalidate the form so we can force a repaint.
   this.Invalidate();
  }

private void InkPainted( object sender, PaintEventArgs e)
  {
   // Call the helper function which will redraw the form.
   RendererEx.DrawStrokeIds(e.Graphics, Font, m_InkOverlay.Ink);
  }

protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if (components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

private void InitializeComponent()
  {

this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.btnSave = new System.Windows.Forms.Button();
            this.PointErase = new System.Windows.Forms.RadioButton();
            this.SelectIt = new System.Windows.Forms.RadioButton();
            this.DelIt = new System.Windows.Forms.RadioButton();
            this.InkIt = new System.Windows.Forms.RadioButton();
            this.pictureBox1 = new System.Windows.Forms.PictureBox();
            this.groupBox1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
            this.SuspendLayout();

     this.groupBox1.Controls.Add(this.btnSave);
            this.groupBox1.Controls.Add(this.PointErase);
            this.groupBox1.Controls.Add(this.SelectIt);
            this.groupBox1.Controls.Add(this.DelIt);
            this.groupBox1.Controls.Add(this.InkIt);
            this.groupBox1.Dock = System.Windows.Forms.DockStyle.Bottom;
            this.groupBox1.Location = new System.Drawing.Point(0, 278);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(458, 45);
            this.groupBox1.TabIndex = 0;
            this.groupBox1.TabStop = false;

     this.btnSave.Location = new System.Drawing.Point(371, 16);
            this.btnSave.Name = "btnSave";
            this.btnSave.Size = new System.Drawing.Size(75, 23);
            this.btnSave.TabIndex = 4;
            this.btnSave.Text = "Save";
            this.btnSave.UseVisualStyleBackColor = true;
            this.btnSave.Click += new System.EventHandler(this.btnSave_Click);

    this.PointErase.Location = new System.Drawing.Point(272, 15);
            this.PointErase.Name = "PointErase";
            this.PointErase.Size = new System.Drawing.Size(96, 22);
            this.PointErase.TabIndex = 3;
            this.PointErase.Text = "Point Erase";
            this.PointErase.CheckedChanged += new System.EventHandler(this.PointErase_CheckedChanged);

    this.SelectIt.Location = new System.Drawing.Point(80, 15);
            this.SelectIt.Name = "SelectIt";
            this.SelectIt.Size = new System.Drawing.Size(80, 22);
            this.SelectIt.TabIndex = 2;
            this.SelectIt.Text = "Select";
            this.SelectIt.CheckedChanged += new System.EventHandler(this.SelectIt_CheckedChanged);

    this.DelIt.Location = new System.Drawing.Point(184, 15);
            this.DelIt.Name = "DelIt";
            this.DelIt.Size = new System.Drawing.Size(64, 22);
            this.DelIt.TabIndex = 1;
            this.DelIt.Text = "Delete";
            this.DelIt.CheckedChanged += new System.EventHandler(this.DelIt_CheckedChanged);

    this.InkIt.Checked = true;
            this.InkIt.Location = new System.Drawing.Point(8, 15);
            this.InkIt.Name = "InkIt";
            this.InkIt.Size = new System.Drawing.Size(56, 22);
            this.InkIt.TabIndex = 0;
            this.InkIt.TabStop = true;
            this.InkIt.Text = "Ink";
            this.InkIt.CheckedChanged += new System.EventHandler(this.InkIt_CheckedChanged);

     this.pictureBox1.Location = new System.Drawing.Point(248, 26);
            this.pictureBox1.Name = "pictureBox1";
            this.pictureBox1.Size = new System.Drawing.Size(198, 246);
            this.pictureBox1.TabIndex = 1;
            this.pictureBox1.TabStop = false;

     this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
            this.ClientSize = new System.Drawing.Size(458, 323);
            this.Controls.Add(this.pictureBox1);
            this.Controls.Add(this.groupBox1);
            this.Name = "Form1";
            this.Text = "StrokeViewer";
            this.groupBox1.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
            this.ResumeLayout(false);

}

[STAThread]
  static void Main()
  {
   Application.Run(new Form1());
  }

private void InkIt_CheckedChanged(object sender, System.EventArgs e)
  {
   InkDrawState = (int) InkDrawStateEnum.Ink;
   m_InkOverlay.EditingMode = InkOverlayEditingMode.Ink;
  }

private void SelectIt_CheckedChanged(object sender, System.EventArgs e)
  {
   InkDrawState = (int) InkDrawStateEnum.Select;
   m_InkOverlay.EditingMode = InkOverlayEditingMode.Select;
  }

private void DelIt_CheckedChanged(object sender, System.EventArgs e)
  {
   InkDrawState = (int) InkDrawStateEnum.Delete;
   m_InkOverlay.EditingMode = InkOverlayEditingMode.Delete;
   m_InkOverlay.EraserMode = InkOverlayEraserMode.StrokeErase;
  }

private void PointErase_CheckedChanged(object sender, System.EventArgs e)
  {
   InkDrawState = (int) InkDrawStateEnum.PointErase;
   m_InkOverlay.EditingMode = InkOverlayEditingMode.Delete;
   m_InkOverlay.EraserMode = InkOverlayEraserMode.PointErase;
  }

private void btnSave_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Filter = "(*.*)|*.gif";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                FileStream gifFile;
                byte[] fortifiedGif = null;
                gifFile = File.OpenWrite(sfd.FileName);
                fortifiedGif = m_InkOverlay.Ink.Save(PersistenceFormat.Gif);
                gifFile.Write(fortifiedGif, 0, fortifiedGif.Length);
                gifFile.Close();
            }
        }

InkPicture 控件使用_01的更多相关文章

  1. JS调用Android、Ios原生控件

    在上一篇博客中已经和大家聊了,关于JS与Android.Ios原生控件之间相互通信的详细代码实现,今天我们一起聊一下JS调用Android.Ios通信的相同点和不同点,以便帮助我们在进行混合式开发时, ...

  2. HTML5 progress和meter控件

    在HTML5中,新增了progress和meter控件.progress控件为进度条控件,可表示任务的进度,如Windows系统中软件的安装.文件的复制等场景的进度.meter控件为计量条控件,表示某 ...

  3. 百度 flash html5自切换 多文件异步上传控件webuploader基本用法

    双核浏览器下在chrome内核中使用uploadify总有302问题,也不知道如何修复,之所以喜欢360浏览器是因为帮客户控制渲染内核: 若页面需默认用极速核,增加标签:<meta name=& ...

  4. JS与APP原生控件交互

    "热更新"."热部署"相信对于混合式开发的童鞋一定不陌生,那么APP怎么避免每次升级都要在APP应用商店发布呢?这里就用到了混合式开发的概念,对于电商网站尤其显 ...

  5. UWP开发必备:常用数据列表控件汇总比较

    今天是想通过实例将UWP开发常用的数据列表做汇总比较,作为以后项目开发参考.UWP开发必备知识点总结请参照[UWP开发必备以及常用知识点总结]. 本次主要讨论以下控件: GridView:用于显示数据 ...

  6. 【踩坑速记】开源日历控件,顺便全面解析开源库打包发布到Bintray/Jcenter全过程(新),让开源更简单~

    一.写在前面 自使用android studio开始,就被它独特的依赖方式:compile 'com.android.support:appcompat-v7:25.0.1'所深深吸引,自从有了它,麻 ...

  7. 对百度WebUploader开源上传控件的二次封装,精简前端代码(两句代码搞定上传)

    前言 首先声明一下,我这个是对WebUploader开源上传控件的二次封装,底层还是WebUploader实现的,只是为了更简洁的使用他而已. 下面先介绍一下WebUploader 简介: WebUp ...

  8. Windows API 设置窗口下控件Enable属性

    参考页面: http://www.yuanjiaocheng.net/webapi/create-crud-api-1-put.html http://www.yuanjiaocheng.net/we ...

  9. VB.NET设置控件和窗体的显示级别

    前言:在用VB.NET开发射频检测系统ADS时,当激活已存在的目标MDI子窗体时,被其他子窗体遮住了,导致目标MDI子窗体不能显示. 这个问题怎么解决呢?网上看到一篇帖子VB.NET设置控件和窗体的显 ...

随机推荐

  1. ASIHTTPRequest 中url参数中文乱码

    ASIHTTPReques确实是在开发过程中,数据的传输,获取方面给我们很大的帮助.然而在一些方面也是需要一些的注意. 在我们使用ASIHTTPReques 进行get方式获取数据时,如果需要传入中文 ...

  2. python selenium启动浏览器打开百度搜索

    python selenium打开百度搜索 #!usr/bin/python from selenium import webdriver import time browser = webdrive ...

  3. 第二步 在D2RQ平台上配置jena环境

    第二步 在D2RQ平台上配置jena环境 2013年10月16日 9:48:53 搞了这么长时间语义,只用过protege这样的工具,一直没有落实到实际代码上.jena也看过好久了,总认为是hp公司的 ...

  4. C# .Net基础知识点解答

    原文地址 1. 什么是.NET?什么是CLI?什么是CLR?IL是什么?JIT是什么,它是如何工作的?GC是什么,简述一下GC的工作方式? 通俗的讲,.Net是微软开发应用程序的一个平台: CLI是C ...

  5. javascript中bind,apply,call的相同和不同之处

    javasctipt中bind,apply,call的相同点是: 1,都是用来改变this的指向; 2,都可以通过后续参数进行传参; 3,第一个参数都是指定this要指向的对象; 不同点: 1,调用方 ...

  6. 用HiveDB横向切分MySQL数据库

    HiveDB是一个用来横向切分mysql数据库的开源框架,构建一个高性能和可扩展的基于mysql的系统需要大量的系统设计经验和良好的代码的实现,一个比较好的策略是将你的数据横向切分在多个server上 ...

  7. Android - TextView Ellipsize属性

    Android - TextView Ellipsize属性 本文地址: http://blog.csdn.net/caroline_wendy android:ellipsize属性: If set ...

  8. android应用程序的优先级

    andorid系统为保障应用程序运行的流畅性,当内存资源比较匮乏的时候会杀死那些优先级比较低的进程 android进程的优先级如下图: 1.活动进程: 是指那些正在与用户进行交互的应用程序进程,这种组 ...

  9. 大区间素数筛选 POJ2689

    题意: 给一个区间[L,U],(1<=L< U<=2,147,483,647),U-L<=1000000,求出[L,U]内距离近期和距离最远的素数对. 因为L,U都小于2^32 ...

  10. 如何使用axis2 构建 Android 服务器后端--- 工具准备与环境配置

    最近一个项目要做个android端的实验室器材管理系统.小伙伴英勇地接下android端的锅,我就 负责给他写后端,最近看到axis2 这个webservice挺好用的,折腾了几天给大家分享下: 1. ...