0% found this document useful (0 votes)
54 views3 pages

Using Using Using Using Using Using Using Using Using Namespace Public Partial Class Public

The document contains code for a Windows Forms application in C#. It defines a Form1 class that inherits from the base Form class and overrides the Paint and Resize methods. The Paint method draws lines on the form when it is rendered, and the Resize method calls Refresh to redraw the form when it is resized. The code samples show different implementations of the Paint method to draw different line patterns on the form.

Uploaded by

Miloš Marković
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views3 pages

Using Using Using Using Using Using Using Using Using Namespace Public Partial Class Public

The document contains code for a Windows Forms application in C#. It defines a Form1 class that inherits from the base Form class and overrides the Paint and Resize methods. The Paint method draws lines on the form when it is rendered, and the Resize method calls Refresh to redraw the form when it is resized. The code samples show different implementations of the Paint method to draw different line patterns on the form.

Uploaded by

Miloš Marković
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

72.

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

namespace WindowsFormsApp2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Paint(object sender, PaintEventArgs e)


{
Graphics g = e.Graphics;
int A = ClientRectangle.Height, B = ClientRectangle.Height;
for(int y = 0; y <= A; y += A / 45)
{
g.DrawLine(Pens.Red, 0, 0, B, y);
g.DrawLine(Pens.Indigo, 0, A, B, y);
}
}

private void Form1_Resize(object sender, EventArgs e)


{
Refresh();
}
}
}
71 .

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

namespace _73.stepenice
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Paint(object sender, PaintEventArgs e)


{
Graphics g = e.Graphics;
int x = 0, y = ClientRectangle.Height;
while (x<ClientRectangle.Width && y>0)
{
g.DrawLine(Pens.Red, x, y, x, y - 20);
g.DrawLine(Pens.Red, x, y - 20, x + 20, y - 20);
x += 20;
y -= 20;
}
}

private void Form1_Resize(object sender, EventArgs e)


{
Refresh();
}
}
}
73.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Button1_Click(object sender, EventArgs e)


{
int x, y, d;
try
{
d = Convert.ToInt32(textBox1.Text);
}
catch
{
MessageBox.Show("Neispravna duzina stranice podaci", "Greska");
textBox1.SelectAll();
textBox1.Focus();
return;
}
Graphics g = CreateGraphics();
Random r = new Random();
Pen olovka = new Pen(Color.Blue, 2);
Refresh();
x = ClientRectangle.Width / 2;
y = panel1.Height + (ClientRectangle.Height - panel1.Height) / 2;
while (d < 0)
{
olovka.Color = Color.FromArgb(r.Next(150), r.Next(150), 255);
g.DrawRectangle(olovka, x - d/2, y - d/2, d, d);
d = d - 20;
}
olovka.Dispose();
g.Dispose();
}
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy