lab12(PatternPenDialog)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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 lab12
{
public partial class PatternPenDialog : Form
{
//Form1 MainForm = new Form1();
Pen My_Pen;
float[] Patter = new float[] { 1.0F, 1.0F, 1.0F, 1.0F };
float OffSet = new float();
public PatternPenDialog()
{
InitializeComponent();
My_Pen = new Pen(Brushes.Black, 3);
OffSet = 1.0F;
My_Pen.DashPattern = Patter;
}
private void button1_Click(object sender, EventArgs e)
{
DialogResult = System.Windows.Forms.DialogResult.OK;
}
private void button2_Click(object sender, EventArgs e)
{
DialogResult = System.Windows.Forms.DialogResult.Cancel;
}
private void Drawing(object sender, PaintEventArgs e)
{
e.Graphics.DrawLine(My_Pen, new Point(50, 100), new Point(250, 100));
}
public float[] GetPenPattern()
{
return Patter;
}
public float GetPenOffSet()
{
return OffSet;
}
private void ValuePatternChange(object sender, EventArgs e)
{
NumericUpDown temp = sender as NumericUpDown;
Patter[Convert.ToInt32(temp.Tag)] = (float)temp.Value;
My_Pen.DashPattern = Patter;
Invalidate();
}
private void DashOffSetChange(object sender, EventArgs e)
{
NumericUpDown temp = sender as NumericUpDown;
OffSet = (float)temp.Value;
My_Pen.DashOffset = OffSet;
Invalidate();
}
}
}