protected override void ExecuteCore()
        {
            actor.name      = final.name;
            actor.draggable = final.draggable;
            actor.acceleratorSensibility = final.acceleratorSensibility;
            actor.anchor          = final.anchor;
            actor.position        = final.position;
            actor.scale           = final.scale;
            actor.skew            = final.skew;
            actor.rotation        = final.rotation;
            actor.backgroundColor = final.backgroundColor;
            actor.alpha           = final.alpha;
            actor.zIndex          = final.zIndex;

            actor.interactionBound     = final.interactionBound;
            actor.autoInteractionBound = final.autoInteractionBound; // must assign autoInteractionBound after assin interaction bound, because interactionBound setting will change autoInteractionBound property

            actor.puzzleArea = final.puzzleArea;
            actor.puzzle     = final.puzzle;

            if (actor is TTextActor)
            {
                TTextActor textActor = actor as TTextActor;
                textActor.text    = final.text;
                textActor.font    = final.font;
                textActor.color   = final.color;
                textActor.boxSize = final.boxSize;
            }

            TScene scene = actor.ownerScene();

            document.sceneManager.updateThumbnail(scene);
        }
        protected override void ExecuteCore()
        {
            actor.parent.childs.Add(actor);
            TScene scene = actor.ownerScene();

            document.sceneManager.updateThumbnail(scene);
        }
예제 #3
0
        // move the puzzle area of selected items the specified delta, parameters are based on real drawing canvas coordinates
        public void movePuzzleArea(float dx, float dy, bool fixedMove)
        {
            if (fixedMove)
            {
                double al = Math.Atan2(dy, dx) * 180 / Math.PI;
                float  d  = Math.Min(Math.Abs(dx), Math.Abs(dy));
                if (al >= -22.5 && al < 22.5)
                {
                    dy = 0;
                }
                else if (al >= 22.5 && al < 67.5)
                {
                    dx = d; dy = d;
                }
                else if (al >= 67.5 && al < 112.5)
                {
                    dx = 0;
                }
                else if (al >= 112.5 && al < 157.5)
                {
                    dx = -d; dy = d;
                }
                else if (al >= 157.5 || al < -157.5)
                {
                    dy = 0;
                }
                else if (al >= -157.5 && al < -112.5)
                {
                    dx = -d; dy = -d;
                }
                else if (al >= -112.5 && al < -67.5)
                {
                    dx = 0;
                }
                else if (al >= 67.5 && al < 22.5)
                {
                    dx = d; dy = -d;
                }
            }

            for (int i = 0; i < selectedItems.Count; i++)
            {
                TActor item   = this.selectedItems[i];
                TActor origin = item.backupActor;
                PointF p      = origin.ownerScene().logicalToScreen(origin.puzzleArea.Location);
                p.X            += dx; p.Y += dy;
                item.puzzleArea = new RectangleF(origin.ownerScene().screenToLogical(p), origin.puzzleArea.Size);
            }
        }
예제 #4
0
        // scale the puzzle area of selected items the specified delta, parameters are based on real drawing canvas coordinates
        public void scalePuzzleArea(int part, float dx, float dy, bool fixedRatio)
        {
            for (int i = 0; i < selectedItems.Count; i++)
            {
                TActor item   = this.selectedItems[i];
                TActor origin = item.backupActor;

                PointF     d     = origin.ownerScene().screenVectorToLogical(new PointF(dx, dy));
                RectangleF bound = origin.puzzleArea;

                if (fixedRatio)
                {
                    float z;
                    if (part == 1)
                    {
                        z = Math.Max(-d.X / bound.Width, -d.Y / bound.Height);
                        d = new PointF(-z * bound.Width, -z * bound.Height);
                    }
                    else if (part == 2)
                    {
                        z = Math.Max(-d.X / bound.Width, d.Y / bound.Height);
                        d = new PointF(-z * bound.Width, z * bound.Height);
                    }
                    else if (part == 3)
                    {
                        z = Math.Max(d.X / bound.Width, d.Y / bound.Height);
                        d = new PointF(z * bound.Width, z * bound.Height);
                    }
                    else if (part == 4)
                    {
                        z = Math.Max(d.X / bound.Width, -d.Y / bound.Height);
                        d = new PointF(z * bound.Width, -z * bound.Height);
                    }
                }

                float x1 = bound.Left, y1 = bound.Top, x2 = bound.Right, y2 = bound.Bottom;
                if (part == 1 || part == 2 || part == 5)
                {
                    x1 += d.X;
                }
                if (part == 3 || part == 4 || part == 7)
                {
                    x2 += d.X;
                }
                if (part == 1 || part == 4 || part == 8)
                {
                    y1 += d.Y;
                }
                if (part == 2 || part == 3 || part == 6)
                {
                    y2 += d.Y;
                }

                item.puzzleArea = new RectangleF(x1, y1, x2 - x1, y2 - y1);
            }
        }
        protected override void UnExecuteCore()
        {
            for (int i = actorDatas.Count - 1; i >= 0; i--)
            {
                ActorData actorData = actorDatas[i];
                actorData.parent.childs.Insert(actorData.index, actorData.actor);
            }

            if (actorList.Count > 0)
            {
                TActor actor = actorList[0];
                TScene scene = actor.ownerScene();
                document.sceneManager.updateThumbnail(scene);
            }
        }
        protected override void ExecuteCore()
        {
            actorDatas.Clear();
            document.selectedItems.Clear();

            actorList.ForEach((actor) => {
                if (actor.parent != null)
                {
                    actorDatas.Add(new ActorData {
                        actor = actor, parent = actor.parent, index = actor.parent.childs.IndexOf(actor)
                    });
                    actor.parent.childs.Remove(actor);
                }
            });

            if (actorList.Count > 0)
            {
                TActor actor = actorList[0];
                TScene scene = actor.ownerScene();
                document.sceneManager.updateThumbnail(scene);
            }
        }
예제 #7
0
        //============== return value ===============//
        //
        //                    -1
        //      9                           9
        //        ┌───────────────────────┐
        //        │ 1         8         4 │
        //        │                       │
        //  -1    │ 5         0         7 │    -1
        //        │                       │
        //        │ 2         6         3 │
        //        └───────────────────────┘
        //      9                           9
        //                    -1
        //
        //
        // Anchor Point : 10
        //============================================//
        public int partOfSelection(float x, float y, out int cursor)
        {
            cursor = -1;

            if (selectedItems.Count == 0)
            {
                return(-1);
            }
            if (selectedItems.Count > 1)
            {
                return(containsInSelection(x, y) ? 0 : 9);
            }

            TActor actor = selectedItems[0];

            if (currentTool == TDocument.TOOL_PUZZLE && !actor.puzzle)
            {
                return(-1);
            }

            PointF screenPos  = new PointF(x, y);
            PointF logicalPos = currentTool != TDocument.TOOL_PUZZLE ? actor.screenToLogical(new PointF(x, y)) : actor.ownerScene().screenToLogical(new PointF(x, y));

            RectangleF actorBound        = actor.bound();
            PointF     anchorPosOnScreen = actor.logicalToScreen(new PointF(actorBound.Width * actor.anchor.X, actorBound.Height * actor.anchor.Y));

            RectangleF bound;

            if (currentTool == TDocument.TOOL_BOUNDING)
            {
                bound = actor.interactionBound;
            }
            else if (currentTool == TDocument.TOOL_PUZZLE)
            {
                bound = actor.puzzleArea;
            }
            else
            {
                bound = actorBound;
            }

            PointF[] boundOnScreen;
            if (currentTool == TDocument.TOOL_BOUNDING)
            {
                boundOnScreen = actor.interactionBoundOnScreen();
            }
            else if (currentTool == TDocument.TOOL_PUZZLE)
            {
                boundOnScreen = actor.puzzleAreaOnScreen();
            }
            else
            {
                boundOnScreen = actor.boundOnScreen();
            }
            int ctrl_size = 6;

            bool leftEdge    = TUtil.distanceBetweenPointLine(screenPos, boundOnScreen[0], boundOnScreen[1]) <= ctrl_size;
            bool bottomEdge  = TUtil.distanceBetweenPointLine(screenPos, boundOnScreen[1], boundOnScreen[2]) <= ctrl_size;
            bool rightEdge   = TUtil.distanceBetweenPointLine(screenPos, boundOnScreen[2], boundOnScreen[3]) <= ctrl_size;
            bool topEdge     = TUtil.distanceBetweenPointLine(screenPos, boundOnScreen[3], boundOnScreen[0]) <= ctrl_size;
            bool insideBound = bound.Contains(logicalPos);

            int    first_cursor = 0; // cursor form part 5
            double angle        = -Math.Atan2(boundOnScreen[1].Y - boundOnScreen[0].Y, boundOnScreen[1].X - boundOnScreen[0].X) * 180 / Math.PI;

            if (angle < 0)
            {
                angle += 360;
            }
            first_cursor = (int)((angle + 22.5) / 45) % 4;

            int part = -1;

            if (leftEdge && topEdge)
            {
                part = 1; cursor = (first_cursor - 1) % 4;
            }
            else if (leftEdge && bottomEdge)
            {
                part = 2; cursor = (first_cursor + 1) % 4;
            }
            else if (rightEdge && bottomEdge)
            {
                part = 3; cursor = (first_cursor + 3) % 4;
            }
            else if (rightEdge && topEdge)
            {
                part = 4; cursor = (first_cursor + 5) % 4;
            }
            else if (leftEdge && TUtil.isPointProjectionInLineSegment(screenPos, boundOnScreen[0], boundOnScreen[1]))
            {
                part = 5; cursor = (first_cursor + 0) % 4;
            }
            else if (bottomEdge && TUtil.isPointProjectionInLineSegment(screenPos, boundOnScreen[1], boundOnScreen[2]))
            {
                part = 6; cursor = (first_cursor + 2) % 4;
            }
            else if (rightEdge && TUtil.isPointProjectionInLineSegment(screenPos, boundOnScreen[2], boundOnScreen[3]))
            {
                part = 7; cursor = (first_cursor + 4) % 4;
            }
            else if (topEdge && TUtil.isPointProjectionInLineSegment(screenPos, boundOnScreen[3], boundOnScreen[0]))
            {
                part = 8; cursor = (first_cursor + 6) % 4;
            }
            else if (TUtil.distanceBetweenPoints(screenPos, anchorPosOnScreen) <= ctrl_size)
            {
                part = 10;
            }
            else if (insideBound)
            {
                part = 0;
            }
            else if (currentTool != TDocument.TOOL_BOUNDING && currentTool != TDocument.TOOL_PUZZLE)
            {
                if (TUtil.distanceBetweenPoints(screenPos, boundOnScreen[0]) <= ctrl_size * 3 ||
                    TUtil.distanceBetweenPoints(screenPos, boundOnScreen[1]) <= ctrl_size * 3 ||
                    TUtil.distanceBetweenPoints(screenPos, boundOnScreen[2]) <= ctrl_size * 3 ||
                    TUtil.distanceBetweenPoints(screenPos, boundOnScreen[3]) <= ctrl_size * 3)
                {
                    part = 9;
                }
            }

            return(part);
        }