public void GestureComplete(IPointerEvent evnt)
        {
            Location cur = current;

            if (currentValid)
            {
                // Console.WriteLine("**** Adding {0} ****", master.GetType().Name);
                layoutModel.Execute((ILayoutAccess lo) => {
                    if (master is ModuleComponent)
                    {
                        ProjectModule sub = ((ModuleComponent)master).Module;
                        if (sub.HasDescendent(lo.Layout))
                        {
                            return;
                        }
                    }
                    Component clone = lo.AddComponent(master, cur.X, cur.Y);
                    WireTools.CheckForSplits(lo, layoutModel.WiringPoints, new Component[] { clone });
                });
            }
            this.current      = new Location(0, 0);
            this.currentValid = false;
            OnGestureCompleteEvent(true);
            layoutModel.Gesture = null;
            evnt.RepaintCanvas();
        }
Exemple #2
0
        public void GestureComplete(IPointerEvent evnt)
        {
            ComponentInstance toMove = moving;

            if (toMove != null)
            {
                moving = null;
                layoutCanvas.Execute((ILayoutAccess lo) => {
                    Component comp          = toMove.Component;
                    List <Location> toCheck = new List <Location>();
                    foreach (ConnectionPoint conn in comp.Connections)
                    {
                        toCheck.Add(movingLocation.Translate(conn.Dx, conn.Dy));
                    }

                    if (curValid)
                    {
                        lo.MoveComponent(toMove.Component, curDx, curDy);
                        layoutCanvas.WiringPoints.Update();
                        WireTools.CheckForMerges(lo, layoutCanvas.WiringPoints, toCheck);
                        layoutCanvas.WiringPoints.Update();
                        WireTools.CheckForSplits(lo, layoutCanvas.WiringPoints, new Component[] { comp });
                    }
                    else
                    {
                        lo.RemoveComponent(toMove.Component);
                        layoutCanvas.WiringPoints.Update();
                        WireTools.CheckForMerges(lo, layoutCanvas.WiringPoints, toCheck);
                    }
                });
                layoutCanvas.Hidden  = null;
                layoutCanvas.Gesture = null;
                evnt.RepaintCanvas();
            }
        }