I have added many GoObjects on GoView of my application.
On Goview, all objects are placed at different positions.
But when i use printpreview method to see the print preview window, then view's object which is first from top of the view but not at the top of view itself, print preview window shows that object on its top.
View's image:
Print preview's window:
So the requirement is that there should be same distance from top of view as welll as on printpreview window.
You can override GoView.PrintDocumentTopLeft and GoView.PrintDocumentSize if you want to change this. By default, GoView uses GoView.ComputeDocumentBounds to get the bounding box for visible objects and then prints those.
get
{
return base.PrintDocumentTopLeft;
}
set
{
base.PrintDocumentTopLeft = value;
}
}
But there is following compilation error:
Error 1 'VLDGraph.GUI.GUI_View.PrintDocumentTopLeft.set': cannot override because 'Northwoods.Go.GoView.PrintDocumentTopLeft' does not have an overridable set accessor.
How can i override GoView.PrintDocumentTopLeft and GoView.PrintDocumentSize because both properties are read only.
But there is a symbol appears at each corner on every printed page, that i don't require. I marked it in paint & then attached the image.Please have a look:
Please let me know how this symbol be removed from printed page?
Still there is a problem. Very first time when data is displayed on y axis view & x axis view, If i don't trigger any drag event on y axis view & call directly print preview, then preview shows correct data for y axis view, but doesn't shows x axis view's data as per original data on x axis view & it appears as:
But if i trigger any drag event on y axis view, then call print preview, then preview perfectly appear as per original data on both views & it appears same as on both views as:
Please have a look of the following code. I implemented this code in x axis view class, whose data changes on each sheet on print preview window & places y axis data on each sheet.
protected override void PrintDecoration(Graphics g, PrintPageEventArgs e, int hpnum, int hpmax, int vpnum, int vpmax)
{
this.PrintScale = 1.0F;
GlobalResourceManager gRM = GlobalResourceManager.instance();
String msg = gRM.GetStringFromResource("MF_DAYTYPE") + this.FPLCreateGraph.FrmFpl.SelectedDayType + "\n" +
gRM.GetStringFromResource("MF_ROUTES") + this.FPLCreateGraph.FrmFpl.SelectedRouteList + "\n" +
gRM.GetStringFromResource("MF_BLOCKS") + this.FPLCreateGraph.FrmFpl.SelectedBlockList;
Font font = new Font("Verdana", 10);
SizeF size = g.MeasureString(msg, font);
PointF pt = new PointF(e.MarginBounds.X,e.MarginBounds.Y + e.MarginBounds.Height);
g.DrawString(msg, font, Brushes.Blue, pt);
msg = (hpnum + 1).ToString() + "/" + hpmax.ToString();
size = g.MeasureString(msg, font);
pt = new PointF(e.MarginBounds.X + e.MarginBounds.Width / 2 - size.Width / 2,
e.MarginBounds.Y + e.MarginBounds.Height);
g.DrawString(msg, font, Brushes.Blue, pt);
msg = System.Windows.Forms.SystemInformation.UserName + "\n" + System.DateTime.Today.ToShortDateString();
size = g.MeasureString(msg, font);
pt = new PointF(e.MarginBounds.X + e.MarginBounds.Width - size.Width,
e.MarginBounds.Y + e.MarginBounds.Height);
g.DrawString(msg, font, Brushes.Blue, pt);
GraphicsContainer before = g.BeginContainer(); // save Graphics state
GoView yAxisView = this.FPLCreateGraph.YAxisView; // get the GoView to be same while printed on each page
RectangleF pYAxisBounds = new RectangleF(yAxisView.DocumentTopLeft, yAxisView.DocExtentSize);
// 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 - pYAxisBounds.Width), e.MarginBounds.Y);
g.ScaleTransform(this.PrintScale, this.PrintScale); // draw at same scale as the rest of the view
g.TranslateTransform(pYAxisBounds.X, pYAxisBounds.Y); // normalize palette's PrintDocumentTopLeft
foreach (GoLayer oLayer in yAxisView.Layers) // draw each palette's document's layer
{
if (oLayer.Identifier.ToString() == "YAxisLabelLayer")
{
oLayer.Paint(g, yAxisView, pYAxisBounds);
Pen objPen = new Pen(Color.Black, 1.0F);
g.DrawLine(objPen, new PointF(pYAxisBounds.Width, pYAxisBounds.Top), new PointF(pYAxisBounds.Width, pYAxisBounds.Top + pYAxisBounds.Height));
break;
}
}
g.EndContainer(before); // restore Graphics state, so that this view will print normally
//base.PrintDecoration(g, e, hpnum, hpmax, vpnum, vpmax);
}
When first time x axis view & y axis view is loaded & then i go for print preview option, then print preview window doesn't show x axis view objects on its original position.
But if i do scroll x axis view a little horizontally by x axis view's horizontal scrollbar & then again go for print preview option, then problem is resolved in print preview window.
I also analysed taht when data is first time loaded on x axis view, then x axis view's horizontal scroll bar's width is little bit more than that of when i scrolled x axis view's horizontal scroll bar manually.
Is there any GoView's function, which do the same automatically?
So i can try by calling that function when first time data is loaded on X axis view.
Please provide me some piece of code or hint why first time print preview window doesn't work properly.
Analysis:
When i close print preview window first time, then x axis view's horizontal scroll bar's width increases a very little bit than that of it was before opening print preview window & as soon as i scroll it a little bit, than it sets to the same as it was before & then if i again open print peview window, then everythings looks perfect.