-
Notifications
You must be signed in to change notification settings - Fork 1
/
Status.cs
182 lines (165 loc) · 7.74 KB
/
Status.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace IMV
{
public partial class Status : Form
{
uint ID = 0; // Айди пользователя, которому отправляем статус. Если 0, то себе
delegate string SetStatus(string text);
delegate string SetWallStatus(string text, string name, uint id);
delegate string UploadFile(uint id, string path);
delegate void NotifyEvent(string name, string text, uint id);
public Status()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
vk start = new vk();
if (checkBox1.Checked) // если флажон для статуса
{
SetStatus setStatus = new SetStatus(start.setStatus);
IAsyncResult res1 = setStatus.BeginInvoke(richTextBox1.Text, null, null);
res1.AsyncWaitHandle.WaitOne(2000);
if (setStatus.EndInvoke(res1).IndexOf("error") != -1)
{
NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
this.Invoke(ShowNotify, "Ошибка!", "При публикации\nвозникли проблемы!", (uint)0);
}
//start.setStatus(richTextBox1.Text);
}
else // если для записи на стене
{
string name = "";
if (checkBox2.Checked) // если нужно изображение, загружаем
{
OpenFileDialog open = new OpenFileDialog();
open.FileName = "";
open.Filter = "Изображения|*.jpg;*.gif;*.png";
if (open.ShowDialog() == DialogResult.OK)
{
UploadFile upload = new UploadFile(start.UploadFile);
IAsyncResult res11 = upload.BeginInvoke(ID, open.FileName, null, null);
int iter = 0;
while (!res11.IsCompleted)
{
iter++;
if (iter == 500)
{
iter = 0;
Application.DoEvents();
}
}
res11.AsyncWaitHandle.WaitOne();
name = upload.EndInvoke(res11);
}
if (name == "")
{
NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
this.Invoke(ShowNotify, "Ошибка!", "При публикации\nвозникли проблемы!", (uint)0);
}
}
if (ID != 0) // не себе
{
if (name != "")
{
SetWallStatus setWallStatus = new SetWallStatus(start.SetWallStatus);
IAsyncResult res1 = setWallStatus.BeginInvoke(richTextBox1.Text, name, ID, null, null);
res1.AsyncWaitHandle.WaitOne(2000);
if (setWallStatus.EndInvoke(res1).IndexOf("error") != -1)
{
NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
this.Invoke(ShowNotify, "Ошибка!", "При публикации\nвозникли проблемы!", (uint)0);
}
//start.SetWallStatus(richTextBox1.Text, name, ID);
}
else
{
SetWallStatus setWallStatus = new SetWallStatus(start.SetWallStatus);
IAsyncResult res1 = setWallStatus.BeginInvoke(richTextBox1.Text, "", ID, null, null);
res1.AsyncWaitHandle.WaitOne(2000);
if (setWallStatus.EndInvoke(res1).IndexOf("error") != -1)
{
NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
this.Invoke(ShowNotify, "Ошибка!", "При публикации\nвозникли проблемы!", (uint)0);
}
//start.SetWallStatus(richTextBox1.Text, "", ID);
}
}
else // себе
{
if (name != "")
{
SetWallStatus setWallStatus = new SetWallStatus(start.SetWallStatus);
IAsyncResult res1 = setWallStatus.BeginInvoke(richTextBox1.Text, name, ID, null, null);
res1.AsyncWaitHandle.WaitOne(2000);
if (setWallStatus.EndInvoke(res1).IndexOf("error") != -1)
{
NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
this.Invoke(ShowNotify, "Ошибка!", "При публикации\nвозникли проблемы!", (uint)0);
}
//start.SetWallStatus(richTextBox1.Text, name, ID);
}
else
{
SetStatus setWallStatus = new SetStatus(start.SetWallStatus);
IAsyncResult res1 = setWallStatus.BeginInvoke(richTextBox1.Text, null, null);
res1.AsyncWaitHandle.WaitOne(2000);
if (setWallStatus.EndInvoke(res1).IndexOf("error") != -1)
{
NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
this.Invoke(ShowNotify, "Ошибка!", "При публикации\nвозникли проблемы!", (uint)0);
}
//start.SetWallStatus(richTextBox1.Text);
}
}
}
this.Close();
}
void ShowNotifyWindow(string name, string text, uint ID)
{
Notify noti = new Notify(name, text, ID);
noti.ShowWindow();
noti.ShowTime();
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void Wait_Paint(object sender, PaintEventArgs e)
{// Рисуем рамочку вокруг textBox'a
e.Graphics.DrawRectangle(Pens.Black, 4, 4, 392, 64);
}
private void checkBox3_CheckedChanged(object sender, EventArgs e)
{
if (checkBox3.Checked)
{// открываем окно поиска пользователя
FindUser find = new FindUser();
find.ShowDialog();
ID = find.UserID;
find.Close();
find.Dispose();
if (ID == 0)
checkBox3.Checked = false;
else
checkBox1.Enabled = false;
}
else
checkBox1.Enabled = true;
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked)
checkBox3.Enabled = false;
else
checkBox3.Enabled = true;
}
}
}