public MediaFileTransfer(string source, string destination, SortQueue _callingWindow, bool needTransferConfirmation = true) { InitializeComponent(); client = new WebClient(); client.DownloadProgressChanged += Client_DownloadProgressChanged; client.DownloadFileCompleted += Client_DownloadFileCompleted; Source = source; Destination = destination; CallingWindow = _callingWindow; SourceFile.Text = Source; DestinationFile.Text = Destination; if (!needTransferConfirmation) { Thread thread = new Thread(() => { client = new WebClient(); Uri uri = new Uri(Source); Source = Path.GetFileName(uri.AbsolutePath).ToString(); client.DownloadFileAsync(uri, Destination); }); thread.Start(); } else { BeginTransferManuallyBtn.Visibility = Visibility.Visible; } }
private void MoveSortToLibraryBtn_Click(object sender, RoutedEventArgs e) { Button clicked = sender as Button; StackPanel ParentPanel = clicked.Parent as StackPanel; string source; string finalDestination = (ParentPanel.Children[2] as TextBlock).Text; var ParentWindow = ParentPanel.Parent as StackPanel; var ParentWindow2 = ParentWindow.Parent as StackPanel; Border border = ParentWindow2.Parent as Border; var ParentWindow3 = border.Parent as StackPanel; var ParentWindow4 = ParentWindow3.Parent as StackPanel; Grid grid = ParentWindow4.Parent as Grid; ListBox SortQueueList = ParentWindow4.Children[2] as ListBox; source = (SortQueueList.SelectedItem as IMediaFile).FilePath; SortQueue thisWindow = this; MediaFileTransfer _transferWindow = new MediaFileTransfer(source, finalDestination, thisWindow); _transferWindow.Activate(); _transferWindow.Visibility = Visibility.Visible; _transferWindow.Topmost = true; }