Example #1
0
        public override bool Execute(UICommandContext ctx)
        {
            //创建事务
            var transaction = new UndoTransaction(ctx.Document);

            transaction.Start(this.Name);

            var text = new MyTextElement();

            text.Text     = "这是一个好引擎!";
            text.Position = new Vector3(100, 100, 100);

            text.AddElement(ctx.Document);

            text.Show(ctx.RenderView.GetScene());


            //提交事务
            transaction.Commit();

            ctx.RequestUpdate();

            return(true);
        }
Example #2
0
        /// <summary>
        /// 换个文档显示
        /// </summary>
        /// <param name="doc"></param>
        public void ResetDocument(Document doc)
        {
            mDocument = doc;
            mRootSceneNode.SetDocument(mDocument);
            mDbView = DbView.Cast(mDocument.FindElement(mDocument.GetActiveDbViewId()));

            var table   = mDocument.FindTable("UserElement");
            var userIds = table.GetIds();
            var scene   = mContext.RenderView.GetScene();

            foreach (var id in userIds)
            {
                var element = mDocument.FindElement(id);
                if (MyTextElement.IsKindOf(element))
                {
                    var text = new MyTextElement();
                    text.Load(UserElement.Cast(element));
                    text.Show(scene);
                }
            }

            mContext.RequestUpdate();
            mRenderCtrl.ZoomAll(0.8f);
        }