This isn't a NinjaScript question, but I'm hoping someone out there can throw me a bone.
I've created a custom chart of a statistical distribution. I create the graphic and it works fine when I save it to file.
What I want to do is to display the graphic in a separate form that I've created and to update it once per bar. My problem is with the updating - I can't figure out how to pass my Graphics object to my form1 object in order to make it paint.
Things I tried:
Setting e.Graphics equal to a class variable hoping it would "stick" to the form from OnBarUpdate(). No such luck.
Setting a panel on the form, then updating the panel BackgroundImage property from OnBarUpdate(). I don't see anything "goldenrod" in the background, so maybe this is the avenue and I messed it up. I'm at the point where I'm frustrated and not thinking clearly. Help is much appreciated!
public class HurstBars : Indicator { private Form1 form1; protected override void OnStartUp() { form1 = new Form1(); form1.Show(); } protected override void OnTermination() { form1.Dispose(); } protected override void OnBarUpdate() { Bitmap bmp = new Bitmap(width,height); Graphics g = Graphics.FromImage( bmp ); // do operations on g // .... form1.ImagePanel.BackgroundImage = bmp; form1.G = g; } } public class Form1 : Form { private Graphics g; private Panel panel; private Image image; public Form1() { //InitializeComponent(); this.Text = "Initial title"; this.Height = 600; this.Width = 800; this.Load += new System.EventHandler(this.Form1_Load); this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint); panel = new Panel(); } private void Form1_Paint(object sender, PaintEventArgs e) { this.Text = "Painted form"; Graphics temp = e.Graphics; temp = g; } private void Form1_Load(object sender, EventArgs e) { //this.Text = "New title"; panel.Width = 800; panel.Height = 600; panel.BackColor = Color.PaleGoldenrod; panel.Location = new System.Drawing.Point(0, 0); panel.BackgroundImage = image; } private void Form1_FormClosing(object sender, FormClosingEventArgs e) { } public Graphics G { get { return g; } set { g = value; } } public Panel ImagePanel { get{ return panel; } set{ panel = value; } } }
Comment