internal override void ProcessEvent(InteractionOutput output) { if (output.Data.Interaction == Win32.INTERACTION.TAP) { if (output.Data.Tap.Count == 2) { ResetPoints(); _form.Invalidate(); } } else if (output.Data.Interaction == Win32.INTERACTION.MANIPULATION) { if (output.IsBegin()) { _baseXY.Clear(); _center = PointF.Empty; foreach (PointF pt in _points) { _baseXY.Add(new PointF(pt.X, pt.Y)); _center.X += pt.X; _center.Y += pt.Y; } _center.X /= _points.Count; _center.Y /= _points.Count; } else { Win32.MANIPULATION_TRANSFORM mt = output.Data.Manipulation.Cumulative; PointF ct = _center; ct.X += mt.TranslationX; ct.Y += mt.TranslationY; for (int i = 0; i < _points.Count; i++) { PointF pt = _baseXY[i]; pt.X += mt.TranslationX; pt.Y += mt.TranslationY; float deltaX = pt.X - ct.X; float deltaY = pt.Y - ct.Y; double r = Math.Sqrt(deltaX * deltaX + deltaY * deltaY); double a = Math.Atan2(deltaY, deltaX) + mt.Rotation; pt.X = Convert.ToSingle(Math.Cos(a) * r) + ct.X; pt.Y = Convert.ToSingle(Math.Sin(a) * r) + ct.Y; pt.X = mt.Scale * (pt.X - ct.X) + ct.X; pt.Y = mt.Scale * (pt.Y - ct.Y) + ct.Y; _points[i] = pt; } _form.Invalidate(); } } }
internal static IntPtr CreateInteractionContext(IInteractionHandler interactionHandler, SynchronizationContext syncContext) { IntPtr ic; CreateInteractionContext(out ic); InteractionOutput io = new InteractionOutput(ic, interactionHandler, syncContext); lock (_lockObj) { _listeners.Add(ic.ToInt64(), io); } RegisterOutputCallbackInteractionContext(ic, Marshal.GetFunctionPointerForDelegate(_callback), ic); return(ic); }
static void TimerElapsed(object state) { InteractionOutput[] items = null; lock (_lockObj) { if (_inertiaQueue.Count > 0) { items = _inertiaQueue.ToArray(); _inertiaQueue.Clear(); } } if (items != null) { for (int i = 0; i < items.Length; i++) { InteractionOutput io = items[i]; for (int j = 0; j < i; j++) { if (items[j].InteractionContext == io.InteractionContext) { io = null; break; } } if (io != null && io.Alive) { io.SyncContext.Post(delegate(object obj) { InteractionOutput m = (InteractionOutput)obj; if (m.Alive) { ProcessInertiaInteractionContext(m.InteractionContext); } }, io); } } } }
internal override void ProcessEvent(InteractionOutput output) { if (output.Data.Interaction == Win32.INTERACTION.TAP) { if (output.Data.Tap.Count == 2) { foreach (Figure f in _form.Figures) { f.ResetPoints(); } _form.Invalidate(); } } else if (output.Data.Interaction == Win32.INTERACTION.SECONDARY_TAP) { _n++; if (_n > 3) { _n = 1; } Color c = Color.Green; switch (_n) { case 1: c = Color.FromArgb(64, 64, 64); break; case 2: c = Color.Maroon; break; case 3: c = Color.DarkGreen; break; } _form.BackColor = c; } }
internal abstract void ProcessEvent(InteractionOutput output);
void IInteractionHandler.ProcessInteractionEvent(InteractionOutput output) { ProcessEvent(output); }