AalborgHTX

Tegneprogram 1.0

Apr 16th, 2020
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsApp26
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         Graphics myCanvas;
  16.         Pen myPen = new Pen(Color.Green, 3.0f);
  17.  
  18.         int oldX = 0;
  19.         int oldY = 0;
  20.         public Form1()
  21.         {
  22.             InitializeComponent();
  23.         }
  24.  
  25.         private void btnTegn_Click(object sender, EventArgs e)
  26.         {
  27.             int newX = int.Parse(txtX.Text);
  28.             int newY = int.Parse(txtY.Text);
  29.  
  30.             myCanvas.DrawLine(myPen, oldX, oldY, newX, newY);
  31.  
  32.             oldX = newX;
  33.             oldY = newY;
  34.         }
  35.  
  36.         private void Form1_Load(object sender, EventArgs e)
  37.         {
  38.             myCanvas = this.CreateGraphics();
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment