/// <summary> /// キューにたまっているイベントを処理する。 /// </summary> void ProcessAllQueuedEvents() { // EventQueueの中身をCurrent反映 for (int i = 0; i < eventQueue.Count; i++) { TouchEvent e = eventQueue[i]; Touch t = null; if (e.Down) { activeItems.Add(t = new Touch() { ID = e.ID, Primary = e.Primary, Src = e.SourceHandle, LifeTime = 30, Duration = 0, }); } else { for (int j = 0; j < activeItems.Count; j++) { if (activeItems[j].ID == e.ID) { t = activeItems[j]; break; } } } // こうしん t.Current = new Touch.TouchStatus() { X = e.X, Y = e.Y, Width = e.Width, Height = e.Height, InRange = e.InRange, Touched = (t.Current.Touched | e.Down) & !e.Up, }; } eventQueue.Clear(); }
/// <summary> /// マウスをタッチイベントとしてシミュレートする /// </summary> void MouseToTouch() { if (!control.Created) { return; } // マウス座標と左ボタンの状態を得る Point p = System.Windows.Forms.Cursor.Position; // スクリーン座標系 bool lButton = (System.Windows.Forms.Form.MouseButtons & MouseButtons.Left) != 0; bool clickDown = lButton & !lastLButtonStatus; lastLButtonStatus = lButton; // クライアント座標系に変換。 IntPtr controlHanle = control.Handle; Win32.POINT pt = new Win32.POINT() { X = p.X, Y = p.Y }; Win32.ScreenToClient(controlHanle, ref pt); p = new Point(pt.X, pt.Y); // if (clickDown && mouseInput == null) { if (control.ClientRectangle.Contains(p)) { mouseInput = new Touch() { ID = -1, Duration = 0, Src = IntPtr.Zero, LifeTime = 30, Primary = true, Current = new Touch.TouchStatus() { Touched = true, InRange = true, X = p.X, Y = p.Y, Width = 10, Height = 10, }, Previous = new Touch.TouchStatus(), }; activeItems.Add(mouseInput); } } if (mouseInput != null) { mouseInput.Current.X = p.X; mouseInput.Current.Y = p.Y; } if (mouseInput != null && !lButton) { mouseInput.Current.Touched = false; mouseInput = null; } }