Minggu, 06 April 2014

TUGAS 5

SOAL

BUATLAH FUNGSI DRAWLINE DAN HITUNGLAH LUASNYA!!

1.DESIGN :


2. PROGRAM :

namespace tugas_5
{
    /// <summary>
    /// Description of MainForm.
    /// </summary>
    public partial class MainForm : Form
    {
        private Graphics gr;
        private int x1, x2, y1, y2;
        private double luas;
        private Boolean painter;
       
       
        public MainForm()
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
           
            //
            // TODO: Add constructor codeh after the InitializeComponent() call.
            //
        }
       
        void MainFormLoad(object sender, EventArgs e)
        {
            gr = panel1.CreateGraphics();
        }
       
       
        void Panel1MouseDown(object sender, MouseEventArgs e)
        {
            if ( e.Button == MouseButtons.Left)
            {
                painter = true;
            }
           
            x1 = e.X;
            y1 = e.Y;
        }
       
        void Panel1MouseMove(object sender, MouseEventArgs e)
        {
            if ( painter == true )
            {
                panel1.Refresh();
                gr.DrawLinenew Pen ( Color.Red ),x1,y1,e.X,e.Y);
            }
        }
       
       
       
        void Panel1MouseUp(object sender, MouseEventArgs e)
        {
            x2 = e.X - x1;
            y2 = e.Y - y1;
            luas = Math.Sqrt ((x2 + x2 ) + ( y2 + y2 ));
            textBox1.Text=Convert.ToString(luas);
            painter = false;
        }
    }
}


3. RUN PROGRAM : 
 


VIDIO :

@YOUTUBE


0 komentar:

Posting Komentar