Example #1
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            base.OnPaint(pevent);
            PreviewPageInfo[] previewPageInfoArray = (PreviewPageInfo[])typeof(PrintPreviewControl).GetField("pageInfo", BindingFlags.Instance | BindingFlags.NonPublic).GetValue((object)this);
            if (previewPageInfoArray == null || previewPageInfoArray.Length == 0)
            {
                return;
            }
            Point empty  = Point.Empty;
            int   val1   = 0;
            Size  size1  = this.Size;
            Size  size2  = this.Size;
            Point point1 = new Point(this.VirtualSize);
            Point point2 = new Point(Math.Max(0, (size1.Width - point1.X) / 2), Math.Max(0, (size2.Height - point1.Y) / 2));

            point2.X -= this.ScrollOffset.X;
            point2.Y -= this.ScrollOffset.Y;
            int pixels1 = RadPrintPreviewControl.PhysicalToPixels(10, this.screendpi.Y);
            int pixels2 = RadPrintPreviewControl.PhysicalToPixels(10, this.screendpi.X);

            Rectangle[] rectangleArray = new Rectangle[this.Rows * this.Columns];
            for (int index1 = 0; index1 < this.Rows; ++index1)
            {
                empty.X = 0;
                empty.Y = val1 * index1;
                for (int index2 = 0; index2 < this.Columns; ++index2)
                {
                    int index3 = this.StartPage + index2 + index1 * this.Columns;
                    if (index3 < previewPageInfoArray.Length)
                    {
                        Size  physicalSize = previewPageInfoArray[index3].PhysicalSize;
                        Point pixels3      = RadPrintPreviewControl.PhysicalToPixels(new Point(new Size((int)(this.Zoom * (double)physicalSize.Width), (int)(this.Zoom * (double)physicalSize.Height))), this.screendpi);
                        int   x            = point2.X + pixels2 * (index2 + 1) + empty.X;
                        int   y            = point2.Y + pixels1 * (index1 + 1) + empty.Y;
                        empty.X += pixels3.X;
                        val1     = Math.Max(val1, pixels3.Y);
                        rectangleArray[index3 - this.StartPage] = new Rectangle(x, y, pixels3.X, pixels3.Y);
                    }
                }
            }
            for (int index = 0; index < rectangleArray.Length; ++index)
            {
                if (index + this.StartPage < previewPageInfoArray.Length)
                {
                    Rectangle rect = rectangleArray[index];
                    Pen       pen1 = new Pen(this.PageBorderColor);
                    pevent.Graphics.DrawRectangle(pen1, rect);
                    pen1.Dispose();
                    Brush brush = (Brush) new SolidBrush(this.PageShadowColor);
                    int   num   = Math.Min(1 + (int)Math.Ceiling((double)this.ShadowThickness * this.Zoom), 10);
                    pevent.Graphics.FillRectangle(brush, new Rectangle(rect.Left + num, rect.Bottom + 1, rect.Width + 1, num));
                    pevent.Graphics.FillRectangle(brush, new Rectangle(rect.Right + 1, rect.Top + num, num, rect.Height));
                    rect.Inflate(-1, -1);
                    --rect.Width;
                    --rect.Height;
                    Pen pen2 = new Pen(this.PageInnerBorderColor);
                    pevent.Graphics.DrawRectangle(pen2, rect);
                }
            }
        }
        private void InitializeComponent()
        {
            ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(RadPrintPreviewDialog));

            this.printPreviewControl       = new RadPrintPreviewControl();
            this.radCommandBar             = new RadCommandBar();
            this.commandBarRowElement1     = new CommandBarRowElement();
            this.stripElementTools         = new CommandBarStripElement();
            this.buttonPrint               = new CommandBarButton();
            this.buttonSettings            = new CommandBarButton();
            this.commandBarButtonWatermark = new CommandBarButton();
            this.stripElementNavigation    = new CommandBarStripElement();
            this.buttonPrevPage            = new CommandBarButton();
            this.buttonNextPage            = new CommandBarButton();
            this.textBoxCurrentPage        = new CommandBarTextBox();
            this.labelTotalPages           = new CommandBarLabel();
            this.commandBarSeparator1      = new CommandBarSeparator();
            this.buttonZoomOut             = new CommandBarButton();
            this.buttonZoomIn              = new CommandBarButton();
            this.dropDownZoom              = new CommandBarDropDownList();
            this.dropDownButtonLayout      = new CommandBarDropDownButton();
            this.menuItemFile              = new RadMenuItem();
            this.menuItemPrint             = new RadMenuItem();
            this.menuItemExit              = new RadMenuItem();
            this.menuItemView              = new RadMenuItem();
            this.radMenuSeparatorItem1     = new RadMenuSeparatorItem();
            this.menuItemPreviousPage      = new RadMenuItem();
            this.menuItemNextPage          = new RadMenuItem();
            this.radMenuSeparatorItem2     = new RadMenuSeparatorItem();
            this.menuItemLayout            = new RadMenuItem();
            this.menuItemTools             = new RadMenuItem();
            this.menuItemPrintSettings     = new RadMenuItem();
            this.menuItemWatermark         = new RadMenuItem();
            this.radMenu = new RadMenu();
            this.radCommandBar.BeginInit();
            this.radMenu.BeginInit();
            this.BeginInit();
            this.SuspendLayout();
            this.printPreviewControl.AutoZoom             = false;
            this.printPreviewControl.BackColor            = Color.FromArgb(156, 179, 207);
            this.printPreviewControl.Dock                 = DockStyle.Fill;
            this.printPreviewControl.Location             = new Point(0, 58);
            this.printPreviewControl.Name                 = "printPreviewControl";
            this.printPreviewControl.PageBorderColor      = Color.White;
            this.printPreviewControl.PageInnerBorderColor = Color.White;
            this.printPreviewControl.PageShadowColor      = Color.FromArgb(109, 125, 144);
            this.printPreviewControl.ScrollOffset         = new Point(0, 0);
            this.printPreviewControl.ShadowThickness      = 6;
            this.printPreviewControl.Size                 = new Size(713, 399);
            this.printPreviewControl.TabIndex             = 1;
            this.printPreviewControl.StartPageChanged    += new EventHandler(this.printPreviewControl1_StartPageChanged);
            this.printPreviewControl.MouseDown           += new MouseEventHandler(this.printPreviewControl1_MouseDown);
            this.printPreviewControl.MouseMove           += new MouseEventHandler(this.printPreviewControl1_MouseMove);
            this.printPreviewControl.MouseUp             += new MouseEventHandler(this.printPreviewControl1_MouseUp);
            this.printPreviewControl.MouseWheel          += new MouseEventHandler(this.printPreviewControl1_MouseWheel);
            this.radCommandBar.AutoSize = true;
            this.radCommandBar.Dock     = DockStyle.Top;
            this.radCommandBar.Location = new Point(0, 20);
            this.radCommandBar.Name     = "radCommandBar";
            this.radCommandBar.Rows.AddRange(this.commandBarRowElement1);
            this.radCommandBar.Size                = new Size(713, 38);
            this.radCommandBar.TabIndex            = 3;
            this.radCommandBar.Text                = "radCommandBar1";
            this.commandBarRowElement1.DisplayName = (string)null;
            this.commandBarRowElement1.MinSize     = new Size(25, 25);
            this.commandBarRowElement1.Strips.AddRange(this.stripElementTools, this.stripElementNavigation);
            this.stripElementTools.DisplayName = "Tools";
            this.stripElementTools.Items.AddRange((RadCommandBarBaseItem)this.buttonPrint, (RadCommandBarBaseItem)this.buttonSettings, (RadCommandBarBaseItem)this.commandBarButtonWatermark);
            this.stripElementTools.Name            = "commandBarStripElement1";
            this.stripElementTools.Text            = "";
            this.buttonPrint.AccessibleDescription = "Print";
            this.buttonPrint.AccessibleName        = "Print";
            this.buttonPrint.DisplayName           = "Print...";
            this.buttonPrint.DrawText    = false;
            this.buttonPrint.Image       = (Image)componentResourceManager.GetObject("print");
            this.buttonPrint.Name        = "buttonPrint";
            this.buttonPrint.Text        = "Print";
            this.buttonPrint.ToolTipText = "Print...";
            this.buttonPrint.Visibility  = ElementVisibility.Visible;
            this.buttonPrint.MouseDown  += new MouseEventHandler(this.buttonPrint_Click);
            this.buttonSettings.AccessibleDescription = "Settings";
            this.buttonSettings.AccessibleName        = "Settings";
            this.buttonSettings.DisplayName           = "Print Settings...";
            this.buttonSettings.DrawText    = false;
            this.buttonSettings.Image       = (Image)componentResourceManager.GetObject("page-setup");
            this.buttonSettings.Name        = "buttonSettings";
            this.buttonSettings.Text        = "Settings";
            this.buttonSettings.ToolTipText = "Print Settings...";
            this.buttonSettings.Visibility  = ElementVisibility.Visible;
            this.buttonSettings.MouseDown  += new MouseEventHandler(this.buttonSettings_Click);
            this.commandBarButtonWatermark.AccessibleDescription = "Watermark";
            this.commandBarButtonWatermark.AccessibleName        = "Watermark";
            this.commandBarButtonWatermark.DisplayName           = "Watermark";
            this.commandBarButtonWatermark.DrawText    = false;
            this.commandBarButtonWatermark.Image       = (Image)componentResourceManager.GetObject("watermark");
            this.commandBarButtonWatermark.Name        = "commandBarButtonWatermark";
            this.commandBarButtonWatermark.Text        = "Watermark";
            this.commandBarButtonWatermark.ToolTipText = "Watermark";
            this.commandBarButtonWatermark.Visibility  = ElementVisibility.Visible;
            this.commandBarButtonWatermark.MouseUp    += new MouseEventHandler(this.commandBarButtonWatermark_Click);
            this.stripElementNavigation.DisplayName    = "Navigation";
            this.stripElementNavigation.Items.AddRange((RadCommandBarBaseItem)this.buttonPrevPage, (RadCommandBarBaseItem)this.buttonNextPage, (RadCommandBarBaseItem)this.textBoxCurrentPage, (RadCommandBarBaseItem)this.labelTotalPages, (RadCommandBarBaseItem)this.commandBarSeparator1, (RadCommandBarBaseItem)this.buttonZoomOut, (RadCommandBarBaseItem)this.buttonZoomIn, (RadCommandBarBaseItem)this.dropDownZoom, (RadCommandBarBaseItem)this.dropDownButtonLayout);
            this.stripElementNavigation.Name          = "commandBarStripElement2";
            this.stripElementNavigation.Text          = "";
            this.buttonPrevPage.AccessibleDescription = "<";
            this.buttonPrevPage.AccessibleName        = "<";
            this.buttonPrevPage.DisplayName           = "Previous Page";
            this.buttonPrevPage.DrawText                          = false;
            this.buttonPrevPage.Image                             = (Image)componentResourceManager.GetObject("arrow-up");
            this.buttonPrevPage.Name                              = "buttonPrevPage";
            this.buttonPrevPage.Text                              = "<";
            this.buttonPrevPage.ToolTipText                       = "Previous Page";
            this.buttonPrevPage.Visibility                        = ElementVisibility.Visible;
            this.buttonPrevPage.MouseDown                        += new MouseEventHandler(this.buttonPrevPage_Click);
            this.buttonNextPage.AccessibleDescription             = ">";
            this.buttonNextPage.AccessibleName                    = ">";
            this.buttonNextPage.DisplayName                       = "Next Page";
            this.buttonNextPage.DrawText                          = false;
            this.buttonNextPage.Image                             = (Image)componentResourceManager.GetObject("arrow-down");
            this.buttonNextPage.Name                              = "buttonNextPage";
            this.buttonNextPage.Text                              = ">";
            this.buttonNextPage.ToolTipText                       = "Next Page";
            this.buttonNextPage.Visibility                        = ElementVisibility.Visible;
            this.buttonNextPage.MouseDown                        += new MouseEventHandler(this.buttonNextPage_Click);
            this.textBoxCurrentPage.DisplayName                   = "Current Page";
            this.textBoxCurrentPage.Font                          = new Font("Segoe UI Semibold", 12f, FontStyle.Bold, GraphicsUnit.Point, (byte)204);
            this.textBoxCurrentPage.MaxSize                       = new Size(0, 0);
            this.textBoxCurrentPage.Name                          = "textBoxCurrentPage";
            this.textBoxCurrentPage.StretchVertically             = true;
            this.textBoxCurrentPage.Text                          = "";
            this.textBoxCurrentPage.Visibility                    = ElementVisibility.Visible;
            this.textBoxCurrentPage.KeyDown                      += new KeyEventHandler(this.commandBarTextBox1_KeyDown);
            ((RadItem)this.textBoxCurrentPage.GetChildAt(0)).Text = "";
            this.textBoxCurrentPage.GetChildAt(0).Alignment       = ContentAlignment.MiddleCenter;
            this.textBoxCurrentPage.GetChildAt(0).MinSize         = new Size(40, 20);
            this.labelTotalPages.AccessibleDescription            = "of 0";
            this.labelTotalPages.AccessibleName                   = "of 0";
            this.labelTotalPages.DisplayName                      = "Total Pages";
            this.labelTotalPages.Font                             = new Font("Segoe UI Semibold", 12f, FontStyle.Bold, GraphicsUnit.Point, (byte)204);
            this.labelTotalPages.Name                             = "labelTotalPages";
            this.labelTotalPages.Text                             = "/ 0";
            this.labelTotalPages.Visibility                       = ElementVisibility.Visible;
            this.commandBarSeparator1.AccessibleDescription       = "commandBarSeparator1";
            this.commandBarSeparator1.AccessibleName              = "commandBarSeparator1";
            this.commandBarSeparator1.DisplayName                 = "commandBarSeparator1";
            this.commandBarSeparator1.Name                        = "commandBarSeparator1";
            this.commandBarSeparator1.Visibility                  = ElementVisibility.Visible;
            this.commandBarSeparator1.VisibleInOverflowMenu       = false;
            this.buttonZoomOut.AccessibleDescription              = "-";
            this.buttonZoomOut.AccessibleName                     = "-";
            this.buttonZoomOut.DisplayName                        = "Zoom Out";
            this.buttonZoomOut.DrawText                           = false;
            this.buttonZoomOut.Image                              = (Image)componentResourceManager.GetObject("zoom-out");
            this.buttonZoomOut.Name                 = "buttonZoomOut";
            this.buttonZoomOut.Text                 = "-";
            this.buttonZoomOut.ToolTipText          = "Zoom Out";
            this.buttonZoomOut.Visibility           = ElementVisibility.Visible;
            this.buttonZoomIn.AccessibleDescription = "+";
            this.buttonZoomIn.AccessibleName        = "+";
            this.buttonZoomIn.DisplayName           = "Zoom In";
            this.buttonZoomIn.DrawText              = false;
            this.buttonZoomIn.Image                 = (Image)componentResourceManager.GetObject("zoom-in");
            this.buttonZoomIn.Name        = "buttonZoomIn";
            this.buttonZoomIn.Text        = "+";
            this.buttonZoomIn.ToolTipText = "Zoom In";
            this.buttonZoomIn.Visibility  = ElementVisibility.Visible;
            this.dropDownZoom.DisplayName = "Zoom";
            this.dropDownZoom.DropDownAnimationEnabled = true;
            this.dropDownZoom.MinSize    = new Size(90, 22);
            this.dropDownZoom.Name       = "dropDownZoom";
            this.dropDownZoom.Text       = "";
            this.dropDownZoom.Visibility = ElementVisibility.Visible;
            this.dropDownButtonLayout.AccessibleDescription = "commandBarDropDownButton1";
            this.dropDownButtonLayout.AccessibleName        = "commandBarDropDownButton1";
            this.dropDownButtonLayout.DisplayName           = "Layout";
            this.dropDownButtonLayout.Image         = (Image)componentResourceManager.GetObject("view-thumbnail");
            this.dropDownButtonLayout.Name          = "dropDownButtonLayout";
            this.dropDownButtonLayout.Text          = "commandBarDropDownButton1";
            this.dropDownButtonLayout.ToolTipText   = "Layout";
            this.dropDownButtonLayout.Visibility    = ElementVisibility.Visible;
            this.menuItemFile.AccessibleDescription = "File";
            this.menuItemFile.AccessibleName        = "File";
            this.menuItemFile.Items.AddRange((RadItem)this.menuItemPrint, (RadItem)this.menuItemExit);
            this.menuItemFile.Name                   = "menuItemFile";
            this.menuItemFile.Text                   = "File";
            this.menuItemFile.Visibility             = ElementVisibility.Visible;
            this.menuItemPrint.AccessibleDescription = "Print...";
            this.menuItemPrint.AccessibleName        = "Print...";
            this.menuItemPrint.Name                  = "menuItemPrint";
            this.menuItemPrint.Text                  = "Print...";
            this.menuItemPrint.Visibility            = ElementVisibility.Visible;
            this.menuItemPrint.Click                += new EventHandler(this.buttonPrint_Click);
            this.menuItemExit.AccessibleDescription  = "Exit";
            this.menuItemExit.AccessibleName         = "Exit";
            this.menuItemExit.Name                   = "menuItemExit";
            this.menuItemExit.Text                   = "Exit";
            this.menuItemExit.Visibility             = ElementVisibility.Visible;
            this.menuItemExit.Click                 += new EventHandler(this.radMenuItem6_Click);
            this.menuItemView.AccessibleDescription  = "View";
            this.menuItemView.AccessibleName         = "View";
            this.menuItemView.Items.AddRange((RadItem)this.radMenuSeparatorItem1, (RadItem)this.menuItemPreviousPage, (RadItem)this.menuItemNextPage, (RadItem)this.radMenuSeparatorItem2, (RadItem)this.menuItemLayout);
            this.menuItemView.Name                          = "menuItemView";
            this.menuItemView.Text                          = "View";
            this.menuItemView.Visibility                    = ElementVisibility.Visible;
            this.radMenuSeparatorItem1.Name                 = "radMenuSeparatorItem1";
            this.radMenuSeparatorItem1.Visibility           = ElementVisibility.Visible;
            this.menuItemPreviousPage.AccessibleDescription = "Previous Page";
            this.menuItemPreviousPage.AccessibleName        = "Previous Page";
            this.menuItemPreviousPage.Name                  = "menuItemPreviousPage";
            this.menuItemPreviousPage.Text                  = "Previous Page";
            this.menuItemPreviousPage.Visibility            = ElementVisibility.Visible;
            this.menuItemPreviousPage.Click                += new EventHandler(this.buttonPrevPage_Click);
            this.menuItemNextPage.AccessibleDescription     = "Next Page";
            this.menuItemNextPage.AccessibleName            = "Next Page";
            this.menuItemNextPage.Name                      = "menuItemNextPage";
            this.menuItemNextPage.Text                      = "Next Page";
            this.menuItemNextPage.Visibility                = ElementVisibility.Visible;
            this.menuItemNextPage.Click                    += new EventHandler(this.buttonNextPage_Click);
            this.radMenuSeparatorItem2.Name                 = "radMenuSeparatorItem2";
            this.radMenuSeparatorItem2.Visibility           = ElementVisibility.Visible;
            this.menuItemLayout.AccessibleDescription       = "Layout";
            this.menuItemLayout.AccessibleName              = "Layout";
            this.menuItemLayout.Name                        = "menuItemLayout";
            this.menuItemLayout.Text                        = "Layout";
            this.menuItemLayout.Visibility                  = ElementVisibility.Visible;
            this.menuItemTools.AccessibleDescription        = "Tools";
            this.menuItemTools.AccessibleName               = "Tools";
            this.menuItemTools.Items.AddRange((RadItem)this.menuItemPrintSettings, (RadItem)this.menuItemWatermark);
            this.menuItemTools.Name       = "menuItemTools";
            this.menuItemTools.Text       = "Tools";
            this.menuItemTools.Visibility = ElementVisibility.Visible;
            this.menuItemPrintSettings.AccessibleDescription = "Printer Settings";
            this.menuItemPrintSettings.AccessibleName        = "Printer Settings";
            this.menuItemPrintSettings.Name              = "menuItemPrintSettings";
            this.menuItemPrintSettings.Text              = "Printer Settings...";
            this.menuItemPrintSettings.Visibility        = ElementVisibility.Visible;
            this.menuItemPrintSettings.Click            += new EventHandler(this.buttonSettings_Click);
            this.menuItemWatermark.AccessibleDescription = "Watermark Settings...";
            this.menuItemWatermark.AccessibleName        = "Watermark Settings...";
            this.menuItemWatermark.Name       = "menuItemWatermark";
            this.menuItemWatermark.Text       = "Watermark Settings...";
            this.menuItemWatermark.Visibility = ElementVisibility.Visible;
            this.menuItemWatermark.Click     += new EventHandler(this.commandBarButtonWatermark_Click);
            this.radMenu.Items.AddRange((RadItem)this.menuItemFile, (RadItem)this.menuItemView, (RadItem)this.menuItemTools);
            this.radMenu.Location    = new Point(0, 0);
            this.radMenu.Name        = "radMenu";
            this.radMenu.Size        = new Size(713, 20);
            this.radMenu.TabIndex    = 4;
            this.radMenu.Text        = "radMenu1";
            this.radMenu.Visible     = false;
            this.AutoScaleDimensions = new SizeF(96f, 96f);
            this.AutoScaleMode       = AutoScaleMode.Dpi;
            this.ClientSize          = new Size(713, 457);
            this.Controls.Add((Control)this.printPreviewControl);
            this.Controls.Add((Control)this.radCommandBar);
            this.Controls.Add((Control)this.radMenu);
            this.Icon        = (Icon)componentResourceManager.GetObject("$this.Icon");
            this.MinimizeBox = false;
            this.Name        = nameof(RadPrintPreviewDialog);
            this.RootElement.ApplyShapeToControl = true;
            this.ShowInTaskbar = false;
            this.StartPosition = FormStartPosition.CenterScreen;
            this.Text          = "Print Preview";
            this.radCommandBar.EndInit();
            this.radMenu.EndInit();
            this.EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();
        }
Example #3
0
 public static Point PhysicalToPixels(Point physical, Point dpi)
 {
     return(new Point(RadPrintPreviewControl.PhysicalToPixels(physical.X, dpi.X), RadPrintPreviewControl.PhysicalToPixels(physical.Y, dpi.Y)));
 }
Example #4
0
 public static Point PixelsToPhysical(Point pixels, Point dpi)
 {
     return(new Point(RadPrintPreviewControl.PixelsToPhysical(pixels.X, dpi.X), RadPrintPreviewControl.PixelsToPhysical(pixels.Y, dpi.Y)));
 }