Exemple #1
0
        public void FillContacts(AccountDTO account)
        {
            List <AccountDTO> contacts = null;
            MemoryStream      memory   = new MemoryStream();

            Dispatcher.Invoke(() =>
            {
                panelContacts.Children.Clear();
                contacts = messengerClient.GetContacts(account).ToList();
            });
            foreach (var item in contacts)
            {
                Chip chip = null;
                Dispatcher.Invoke(() =>
                {
                    chip = new Chip
                    {
                        Background = Brushes.Gray,
                        Foreground = Brushes.White,
                        Content    = item.Name,
                        Width      = Double.NaN,
                        Height     = Double.NaN,
                        Margin     = new Thickness(0, 15, 0, 0),
                        Tag        = item
                    };
                });
                memory = new MemoryStream(item.Image);
                Dispatcher.Invoke(() =>
                {
                    chip.Icon = new Ellipse
                    {
                        Width  = 32,
                        Height = 32,
                        Fill   = new ImageBrush
                        {
                            Stretch     = Stretch.UniformToFill,
                            ImageSource = BitmapFrame.Create(memory)
                        }
                    };
                    chip.IsDeletable  = true;
                    chip.Click       += Chip_Click;
                    chip.DeleteClick += Contact_DeleteClick;
                    panelContacts.Children.Add(chip);
                });
            }
        }