But this doesn't work when the CustomXRadius and CustomYRadius are used.
In our application we are adding some stuff outside the polar circle using the BeforeDraw and AfterDraw events. Therefore we have to use a smaller size for the polar circle. We therefore calculates the size of the circle on the SizeChanged event by setting the CustomX/YRadius.
Please try the demo below. Try the Print at different sizes of the window. Outprint is ok when not using Custom radius.
It obviously seems to be a bug here. The version tested are 1.1.2179 and 2.0.2040.
I have tried to find a work-around but I haven't found any that is acceptable. I can't see any way to trap the internal resizing that the Printer.Print(rect) is performing.
Any suggestions for a work-around???
Thanks in advance!
//Lars Jönson, Sweden
Demo code here:
Code: Select all
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace PolarPrintDemo
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private Steema.TeeChart.TChart tChart1;
private Steema.TeeChart.Styles.Polar polar1;
private System.Windows.Forms.Button printButton;
private System.Windows.Forms.Button exitButton;
private System.Windows.Forms.CheckBox customCheckBox;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
myInit();
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.tChart1 = new Steema.TeeChart.TChart();
this.polar1 = new Steema.TeeChart.Styles.Polar();
this.printButton = new System.Windows.Forms.Button();
this.exitButton = new System.Windows.Forms.Button();
this.customCheckBox = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// tChart1
//
this.tChart1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
//
// tChart1.Aspect
//
this.tChart1.Aspect.Elevation = 315;
this.tChart1.Aspect.Orthogonal = false;
this.tChart1.Aspect.Perspective = 0;
this.tChart1.Aspect.Rotation = 360;
this.tChart1.Aspect.View3D = false;
this.tChart1.BackColor = System.Drawing.Color.White;
//
// tChart1.Header
//
this.tChart1.Header.Lines = new string[] {
"TeeChart"};
this.tChart1.Location = new System.Drawing.Point(0, 0);
this.tChart1.Name = "tChart1";
//
// tChart1.Panel
//
//
// tChart1.Panel.Brush
//
this.tChart1.Panel.Brush.Color = System.Drawing.Color.White;
this.tChart1.Series.Add(this.polar1);
this.tChart1.Size = new System.Drawing.Size(760, 416);
this.tChart1.TabIndex = 0;
this.tChart1.SizeChanged += new System.EventHandler(this.tChart1_SizeChanged);
this.tChart1.ChartPrint += new Steema.TeeChart.ChartPrintEventHandler(this.tChart1_ChartPrint);
//
// polar1
//
//
// polar1.Brush
//
this.polar1.Brush.Color = System.Drawing.Color.Red;
this.polar1.Circled = true;
//
// polar1.Pen
//
this.polar1.Pen.Color = System.Drawing.Color.Red;
//
// polar1.Pointer
//
//
// polar1.Pointer.Brush
//
this.polar1.Pointer.Brush.Color = System.Drawing.Color.FromArgb(((System.Byte)(254)), ((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(0)));
this.polar1.Pointer.Style = Steema.TeeChart.Styles.PointerStyles.Rectangle;
this.polar1.ShowInLegend = false;
this.polar1.Title = "polar1";
//
// polar1.XValues
//
this.polar1.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.Ascending;
//
// printButton
//
this.printButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.printButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.printButton.Location = new System.Drawing.Point(8, 432);
this.printButton.Name = "printButton";
this.printButton.TabIndex = 1;
this.printButton.Text = "Print";
this.printButton.Click += new System.EventHandler(this.printButton_Click);
//
// exitButton
//
this.exitButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.exitButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.exitButton.Location = new System.Drawing.Point(680, 432);
this.exitButton.Name = "exitButton";
this.exitButton.TabIndex = 2;
this.exitButton.Text = "Exit";
this.exitButton.Click += new System.EventHandler(this.exitButton_Click);
//
// customCheckBox
//
this.customCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.customCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.customCheckBox.Location = new System.Drawing.Point(208, 432);
this.customCheckBox.Name = "customCheckBox";
this.customCheckBox.Size = new System.Drawing.Size(104, 16);
this.customCheckBox.TabIndex = 3;
this.customCheckBox.Text = "Custom radius";
this.customCheckBox.CheckedChanged += new System.EventHandler(this.customCheckBox_CheckedChanged);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(760, 462);
this.Controls.Add(this.customCheckBox);
this.Controls.Add(this.exitButton);
this.Controls.Add(this.printButton);
this.Controls.Add(this.tChart1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
private Rectangle frameRect;
private void myInit()
{
frameRect = new Rectangle(10, 30, 1072, 700);
polar1.FillSampleValues(25);
}
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}
private void customCheckBox_CheckedChanged(object sender, System.EventArgs e)
{
calcCustomSize();
}
private void printButton_Click(object sender, System.EventArgs e)
{
tChart1.Printer.Landscape = true;
tChart1.Printer.BeginPrint();
tChart1.Printer.Print(frameRect);
tChart1.Printer.Preview();
}
private void exitButton_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
private void tChart1_SizeChanged(object sender, System.EventArgs e)
{
calcCustomSize();
}
private void tChart1_ChartPrint(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
// some custom printing
e.Graphics.DrawRectangle(new Pen(Color.Black), frameRect);
}
private void calcCustomSize()
{
if (customCheckBox.Checked)
{
// do some silly custom calculation of size
int x, y, rad;
x = tChart1.Width / 2 - 70;
y = tChart1.Height / 2 - 70;
rad = Math.Min(x, y);
polar1.CustomXRadius = rad;
polar1.CustomYRadius = rad;
}
else
{
polar1.CustomXRadius = 0;
polar1.CustomYRadius = 0;
}
}
}
}