예제 #1
0
        private void grpxView_Paint(object sender, PaintEventArgs e)
        {
            var stringFormat = new StringFormat
            {
                Alignment     = StringAlignment.Center,
                LineAlignment = StringAlignment.Center
            };

            if (_helperDevice == null)
            {
                e.Graphics.DrawString("没有合适的LayoutHelperDevice", SystemFonts.DefaultFont, Brushes.Blue, e.ClipRectangle, stringFormat);
                return;
            }
            try
            {
                e.Graphics.DrawString("11111111111115555555555555555555555555555555555", SystemFonts.DefaultFont, Brushes.Blue, e.ClipRectangle, stringFormat);
                //var props = _helperDevice.Properties;
                //if (props.Contains("WindowHDC")) // Check if property is supported
                //    props.AtPut("WindowHDC", new RxVariant(e.Graphics.GetHdc())); // hWindowDC necessary for Bitmap device
                _helperDevice.OnSize(e.ClipRectangle);
                _helperDevice.Update();
                e.Graphics.DrawString("333333333333333333333", SystemFonts.DefaultFont, Brushes.Blue, e.ClipRectangle, stringFormat);
                e.Graphics.ReleaseHdc();
            }
            catch (System.Exception ex)
            {
                e.Graphics.DrawString(ex.ToString(), SystemFonts.DefaultFont, Brushes.Red, e.ClipRectangle);
            }
        }
예제 #2
0
        public static void SVG_export(Database database)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.AddExtension = true;
            sfd.DefaultExt   = "svg";
            sfd.Filter       = "SVG files (*.svg)|*.svg";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                // SVG export is a rendering device too
                using (GsModule gsModule = (GsModule)SystemObjects.DynamicLinker.LoadModule("TD_SvgExport.tx", false, true))
                {
                    if (gsModule == null) // if SVG export module is not found
                    {
                        return;
                    }
                    // create graphics device
                    using (Teigha.GraphicsSystem.Device dev = gsModule.CreateDevice())
                    {
                        using (FileStreamBuf outStr = new FileStreamBuf(sfd.FileName, false, FileShareMode.DenyWrite, FileCreationDisposition.CreateAlways))
                        {
                            // setup device properties
                            using (Dictionary props = dev.Properties)
                            {
                                // SVG export uses stream output
                                props.AtPut("Output", outStr);
                                // lines may look thin - may be scaled
                                props.AtPut("LineWeightScale", new RxVariant(1.0));
                                // number of digits after decimal point in the output file
                                props.AtPut("Precision", new RxVariant(6));
                                // place to put images (may be relative path)
                                props.AtPut("ImageBase", new RxVariant(System.IO.Path.GetDirectoryName(sfd.FileName)));
                                // missing font
                                props.AtPut("GenericFontFamily", new RxVariant("sans-serif"));
                                // software HLR engine enabled
                                props.AtPut("UseHLR", new RxVariant(true));
                                // whether to use blended gradients for complex gradient fill (may increase size)
                                props.AtPut("EnableGouraudShading", new RxVariant(true));
                            }
                            dev.SetLogicalPalette(Device.LightPalette); // light palette with white background
                            ContextForDbDatabase ctx = new ContextForDbDatabase(database);
                            ctx.SetPlotGeneration(true);
                            LayoutHelperDevice hd = LayoutHelperDevice.SetupActiveLayoutViews(dev, ctx);
                            // size is SVG viewbox
                            hd.OnSize(new System.Drawing.Rectangle(0, 0, 1024, 768));
                            hd.Update();
                        }
                    }
                }
            }
        }
예제 #3
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();
                        }
                    }
                }
            }
        }