lab16(My_Dialog)

 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
65
66
67
68
69
70
71
72
73
74
75
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;
using System.IO;
namespace lab16
{
public partial class My_Dialog : Form
{
Image My_Image_For_Label;
Label My_Label;
TextBox My_TextBox;
public My_Dialog()
{
InitializeComponent();
My_Label = new Label();
My_Image_For_Label = Image.FromFile("C:\\Users\\SONY\\Pictures\\photo.PNG");
My_Label.Size = new Size(My_Image_For_Label.Width, My_Image_For_Label.Height);
My_Label.Location = new Point(0, My_MenuStrip.Height + 5);
Controls.Add(My_Label);
My_TextBox = new TextBox();
My_TextBox.Multiline = true;
My_TextBox.Location = new Point(0, My_MenuStrip.Height + My_Label.Height + 10);
My_TextBox.Size = new Size(this.ClientSize.Width, 90);
Controls.Add(My_TextBox);
}
private void buttonAccept_Click(object sender, EventArgs e)
{
DialogResult = System.Windows.Forms.DialogResult.OK;
}
private void Move_Mouse(object sender, MouseEventArgs e)
{
statusStrip1.Items[1].Text = e.X.ToString();
statusStrip1.Items[3].Text = e.Y.ToString();
}
private void ChangeInvisble(object sender, EventArgs e)
{
if (!My_CheckBox.Checked)
My_Label.Image = null;
else My_Label.Image = My_Image_For_Label;
}
private void нажмиToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("При нажатии на дату в календаре создается текстовый документ, имя которого является дата, а содержимое его - текст из TextBox");
}
private void SelectData(object sender, DateRangeEventArgs e)
{
string Path = @"D:\" + My_Calendar.SelectionStart.ToShortDateString() + ".txt";
if (File.Exists(Path))
{
File.Delete(Path);
}
using (FileStream fs = File.Create(Path))
{
Byte[] info = new UTF8Encoding(true).GetBytes(My_TextBox.Text);
// Add some information to the file.
fs.Write(info, 0, info.Length);
}
MessageBox.Show(@"Файл создан и хранится здесь: D:\" + My_Calendar.SelectionStart.ToShortDateString() + ".txt");
}
}
}