|
■No7930 (渋木宏明(ひどり) さん) に返信
返信ありがとうございます!
いまさらで本当に申し訳ないのですが、今自分が作りたいのはタブレットPC上でペンで操作することを前提としています。 VisualStudio .NET2003 .NET Framework SDK Ver.1.1です。
ですので今一度自分で作り直しています。
何回も重複していてすいませんが、理想としては、 ・デスクトップ上で何かしらのジェスチャを行うとそこにフォーム(inkpicture)が表示される。 ・ペンで操作し、フォームの領域から出たらその方向に新しくinkpictureを表示する。 ・この動作は繰り返され、ペンの軌道にそって蛇のようにinkpictureが表示される。 ・ひとつ前のフォームに戻すと新しく表示されたフォームはその都度消える。
このようなものを考えています。
今は
フォームの領域から出たらその方向に新しくinkpictureを表示する
というところを作成しています。
********************************************************** using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data;
using Microsoft.Win32; using System.Runtime.InteropServices; using Microsoft.Ink; using System.Threading; namespace WindowsApplication1 { /// <summary> /// Form1 の概要の説明です。 /// </summary> public class Form1 : System.Windows.Forms.Form { private System.ComponentModel.IContainer components;
public Form1() { // // Windows フォーム デザイナ サポートに必要です。 // InitializeComponent();
// // TODO: InitializeComponent 呼び出しの後に、コンストラクタ コードを追加してください。 // GetXYIndexes(ref indexX, ref indexY);
} private Microsoft.Ink.InkPicture inkPicture1; int indexX = 0; int indexY = 0;
/// <summary> /// 使用されているリソースに後処理を実行します。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); }
#region Windows フォーム デザイナで生成されたコード /// <summary> /// デザイナ サポートに必要なメソッドです。このメソッドの内容を /// コード エディタで変更しないでください。 /// </summary> private void InitializeComponent() { this.inkPicture1 = new Microsoft.Ink.InkPicture(); this.SuspendLayout(); // // inkPicture1 // this.inkPicture1.BackColor = System.Drawing.SystemColors.ActiveCaption; this.inkPicture1.Location = new System.Drawing.Point(0, 0); this.inkPicture1.MarginX = -2147483648; this.inkPicture1.MarginY = -2147483648; this.inkPicture1.Name = "inkPicture1"; this.inkPicture1.Size = new System.Drawing.Size(70, 70); this.inkPicture1.TabIndex = 0; this.inkPicture1.NewPackets += new Microsoft.Ink.InkCollectorNewPacketsEventHandler(this.inkPicture1_NewPackets); // // Form1 // this.AutoScale = false; this.AutoScaleBaseSize = new System.Drawing.Size(5, 12); this.BackColor = System.Drawing.SystemColors.ActiveCaption; this.ClientSize = new System.Drawing.Size(70, 70); this.ControlBox = false; this.Controls.Add(this.inkPicture1); this.ForeColor = System.Drawing.SystemColors.ActiveCaption; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "Form1"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false);
} #endregion
[DllImport("user32.dll")] extern static void mouse_event( int dwFlags,int dx,int dy,int mouseData, int dwExtraInfo );
/// <summary> /// アプリケーションのメイン エントリ ポイントです。 /// </summary> [STAThread] static void Main() { Application.Run(new Form1()); }
private void Form1_Load(object sender, System.EventArgs e) { this.Size = new Size(70, 70); //インクを透明にする this.inkPicture1.DefaultDrawingAttributes.Color = System.Drawing.Color.Transparent; inkPicture1.DefaultDrawingAttributes.Transparency = 255; }
private void GetXYIndexes(ref int theXIndex, ref int theYIndex) { Guid[] theGuids = inkPicture1.DesiredPacketDescription;
for (int i=0; i<theGuids.Length -1; i++) { if (theGuids[i].Equals(PacketProperty.X)) theXIndex = i;
if (theGuids[i].Equals(PacketProperty.Y)) theYIndex = i; } }
private void inkPicture1_NewPackets(object sender, Microsoft.Ink.InkCollectorNewPacketsEventArgs e) { int x = this.Location.X; int y = this.Location.Y; if (e.PacketData[indexX] < this.Left) {
x -= this.Width; Form1 form = new Form1(); form.StartPosition = FormStartPosition.Manual; form.Location = new Point(x, y); form.Show(); Console.WriteLine("ここを認識している");
} } } }
**********************************************************
inkPicture1_NewPacketsイベントのところで今行き詰っています。 最初に表示されてるinkpictureの左側に出たらその方向に新しく表示させたいのですが、 このコードではうまく動いてくれません。 if文内は認識されているようですが、何回も認識されてしまっています。
どんなささいなことでもいいので何かアドバイスを頂けたらうれしいです。
よろしくお願いします!!
|