Inheritance: System.Windows.Controls.UserControl
Exemplo n.º 1
0
        public void AddDownload(string url, string filepath, string filename)
        {
            Dispatcher.BeginInvoke((Action) (() =>
            {
                Item = new DownloadItem(filepath, url, filename);
                Item.Width = content.ActualWidth;
                Item.VerticalAlignment = VerticalAlignment.Top;
                Item.HorizontalAlignment = HorizontalAlignment.Stretch;
                Item.Height = ItemHeight;
                content.Children.Add(Item);
                Item.Margin = new Thickness(0, MarginTop + Item.Height*ItemsCount, 0, 0);
                Items.Add(Item);
                var fade = new DoubleAnimation
                {
                    From = ActualHeight,
                    To = 103 + Items.Count*ItemHeight,
                    Duration = TimeSpan.FromSeconds(0.1)
                };
                Storyboard.SetTarget(fade, this);
                Storyboard.SetTargetProperty(fade, new PropertyPath(HeightProperty));

                var sb = new Storyboard();
                sb.Children.Add(fade);
                sb.Begin();
                ItemsCount += 1;
            }));
        }
Exemplo n.º 2
0
        public void RemoveDownload(DownloadItem di)
        {
            Items.Remove(di);
            content.Children.Remove(di);
            ItemsCount = 0;

            Dispatcher.BeginInvoke((Action) (() =>
            {
                foreach (var Item in Items)
                {
                    Item.Width = content.ActualWidth;
                    Item.Height = ItemHeight;
                    Item.Margin = new Thickness(0, MarginTop + Item.Height*ItemsCount, 0, 0);
                    ItemsCount += 1;
                    var fade = new DoubleAnimation
                    {
                        From = ActualHeight,
                        To = 103 + Items.Count*ItemHeight,
                        Duration = TimeSpan.FromSeconds(0.1)
                    };
                    Storyboard.SetTarget(fade, this);
                    Storyboard.SetTargetProperty(fade, new PropertyPath(HeightProperty));

                    var sb = new Storyboard();
                    sb.Children.Add(fade);
                    sb.Begin();
                }
            }));
        }