First I thought it had something to do with that new "automatic properties" feature of C#, but when I used the normal scheme for properties I got the same error message : Cannot modify the return value of 'AxisTest.Form1.Axis.XOrg' because it is not a variable
Wonder what is wrong here.
I tried a few things, my code is a bit of a mess but here it is :
namespace AxisTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics G = e.Graphics;
Axis Ax = new Axis();
Pen P = new Pen(Ax.LineColor);
//***error*** Ax.Origin.X = 50;
//***error*** Ax.XOrg.X = 50F;
G.DrawLine(P, (float)(50.0 + Ax.Minimum), (float)50.0,
(float)(50.0 + Ax.Maximum), (float)50.0);
}
class Axis
{
private PointF _XOrg = new PointF(50, 50);
public Axis()
{
LineColor = Color.Black;
Minimum = 0;
Maximum = 100;
PrimaryTicUnit = 10;
SecondaryTicUnit = 5;
//***error*** this.Origin.X = 50;
//***error*** Origin.Y = 50;
}
public Color LineColor { get; set; }
public float Minimum { get; set; }
public float Maximum { get; set; }
public float PrimaryTicUnit { get; set; }
public float SecondaryTicUnit { get; set; }
public PointF Origin { get; set; }
public PointF XOrg
{
get { return _XOrg; }
set { _XOrg = value; }
}
}
}
}