示例#1
0
        private void 打印布局ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Printer printer = mapLayoutControl1.MapLayout.Printer;

            printer.PaperSize = PaperSize.A4;

            printer.Orientation = PaperOrientation.Landscape;

            //设置页边距

            PaperMargin paperMargin = new PaperMargin(70);

            paperMargin.Left = 100;

            paperMargin.Right = 100;

            printer.Margin = paperMargin;

            //打印机设置

            printer.DeviceDPI = 72;

            printer.IsVectorPrint = true;

            printer.PrinterName = "Microsoft XPS Document Writer";

            //打印布局

            if (printer.IsValidPrinter)
            {
                MessageBox.Show("可以打印!");
            }

            else
            {
                MessageBox.Show("打印机不合法!");
            }
        }
示例#2
0
文件: DxfMap.cs 项目: DomCR/ACadSharp
        public void SetValue <T>(T obj, object value)
            where T : CadObject
        {
            if (_property.PropertyType.IsEquivalentTo(typeof(XY)))
            {
                XY vector = (XY)_property.GetValue(obj);

                int      index      = (this.Code / 10) % 10 - 1;
                double[] components = vector.GetComponents();
                components[index] = Convert.ToDouble(value);

                vector = vector.SetComponents(components);

                this._property.SetValue(obj, vector);
            }
            else if (_property.PropertyType.IsEquivalentTo(typeof(XYZ)))
            {
                XYZ vector = (XYZ)_property.GetValue(obj);

                int      index      = (this.Code / 10) % 10 - 1;
                double[] components = vector.GetComponents();
                components[index] = Convert.ToDouble(value);

                vector = vector.SetComponents(components);

                this._property.SetValue(obj, vector);
            }
            else if (_property.PropertyType.IsEquivalentTo(typeof(Color)))
            {
                //TODO: Implement color setter

                switch (this.Code)
                {
                case 62:
                    this._property.SetValue(obj, new Color((short)value));
                    break;

                case 420:
                    // true color
                    break;

                case 430:
                    // dictionary color
                    break;
                }
            }
            else if (_property.PropertyType.IsEquivalentTo(typeof(PaperMargin)))
            {
                PaperMargin margin = (PaperMargin)_property.GetValue(obj);

                switch (this.Code)
                {
                //40	Size, in millimeters, of unprintable margin on left side of paper
                case 40:
                    margin = new PaperMargin((double)value, margin.Bottom, margin.Right, margin.Top);
                    break;

                //41	Size, in millimeters, of unprintable margin on bottom of paper
                case 41:
                    margin = new PaperMargin(margin.Left, (double)value, margin.Right, margin.Top);
                    break;

                //42	Size, in millimeters, of unprintable margin on right side of paper
                case 42:
                    margin = new PaperMargin(margin.Left, margin.Bottom, (double)value, margin.Top);
                    break;

                //43	Size, in millimeters, of unprintable margin on top of paper
                case 43:
                    margin = new PaperMargin(margin.Left, margin.Bottom, margin.Right, (double)value);
                    break;
                }

                this._property.SetValue(obj, margin);
            }
            else if (_property.PropertyType.IsEquivalentTo(typeof(Transparency)))
            {
                //TODO: Implement transparency setter
                //this._property.SetValue(obj, new Transparency((short)value));
            }
            else if (_property.PropertyType.IsEquivalentTo(typeof(bool)))
            {
                this._property.SetValue(obj, Convert.ToBoolean(value));
            }
            else if (_property.PropertyType.IsEquivalentTo(typeof(char)))
            {
                this._property.SetValue(obj, Convert.ToChar(value));
            }
            else if (_property.PropertyType.IsEquivalentTo(typeof(byte)))
            {
                this._property.SetValue(obj, Convert.ToByte(value));
            }
            else if (_property.PropertyType.IsEnum)
            {
                this._property.SetValue(obj, Enum.ToObject(_property.PropertyType, value));
            }
            else
            {
                this._property.SetValue(obj, value);
            }
        }