Beispiel #1
0
 public void ResumeDrawing()
 {
     ctrl.VerticalScroll.Value = Math.Min(ctrl.VerticalScroll.Maximum, scrollValue);
     ctrl.ResumeLayout();
     SendMessage(ctrl.Handle, WM_SETREDRAW, true, 0);
     ctrl.Refresh();
 }
Beispiel #2
0
        public static Bitmap ScrollableControlToBitmap(ScrollableControl canvas, bool fullSize, bool includeHidden)
        {
            canvas.AutoScrollPosition = new Point(0, 0);
            if (includeHidden)
            {
                canvas.SuspendLayout();
                foreach (Control child in canvas.Controls)
                {
                    child.Visible = true;
                }
                canvas.ResumeLayout(true);
            }

            canvas.PerformLayout();
            Size containerSize = canvas.DisplayRectangle.Size;

            if (fullSize)
            {
                containerSize.Width  = Math.Max(containerSize.Width, canvas.ClientSize.Width);
                containerSize.Height = Math.Max(containerSize.Height, canvas.ClientSize.Height);
            }
            else
            {
                containerSize = (canvas is Form) ? canvas.PreferredSize : canvas.ClientSize;
            }

            var bitmap = new Bitmap(containerSize.Width, containerSize.Height, PixelFormat.Format32bppArgb);

            bitmap.SetResolution(canvas.DeviceDpi, canvas.DeviceDpi);

            var graphics = Graphics.FromImage(bitmap);

            graphics.Clear(canvas.BackColor);
            var rtfPrinter = new RichEditPrinter(graphics);

            try
            {
                DrawNestedControls(canvas, canvas, new Rectangle(Point.Empty, containerSize), bitmap, rtfPrinter);
                return(bitmap);
            }
            finally
            {
                rtfPrinter.Dispose();
                graphics.Dispose();
            }
        }
Beispiel #3
0
        public void Display(Rule rule)
        {
            this.rule = rule;
            int    startY = 4;
            int    startX = 4;
            int    index  = 0;
            string prefix = "";

            control.SuspendLayout();
            control.Controls.Clear();

            Label lbl = new Label();

            lbl.Text     = rule.TriggerText;
            lbl.AutoSize = true;
            control.Controls.Add(lbl);
            lbl.SetBounds(2, startX, lbl.Width, lbl.Height);
            startY += lbl.Height + 4;

            // show conditions
            foreach (RuleCondition rc in rule.Conditions)
            {
                LinkLabel ll = new LinkLabel();
                ll.AutoSize = true;
                SetLinkLabel(ll, prefix, rc);
                ll.Click += new EventHandler(ll_Click);
                ll.SetBounds(startX, startY, ll.Width, ll.Height);
                ll.Tag = new RulePartTag(rc, 0, index);
                control.Controls.Add(ll);
                startY += ll.Height;
                startX  = 12;
                prefix  = textAnd + " ";
                index++;
            }

            // show actions
            startX = 4;
            prefix = "";
            index  = 0;
            foreach (RuleAction ra in rule.Actions)
            {
                LinkLabel ll = new LinkLabel();
                ll.AutoSize = true;
                SetLinkLabel(ll, prefix, ra);
                ll.Click += new EventHandler(ll_Click);
                ll.SetBounds(startX, startY, ll.Width, ll.Height);
                ll.Tag = new RulePartTag(ra, 1, index);
                control.Controls.Add(ll);
                startY += ll.Height;
                startX  = 12;
                prefix  = textAnd + " ";
            }

            //show exceptions
            startX = 4;
            prefix = "";
            index  = 0;
            foreach (RuleCondition rc in rule.Exceptions)
            {
                LinkLabel ll = new LinkLabel();
                ll.AutoSize = true;
                SetLinkLabel(ll, prefix, rc);
                ll.Click += new EventHandler(ll_Click);
                ll.SetBounds(startX, startY, ll.Width, ll.Height);
                ll.Tag = new RulePartTag(rc, 2, index);
                control.Controls.Add(ll);
                startY += ll.Height;
                startX  = 12;
                prefix  = textOr + " ";
            }

            control.ResumeLayout();
        }