-
Notifications
You must be signed in to change notification settings - Fork 0
/
EditBotDescription.cs
105 lines (87 loc) · 2.94 KB
/
EditBotDescription.cs
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TelegramBotsApp.Models;
namespace TelegramBotsApp
{
public partial class EditBotDescription : Form
{
private string botToken;
private int botIndex = -1;
private string avatarPath;
private Bot Bot
{
get { return DataBase.bots[botIndex]; }
set { DataBase.bots[botIndex] = value; }
}
public EditBotDescription()
{
InitializeComponent();
}
public EditBotDescription(string _botToken)
{
InitializeComponent();
botToken = _botToken;
botIndex = DataBase.FindBotByToken(botToken);
if (Bot.Name != null) textBox1.Text = Bot.Name;
if (Bot.Description != null) textBox2.Text = Bot.Description;
if (Bot.AvatarPath != null)
{
avatarPath = Bot.AvatarPath;
pictureBox1.Image = Image.FromFile(Bot.AvatarPath);
UpdateChangeAvatarButton();
}
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void EditBotDescription_Load(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void UpdateChangeAvatarButton()
{
button1.Location = new Point(button1.Location.X + 107, button1.Location.Y);
button1.Text = "Изменить аватар";
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog openDialog = new OpenFileDialog();
openDialog.Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png";
if (openDialog.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image = Image.FromFile(openDialog.FileName);
avatarPath = openDialog.FileName;
avatarPath = avatarPath.Replace('\\', '/');
UpdateChangeAvatarButton();
}
}
private void button2_Click(object sender, EventArgs e)
{
int botIndex = DataBase.FindBotByToken(botToken);
DataBase.bots[botIndex].Name = textBox1.Text;
DataBase.bots[botIndex].Description = textBox2.Text;
DataBase.bots[botIndex].AvatarPath = avatarPath;
this.Close();
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
}
private void textBox2_TextChanged_1(object sender, EventArgs e)
{
}
}
}