private void Window_Loaded(object sender, RoutedEventArgs e) { NameLabel.Content = FileName; LoadingBar.Maximum = FileSize; SmallSize = SetSmallSize(FileSize); BytesLabel.Content = "0 / " + SmallSize.ToString("0.00") + PostSize; Connection.SendMessage(new MessageClass(Connection.ID, UserID, Commands.FileOK, ID)); LastTime = DateTime.Now; LastNow = 0; Task.Run(() => { Dispatcher.Invoke(() => { var opacityAnim = new DoubleAnimation(); opacityAnim.From = 0; opacityAnim.To = 1; opacityAnim.Duration = TimeSpan.FromSeconds(2); opacityAnim.RepeatBehavior = RepeatBehavior.Forever; Circle1.BeginAnimation(System.Windows.Shapes.Ellipse.OpacityProperty, opacityAnim); var circleAnim = new DoubleAnimation(); circleAnim.From = 80; circleAnim.To = 20; circleAnim.Duration = TimeSpan.FromSeconds(2); circleAnim.RepeatBehavior = RepeatBehavior.Forever; Circle1.BeginAnimation(System.Windows.Shapes.Ellipse.WidthProperty, circleAnim); Circle1.BeginAnimation(System.Windows.Shapes.Ellipse.HeightProperty, circleAnim); }); Thread.Sleep(670); Dispatcher.Invoke(() => { var opacityAnim = new DoubleAnimation(); opacityAnim.From = 0; opacityAnim.To = 1; opacityAnim.Duration = TimeSpan.FromSeconds(2); opacityAnim.RepeatBehavior = RepeatBehavior.Forever; Circle2.BeginAnimation(System.Windows.Shapes.Ellipse.OpacityProperty, opacityAnim); var circleAnim = new DoubleAnimation(); circleAnim.From = 80; circleAnim.To = 20; circleAnim.Duration = TimeSpan.FromSeconds(2); circleAnim.RepeatBehavior = RepeatBehavior.Forever; Circle2.BeginAnimation(System.Windows.Shapes.Ellipse.WidthProperty, circleAnim); Circle2.BeginAnimation(System.Windows.Shapes.Ellipse.HeightProperty, circleAnim); }); Thread.Sleep(670); Dispatcher.Invoke(() => { var opacityAnim = new DoubleAnimation(); opacityAnim.From = 0; opacityAnim.To = 1; opacityAnim.Duration = TimeSpan.FromSeconds(2); opacityAnim.RepeatBehavior = RepeatBehavior.Forever; Circle3.BeginAnimation(System.Windows.Shapes.Ellipse.OpacityProperty, opacityAnim); var circleAnim = new DoubleAnimation(); circleAnim.From = 80; circleAnim.To = 20; circleAnim.Duration = TimeSpan.FromSeconds(2); circleAnim.RepeatBehavior = RepeatBehavior.Forever; Circle3.BeginAnimation(System.Windows.Shapes.Ellipse.WidthProperty, circleAnim); Circle3.BeginAnimation(System.Windows.Shapes.Ellipse.HeightProperty, circleAnim); }); /* * while (true) * { * try * { * Dispatcher.Invoke(() => Circle1.Width -= 1); * Dispatcher.Invoke(() => Circle1.Height -= 1); * Dispatcher.Invoke(() => Circle1.Opacity += 0.017); * if (Dispatcher.Invoke(() => Circle1.Opacity >= 1)) * { * Dispatcher.Invoke(() => Circle1.Width = 79); * Dispatcher.Invoke(() => Circle1.Height = 79); * Dispatcher.Invoke(() => Circle1.Opacity = 0); * } * Dispatcher.Invoke(() => Circle2.Width -= 1); * Dispatcher.Invoke(() => Circle2.Height -= 1); * Dispatcher.Invoke(() => Circle2.Opacity += 0.017); * if (Dispatcher.Invoke(() => Circle2.Opacity >= 1)) * { * Dispatcher.Invoke(() => Circle2.Width = 79); * Dispatcher.Invoke(() => Circle2.Height = 79); * Dispatcher.Invoke(() => Circle2.Opacity = 0); * } * Dispatcher.Invoke(() => Circle3.Width -= 1); * Dispatcher.Invoke(() => Circle3.Height -= 1); * Dispatcher.Invoke(() => Circle3.Opacity += 0.017); * if (Dispatcher.Invoke(() => Circle3.Opacity >= 1)) * { * Dispatcher.Invoke(() => Circle3.Width = 79); * Dispatcher.Invoke(() => Circle3.Height = 79); * Dispatcher.Invoke(() => Circle3.Opacity = 0); * } * * Thread.Sleep(36); * } * catch * { * break; * } * }*/ }); }
private void SendButton_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { FileInfo file = null; if (File.Exists(FilePath)) { file = new FileInfo(FilePath); } if (file != null && file.Length > 0) { Task.Run(() => { Dispatcher.Invoke(() => SetupPage.IsEnabled = false); Dispatcher.Invoke(() => SenderPage.IsEnabled = true); Dispatcher.Invoke(() => CloseButton.IsEnabled = true); for (int i = 0; i < 10; i++) { Dispatcher.Invoke(() => SetupPage.Opacity -= 0.1); Dispatcher.Invoke(() => CloseButton.Opacity += 0.1); Dispatcher.Invoke(() => MainBorder.Margin = new Thickness(MainBorder.Margin.Left, MainBorder.Margin.Top, MainBorder.Margin.Right, MainBorder.Margin.Bottom + 12.5)); Dispatcher.Invoke(() => MainGrid.Margin = new Thickness(MainGrid.Margin.Left, MainGrid.Margin.Top + 12.5, MainGrid.Margin.Right, MainGrid.Margin.Bottom)); Thread.Sleep(17); } for (int i = 0; i < 10; i++) { Dispatcher.Invoke(() => SenderPage.Opacity += 0.1); Thread.Sleep(17); } Connection.SendMessage(new MessageClass(Connection.ID, UserID, Commands.RFileSend, ID, System.IO.Path.GetFileName(FilePath))); Dispatcher.Invoke(() => { var opacityAnim = new DoubleAnimation(); opacityAnim.From = 1; opacityAnim.To = 0; opacityAnim.Duration = TimeSpan.FromSeconds(2); opacityAnim.RepeatBehavior = RepeatBehavior.Forever; Circle1.BeginAnimation(Ellipse.OpacityProperty, opacityAnim); var circleAnim = new DoubleAnimation(); circleAnim.From = 20; circleAnim.To = 80; circleAnim.Duration = TimeSpan.FromSeconds(2); circleAnim.RepeatBehavior = RepeatBehavior.Forever; Circle1.BeginAnimation(Ellipse.WidthProperty, circleAnim); Circle1.BeginAnimation(Ellipse.HeightProperty, circleAnim); }); Thread.Sleep(670); Dispatcher.Invoke(() => { var opacityAnim = new DoubleAnimation(); opacityAnim.From = 1; opacityAnim.To = 0; opacityAnim.Duration = TimeSpan.FromSeconds(2); opacityAnim.RepeatBehavior = RepeatBehavior.Forever; Circle2.BeginAnimation(Ellipse.OpacityProperty, opacityAnim); var circleAnim = new DoubleAnimation(); circleAnim.From = 20; circleAnim.To = 80; circleAnim.Duration = TimeSpan.FromSeconds(2); circleAnim.RepeatBehavior = RepeatBehavior.Forever; Circle2.BeginAnimation(Ellipse.WidthProperty, circleAnim); Circle2.BeginAnimation(Ellipse.HeightProperty, circleAnim); }); Thread.Sleep(670); Dispatcher.Invoke(() => { var opacityAnim = new DoubleAnimation(); opacityAnim.From = 1; opacityAnim.To = 0; opacityAnim.Duration = TimeSpan.FromSeconds(2); opacityAnim.RepeatBehavior = RepeatBehavior.Forever; Circle3.BeginAnimation(Ellipse.OpacityProperty, opacityAnim); var circleAnim = new DoubleAnimation(); circleAnim.From = 20; circleAnim.To = 80; circleAnim.Duration = TimeSpan.FromSeconds(2); circleAnim.RepeatBehavior = RepeatBehavior.Forever; Circle3.BeginAnimation(Ellipse.WidthProperty, circleAnim); Circle3.BeginAnimation(Ellipse.HeightProperty, circleAnim); }); /* * while (true) * { * try * { * Dispatcher.Invoke(() => Circle1.Width += 1); * Dispatcher.Invoke(() => Circle1.Height += 1); * Dispatcher.Invoke(() => Circle1.Opacity -= 0.017); * if (Dispatcher.Invoke(() => Circle1.Opacity <= 0)) * { * Dispatcher.Invoke(() => Circle1.Width = 20); * Dispatcher.Invoke(() => Circle1.Height = 20); * Dispatcher.Invoke(() => Circle1.Opacity = 1); * } * Dispatcher.Invoke(() => Circle2.Width += 1); * Dispatcher.Invoke(() => Circle2.Height += 1); * Dispatcher.Invoke(() => Circle2.Opacity -= 0.017); * if (Dispatcher.Invoke(() => Circle2.Opacity <= 0)) * { * Dispatcher.Invoke(() => Circle2.Width = 20); * Dispatcher.Invoke(() => Circle2.Height = 20); * Dispatcher.Invoke(() => Circle2.Opacity = 1); * } * Dispatcher.Invoke(() => Circle3.Width += 1); * Dispatcher.Invoke(() => Circle3.Height += 1); * Dispatcher.Invoke(() => Circle3.Opacity -= 0.017); * if (Dispatcher.Invoke(() => Circle3.Opacity <= 0)) * { * Dispatcher.Invoke(() => Circle3.Width = 20); * Dispatcher.Invoke(() => Circle3.Height = 20); * Dispatcher.Invoke(() => Circle3.Opacity = 1); * } * * Thread.Sleep(36); * } * catch * { * break; * } * }*/ } ); } else { Task.Run(() => { for (int i = 0; i < 10; i++) { Dispatcher.Invoke(() => PathLabel.Opacity -= 0.1); Thread.Sleep(17); } for (int i = 0; i < 10; i++) { Dispatcher.Invoke(() => ErrorLabel.Opacity += 0.1); Thread.Sleep(17); } Thread.Sleep(500); for (int i = 0; i < 10; i++) { Dispatcher.Invoke(() => ErrorLabel.Opacity -= 0.1); Thread.Sleep(17); } for (int i = 0; i < 10; i++) { Dispatcher.Invoke(() => PathLabel.Opacity += 0.1); Thread.Sleep(17); } } ); } }