public DDNotifyIcon(IFop2Client client) { _notifyicon = new NotifyIcon(); _notifyicon.BalloonTipClosed += (s, e) => { _currentballoon = null; }; _notifyicon.BalloonTipClicked += (s, e) => { if ((_currentballoon != null) && (BalloonClicked != null)) { BalloonClicked(this, new DDBalloonClickedEventArgs(_currentballoon)); } }; _client = client; _client.MessageReceived += MessageReceived; _client.MessageSent += MessageSent; }
public void MessageReceived(object sender, MessageReceivedEventArgs e) { logger.LogDebug("Message received:\n\tButton\t: {0}\n\tCommand\t: {1}\n\tData\t: {2}\n\tSlot\t: {3}", e.Message.Button, e.Message.Command, e.Message.Data, e.Message.Slot); //TODO: {0}@{1} (or id@context) should probably be some property/method on Fop2Client for easy usage if (e.Message.Button.Equals(string.Format("{0}@{1}", _client.Id, _client.Context), StringComparison.OrdinalIgnoreCase)) { switch (e.Message.Command.ToLowerInvariant()) { case "clidname": _lastclidname = e.Message.Data; break; case "clidnum": _lastclidnum = e.Message.Data; break; case "notifyringing": if ((!string.IsNullOrEmpty(_lastclidnum)) && (_lastclidname != null)) { if (_lastclidnum.Length >= Properties.Settings.Default.DialCmd_MinLength) { _notifyicon.ShowBalloonTip( (int)TimeSpan.FromSeconds(30).TotalMilliseconds, string.Format(Properties.Resources.balloon_title), string.Format(string.Format(Properties.Resources.balloon_text, _lastclidname, _lastclidnum)), ToolTipIcon.Info ); _currentballoon = new DDBalloonInfo(_lastclidname, _lastclidnum); _lastclidname = null; _lastclidnum = null; } } break; } } }
public DDBalloonClickedEventArgs(DDBalloonInfo ballooninfo) { this.BalloonInfo = ballooninfo; }