public NotificationForm(UI ui) { this.ui = ui; // Timers timerShowAnimate.Interval = 1; timerShowAnimate.Tick += new EventHandler(timerShowAnimate_Tick); int Interval = Properties.Settings.Default.NotificationDisplayTime; timerDisplayed.Interval = Interval == 0 ? 1 : Interval; timerDisplayed.Tick += new EventHandler(timerDisplayed_Tick); timerCloseAnimate.Interval = 1; timerCloseAnimate.Tick += new EventHandler(timerCloseAnimate_Tick); // Default Settings for a Notification ScreenPosition = Properties.Settings.Default.NotificationScreenPosition; EdgeSpacing = new Padding(10,10,10,10); this.Size = new Size(350, 100); this.BackColor = Color.White; this.Opacity = 0; this.ShowInTaskbar = false; this.ControlBox = false; this.FormBorderStyle = FormBorderStyle.FixedSingle; this.Load += new EventHandler(NotificationForm_Load); // Close Control btnCloseNotification.Text = "x"; btnCloseNotification.Size = new Size(19, 20); btnCloseNotification.BackColor = System.Drawing.Color.Transparent; btnCloseNotification.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; btnCloseNotification.FlatAppearance.BorderSize = 0; btnCloseNotification.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Silver; btnCloseNotification.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; btnCloseNotification.UseVisualStyleBackColor = false; btnCloseNotification.FlatStyle = System.Windows.Forms.FlatStyle.Flat; btnCloseNotification.Click += btnCloseNotification_Click; // Default Controls lblTitle.AutoSize = true; lblTitle.Font = new Font(lblTitle.Font, FontStyle.Bold); lblTitle.Location = new Point(10,10); lblMessage.AutoSize = true; //lblMessage.Font = new Font(lblTitle.Font, FontStyle.Bold); lblMessage.Location = new Point(10, 40); this.ControlAdded += NotificationForm_ControlAdded; }
private void NotificationPosition(NotificationScreenPosition ScreenPosition) { List<NotificationForm> ActiveNotifications = ui.NewActiveNotification(this); foreach(NotificationForm an in ActiveNotifications){ if (an != this){ Padding Edge = an.EdgeSpacing; ActiveNotificationsHeight += an.Height + Edge.Top; } } TaskBarHeight = Screen.PrimaryScreen.Bounds.Bottom - Screen.PrimaryScreen.WorkingArea.Bottom; switch (ScreenPosition) { // Top Left case NotificationScreenPosition.TopLeft: TaskBar = false; this.PositionStart = new Point( Screen.PrimaryScreen.Bounds.Left + EdgeSpacing.Left, Screen.PrimaryScreen.Bounds.Top - this.Height ); this.PositionEnd = new Point( Screen.PrimaryScreen.Bounds.Left + EdgeSpacing.Left, Screen.PrimaryScreen.Bounds.Top - this.Height + EdgeSpacing.Top ); break; // Top Right case NotificationScreenPosition.TopRight: TaskBar = false; this.PositionStart = new Point( Screen.PrimaryScreen.Bounds.Right - this.Width - EdgeSpacing.Right, Screen.PrimaryScreen.Bounds.Top - this.Height ); this.PositionEnd = new Point( Screen.PrimaryScreen.Bounds.Right - this.Width - EdgeSpacing.Right, Screen.PrimaryScreen.Bounds.Top - this.Height + EdgeSpacing.Top ); break; // Bottom Left case NotificationScreenPosition.BottomLeft: TaskBar = true; this.PositionStart = new Point( Screen.PrimaryScreen.Bounds.Left + EdgeSpacing.Left, Screen.PrimaryScreen.Bounds.Bottom ); this.PositionEnd = new Point( Screen.PrimaryScreen.Bounds.Left + EdgeSpacing.Left, Screen.PrimaryScreen.Bounds.Bottom - EdgeSpacing.Bottom ); break; // Bottom Right case NotificationScreenPosition.BottomRight: TaskBar = true; this.PositionStart = new Point( Screen.PrimaryScreen.Bounds.Right - this.Width - EdgeSpacing.Right, Screen.PrimaryScreen.Bounds.Bottom ); this.PositionEnd = new Point( Screen.PrimaryScreen.Bounds.Right - this.Width - EdgeSpacing.Right, Screen.PrimaryScreen.Bounds.Bottom - EdgeSpacing.Bottom ); break; } if (!TaskBar) { TaskBarHeight = 0; }; }