/// <summary> /// /// </summary> /// <param name="title"></param> /// <param name="body"></param> /// <param name="duration"></param> /// <param name="animation"></param> /// <param name="direction"></param> public Notification(string title, string body, int duration, FormAnimator.AnimationMethod animation, FormAnimator.AnimationDirection direction, int type) { InitializeComponent(); if (type == 1) { icon_stock.Visible = true; icon_expired.Visible = false; } else { icon_stock.Visible = false; icon_expired.Visible = true; } if (duration < 0) { duration = int.MaxValue; } else { duration = duration * 1000; } lifeTimer.Interval = duration; labelTitle.Text = title; labelBody.Text = body; _animator = new FormAnimator(this, animation, direction, 500); Region = Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, Width - 5, Height - 5, 15, 15)); }
/// <summary> /// /// </summary> /// <param name="body"></param> /// <param name="duration"></param> /// <param name="animation"></param> /// <param name="direction"></param> public Notification(string body, string imageName, int duration, bool closeAllNotifEnabled, bool showHSNotifEnabled, Color bgColor, Color txtColor) { InitializeComponent(imageName, bgColor, txtColor); closeAllEnabled = closeAllNotifEnabled; showHSEnabled = showHSNotifEnabled; if (duration < 1) { duration = int.MaxValue; } else { duration = duration * 1000; } lifeTimer.Interval = duration; labelTitle.Text = body; _animator = new FormAnimator(this, FormAnimator.AnimationMethod.Fade, FormAnimator.AnimationDirection.Left, 300); //System.Drawing.Drawing2D.GraphicsPath buttonPath = new System.Drawing.Drawing2D.GraphicsPath(); //Region = Region. //Region = Region.FromHrgn(new IntPtr()) //Region = Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, Width, Height, 0, 0)); }
/// <summary> /// /// </summary> /// <param name="title"></param> /// <param name="body"></param> /// <param name="duration"></param> /// <param name="animation"></param> /// <param name="direction"></param> public Notification(string title, string body, int duration, FormAnimator.AnimationMethod animation, FormAnimator.AnimationDirection direction, PictureBox avatar = null) { InitializeComponent(); if (duration < 0) { duration = int.MaxValue; } else { duration = duration * 1000; } this.lifeTimer.Interval = duration; this.labelTitle.Text = title; this.labelBody.Text = body; if (avatar != null) { avatarBox.Image = avatar.Image; } else { avatarBox.Image = avatarBox.InitialImage; } this.animator = new FormAnimator(this, animation, direction, 500); Region = Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, Width - 5, Height - 5, 20, 20)); }
/// <summary> /// /// </summary> /// <param name="channelId"></param> /// <param name="body"></param> /// <param name="durationSeconds"></param> /// <param name="animation"></param> /// <param name="direction"></param> public Notification(string channelId, string channelName, int durationSeconds, FormAnimator.AnimationMethod animation, FormAnimator.AnimationDirection direction) { InitializeComponent(); ChannelId = channelId; ChannelName = channelName; if (durationSeconds < 0) durationSeconds = int.MaxValue; else durationSeconds = durationSeconds * 1000; lifeTimer.Interval = durationSeconds; labelTitle.Text = channelName; _animator = new FormAnimator(this, animation, direction, 500); Region = Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, Width - 5, Height - 5, 20, 20)); htmlBody.Text = "<head>" + "<style>" + " p {margin: 0}" + " .username {font-weight: bold; }" + " .incoming {color: yellow; }" + " .outgoing {color: white; }" + "</style>" + "</head>"; MouseMove += AllControls_MouseMove; foreach (Control control in this.Controls) { control.MouseMove += AllControls_MouseMove; } }
/// <summary> /// /// </summary> /// <param name="title"></param> /// <param name="body"></param> /// <param name="duration"></param> /// <param name="animation"></param> /// <param name="direction"></param> public Notification(WordsNotifier.Form1 form, int duration, FormAnimator.AnimationMethod animation, FormAnimator.AnimationDirection direction, Position position) { InitializeComponent(); _mainForm = form; if (duration < 0) { duration = int.MaxValue; } else { duration = duration * 1000; } WordsNotifier.Word w = _mainForm.GetWord(true); switch (_mainForm.GetMode()) { case WordsNotifier.Mode.Default: { _showFullWords = true; labelTitle.Text = w.word + "[" + w.part + "]"; labelBody.Text = w.translation; break; } case WordsNotifier.Mode.HideTranslation: { _showFullWords = false; labelTitle.Text = w.word + "[" + w.part + "]"; labelBody.Text = "[click to show translation]"; break; } case WordsNotifier.Mode.Inverse: { _showFullWords = false; labelTitle.Text = w.translation + "[" + w.part + "]"; labelBody.Text = "[click to show the word]"; break; } } lifeTimer.Interval = duration; _position = position; _animator = new FormAnimator(this, animation, direction, 500); _hrgn = NativeMethods.CreateRoundRectRgn(0, 0, Width - 5, Height - 5, 20, 20); Region = Region.FromHrgn(_hrgn); }
/// <summary> /// /// </summary> /// <param name="title"></param> /// <param name="body"></param> /// <param name="duration"></param> /// <param name="animation"></param> /// <param name="direction"></param> public Notification(string title, string body, int duration, FormAnimator.AnimationMethod animation, FormAnimator.AnimationDirection direction) { InitializeComponent(); if (duration < 0) duration = int.MaxValue; else duration = duration * 1000; lifeTimer.Interval = duration; labelTitle.Text = title; labelBody.Text = body; _animator = new FormAnimator(this, animation, direction, 500); Region = Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, Width - 5, Height - 5, 20, 20)); }
/// <summary> /// /// </summary> /// <param name="title"></param> /// <param name="body"></param> /// <param name="duration"></param> /// <param name="animation"></param> /// <param name="direction"></param> public Notification(string title, string body, int duration, Color color, FormAnimator.AnimationMethod animation, FormAnimator.AnimationDirection direction) { InitializeComponent(); if (duration < 0) { duration = int.MaxValue; } else { duration = duration * 1000; } lifeTimer.Interval = duration; labelTitle.Text = title; labelBody.Text = body; BackColor = color; _animator = new FormAnimator(this, animation, direction, 500); Region = Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, Width - 5, Height - 5, 0, 0)); }
/// <summary> /// /// </summary> /// <param name="title"></param> /// <param name="body"></param> /// <param name="duration"></param> /// <param name="animation"></param> /// <param name="direction"></param> public Notification(string title, string body, int duration, FormAnimator.AnimationMethod animation, FormAnimator.AnimationDirection direction) { InitializeComponent(); if (duration < 0) { duration = int.MaxValue; } else { duration = duration * 1000; } lifeTimer.Interval = duration; labelTitle.Text = title; labelBody.Text = body; if (title == null || title.Length == 0) { labelBody.Location = labelTitle.Location; labelBody.Top += 5; Height = Height - labelTitle.Height; labelTitle.Visible = false; } Graphics g = labelBody.CreateGraphics(); SizeF size = g.MeasureString(body, labelBody.Font); if (Width < size.Width) { Width = (int)size.Width + 20; } if (Height < size.Height) { Height = (int)size.Height + 20; } _animator = new FormAnimator(this, animation, direction, 500); Region = Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, Width - 5, Height - 5, 20, 20)); }
/// <summary> /// /// </summary> /// <param name="channelId"></param> /// <param name="body"></param> /// <param name="durationSeconds"></param> /// <param name="animation"></param> /// <param name="direction"></param> public Notification(string channelId, string channelName, int durationSeconds, FormAnimator.AnimationMethod animation, FormAnimator.AnimationDirection direction) { InitializeComponent(); ChannelId = channelId; ChannelName = channelName; if (durationSeconds < 0) { durationSeconds = int.MaxValue; } else { durationSeconds = durationSeconds * 1000; } lifeTimer.Interval = durationSeconds; labelTitle.Text = channelName; _animator = new FormAnimator(this, animation, direction, 500); Region = Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, Width - 5, Height - 5, 20, 20)); htmlBody.Text = "<head>" + "<style>" + " p {margin: 0}" + " .username {font-weight: bold; }" + " .incoming {color: yellow; }" + " .outgoing {color: white; }" + "</style>" + "</head>"; MouseMove += AllControls_MouseMove; foreach (Control control in this.Controls) { control.MouseMove += AllControls_MouseMove; } }
/// <summary> /// /// </summary> /// <param name="title"></param> /// <param name="body"></param> /// <param name="duration"></param> /// <param name="animation"></param> /// <param name="direction"></param> public Notification(string title, string body, int duration, FormAnimator.AnimationMethod animation, FormAnimator.AnimationDirection direction, NotificationType notificationType) { InitializeComponent(); if (duration < 0) { duration = int.MaxValue; } else { duration = duration * 1000; } lifeTimer.Interval = duration; labelTitle.Text = title; labelBody.Text = body; labelTitle.BackColor = (notificationType == NotificationType.Success) ? Color.FromArgb(0, 0, 192) : Color.Red; this.BackColor = (notificationType == NotificationType.Error) ? Color.FromArgb(255, 128, 128) : Color.FromArgb(128, 128, 255); _animator = new FormAnimator(this, animation, direction, 500); Region = Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, Width - 5, Height - 5, 20, 20)); }
/// <summary> /// /// </summary> /// <param name="title"></param> /// <param name="body"></param> /// <param name="duration"></param> /// <param name="animation"></param> /// <param name="direction"></param> public Notification(string title, Color titleColor, string body, int duration, FormAnimator.AnimationMethod animation, FormAnimator.AnimationDirection direction, PictureBox avatar = null, Action actionToComplete = null) { InitializeComponent(); if (duration < 0) duration = int.MaxValue; else duration = duration * 1000; this.lifeTimer.Interval = duration; this.labelTitle.ForeColor = titleColor; this.labelTitle.Text = title; this.labelBody.Text = body; this.actionToComplete = actionToComplete; if (avatar != null) avatarBox.Image = avatar.Image; else avatarBox.Image = avatarBox.InitialImage; this.animator = new FormAnimator(this, animation, direction, 250); Region = Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, Width + 1, Height + 1, 0, 0)); }