Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows.Forms;
- using System.Drawing;
- using System.IO;
- using System.Globalization;
- using System.Threading;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- int scale = 15;
- public Form1()
- {
- InitializeComponent();
- }
- StreamReader file = new StreamReader("D:\\zadanie.txt");
- private void panel1_Paint(object sender, PaintEventArgs e)
- {
- Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
- Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
- e.Graphics.DrawLine(Pens.BlueViolet, panel1.Width / 2, 0, panel1.Width / 2, panel1.Height); //os y
- e.Graphics.DrawLine(Pens.BlueViolet, 0, panel1.Height / 2, panel1.Width, panel1.Height / 2); //os x
- Point absZero = new Point(panel1.Width / 2, panel1.Height / 2);
- int i = absZero.X;
- while (i < panel1.Width)
- {
- i += scale;
- e.Graphics.DrawLine(Pens.BlueViolet, i, absZero.Y - 4, i, absZero.Y + 4);
- }
- //Point absZero = new Point(panel1.Width / 2, panel1.Height / 2);
- e.Graphics.DrawLine(Pens.BlueViolet, absZero.X, 0, absZero.X, panel1.Height);
- e.Graphics.DrawLine(Pens.BlueViolet, 0, absZero.Y, 0, absZero.Y);
- //int i = absZero.X;
- while (i < panel1.Width)
- {
- i += scale;
- e.Graphics.DrawLine(Pens.BlueViolet, i, absZero.Y - 4, i, absZero.Y + 4);
- }
- i = absZero.X;
- while (i > 0)
- {
- i -= scale;
- e.Graphics.DrawLine(Pens.BlueViolet, i, absZero.Y - 4, i, absZero.Y + 4);
- }
- i = absZero.Y;
- while (i < panel1.Height)
- {
- i += scale;
- e.Graphics.DrawLine(Pens.BlueViolet, absZero.X - 4, i, absZero.X + 4, i);
- }
- i = absZero.Y;
- while (i > 0)
- {
- i -= scale;
- e.Graphics.DrawLine(Pens.BlueViolet, absZero.X - 4, i, absZero.X + 4, i);
- }
- String line;
- float X ;
- float Y ;
- while ((line = file.ReadLine()) != null)
- {
- X = float.Parse(line.Split(' ')[0]);
- Y = float.Parse(line.Split(' ')[1]);
- e.Graphics.FillEllipse(Brushes.Red, (absZero.X + (X * scale)) - 2, (absZero.Y - (Y * scale)) - 2, 4, 4);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement