| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- using ivf_tl_Entity.Entity.DownLoad;
- using ivf_tl_Entity.Enums;
- using ivf_tl_Entity.Response;
- using ivf_tl_Manage.ViewModels;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.IO;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- namespace ivf_tl_Manage.Win
- {
- /// <summary>
- /// DownLoadDetailWindow.xaml 的交互逻辑
- /// </summary>
- public partial class DownLoadDetailWindow : Window
- {
- MainWindowViewModel vm;
- public DownLoadDetailWindow(MainWindowViewModel mainWindowViewModel)
- {
- InitializeComponent();
- vm = mainWindowViewModel;
- DataCount = vm.DownLoadFileList.Count;
- var aa = vm.DownLoadFileList.Take(pagesize);
- ShowDownLoadList.Clear();
- foreach (var item in aa)
- {
- ShowDownLoadList.Add(item);
- }
- this.Owner = AppData.Instance.MainWindow;
-
- Unloaded += (s, e) =>
- {
- this.Canvas_BigRoot.Children.Clear();
- AppData.Instance.MainWindow.Activate();
- };
- }
- private void Cancel_Click(object sender, RoutedEventArgs e)
- {
- this.DialogResult = true;
- return;
- }
- private void ScrollViewer_ManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
- {
- e.Handled = true;
- }
- private void ListBox_ManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
- {
- e.Handled = true;
- }
- private void Button_ClickEd(object sender, RoutedEventArgs e)
- {
- //if (vm.NewdownLoadFileList.TryDequeue(out DownLoadEntity result))
- //{
- // result.state = 4;
- //}
- //vm.ListdownLoadFileList.First().state = 4;
- //if (vm.NewdownLoadFileList.TryDequeue(out DownLoadEntity result))
- //{
- // result.state = 2;
- //}
- Task.Run(() =>
- {
- if (vm.DownLoadFileList.First().state == 2)
- {
- vm.DownLoadFileList.First().state = 3;
- }
- else
- {
- vm.DownLoadFileList.First().state = 2;
- }
- });
- }
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- //vm.NewdownLoadFileList.Enqueue(new DownLoadEntity
- //{
- // DownLoadUrl = "123",
- // FileName = "filename",
- // NewFileFullName = "newfileName"
- //});
- //vm.ListdownLoadFileList.Add(new DownLoadEntity
- //{
- // DownLoadUrl = "123",
- // FileName = "filename",
- // NewFileFullName = "newfileName"
- //});
- vm.DownLoadFileList.First().state = 2;
- return;
- for (int i = 0; i < 100; i++)
- {
- vm.DownLoadFileList.Add(new DownLoadEntity
- {
- DownLoadUrl = "123",
- FileName = i.ToString(),
- NewFileFullName = "newfileName"
- });
- }
- return;
- Task.Run(() =>
- {
- vm.NewdownLoadFileList.Enqueue(new DownLoadEntity
- {
- DownLoadUrl = "123",
- FileName = "filename",
- NewFileFullName = "newfileName"
- });
- });
- //Task.Run(async () =>
- //{
- // while (true)
- // {
- // var a = vm.DownLoadQueue.Dequeue();
- // if (a != null)
- // {
- // a.state = (int)DownLoadEnum.DownLoad;
- // await Task.Delay(1000);
- // continue;
- // }
- // return;
- // }
- //});
- }
- private void Button_Click_1(object sender, RoutedEventArgs e)
- {
- if (!(sender is Button button)) return;
- if (!(button.Tag is DownLoadEntity downLoadEntity)) return;
- //string fileName = "C:\\PersonalSpace\\work\\1 VisualWorkSpace\\Personal\\Git\\ivf_tl_Manage_2.0\\ivf_tl_Manage\\Resources\\1.ico";
- string fileName = downLoadEntity.NewFileFullName;
- if (string.IsNullOrEmpty(fileName))
- {
- return;
- }
- if (File.Exists(fileName))
- {
- OpenFolderAndSelectFile(fileName);
- }
- else
- {
- System.Diagnostics.Process.Start("explorer.exe", Path.GetDirectoryName(fileName));
- }
- }
- private void ReDown_Click_1(object sender, RoutedEventArgs e)
- {
- if (!(sender is Button button)) return;
- if (!(button.Tag is DownLoadEntity downLoadEntity)) return;
- AppData.Instance.MainWindowViewModel.DownLoadStart(downLoadEntity);
- //AppData.Instance.MainWindowViewModel.DownLoadStart(new ivf_tl_Entity.Entity.DownLoad.DownLoadEntity
- //{
- // DownLoadUrl = downLoadEntity.DownLoadUrl,
- // NewFileFullName = downLoadEntity.NewFileFullName,
- // FileName = downLoadEntity.FileName,
- // Body = downLoadEntity.Body,
- //});
- }
- [DllImport("shell32.dll", ExactSpelling = true)]
- private static extern void ILFree(IntPtr pidlList);
- [DllImport("shell32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
- private static extern IntPtr ILCreateFromPathW(string pszPath);
- [DllImport("shell32.dll", ExactSpelling = true)]
- private static extern int SHOpenFolderAndSelectItems(IntPtr pidlList, uint cild, IntPtr children, uint dwFlags);
- public void OpenFolderAndSelectFile(string filePath)
- {
- IntPtr pidl = ILCreateFromPathW(filePath);
- SHOpenFolderAndSelectItems(pidl, 0, IntPtr.Zero, 0);
- ILFree(pidl);
- }
- private void PaginationUserControl_PageChangedEvent(UserControls.PaginationUserControl arg1, int arg2)
- {
- if (!this.IsLoaded || !arg1.IsLoaded) return;
- PageCurrent = arg2;
- var aa = vm.DownLoadFileList.Skip((PageCurrent - 1) * pagesize).Take(pagesize);
- ShowDownLoadList.Clear();
- foreach (var item in aa)
- {
- ShowDownLoadList.Add(item);
- }
- }
- public int pagesize = 10;
- public int PageCurrent
- {
- get { return (int)GetValue(PageCurrentProperty); }
- set { SetValue(PageCurrentProperty, value); }
- }
- // Using a DependencyProperty as the backing store for PageCurrent. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty PageCurrentProperty =
- DependencyProperty.Register("PageCurrent", typeof(int), typeof(DownLoadDetailWindow), new PropertyMetadata(1));
- public int DataCount
- {
- get { return (int)GetValue(DataCountProperty); }
- set { SetValue(DataCountProperty, value); }
- }
- // Using a DependencyProperty as the backing store for DataCount. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty DataCountProperty =
- DependencyProperty.Register("DataCount", typeof(int), typeof(DownLoadDetailWindow), new PropertyMetadata(-1));
- public ObservableCollection<DownLoadEntity> ShowDownLoadList
- {
- get { return (ObservableCollection<DownLoadEntity>)GetValue(ShowDownLoadListProperty); }
- set { SetValue(ShowDownLoadListProperty, value); }
- }
- // Using a DependencyProperty as the backing store for ShowDownLoadList. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty ShowDownLoadListProperty =
- DependencyProperty.Register("ShowDownLoadList", typeof(ObservableCollection<DownLoadEntity>), typeof(DownLoadDetailWindow), new PropertyMetadata(new ObservableCollection<DownLoadEntity>()));
- }
- }
|