/
NotificationForm.cs
119 lines (102 loc) · 3.04 KB
/
NotificationForm.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
using Sunny.UI;
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 miniSys0._3
{
public partial class NotificationForm : UIForm
{
Color brown = Color.FromArgb(55, 55, 57);
Color wordBlue = Color.FromArgb(22, 93, 255);
Color green = Color.FromArgb(0, 180, 42);
Color orange = Color.FromArgb(245, 63, 63);
Color red = Color.FromArgb(255, 125, 0);
public NotificationForm(string type, string contentText)
{
InitializeComponent();
content.Text = contentText;
InitStyle(type);
InitSize(contentText);
InitTheme();
cancel.Hide();
}
private void InitTheme()
{
if (User_type.user_theme == "dark")
{
this.BackColor = brown;
typeText.ForeColor = Color.White;
content.ForeColor = Color.White;
this.ShowShadow = false;
}
else
{
this.BackColor = Color.White;
typeText.ForeColor = Color.Black;
content.ForeColor = Color.Black;
this.ShowShadow = true;
}
}
private void InitStyle(string type)
{
type = type.ToLower();
if (type == "notification")
{
icon.FillColor = wordBlue;
icon.Symbol = 61737;
typeText.Text = "Notification";
}
else if (type == "success")
{
icon.FillColor = green;
icon.Symbol = 61452;
typeText.Text = "Success";
}
else if (type == "warning")
{
icon.FillColor = orange;
icon.Symbol = 61737;
typeText.Text = "Warning";
}
else if (type == "error")
{
icon.FillColor = red;
icon.Symbol = 61453;
typeText.Text = "Error";
}
else
{
icon.Hide();
typeText.Location = new Point(22, 10);
typeText.Text = "Normal";
}
}
private void InitSize(string contentText)
{
if(contentText !="" || contentText != null)
{
if(contentText.Length > 70)
{
this.Size = new Size(350, 200);
ok.Location = new Point(248, 156);
cancel.Location = new Point(149, 156);
content.Size = new Size(305,95);
}
}
}
private void cancel_Click(object sender, EventArgs e)
{
this.Dispose();
}
private void ok_Click(object sender, EventArgs e)
{
this.Dispose();
}
}
}