Ejemplo n.º 1
0
        // On mouse move, we try to find the render object under the mouse.
        // In case of success we cache the reference to that render object
        // in the _roUnderMouse var, which is used in Paint handler to high-light
        // that object. Also, we list info about that object in the list box.
        private void c1PrintPreviewControl1_PreviewPane_MouseMove(object sender, MouseEventArgs e)
        {
            C1PreviewPane pane = (C1PreviewPane)sender;
            // this is the point in C1PreviewPane's client coords:
            Point  previewPanelP = new Point(e.X, e.Y);
            int    pageIdx;
            PointF docP;

            // convert to document coords, which are pixels which have also been:
            // - scaled by the preview zoom factor, and
            // - related to the document page (top left corner of the page is (0,0)).
            pane.ClientToDocument(previewPanelP, out pageIdx, out docP);
            // further processing if the mouse is over a point on a document page:
            if (pageIdx >= 0)
            {
                // clear the list box of old stuff
                if ((listBox1.Items.Count + 1) * listBox1.ItemHeight > listBox1.ClientSize.Height)
                {
                    listBox1.Items.RemoveAt(0);
                }

                // find the RenderObject under the mouse
                RenderObject ro = FindRenderObject(pane.Document, pageIdx, docP, pane.DpiX, pane.DpiY);
                if (ro != _roUnderMouse)
                {
                    // print info in the list box
                    listBox1.Items.Add(string.Format("pageIdx: {0}, pos: {1}. Client: {2}. RO: {3}", pageIdx, docP, previewPanelP,
                                                     (ro == null ? (object)"<none>" : ro)));
                    // cache the render object (so that it is highlighted in the Paint handler)
                    HighlightRenderObject(ro);
                }
            }
        }
Ejemplo n.º 2
0
        // highlight the render object under the mouse, if any
        private void c1PrintPreviewControl1_PreviewPane_Paint(object sender, PaintEventArgs e)
        {
#if C1REPORT_PRIOR_TO_2011v2
            if (_roUnderMouse == null)
            {
                return;
            }
            C1PreviewPane pane = c1PrintPreviewControl1.PreviewPane;
            // paint red rectangles over all fragments of the render object
            foreach (RenderFragment rf in _roUnderMouse.Fragments)
            {
                RectangleD rd = rf.BoundsOnPage;
                // FromRU converts from "resolved units" (units in which fragment's bounds are
                // expressed) to any desired unit - in our case, we convert to pixels
                RectangleD rpreview = _roUnderMouse.Document.FromRU(rd, UnitTypeEnum.Pixel, pane.DpiX, pane.DpiY);
                // but because the document does not know anything about the preview's zoom
                // or offset of pages in the preview, we convert "document pixels" to preview ones:
                RectangleF rectf = pane.DocumentToClient(rf.PageIndex, rpreview.ToRectangleF());
                // finally, highlight the rectangle in the preview pane:
                e.Graphics.DrawRectangle(_hilitePen, rectf.X, rectf.Y, rectf.Width, rectf.Height);
            }
#else
            if (_roUnderMouse == null && _outlinePageIdx == -1)
            {
                return;
            }
            C1PreviewPane pane = c1PrintPreviewControl1.PreviewPane;

            if (_outlinePageIdx != -1)
            {
                C1PrintDocument doc = c1PrintPreviewControl1.Document as C1PrintDocument;
                if (doc == null)
                {
                    return;
                }

                RectangleF rectf = pane.DocumentToClient(_outlinePageIdx, _outlineRc.ToRectangleF());
                // finally, highlight the rectangle in the preview pane:
                e.Graphics.DrawRectangle(_hilitePen, rectf.X, rectf.Y, rectf.Width, rectf.Height);
            }
            else
            {
                // paint red rectangles over all fragments of the render object
                foreach (RenderFragment rf in _roUnderMouse.Fragments)
                {
                    RectangleD rd = rf.BoundsOnPage;
                    // FromRU converts from "resolved units" (units in which fragment's bounds are
                    // expressed) to any desired unit - in our case, we convert to pixels
                    RectangleD rpreview = _roUnderMouse.Document.FromRU(rd, UnitTypeEnum.Pixel, pane.DpiX, pane.DpiY);
                    // but because the document does not know anything about the preview's zoom
                    // or offset of pages in the preview, we convert "document pixels" to preview ones:
                    RectangleF rectf = pane.DocumentToClient(rf.PageIndex, rpreview.ToRectangleF());
                    // finally, highlight the rectangle in the preview pane:
                    e.Graphics.DrawRectangle(_hilitePen, rectf.X, rectf.Y, rectf.Width, rectf.Height);
                }
            }
#endif
        }
Ejemplo n.º 3
0
        // "high-level" method, finds the render object under the screen point
        private RenderObject FindRoUnderScreenPoint(Point screenPt)
        {
            C1PreviewPane pane = c1PrintPreviewControl1.PreviewPane;

            if (!(pane.Document is C1PrintDocument))
            {
                return(null);
            }
            Point  clientP = pane.PointToClient(screenPt);
            int    pageIdx;
            PointF docP;

            pane.ClientToDocument(clientP, out pageIdx, out docP);
            if (pageIdx >= 0)
            {
                return(FindRenderObject((C1PrintDocument)pane.Document, pageIdx, docP, pane.DpiX, pane.DpiY));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
     this._c1r        = new C1.C1Report.C1Report();
     this._tb         = new System.Windows.Forms.ToolBar();
     this._tbFirst    = new System.Windows.Forms.ToolBarButton();
     this._tbPrev     = new System.Windows.Forms.ToolBarButton();
     this._tbNext     = new System.Windows.Forms.ToolBarButton();
     this._tbLast     = new System.Windows.Forms.ToolBarButton();
     this._tbSep      = new System.Windows.Forms.ToolBarButton();
     this._tbActual   = new System.Windows.Forms.ToolBarButton();
     this._tbPage     = new System.Windows.Forms.ToolBarButton();
     this._tbTwoPages = new System.Windows.Forms.ToolBarButton();
     this._il         = new System.Windows.Forms.ImageList(this.components);
     this._status     = new System.Windows.Forms.StatusBar();
     this._ppv        = new C1.Win.C1Preview.C1PreviewPane();
     ((System.ComponentModel.ISupportInitialize)(this._c1r)).BeginInit();
     ((System.ComponentModel.ISupportInitialize)(this._ppv)).BeginInit();
     this.SuspendLayout();
     //
     // _c1r
     //
     this._c1r.ReportDefinition = resources.GetString("_c1r.ReportDefinition");
     this._c1r.EndReport       += new System.EventHandler(this._c1r_EndReport);
     this._c1r.StartPage       += new C1.C1Report.ReportEventHandler(this._c1r_StartPage);
     //
     // _tb
     //
     this._tb.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
     this._tb.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
         this._tbFirst,
         this._tbPrev,
         this._tbNext,
         this._tbLast,
         this._tbSep,
         this._tbActual,
         this._tbPage,
         this._tbTwoPages
     });
     this._tb.DropDownArrows = true;
     this._tb.ImageList      = this._il;
     this._tb.Location       = new System.Drawing.Point(0, 0);
     this._tb.Name           = "_tb";
     this._tb.ShowToolTips   = true;
     this._tb.Size           = new System.Drawing.Size(738, 28);
     this._tb.TabIndex       = 2;
     this._tb.ButtonClick   += new System.Windows.Forms.ToolBarButtonClickEventHandler(this._tb_ButtonClick);
     //
     // _tbFirst
     //
     this._tbFirst.ImageIndex  = 0;
     this._tbFirst.Name        = "_tbFirst";
     this._tbFirst.ToolTipText = "First Page";
     //
     // _tbPrev
     //
     this._tbPrev.ImageIndex  = 1;
     this._tbPrev.Name        = "_tbPrev";
     this._tbPrev.ToolTipText = "Previous Page";
     //
     // _tbNext
     //
     this._tbNext.ImageIndex  = 2;
     this._tbNext.Name        = "_tbNext";
     this._tbNext.ToolTipText = "Next Page";
     //
     // _tbLast
     //
     this._tbLast.ImageIndex  = 3;
     this._tbLast.Name        = "_tbLast";
     this._tbLast.ToolTipText = "Last Page";
     //
     // _tbSep
     //
     this._tbSep.Name  = "_tbSep";
     this._tbSep.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
     //
     // _tbActual
     //
     this._tbActual.ImageIndex  = 4;
     this._tbActual.Name        = "_tbActual";
     this._tbActual.ToolTipText = "Actual Size";
     //
     // _tbPage
     //
     this._tbPage.ImageIndex  = 5;
     this._tbPage.Name        = "_tbPage";
     this._tbPage.ToolTipText = "Whole Page";
     //
     // _tbTwoPages
     //
     this._tbTwoPages.ImageIndex  = 6;
     this._tbTwoPages.Name        = "_tbTwoPages";
     this._tbTwoPages.ToolTipText = "Two Pages";
     //
     // _il
     //
     this._il.ImageStream      = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("_il.ImageStream")));
     this._il.TransparentColor = System.Drawing.Color.Red;
     this._il.Images.SetKeyName(0, "");
     this._il.Images.SetKeyName(1, "");
     this._il.Images.SetKeyName(2, "");
     this._il.Images.SetKeyName(3, "");
     this._il.Images.SetKeyName(4, "");
     this._il.Images.SetKeyName(5, "");
     this._il.Images.SetKeyName(6, "");
     //
     // _status
     //
     this._status.Location = new System.Drawing.Point(0, 551);
     this._status.Name     = "_status";
     this._status.Size     = new System.Drawing.Size(738, 19);
     this._status.TabIndex = 3;
     //
     // _ppv
     //
     this._ppv.Dock     = System.Windows.Forms.DockStyle.Fill;
     this._ppv.Location = new System.Drawing.Point(0, 28);
     this._ppv.Name     = "_ppv";
     this._ppv.Size     = new System.Drawing.Size(738, 523);
     this._ppv.TabIndex = 0;
     this._ppv.ZoomMode = C1.Win.C1Preview.ZoomModeEnum.ActualSize;
     //
     // Form1
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     this.ClientSize        = new System.Drawing.Size(738, 570);
     this.Controls.Add(this._ppv);
     this.Controls.Add(this._tb);
     this.Controls.Add(this._status);
     this.Name          = "Form1";
     this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
     this.Text          = "C1Report: Bind to Hierarchical Dataset";
     this.Load         += new System.EventHandler(this.Form1_Load);
     ((System.ComponentModel.ISupportInitialize)(this._c1r)).EndInit();
     ((System.ComponentModel.ISupportInitialize)(this._ppv)).EndInit();
     this.ResumeLayout(false);
     this.PerformLayout();
 }
Ejemplo n.º 5
0
        private void miStickyNoteRo_Click(object sender, EventArgs e)
        {
            RenderObject ro = ((ToolStripItem)sender).Tag as RenderObject;

            if (ro == null || ro is RenderTable)
            {
                return;
            }
            // Do NOT add notes to notes:
            string testUserData = ro.UserData as string;

            if (testUserData == c_stickyNoteUserData)
            {
                return;
            }

            TextBox tb = new TextBox();

            tb.Multiline = true;
            C1PreviewPane pane     = c1PrintPreviewControl1.PreviewPane;
            RectangleD    rd       = ro.FirstFragment.BoundsOnPage;
            RectangleD    rpreview = _roUnderMouse.Document.FromRU(rd, UnitTypeEnum.Pixel, pane.DpiX, pane.DpiY);
            RectangleF    rectf    = pane.DocumentToClient(ro.FirstFragment.PageIndex, rpreview.ToRectangleF());
            // show note input box to the right/below the render object:
            Point p = new Point((int)rectf.Right, (int)rectf.Bottom);

            // switch to form coordinates:
            p            = pane.PointToScreen(p);
            p            = this.PointToClient(p);
            tb.Location  = p;
            tb.Width     = 200;
            tb.Height    = 40;
            tb.BackColor = Color.Yellow;
            this.Controls.Add(tb);
            tb.BringToFront();
            tb.Focus();
            tb.KeyDown += (ss, ee) =>
            {
                if (ee.KeyCode == Keys.Escape)
                {
                    this.Controls.Remove(tb);
                }
                if (ee.KeyCode == Keys.Enter && ee.Modifiers == Keys.None)
                {
                    ee.Handled = true;
                    this.ValidateChildren();
                    pane.Focus();
                }
            };

            tb.Validated += (ss, ee) =>
            {
                AddStickyNote(ro, tb.Text);

                // remove textbox:
                this.Controls.Remove(tb);

                // Done - update document:
                RegenerateDocument(ro.Document);
            };
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the find helper.
 /// </summary>
 /// <param name="previewPane">The preview pane associated with this instance.</param>
 public FindHelper(C1PreviewPane previewPane)
 {
     PreviewPane = previewPane;
 }