Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (DialogResult.OK == openFileDialog.ShowDialog())
            {
                using (GsModule gsModule = (GsModule)SystemObjects.DynamicLinker.LoadModule("WinDirectX.txv", false, true))
                {
                    // create graphics device
                    using (Teigha.GraphicsSystem.Device dev = gsModule.CreateBitmapDevice())
                    {
                        // setup device properties
                        using (Dictionary props = dev.Properties)
                        {
                            props.AtPut("BitPerPixel", new RxVariant(int.Parse(comboBox1.Text)));
                        }
                        ContextForDbDatabase ctx = new ContextForDbDatabase(database);
                        ctx.PaletteBackground = colorDialog.Color;
                        LayoutHelperDevice helperDevice = LayoutHelperDevice.SetupActiveLayoutViews(dev, ctx);

                        helperDevice.SetLogicalPalette(Device.LightPalette); // light palette
                        Rectangle rect = new Rectangle(0, 0, (int)numericUpDownWidth.Value, (int)numericUpDownHeight.Value);
                        helperDevice.OnSize(rect);
                        ctx.SetPlotGeneration(checkBoxPlotGeneration.Checked);
                        if (ctx.IsPlotGeneration)
                        {
                            helperDevice.BackgroundColor = colorDialog.Color;
                        }
                        else
                        {
                            helperDevice.BackgroundColor = Color.FromArgb(0, 173, 174, 173);
                        }

                        helperDevice.Update();

                        if (DialogResult.OK == saveFileDialog.ShowDialog())
                        {
                            Export_Import.ExportBitmap(helperDevice, saveFileDialog.FileName);
                            Close();
                        }
                    }
                }
            }
        }