Adjust printpreviewdialog's position

Hi,
I have added two GoView objects on my form of same height, but of different width.

One view represents Y axis, which is of fixed size.
Second view represents X axis, which could be horizontally scrolled.
Requirement:
1. I want that printpreviewdialog should adjust data as visible on form, means from same height & width.
2. I want that printpreviewdialog should show all y axis objects on every sheet alongwith new x axis objects based on xaxis view doc position change.
Please provide me some piece of code if it is possible.
Thanks

Sometimes a screenshot helps a lot…

Walter provides some generic help with print preview here: http://www.nwoods.com/forum/forum_posts.asp?TID=582

Hi,

I want that my application's view(only graph data) should be adjusted having same margin value for bottom,left,top & right on print preview window, which is shown below.
So please provide me some piece of code to fullfill this requirement.
Thanks

If I understand you correctly, you have two separate GoViews that you want to print at the same time, repeating one GoView on the side of each page. Is that right?

The following GoView.PrintDecoration override accomplishes that. When I was writing this code, I used a GoPalette as the repeating GoView.

[code] protected override void PrintDecoration(Graphics g, PrintPageEventArgs e, int hpnum, int hpmax, int vpnum, int vpmax) {
base.PrintDecoration(g, e, hpnum, hpmax, vpnum, vpmax);

  GraphicsContainer before = g.BeginContainer();  // save Graphics state
  GoView palette = ...;  // get the GoView to be printed on each page
  RectangleF pbounds = new RectangleF(palette.PrintDocumentTopLeft, palette.PrintDocumentSize);
  // draw into left margin, but not into top-left corner of page
  // NB: the palette's Width needs to fit into the margin, otherwise it will overlap with the main view
  g.TranslateTransform(Math.Max(0, e.MarginBounds.X-pbounds.Width), e.MarginBounds.Y);
  g.ScaleTransform(this.PrintScale, this.PrintScale);  // draw at same scale as the rest of the view
  g.TranslateTransform(pbounds.X, pbounds.Y);  // normalize palette's PrintDocumentTopLeft
  foreach (GoLayer layer in palette.Layers) {  // draw each palette's document's layers
    if (layer.IsInDocument) layer.Paint(g, palette, pbounds);
  }
  g.EndContainer(before);  // restore Graphics state, so that this view will print normally
}

[/code]You will need to fiddle with the positioning of that repeatedly printed GoView. To do that correctly you will need to learn how to define transforms on Graphics. What I have done above might be OK as an initial attempt, but I don’t know the details of your application and how its objects are sized and positioned, so you will need to do that work.

Hi,

Thanks for your help. Now label object with left view is displaying correct on print preview window & it is also displaying on each page's left side repeatedly on print preview window.
How can i set MainView's PrintDocumentTopLeft to MainView's DocumentTopLeft ?

Just override it. You already have a class inheriting from GoView, which is where you overrode the PrintDecoration method.

Hi,

As i have two views in my application.Left view-Y axis & Right view - X Axis
So the requirement was that on vertically dragging object on left view along y axis, the corresponding objects should automatically be dragged along x axis.
That is already implemented.
But problem is with print preview window.
Steps to reproduce:
1. I draged vertically dragging object by mouse on left view along y axis, then corresponding objects automatically dragged along x axis too.That is fine.
2. Then i open print preview window.
3. Only y axis objects are displayed on new position after dragging, but corresponding object along x axis are not displayed on shifted position on print preview window.
Is it so that on left view's object, i am dragging by mouse and for corresponding objects on x axis, i am overriding left view's
GUI_YAxisView_DragOver(...) function to automatically move objects on right view by overriding DoMove(...) function of corresponding object without any mouse drag event on right view.
Please provide me some hint to resolve this problem.
Thanks

Is what you want to do just an issue in printing? Everything is working OK interactively, right?

That’s very odd, because printing, whether for print preview or for actual printing, is just re-rendering all of the GoObjects. So whatever position and appearance they have on screen, they should basically have when printed.

In your case, have you overridden DoMove for the objects in the left view? And does that method find the corresponding object(s) in the right view and just set their Location?

Are you doing anything with graphics transforms or the Paint method, except in the very limited manner that I suggested in the PrintDecoration method in this topic? Note that such manipulations are very limited because of the saving and restoring of the graphics context by using the Graphics.BeginContainer and EndContainer methods. Your code should not be using transforms or Paint to make any GoObject appear somewhere different than it really is.

Hi,

You are right.In my case, I have overridden GUI_YAxisView_DragOver(...) method on left view to handle mouse drag event on Yaxis Gobjects.Then i overridden Yaxis Gobject's ComputeMove(...) method.Then inside GUI_YAxisView_DragOver(...) method of left view, I just find the corresponding object(s) in the right view and just set their Location by calling corresponding object's DoMove(...) method.So it is perfectly visible except print preview window.

I am not doing anything with graphics transforms or the Paint method, except in the very limited manner that you suggested in the PrintDecoration method in this regard.
Thanks

I can’t explain that. I don’t recall ever hearing about any case where some GoObject that was Printable didn’t print in the correct spot on the correct page relative to the other GoObjects around it in the GoView.

Without the override of PaintDecoration, does your right-hand GoView print the way you expect?

What kind of GoObject is it that isn’t printing at the expected location? What are the other kinds of GoObjects that do print at the expected locations?