コード例 #1
0
        protected override void UnExecuteCore()
        {
            actor.name      = original.name;
            actor.draggable = original.draggable;
            actor.acceleratorSensibility = original.acceleratorSensibility;
            actor.anchor          = original.anchor;
            actor.position        = original.position;
            actor.scale           = original.scale;
            actor.skew            = original.skew;
            actor.rotation        = original.rotation;
            actor.backgroundColor = original.backgroundColor;
            actor.alpha           = original.alpha;
            actor.zIndex          = original.zIndex;

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

            actor.puzzleArea = original.puzzleArea;
            actor.puzzle     = original.puzzle;

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

            TScene scene = actor.ownerScene();

            document.sceneManager.updateThumbnail(scene);
        }
コード例 #2
0
        public void setFinalData(TActor actor)
        {
            final.name      = actor.name;
            final.draggable = actor.draggable;
            final.acceleratorSensibility = actor.acceleratorSensibility;
            final.anchor               = actor.anchor;
            final.position             = actor.position;
            final.scale                = actor.scale;
            final.skew                 = actor.skew;
            final.rotation             = actor.rotation;
            final.backgroundColor      = actor.backgroundColor;
            final.alpha                = actor.alpha;
            final.zIndex               = actor.zIndex;
            final.interactionBound     = actor.interactionBound;
            final.autoInteractionBound = actor.autoInteractionBound;

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

            if (actor is TTextActor)
            {
                TTextActor textActor = actor as TTextActor;
                final.text    = textActor.text;
                final.font    = textActor.font;
                final.color   = textActor.color;
                final.boxSize = textActor.boxSize;
            }
        }
コード例 #3
0
        protected override void clone(TLayer target)
        {
            base.clone(target);

            TTextActor targetLayer = (TTextActor)target;
            targetLayer.text = this.text;
            targetLayer.font = (Font)this.font.Clone();
            targetLayer.color = this.color;
            targetLayer.BoxSize = this.boxSize;
            refreshMatrix();
        }
コード例 #4
0
        // scale the selected text actor the specified delta, parameters are based on real drawing canvas coordinates
        public bool resizeSelectedTextActor(int part, float dx, float dy)
        {
            TActor actor = this.selectedActor();

            if (actor != null && actor is TTextActor)
            {
                TTextActor item = (TTextActor)actor;
                PointF     d    = item.screenVectorToLogical(new PointF(dx, dy));

                float w = item.boxSize.Width, h = item.boxSize.Height;
                float px = item.anchor.X * w, py = item.anchor.Y * h;

                if (part == 1 || part == 2 || part == 5)
                {
                    w -= d.X;
                    px = d.X + w * item.anchor.X;
                }
                if (part == 3 || part == 4 || part == 7)
                {
                    w += d.X;
                    px = item.anchor.X * w;
                }
                if (part == 1 || part == 4 || part == 8)
                {
                    h -= d.Y;
                    py = d.Y + h * item.anchor.Y;
                }
                if (part == 2 || part == 3 || part == 6)
                {
                    h += d.Y;
                    py = item.anchor.Y * h;
                }

                if (w > 0 && h > 0)
                {
                    PointF[] p0 = { new PointF(px, py) };
                    item.matrix.TransformPoints(p0);
                    item.position = p0[0];
                    item.boxSize  = new SizeF(w, h);

                    return(true);
                }
            }

            return(false);
        }
コード例 #5
0
        public TTextActor pushText(string text, RectangleF region)
        {
            TTextActor actor = null;

            // new name
            string actorName = this.newLayerName("Actor_");

            // selected layer
            if (document.haveSelection())
            {
                TLayer selectedLayer = document.selectedItems[0];
                PointF pt            = selectedLayer.parent.screenToLogical(new PointF(region.X + region.Width / 2, region.Y + region.Height / 2));
                PointF sz            = selectedLayer.parent.screenVectorToLogical(new PointF(region.Width, region.Height));
                actor = new TTextActor(document, text, pt.X, pt.Y, sz.X, sz.Y, selectedLayer.parent, actorName);
            }
            else
            {
                // text box should have the size at leat 100x30 initially
                PointF minSz = this.logicalVectorToScreen(new PointF(100, 30));
                if (region.Width < minSz.X)
                {
                    region.Width = minSz.X;
                }
                if (region.Height < minSz.Y)
                {
                    region.Height = minSz.Y;
                }

                // create text actor
                PointF pt = this.screenToLogical(new PointF(region.X + region.Width / 2, region.Y + region.Height / 2));
                PointF sz = this.screenVectorToLogical(new PointF(region.Width, region.Height));
                actor = new TTextActor(document, text, pt.X, pt.Y, sz.X, sz.Y, this, actorName);
            }

            return(actor);
        }
コード例 #6
0
        private void pnlWorkspace_MouseUp(object sender, MouseEventArgs e)
        {
            if (this.document.currentScene() == null)
            {
                return;
            }

            // main form
            FrmMainContainer mainForm = (FrmMainContainer)this.MdiParent;

            if (e.Button == MouseButtons.Left && MousePressed)
            {
                if (MouseDownTool == TDocument.TOOL_TEXT)
                {
                    if (this.document.haveSelection() && MouseDownPart == 0)
                    {
                        mainForm.focusTextActorContent();
                    }
                    else if (!this.document.haveSelection() || MouseDownPart == -1)
                    {
                        // positivation
                        RectangleF bound = TUtil.positiveRectangle(SelectRegion);
                        if (bound.Width > 1 && bound.Height > 1)
                        {
                            // item to current scene
                            TTextActor actor = this.document.currentScene().pushText("", bound);
                            this.document.actionManager.RecordAction(new AddActorAction(this.document, actor));

                            // set the document modified flag
                            this.document.modified = true;

                            // select new added text actor
                            this.document.clearSelectedItems();
                            this.document.toggleSelectedItem(actor);

                            // update panels
                            mainForm.updateScenesPanel(this.document.sceneManager.currentSceneIndex);
                            mainForm.updateOutlinePanel();
                            mainForm.updateHistoryPanel();

                            // fire mainform's selected item changed event
                            mainForm.selectedItemChanged();

                            // show textbox of ribbon bar and make let user to edit content
                            mainForm.focusTextActorContent();

                            // record modify action
                            modifyActorAction = new ModifyActorAction(document, actor);
                        }
                    }
                    else if (this.document.haveSelection() && modifyActorAction != null)
                    {
                        // this is the case when text box was resized with text tool
                        modifyActorAction.setFinalData(this.document.selectedActor());
                        if (modifyActorAction.isModified())
                        {
                            this.document.actionManager.RecordAction(modifyActorAction);

                            // set the document modified flag
                            this.document.modified = true;

                            // ready to new modification action
                            modifyActorAction = new ModifyActorAction(document, document.selectedActor());

                            // update history
                            mainForm.updateHistoryPanel();
                        }

                        // update panels
                        this.document.sceneManager.updateThumbnail(this.document.sceneManager.currentSceneIndex);
                        mainForm.updateScenesPanel(this.document.sceneManager.currentSceneIndex);
                        mainForm.updateToolbarSceneSettings();
                        mainForm.updateOutlinePanel();
                    }
                }
                else if (MouseDownTool == TDocument.TOOL_AVATAR)
                {
                    if (!this.document.haveSelection() || MouseDownPart == -1)
                    {
                        // positivation
                        RectangleF bound = TUtil.positiveRectangle(SelectRegion);
                        if (bound.Width > 1 && bound.Height > 1)
                        {
                            // item to current scene
                            TAvatarActor actor = this.document.currentScene().pushAvatar(bound);
                            this.document.actionManager.RecordAction(new AddActorAction(this.document, actor));

                            // set the document modified flag
                            this.document.modified = true;

                            // select new added avatar actor
                            this.document.clearSelectedItems();
                            this.document.toggleSelectedItem(actor);

                            // update panels
                            mainForm.updateScenesPanel(this.document.sceneManager.currentSceneIndex);
                            mainForm.updateOutlinePanel();
                            mainForm.updateHistoryPanel();

                            // fire mainform's selected item changed event
                            mainForm.selectedItemChanged();

                            // record modify action
                            modifyActorAction = new ModifyActorAction(document, actor);
                        }
                    }
                }
                else
                {
                    if (this.document.haveSelection() && modifyActorAction != null)
                    {
                        // this is the case when text box was resized with text tool
                        modifyActorAction.setFinalData(this.document.selectedActor());
                        if (modifyActorAction.isModified())
                        {
                            this.document.actionManager.RecordAction(modifyActorAction);

                            // set the document modified flag
                            this.document.modified = true;

                            // ready to new modification action
                            modifyActorAction = new ModifyActorAction(document, document.selectedActor());

                            // update history
                            mainForm.updateHistoryPanel();
                        }
                    }

                    // update panels
                    this.document.sceneManager.updateThumbnail(this.document.sceneManager.currentSceneIndex);
                    mainForm.updateScenesPanel(this.document.sceneManager.currentSceneIndex);
                    mainForm.updateToolbarSceneSettings();
                    mainForm.updateOutlinePanel();
                }

                foreach (TActor actor in this.document.selectedItems)
                {
                    actor.deleteBackup();
                }

                MousePressed  = false;
                MouseDownTool = TDocument.TOOL_NONE;
                MouseDownPart = -1;
                SelectRegion  = RectangleF.Empty;

                // reset cursor
                this.updateCursor();

                // redraw workspace
                this.pnlWorkspace.Refresh();
            }
        }