Пример #1
0
        public override bool Execute(UICommandContext ctx)
        {
            ctx.Document.Undo();
            ctx.RequestUpdate();

            return(true);
        }
Пример #2
0
        public override bool Execute(UICommandContext ctx)
        {
            var dlg = new OpenFileDialog();

            dlg.Filter = "IGES Files(*.iges;*.igs)|*.iges;*.igs";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                var shape = IgesIO.Open(dlg.FileName);
                if (shape != null)
                {
                    var transaction = new UndoTransaction(ctx.Document);
                    transaction.Start(this.Name);

                    var shapeElement = new ShapeElement();
                    shapeElement.SetName(ImportStepCommand.ExtractName(dlg.SafeFileName));
                    ctx.Document.AddElement(shapeElement);
                    shapeElement.SetMaterialId(ctx.DefaultMaterialId);
                    shapeElement.SetShape(shape);
                    ctx.ShowElement(shapeElement);
                    transaction.Commit();

                    ctx.RequestUpdate();
                }
            }
            return(true);
        }
Пример #3
0
        private void MRenderCtrl_Load(object sender, EventArgs e)
        {
            mDocument = new Document();
            mDbView   = mDocument.Initialize("3D");

            mRootSceneNode = new DocumentSceneNode(mDocument);
            mRenderCtrl.ShowSceneNode(mRootSceneNode);

            mContext = new UICommandContext(this);

            mDocument.EnableTransaction(false);
            var material = new MaterialElement();

            material.SetName("Default");
            mMaterialId = mDocument.AddElement(material);

            mDocument.EnableTransaction(true);

            mRenderCtrl.SetSelectCallback((PickedItem item) =>
            {
                var node      = item.GetNode();
                var elementId = node == null ? ElementId.InvalidId : new ElementId(node.GetUserId());
                mSelectionCallback(item, mDocument, elementId);
            });
        }
Пример #4
0
        public override bool Execute(UICommandContext ctx)
        {
            var dlg = new System.Windows.Forms.ColorDialog();

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                ctx.RenderView.SetBackgroundColor(dlg.Color.R / 255.0f, dlg.Color.G / 255.0f, dlg.Color.B / 255.0f, 1);
            }
            return(true);
        }
Пример #5
0
        public override bool Execute(UICommandContext ctx)
        {
            var dlg = new SaveFileDialog();

            dlg.Filter = "AnyCAD Rapid Files(*.acad)|*.acad";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                DocumentIO.Save(ctx.Document, dlg.FileName);
            }
            return(true);
        }
Пример #6
0
        public static bool ExecuteCommand(string name, UICommandContext ctx)
        {
            UICommand command;

            if (mCommands.TryGetValue(name, out command))
            {
                return(command.Execute(ctx));
            }

            return(false);
        }
Пример #7
0
        public override bool Execute(UICommandContext ctx)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = "Image Files(*.jpg;*.png)|*.jpg;*.png";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                var bkg = new ImageBackground(ImageTexture2D.Create(dlg.FileName));
                ctx.RenderView.GetViewer().SetBackground(bkg);
            }
            return(true);
        }
Пример #8
0
        public override bool Execute(UICommandContext ctx)
        {
            var dlg = new OpenFileDialog();

            dlg.Filter = "AnyCAD Rapid Files(*.acad)|*.acad";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                var doc = DocumentIO.Load(dlg.FileName);
                ctx.mDocView.ResetDocument(doc);
            }
            return(true);
        }
Пример #9
0
        public override bool Execute(UICommandContext ctx)
        {
            var transaction = new UndoTransaction(ctx.Document);

            transaction.Start(this.Name);

            var element = SphereElementSchema.Create(ctx.Document);

            ctx.ShowElement(element);

            transaction.Commit();

            ctx.RequestUpdate();

            return(true);
        }
Пример #10
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);
        }
Пример #11
0
 public override bool Execute(UICommandContext ctx)
 {
     ctx.RenderView.ZoomAll(1.2f);
     return(true);
 }
Пример #12
0
 public virtual bool Execute(UICommandContext ctx)
 {
     return(false);
 }