public void SendMessage(string Text, Player Speaker = null, bool Host = false) { if (CurrentRoom.IsHost(App.CurrentUser)) { foreach (var Client in App.Server) { Client.SendAsync(Encoding.UTF8.GetBytes("ChatMessage|*|" + (Speaker?.Id.ToString() ?? "System") + "|*|" + Text)); } } else { App.Client.SendAsync(Encoding.UTF8.GetBytes("ChatMessage|*|" + (Speaker?.Id.ToString() ?? "System") + "|*|" + Text)); } bool ScrollToBottom = ChatScrollViewer.HorizontalOffset >= ChatStack.ActualHeight - ChatScrollViewer.ActualHeight; ChatterItem Item = new ChatterItem(); Item.Init(Text, Speaker, Host); Item.Opacity = 0; ChatStack.Children.Add(Item); var HeightAnimation = new DoubleAnimation() { From = ChatStack.ActualHeight, To = ChatStack.Children.OfType <FrameworkElement>().Sum(O => O.Height), Duration = TimeSpan.FromSeconds(0.3), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut } }; HeightAnimation.Completed += delegate { Item.BeginAnimation(OpacityProperty, new DoubleAnimation() { From = 0, To = 1, Duration = TimeSpan.FromSeconds(0.2), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut } }); if (ScrollToBottom) { ChatScrollViewer.ScrollToBottom(); } }; ChatStack.BeginAnimation(HeightProperty, HeightAnimation); }
public ProgressItem BeginProgress(string Description, double Length) { bool ScrollToBottom = ChatScrollViewer.HorizontalOffset >= ChatStack.ActualHeight - ChatScrollViewer.ActualHeight; ChatterItem Item = new ChatterItem(); var ProgressItem = Item.SystemProgressInit(Description, Length); Item.Opacity = 0; ChatStack.Children.Add(Item); var HeightAnimation = new DoubleAnimation() { From = ChatStack.ActualHeight, To = ChatStack.Children.OfType <FrameworkElement>().Sum(O => O.Height), Duration = TimeSpan.FromSeconds(0.3), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut } }; HeightAnimation.Completed += delegate { Item.BeginAnimation(OpacityProperty, new DoubleAnimation() { From = 0, To = 1, Duration = TimeSpan.FromSeconds(0.2), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut } }); if (ScrollToBottom) { ChatScrollViewer.ScrollToBottom(); } }; ChatStack.BeginAnimation(HeightProperty, HeightAnimation); return(ProgressItem); }
public void SendMessageAlone(string Text, Player Speaker = null, bool Host = false) { bool ScrollToBottom = ChatScrollViewer.HorizontalOffset >= ChatStack.ActualHeight - ChatScrollViewer.ActualHeight; ChatterItem Item = new ChatterItem(); Item.Init(Text, Speaker, Host); Item.Opacity = 0; ChatStack.Children.Add(Item); var HeightAnimation = new DoubleAnimation() { From = ChatStack.ActualHeight, To = ChatStack.Children.OfType <FrameworkElement>().Sum(O => O.Height), Duration = TimeSpan.FromSeconds(0.3), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut } }; HeightAnimation.Completed += delegate { Item.BeginAnimation(OpacityProperty, new DoubleAnimation() { From = 0, To = 1, Duration = TimeSpan.FromSeconds(0.2), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut } }); if (ScrollToBottom) { ChatScrollViewer.ScrollToBottom(); } }; ChatStack.BeginAnimation(HeightProperty, HeightAnimation); }
private void Start() { instance = this; }
public ChatHistoryService(IOptions <RedisSettings> redisSettings) { chatStack = new ChatStack(redisSettings); }