471,570 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,570 software developers and data experts.

Clearing selection in InkPicture

Hello everybody,
I have a simple form where I have added an 'inkpicture' and 2 buttons. One
of them changes the inkpicture.editing mode to 'select' and the other one
does the same with 'ink' mode. The problem is that when i select a stroke in
'select mode' and then change the inkpicture mode to 'ink', the selected
stroke remains white as when selected. I would like to obtain the same result
as when doing left mouse click in the inkpicture while in 'select mode', this
means, clear the selection and redraw. I would like to do this without
setting the 'autoredraw' property to false and overloading the paint method.

Anybody could help?
Thx
Feb 6 '06 #1
1 2397
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Microsoft.Ink;

namespace DumbPictureBox
{
public class Form1 : System.Windows.Forms.Form
{
private Microsoft.Ink.InkPicture myInkPicture;
private System.Windows.Forms.Button button_toInk;
private System.Windows.Forms.Button button_toSelect;
private System.ComponentModel.Container components = null;
Graphics g;
public Form1()
{
InitializeComponent();
g=myInkPicture.CreateGraphics();
myInkPicture.DefaultDrawingAttributes.Color=Color. Black;
myInkPicture.DefaultDrawingAttributes.Width=10;
}

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

#region Código generado por el Diseñador de Windows Forms

private void InitializeComponent()
{
this.myInkPicture = new Microsoft.Ink.InkPicture();
this.button_toInk = new System.Windows.Forms.Button();
this.button_toSelect = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// myInkPicture
//
this.myInkPicture.BackColor =
System.Drawing.SystemColors.ControlLightLight;
this.myInkPicture.Location = new System.Drawing.Point(16, 80);
this.myInkPicture.MarginX = -2147483648;
this.myInkPicture.MarginY = -2147483648;
this.myInkPicture.Name = "myInkPicture";
this.myInkPicture.Size = new System.Drawing.Size(256, 160);
this.myInkPicture.TabIndex = 0;
this.myInkPicture.Paint += new
System.Windows.Forms.PaintEventHandler(this.myInkP icture_Paint);
//
// button_toInk
//
this.button_toInk.Location = new System.Drawing.Point(32, 32);
this.button_toInk.Name = "button_toInk";
this.button_toInk.TabIndex = 1;
this.button_toInk.Text = "To Ink";
this.button_toInk.Click += new System.EventHandler(this.button1_Click);
//
// button_toSelect
//
this.button_toSelect.Location = new System.Drawing.Point(128, 32);
this.button_toSelect.Name = "button_toSelect";
this.button_toSelect.TabIndex = 2;
this.button_toSelect.Text = "To Select";
this.button_toSelect.Click += new System.EventHandler(this.button2_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.button_toSelect);
this.Controls.Add(this.button_toInk);
this.Controls.Add(this.myInkPicture);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion

[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
myInkPicture.EditingMode=InkOverlayEditingMode.Ink ;

}
private void button2_Click(object sender, System.EventArgs e)
{
myInkPicture.EditingMode=InkOverlayEditingMode.Sel ect;
}

private void myInkPicture_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)
{
}
}
}
Thx

Feb 6 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.