Beispiel #1
0
        // gets a preview image of the style
        public Image GetPreview(bool forceUpdate)
        {
            if (_preview == null || forceUpdate)
            {
                // draw style preview
                Bitmap       bmp = new Bitmap(150, 105);
                StringFormat sf  = StringFormat.GenericTypographic;
                using (Graphics g = Graphics.FromImage(bmp))
                {
                    // highest quality we can get
                    g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
                    g.SmoothingMode     = SmoothingMode.HighQuality;

                    // white background
                    Rectangle rc = new Rectangle(0, 0, bmp.Width, bmp.Height);
                    g.FillRectangle(Brushes.White, rc);

                    // content
                    //rc.Inflate(-3, -3);
                    rc.Height = 30;
                    int height = ReportHeader.Render(g, Name, rc);//"Title", rc);
                    rc.Offset(0, height - 1);
                    height = PageHeader.Render(g, "Page Header", rc);
                    rc.Offset(0, height - 1);
                    height = GroupHeader.Render(g, "Group Header", rc);
                    rc.Offset(0, height - 1);
                    height = Detail.Render(g, "  Detail", rc);
                    rc.Offset(0, height - 1);
                    using (Brush br = new SolidBrush(Detail.AlternateColor))
                    {
                        g.FillRectangle(br, rc);
                    }
                }

                // draw style preview into template
                Bitmap bmpTemplate = StyleSelector.BitmapFromStream("styleTemplate.bmp", Color.Red);
                using (Graphics g = Graphics.FromImage(bmpTemplate))
                {
                    Rectangle rc = new Rectangle(0, 71, bmp.Width, bmp.Height);
                    rc.Offset(+2, +2);
                    g.FillRectangle(Brushes.DarkGray, rc);
                    rc.Offset(-2, -2);
                    g.DrawImageUnscaled(bmp, rc);
                    g.DrawRectangle(Pens.Black, rc);
                }

                // save image for next time
                _preview = bmpTemplate;
            }

            // return the value that was asked for
            return(_preview);
        }
Beispiel #2
0
        private void btnSelectStyle_Click(object sender, EventArgs e)
        {
            StyleSelector rw = new StyleSelector();

            if (_style != null)
            {
                rw.SelectedStyle = _style;
            }

            if (rw.ShowDialog() == DialogResult.OK)
            {
                _style = rw.SelectedStyle;
                if (_style != null && _rep != null)
                {
                    _style.Apply(_rep);
                    _rep.Render();
                }
            }
        }