public void MakeHollow()
        {
            if (_document.Selection.IsEmpty() || _document.Selection.InFaceSelection) return;

            var solids = _document.Selection.GetSelectedObjects().OfType<Solid>().ToList();
            if (!solids.Any()) return;

            if (solids.Count > 1)
            {
                if (MessageBox.Show("This will hollow out every selected solid, are you sure?", "Multiple solids selected", MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return;
                }
            }

            var qf = new QuickForm("Select wall width") { UseShortcutKeys = true } .NumericUpDown("Wall width (negative to hollow outwards)", -1024, 1024, 0, 32).OkCancel();

            decimal width;
            do
            {
                if (qf.ShowDialog() == DialogResult.Cancel) return;
                width = qf.Decimal("Wall width (negative to hollow outwards)");
                if (width == 0) MessageBox.Show("Please select a non-zero value.");
            } while (width == 0);

            _document.PerformAction("Make objects hollow", new MakeHollow(solids, width));
        }
Beispiel #2
0
        public void ScreenshotViewport(object parameter)
        {
            var focused = (parameter as ViewportBase) ?? ViewportManager.Viewports.FirstOrDefault(x => x.IsFocused);
            if (focused == null) return;

            var screen = Screen.FromControl(this);
            var area = screen.Bounds;

            using (var qf = new QuickForm("Select screenshot size") {UseShortcutKeys = true}
                .NumericUpDown("Width", 640, 5000, 0, area.Width)
                .NumericUpDown("Height", 480, 5000, 0, area.Height)
                .OkCancel())
            {
                if (qf.ShowDialog() != DialogResult.OK) return;

                var shot = ViewportManager.CreateScreenshot(focused, (int) qf.Decimal("Width"), (int) qf.Decimal("Height"));
                if (shot == null) return;

                var ext = focused is Viewport2D || (focused is Viewport3D && ((Viewport3D)focused).Type != Viewport3D.ViewType.Textured) ? ".png" : ".jpg";

                using (var sfd = new SaveFileDialog())
                {
                    sfd.FileName = "Sledge - "
                                   + (DocumentManager.CurrentDocument != null ? DocumentManager.CurrentDocument.MapFileName : "untitled")
                                   + " - " + DateTime.Now.ToString("yyyy-MM-ddThh-mm-ss") + ext;
                    sfd.Filter = "Image Files (*.png, *.jpg, *.bmp)|*.png;*.jpg;*.bmp";
                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        if (sfd.FileName.EndsWith("jpg"))
                        {
                            var encoder = GetJpegEncoder();
                            if (encoder != null)
                            {
                                var p = new EncoderParameter(Encoder.Quality, 90L);
                                var ep = new EncoderParameters(1);
                                ep.Param[0] = p;
                                shot.Save(sfd.FileName, encoder, ep);
                            }
                            else
                            {
                                shot.Save(sfd.FileName);
                            }
                        }
                        else
                        {
                            shot.Save(sfd.FileName);
                        }
                    }
                }
                shot.Dispose();
            }
        }