-
Notifications
You must be signed in to change notification settings - Fork 2
/
Popup.cs
75 lines (64 loc) · 1.91 KB
/
Popup.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
using System;
using System.Drawing;
using System.Media;
using System.Windows.Forms;
namespace NotiSharp
{
public partial class Popup : Form
{
public Popup()
{
InitializeComponent();
StartPosition = FormStartPosition.Manual;
Location = GetLocation();
if (PlaySound)
{
SystemSounds.Beep.Play();
}
}
public void SetIcon(Bitmap res)
{
if (Icon != null) PopupLogo.Image = res;
}
public void SetText(string content)
{
if (Text != null) ContentArea.Text = content;
}
public void SetSize(Size size)
{
Size defSize = Size;
if ((size.Width > defSize.Width) && (size.Height > defSize.Height))
{
Size = size;
InnerPane.Size += defSize - size;
ContentArea.Size += defSize - size;
}
}
private bool PlaySound = false;
public void SetNotificationSound(bool isPlaySound)
{
isPlaySound = PlaySound;
}
private const int Marx = 10; // X Position Margin
private const int Mary = 10; // Y Position Margin
private Point GetLocation()
{
Rectangle wArea = Screen.GetWorkingArea(this); // Get First Moniter's Workspace Size (Without Taskbar)
var width = wArea.Width - Marx - Size.Width;
var height = wArea.Height - Mary - Size.Height;
return new Point(width, height); // Send to Point
}
private void PopupLogo_Click(object sender, System.EventArgs e)
{
Close();
}
private void InnerPane_Click(object sender, System.EventArgs e)
{
Close();
}
private void ContentArea_Click(object sender, EventArgs e)
{
Close();
}
}
}