Can't draw in screen open event
Posted: Thu Oct 30, 2014 11:00 pm
I use DrawTest() to draw two rectangles on screen, they can't be displayed when using Screen1_Opened(), but it can in Button_Click().
here is the source code,
namespace Neo.ApplicationFramework.Generated
{
using System.Windows.Forms;
using System;
using System.Drawing;
using Neo.ApplicationFramework.Tools;
using Neo.ApplicationFramework.Common.Graphics.Logic;
using Neo.ApplicationFramework.Controls;
using Neo.ApplicationFramework.Interfaces;
public partial class Screen1
{
void DrawTest()
{
System.Drawing.Pen myPen, myPen1;
myPen = new System.Drawing.Pen(System.Drawing.Color.Red);
myPen1 = new System.Drawing.Pen(System.Drawing.Color.Green, 2);
Graphics formGraphics = this.CreateGraphics();
formGraphics.DrawRectangle(myPen, 52, 52,40, 50);
formGraphics.DrawRectangle(myPen1,50,50,100,150);
myPen.Dispose();
myPen1.Dispose();
formGraphics.Dispose();
}
void Screen1_Opened(System.Object sender, System.EventArgs e)
{
DrawTest();
}
void Button_Click(System.Object sender, System.EventArgs e)
{
DrawTest();
}
}
}
Does someone know how it is?
Thanks.
kenko
here is the source code,
namespace Neo.ApplicationFramework.Generated
{
using System.Windows.Forms;
using System;
using System.Drawing;
using Neo.ApplicationFramework.Tools;
using Neo.ApplicationFramework.Common.Graphics.Logic;
using Neo.ApplicationFramework.Controls;
using Neo.ApplicationFramework.Interfaces;
public partial class Screen1
{
void DrawTest()
{
System.Drawing.Pen myPen, myPen1;
myPen = new System.Drawing.Pen(System.Drawing.Color.Red);
myPen1 = new System.Drawing.Pen(System.Drawing.Color.Green, 2);
Graphics formGraphics = this.CreateGraphics();
formGraphics.DrawRectangle(myPen, 52, 52,40, 50);
formGraphics.DrawRectangle(myPen1,50,50,100,150);
myPen.Dispose();
myPen1.Dispose();
formGraphics.Dispose();
}
void Screen1_Opened(System.Object sender, System.EventArgs e)
{
DrawTest();
}
void Button_Click(System.Object sender, System.EventArgs e)
{
DrawTest();
}
}
}
Does someone know how it is?
Thanks.
kenko