Jakich użyć parametrów w private void OnButton_OK (object sender, EventArgs e) aby wywołać ponownie private void OnPaint_Rezistor (PaintEventArgs e) by narysowało drugą linię a może jest inny sposób by po narysowaniu jednej linii po użyciu np. buttona program narysował drugą linię.
using System;
using System.Windows.Forms;
using System.Drawing;
namespace Nowy_Program
{
public class Window:Form
{
Pen Pen_Rezistor;
Button Button_OK;
int iA;
private void OnPaint (object sender, PaintEventArgs e)
{
OnPaint_Rezistor(e);
}
private void OnPaint_Rezistor (PaintEventArgs e)
{
Pen_Rezistor = new Pen(Color.Red, 2);
e.Graphics.DrawLine(Pen_Rezistor, 30, 20, 150, 20);
if (iA ==1)
e.Graphics.DrawLine(Pen_Rezistor, 30, 60, 150, 60);
}
private void OnButton_OK (object sender, EventArgs e)
{
iA = 1;
// ??
}
public Window()
{
iA = new int ();
this.Width=350;
this.Height=420;
this.Text = "Window";
this.Paint += new PaintEventHandler(OnPaint);
Button_OK = new Button();
Button_OK.Parent = this;
Button_OK.Location = new Point (140,160);
Button_OK.Text = "OK";
Button_OK.Click += new System.EventHandler(OnButton_OK);
this.Controls.Add(Button_OK);
}
[STAThread]
public static void Main()
{
Application.EnableVisualStyles();
Application.Run (new Window());
}
}
}