Welcome Guest ( Login | Register )



All times are UTC - 7 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Can't draw in screen open event
PostPosted: Thu Oct 30, 2014 11:00 pm 

Joined: Fri Oct 24, 2014 3:00 am
Posts: 1

Offline
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


 Profile  
 
 Post subject: Re: Can't draw in screen open event
PostPosted: Fri Mar 10, 2017 2:54 am 

Joined: Fri Mar 10, 2017 2:45 am
Posts: 1

Offline
The screen is refreshed just after the Screen_Opened event. causing the form to be cleared. So whatever You maually place on the screen with this event will be cleared. You can see the same behaviour if you implement this code, in your button script, just after drawing. "this.Refresh(); "


 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 7 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron