Esempio n. 1
0
        public TAvatarActor pushAvatar(RectangleF region)
        {
            TAvatarActor 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 TAvatarActor(document, pt.X, pt.Y, sz.X, sz.Y, selectedLayer.parent, actorName);
            }
            else
            {
                // 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 TAvatarActor(document, pt.X, pt.Y, sz.X, sz.Y, this, actorName);
            }

            return(actor);
        }
        protected override void clone(TLayer target)
        {
            base.clone(target);

            TAvatarActor targetLayer = (TAvatarActor)target;

            targetLayer.BoxSize = this.BoxSize;
            targetLayer.refreshMatrix();
        }
        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();
            }
        }