/// <summary> /// Event handler for the SomeEvent event. /// </summary> void OnEventReceived(object sender, EventSystemArgs e) { DeliverEvent(sender, e); }
public void OnEventReceived(EventSystemArgs args) { NotifyIcon.Text = Core.Properties.Resources.DefaultNotificationToolTip; var msg = args.Message; switch (args.MessageType) { case MessageType.FileChangedAlert: NotifyIcon.BalloonTipText = msg.Replace("<NoBallon>", ""); NotifyIcon.BalloonTipIcon = ToolTipIcon.Info; var fileInfoList = args.Files.Select( file => new FileInfoDataModel {ID = file.Id, FileName = Path.GetFileNameWithoutExtension(file.FilePath), FilePath = file.FilePath, Status = file.Enabled, LastUploadTime = file.UpdatedAt??DateTime.MinValue, LastUploadStatus = true}). ToList(); controller.RefreshFileList(fileInfoList); if (!string.IsNullOrWhiteSpace(msg) && !msg.StartsWith("<NoBallon>")) NotifyIcon.ShowBalloonTip(0); if (msg.StartsWith("<NoBallon>")) msg = msg.Replace("<NoBallon>", ""); break; case MessageType.ExceptionAlert: NotifyIcon.BalloonTipIcon = ToolTipIcon.Error; NotifyIcon.Text = msg; if ("No Api token exists" != NotifyIcon.BalloonTipText) { NotifyIcon.BalloonTipText = msg; NotifyIcon.ShowBalloonTip(0); controller.RefreshFileList(null); } break; case MessageType.TokenChangedAlert: NotifyIcon.BalloonTipText = msg; NotifyIcon.BalloonTipIcon = ToolTipIcon.Info; var tokenInfoList = args.Tokens.Select( token => new UiUserApiToken { ApiToken = token.ApiToken, FriendlyName = token.FriendlyName, IsDefault = token.IsDefault }). ToList(); controller.RefreshTokenList(tokenInfoList); if (!string.IsNullOrWhiteSpace(msg)) NotifyIcon.ShowBalloonTip(1000); break; case MessageType.IsAliveAlert: NotifyIcon.BalloonTipText = msg; NotifyIcon.BalloonTipIcon = ToolTipIcon.Info; Task.Factory.StartNew(()=> { Thread.Sleep(60 * 1000); serviceStatusManager.GetFiles(); }); break; //default: // //NotifyIcon.BalloonTipText = msg; // //NotifyIcon.BalloonTipIcon = ToolTipIcon.Info; // break; } if (args.MessageType != MessageType.ExceptionAlert) controller.AddMessage(msg); }