예제 #1
0
        public void Load()
        {
            if (Model != null)
            {
                string fileExtension   = System.IO.Path.GetExtension(Model.FileName);
                string fileIconPath    = Ultilities.GetRootPath() + "\\Asset\\FileIcons\\" + fileExtension + ".png";
                string unknownIconPath = Ultilities.GetRootPath() + "\\Asset\\FileIcons\\unknown.png";

                if (System.IO.File.Exists(fileIconPath))
                {
                    FileIcon.ImageSource = new BitmapImage(new Uri(fileIconPath));
                }
                else
                {
                    FileIcon.ImageSource = new BitmapImage(new Uri(unknownIconPath));
                }

                // StorageService.DowloadFileAsync(Model);
                FileNameTextBlock.Text = Model.FileName;
            }
        }
예제 #2
0
        public void Load()
        {
            if (Model != null)
            {
                string fileExtension   = System.IO.Path.GetExtension(Model.FileName);
                string fileIconPath    = Ultilities.GetRootPath() + "\\Asset\\FileIcons\\" + fileExtension + ".png";
                string unknownIconPath = Ultilities.GetRootPath() + "\\Asset\\FileIcons\\unknown.png";

                if (System.IO.File.Exists(fileIconPath))
                {
                    FileIcon.ImageSource = new BitmapImage(new Uri(fileIconPath));
                }
                else
                {
                    FileIcon.ImageSource = new BitmapImage(new Uri(unknownIconPath));
                }

                FileName.Text = Model.FileName;

                DowloadedTime.Text = DateTime.Now.ToString();

                using (WebClient client = new WebClient())
                {
                    client.DownloadProgressChanged += new DownloadProgressChangedEventHandler((sender, e) => {
                        Dispatcher.InvokeAsync(() => {
                            MaterialDesignThemes.Wpf.ButtonProgressAssist.SetValue(Loading, e.ProgressPercentage);
                            Console.WriteLine(e.ProgressPercentage);
                            if (e.ProgressPercentage >= 100)
                            {
                                Loading.Visibility  = Visibility.Collapsed;
                                FileSize.Visibility = Visibility.Visible;
                                FileSize.Text       = (e.BytesReceived / (1024 * 1024)).ToString() + " MB";
                            }
                        }, DispatcherPriority.ApplicationIdle);
                    });

                    client.DownloadFileTaskAsync(Model.DowloadUrl, @"C:\Downloads Kchat\" + Model.FileName);
                }
            }
        }