Example #1
0
        private async void messageReceived(Skype4Sharp.ChatMessage pMessage)
        {
            if ((chat != null && pMessage.Chat.ID == chat.ID) ||
                (user != null && pMessage.Sender.Username == user.Username))
            {
                int charID = await CharacterUtil.CharacterManager.GetCharIDForUser(pMessage.Sender);

                string animName = CharacterUtil.Words2Anim.convertToAnim(pMessage.Body);
                await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    receivedMessageBlock.Text = pMessage.Body;
                    receiverBubblePop.Begin();
                    if (chat != null && chat.Type == Skype4Sharp.Enums.ChatType.Group)
                    {
                        int ind               = Array.IndexOf(othersCharIds, charID);
                        double leftMargin     = (ActualWidth / othersCharIds.Length) * (othersCharIds.Length - ind - 1);
                        receiverBubble.Margin = new Thickness(leftMargin, 100, 0, 0);
                        Interoperation.idleAllAnimation();
                        Interoperation.setAnimationNames(ind, animName);
                    }
                    else
                    {
                        receiverBubble.Margin = new Thickness(20, 100, 0, 0);
                        Interoperation.setAnimationName(animName);
                    }
                });
            }
            else
            {
                await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    unreadMark.Visibility = Visibility.Visible;
                });
            }
        }
Example #2
0
        private async void messageReceived(Skype4Sharp.ChatMessage pMessage)
        {
            recent = await App.mainSkype.GetRecent();

            await CharacterUtil.CharacterManager.GetCharAvatarUrlsForChats(recent);

            if (App.unreadRecord.ContainsKey(pMessage.Chat.ID))
            {
                App.unreadRecord[pMessage.Chat.ID]++;
            }
            else
            {
                App.unreadRecord[pMessage.Chat.ID] = 1;
            }

            foreach (Skype4Sharp.Chat chat in recent)
            {
                if (App.unreadRecord.ContainsKey(chat.ID))
                {
                    chat.Unread = true;
                }
            }
            await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => {
                recentListView.ItemsSource = recent;
                App.recentNeedUpdate       = false;
                refreshUnreadCount();
            });
        }
Example #3
0
        public async static Task fillGridWithMessage(Grid grid, Skype4Sharp.ChatMessage message)
        {
            int charID = await CharacterUtil.CharacterManager.GetCharIDForUser(message.Sender);

            string animName  = CharacterUtil.Words2Anim.convertToAnim(message.Body);
            string fileName  = "Assets/comics/" + charID.ToString() + "_" + animName + "_" + rnd.Next(5) + ".png";
            string fileName2 = @"Assets\comics\" + charID.ToString() + "_" + animName + "_" + rnd.Next(5) + ".png";

            if (!await fileExists(fileName2))
            {
                fileName = "Assets/comics/" + charID.ToString() + "_embar_00_" + rnd.Next(5) + ".png";
            }

            Rectangle rect = new Rectangle();

            rect.Stroke          = new SolidColorBrush(Colors.DarkGray);
            rect.StrokeThickness = 3;
            ImageBrush brush = new ImageBrush();

            brush.ImageSource = new BitmapImage(new Uri("ms-appx:///" + fileName));
            brush.Stretch     = Stretch.UniformToFill;
            rect.Fill         = brush;
            rect.Margin       = new Thickness(5);

            TextBlock content = new TextBlock();

            content.TextWrapping = TextWrapping.Wrap;
            content.FontWeight   = FontWeights.SemiBold;
            content.Text         = message.Body;
            content.Margin       = new Thickness(10);

            StackPanel panel = new StackPanel();

            panel.Background = new SolidColorBrush(Colors.Orange);
            panel.Opacity    = 0.8;
            panel.Children.Add(content);

            Polygon tri = new Polygon();

            tri.Fill                = new SolidColorBrush(Colors.Orange);
            tri.Opacity             = 0.8;
            tri.HorizontalAlignment = HorizontalAlignment.Center;

            Grid panelGrid = new Grid();

            panelGrid.MaxWidth = 200;
            panelGrid.Margin   = new Thickness(20);
            panelGrid.Children.Add(panel);
            panelGrid.Children.Add(tri);

            int pos = rnd.Next(2);

            panel.Margin          = new Thickness(0, 15, 0, 0);
            tri.VerticalAlignment = VerticalAlignment.Top;
            tri.Points.Add(new Point(-10, 15));
            tri.Points.Add(new Point(10, 15));
            switch (pos)
            {
            case 0:
                panelGrid.VerticalAlignment   = VerticalAlignment.Bottom;
                panelGrid.HorizontalAlignment = HorizontalAlignment.Left;
                tri.Points.Add(new Point(15, 0));
                break;

            case 1:
                panelGrid.VerticalAlignment   = VerticalAlignment.Bottom;
                panelGrid.HorizontalAlignment = HorizontalAlignment.Right;
                tri.Points.Add(new Point(-15, 0));
                break;
            }

            grid.Children.Add(rect);
            grid.Children.Add(panelGrid);
        }