UWUVCI-AIO-WPF/UWUVCI AIO WPF/UI/Windows/DownloadWait.xaml.cs

112 lines
3.1 KiB
C#
Raw Normal View History

using System;
using System.Windows;
using System.Windows.Threading;
namespace UWUVCI_AIO_WPF.UI.Windows
{
/// <summary>
/// Interaktionslogik für DownloadWait.xaml
/// </summary>
partial class DownloadWait : Window
{
MainViewModel mvm;
2020-04-20 00:35:31 +00:00
DispatcherTimer timer = new DispatcherTimer();
public DownloadWait(string doing, string msg, MainViewModel mvm)
{
2020-04-30 15:01:41 +00:00
try
{
if (Owner?.GetType() == typeof(MainWindow))
2020-04-30 15:01:41 +00:00
{
WindowStartupLocation = WindowStartupLocation.CenterOwner;
2020-04-30 15:01:41 +00:00
}
}
catch (Exception)
{
WindowStartupLocation = WindowStartupLocation.CenterScreen;
2020-04-30 15:01:41 +00:00
}
this.mvm = mvm;
InitializeComponent();
Key.Text = doing;
2020-04-30 15:01:41 +00:00
timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += timer_Tick;
timer.Start();
}
public DownloadWait(string doing, string msg, MainViewModel mvm, bool t)
{
2020-04-30 15:01:41 +00:00
try
{
if (Owner?.GetType() != typeof(MainWindow))
2020-04-30 15:01:41 +00:00
{
WindowStartupLocation = WindowStartupLocation.CenterScreen;
2020-04-30 15:01:41 +00:00
}
}
catch (Exception)
{
WindowStartupLocation = WindowStartupLocation.CenterScreen;
2020-04-30 15:01:41 +00:00
}
this.mvm = mvm;
InitializeComponent();
Key.Text = doing;
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += timer_Tick;
2020-05-04 16:20:21 +00:00
}
private void Window_Minimize(object sender, RoutedEventArgs e)
{
WindowState = WindowState.Minimized;
2020-05-04 16:20:21 +00:00
}
private void timer_Tick(object sender, EventArgs e)
{
msgT.Text = mvm.msg;
pb.Value = mvm.Progress;
if(Key.Text.Contains("Downloading Base"))
{
if(mvm.Progress < 70)
{
2020-04-19 17:36:03 +00:00
mvm.Progress += 1;
}
}
if(mvm.Progress == 100)
{
2020-04-20 00:35:31 +00:00
timer.Stop();
Close();
2020-04-19 17:36:03 +00:00
}
}
2020-04-30 15:01:41 +00:00
public void changeOwner(MainWindow ow)
{
Owner = ow;
2020-04-30 15:01:41 +00:00
try
{
if (Owner?.GetType() == typeof(MainWindow))
2020-04-30 15:01:41 +00:00
{
WindowStartupLocation = WindowStartupLocation.CenterOwner;
ShowInTaskbar = false;
2020-04-30 15:01:41 +00:00
}
}
catch (Exception)
{
WindowStartupLocation = WindowStartupLocation.CenterScreen;
2020-04-30 15:01:41 +00:00
}
2020-05-06 21:53:52 +00:00
}
private void wind_Closed(object sender, EventArgs e)
{
2020-05-07 20:00:24 +00:00
try
{
if ((FindResource("mvm") as MainViewModel).mw != null)
{
(FindResource("mvm") as MainViewModel).mw.Topmost = false;
}
}
catch (Exception )
2020-05-07 20:00:24 +00:00
{
}
2020-05-06 21:53:52 +00:00
}
}
}