private void Form1_Resize_1(object sender, EventArgs e) { if (WindowState == FormWindowState.Minimized) { if (NotifCB.Checked == true) { if (StatusLabelCurrent.Text == "Stopped") { NotifIcon.Visible = true; NotifIcon.BalloonTipText = "App is stopped!"; NotifIcon.BalloonTipTitle = "Good News Bot UI"; NotifIcon.ShowBalloonTip(500); this.Hide(); } else if (StatusLabelCurrent.Text == "Running...") { NotifIcon.Visible = true; NotifIcon.BalloonTipText = "App still running."; NotifIcon.BalloonTipTitle = "Good News Bot UI"; NotifIcon.ShowBalloonTip(500); this.Hide(); } } else { NotifIcon.Visible = true; this.Hide(); } } else if (WindowState == FormWindowState.Normal) { NotifIcon.Visible = false; } }
public static Image ScaleImage(NotifIcon icon, int width, int height) { var adjustX = (double)width / icon.Image.Width; var adjustY = (double)height / icon.Image.Height; var ratio = Math.Min(adjustX, adjustY); var newWidth = (int)(icon.Image.Width * ratio) - icon.Padding; var newHeight = (int)(icon.Image.Height * ratio) - icon.Padding; var newImage = new Bitmap(newWidth, newHeight); using (var graphics = Graphics.FromImage(newImage)) graphics.DrawImage(icon.Image, 0, 0, newWidth, newHeight); return(newImage); }
private void btnShow_Click(object sender, EventArgs e) { var coloring = new Coloring() { BackColor = Color.FromName(cbBackColor.SelectedItem.ToString()), Tile = Color.FromName(cbTile.SelectedItem.ToString()), Body = new SolidBrush(Color.FromName(cbBody.SelectedItem.ToString())) }; var notifIcon = new NotifIcon() { Image = Image.FromFile(txtIconPath.Text), Padding = 10 }; _notification = new Notification((Style)cbFlags.SelectedItem, Direction.Up, (int)nudDuration.Value) { Title = txtTitle.Text, Body = txtBody.Text, Padding = 10, Icon = notifIcon, Color = coloring }; if (cbDelay.Checked) { _notification.Show((int)nudDelay.Value); } else { _notification.Show(); } txtBody.Focus(); }