Selasa, 08 April 2014

laporan tugas minggu 6 string membuat protocol TCP

Berikut adalah link tutorial youtube : http://www.youtube.com/watch?v=trnv86_4xnE&feature=youtu.be



Dan berikut pula koding yang telah dibuat :

using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; namespace Tugas_6 { public partial class MainForm : Form { public MainForm() { InitializeComponent(); } void Button1Click(object sender, EventArgs e) { //awal protokol string hasil = inpt.Text.Substring(0); box1.Text = hasil.Substring(8,5); // (mulai kata yang di ambil,banyaknya yang di ambil) box2.Text = hasil.Substring(45,5); box3.Text = hasil.Substring(13,2); box4.Text = hasil.Substring(15,2); box5.Text = hasil.Substring(17,5); box6.Text = hasil.Substring(22,19); } } }

Selasa, 01 April 2014

vidio tugas 5. graphic


laporan tugas 5 program c# ~ Graphic


Tugas
Buat aplikasi untuk menggambar dan menghitung panjang sebuah
garis. Gunakan method DrawLine:

objGraphic.DrawLine(new Pen(Color.Black), x1, y1, x2, y2);

Object Pen sama seperti SolidBrush, hanya saja Pen menampilkan titik satu piksel saja.
Gambar diletakkan di object panel. Agar dapat menggambar di panel, ada sedikit
perbedaan untuk membuat instance Graphics:

objGraphic = panel1.CreateGraphics();

Kemudian tambahkan object TextBox untuk menampilkan hasil perhitungan





pada tugas ke 5 kali ini saya akan
 mencoba membuat program paint sederhana dimana terdapat 3 tombol pilihan yaitu line (garis), ellipse(lingkaran lonjong ), dan yang terakhir adalah rectangular (persegi).
pada program kali ini saya membutuhkan beberapa tool seperti panel,label,toolbox,dan juga tombol button seperlunya dan sesuai yang diinginkan .
kali ini kita akan bekerja pada panel sebagai pusat programnya dan bukan lagi pada form aplikasinya yang menjadi tempat program berjalan.

berikut adalah koding dari program yang telah saya buat :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        private Graphics objgraphic;
        private bool gambar = false, dragmode = false;
        private int ghafurX, ghafurY, x, y, abdulX, abdulY;
        private double abdulxy;
        private int GO=0, fur=0, warna=0;
        int diameter;
        
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            objgraphic = panel1.CreateGraphics();
        }

        private void panel1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                gambar = true;
                GO++;
            }
            ghafurX = e.X;
            ghafurY = e.Y;
            dragmode = true;

        }
        private void panel1_MouseClick_1(object sender, MouseEventArgs e)
        {

            if (gambar == true)
            {

                x = e.X;
                y = e.Y;
                abdulX = e.X - ghafurX;
                abdulY = ghafurY - e.Y;

                if (fur == 1)
                {
                    if (warna == 1)
                    {
                        objgraphic.DrawLine(new Pen(Color.Black), ghafurX, ghafurY, e.X, e.Y);
                    }
                    else if (warna == 2)
                    {
                        objgraphic.DrawLine(new Pen(Color.Red), ghafurX, ghafurY, e.X, e.Y);
                    }
                    else if (warna == 3)
                    {
                        objgraphic.DrawLine(new Pen(Color.Lime), ghafurX, ghafurY, e.X, e.Y);
                    }
                    else if (warna == 4)
                    {
                        objgraphic.DrawLine(new Pen(Color.Yellow), ghafurX, ghafurY, e.X, e.Y);
                    }
                    else if (warna == 5)
                    {
                        objgraphic.DrawLine(new Pen(Color.Blue), ghafurX, ghafurY, e.X, e.Y);
                    }
                    else { MessageBox.Show("CHOOSE THE COLOUR PLEASE!!!"); }


                }
                else if (fur == 2)
                {
                    if (warna == 1)
                    {
                        objgraphic.DrawEllipse(new Pen(Color.Black), ghafurX, ghafurY, abdulX, -abdulY);
                    }
                    else if (warna == 2)
                    {
                        objgraphic.DrawEllipse(new Pen(Color.Red), ghafurX, ghafurY, abdulX, -abdulY);
                    }
                    else if (warna == 3)
                    {
                        objgraphic.DrawEllipse(new Pen(Color.Lime), ghafurX, ghafurY, abdulX, -abdulY);
                    }
                    else if (warna == 4)
                    {
                        objgraphic.DrawEllipse(new Pen(Color.Yellow), ghafurX, ghafurY, abdulX, -abdulY);
                    }
                    else if (warna == 5)
                    {
                        objgraphic.DrawEllipse(new Pen(Color.Blue), ghafurX, ghafurY, abdulX, -abdulY);
                    }
                    else { MessageBox.Show("choose the colour first!!!"); }
                }
                else if (fur == 3)
                {
                    if (warna == 1)
                    {
                        objgraphic.DrawRectangle(new Pen(Color.Black), ghafurX, ghafurY, abdulX, -abdulY);
                    }
                    else if (warna == 2)
                    {
                        objgraphic.DrawRectangle(new Pen(Color.Red), ghafurX, ghafurY, abdulX, -abdulY);
                    }
                    else if (warna == 3)
                    {
                        objgraphic.DrawRectangle(new Pen(Color.Lime), ghafurX, ghafurY, abdulX, -abdulY);
                    }
                    else if (warna == 4)
                    {
                        objgraphic.DrawRectangle(new Pen(Color.Yellow), ghafurX, ghafurY, abdulX, -abdulY);
                    }
                    else if (warna == 5)
                    {
                        objgraphic.DrawRectangle(new Pen(Color.Blue), ghafurX, ghafurY, abdulX, -abdulY);
                    }
                    else { MessageBox.Show("warnanya dong!"); }
                }
                else { MessageBox.Show("SHAPE please!!!"); }

                
            }
        }
   
        
      



        private void Clear_Click(object sender, EventArgs e)
        {
            this.Refresh();
        }

        private void panel1_MouseMove(object sender, MouseEventArgs e)
        {
            textBox1.Text = Convert.ToString(abdulX);
            textBox2.Text = Convert.ToString(abdulY);
            abdulxy = Math.Sqrt((abdulX * abdulX) + (abdulY * abdulY));
            textBox3.Text = Convert.ToString(abdulxy);
        }


        private void linee_Click(object sender, EventArgs e)
        {
            fur = 1;
            linee.BackColor = Color.Green;
            ellipsee.BackColor = Color.White;
            recc.BackColor = Color.White;
            
        }

        private void ellipsee_Click(object sender, EventArgs e)
        {
            fur = 2;
            linee.BackColor = Color.White;
            ellipsee.BackColor = Color.Green;
            recc.BackColor = Color.White;
           
            
        }
        private void recc_Click(object sender, EventArgs e)
        {
            fur = 3;
            linee.BackColor = Color.White;
            ellipsee.BackColor = Color.White;
            recc.BackColor = Color.Green;
           
            
        }

        


        private void hitam_Click(object sender, EventArgs e)
        {
            warna = 1;
            hitam.FlatStyle = FlatStyle.Popup;
            merah.FlatStyle = FlatStyle.Standard;
            hijau.FlatStyle = FlatStyle.Standard;
            kuning.FlatStyle = FlatStyle.Standard;
            biru.FlatStyle = FlatStyle.Standard;
        }

        private void merah_Click(object sender, EventArgs e)
        {
            warna = 2;
            hitam.FlatStyle = FlatStyle.Standard;
            merah.FlatStyle = FlatStyle.Popup;
            hijau.FlatStyle = FlatStyle.Standard;
            kuning.FlatStyle = FlatStyle.Standard;
            biru.FlatStyle = FlatStyle.Standard;
        }

        private void hijau_Click(object sender, EventArgs e)
        {
            warna = 3;
            hitam.FlatStyle = FlatStyle.Standard;
            merah.FlatStyle = FlatStyle.Standard;
            hijau.FlatStyle = FlatStyle.Popup;
            kuning.FlatStyle = FlatStyle.Standard;
            biru.FlatStyle = FlatStyle.Standard;
        }

        private void kuning_Click(object sender, EventArgs e)
        {
            warna = 4;
            hitam.FlatStyle = FlatStyle.Standard;
            merah.FlatStyle = FlatStyle.Standard;
            hijau.FlatStyle = FlatStyle.Standard;
            kuning.FlatStyle = FlatStyle.Popup;
            biru.FlatStyle = FlatStyle.Standard;
        }

        private void biru_Click(object sender, EventArgs e)
        {
            warna = 5;
            hitam.FlatStyle = FlatStyle.Standard;
            merah.FlatStyle = FlatStyle.Standard;
            hijau.FlatStyle = FlatStyle.Standard;
            kuning.FlatStyle = FlatStyle.Standard;
            biru.FlatStyle = FlatStyle.Popup;
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }


        
    }
}


 setelah membuat programnya dengan koding koding tersebut maka selanjutnya adalah menjalankan program dengan menekan tombol F5 pada keyboard. 
Maka berikut hasil dari programnya setelah di running :


terima kasih telah membaca blog ini, silahkan untuk mencobanya sendiri sesuai dengan kreasi anda..

Tugas 5~ Graphic


Nama : MUHAMMAD ABDUL GHAFUR
NIM     : 4211301005


Tugas 5 Tutorial c# Link Tutorial Youtube dan Blog
Membuat Program Paint Sederhana

Link youtube    : http://youtu.be/e9_Rv3i_NGc
Blog                   : http://ghafur12.blogspot.com/


Terima kasih