Informationen ausgelagert Kleines Spy/Test Programm erstellt Mehr Exceptions/InvalidUpdateFileRequestException.cs Launcher Host in Download Server geändert Download Server macht zusätzlich Abfrage an den Hauptserver Download geht jetzt stückweise von statten
219 lines
6.5 KiB
C#
219 lines
6.5 KiB
C#
using BeWoLauncher.Logic.Behavior;
|
|
using BeWoLauncher.Logic.Controller;
|
|
using BeWoLauncher.View;
|
|
using BeWoLauncher.View.Frames;
|
|
using BS.SharedLauncher.Enums;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Controls;
|
|
using static BeWoLauncher.Logic.Controller.ViewController;
|
|
|
|
namespace BeWoLauncher.Logic
|
|
{
|
|
public class ViewBuilder
|
|
{
|
|
public ViewBuilder()
|
|
{
|
|
|
|
}
|
|
|
|
public UserControl GetNewView(ViewType type)
|
|
{
|
|
switch (type)
|
|
{
|
|
case ViewType.LoginView:
|
|
return getLoginView();
|
|
}
|
|
|
|
throw new NotImplementedException("ViewBuilder: View nicht implementiert");
|
|
}
|
|
|
|
public FrameBase GetNewFrame(FrameType type)
|
|
{
|
|
switch (type)
|
|
{
|
|
case FrameType.GenericFail:
|
|
return getGenericFailedFrame();
|
|
case FrameType.InstallInfo:
|
|
return getInstallInfoFrame();
|
|
case FrameType.InstallProgress:
|
|
return getInstallProgressFrame();
|
|
case FrameType.InstallFailed:
|
|
return getInstallFailedFrame();
|
|
case FrameType.UpdateInfo:
|
|
return getUpdateInfoFrame();
|
|
case FrameType.UpdateProgress:
|
|
return getUpdateProgressFrame();
|
|
case FrameType.UpdateFailed:
|
|
return getUpdateFailedFrame();
|
|
case FrameType.UninstallInfo:
|
|
return getUninstallInfoFrame();
|
|
case FrameType.UninstallProgress:
|
|
return getUninstallProgressFrame();
|
|
case FrameType.UninstallFailed:
|
|
return getUninstallFailedFrame();
|
|
case FrameType.UninstallSuccessful:
|
|
return getUninstallSuccessfulFrame();
|
|
case FrameType.LoadingScreen:
|
|
return getLoadingScreenFrame();
|
|
case FrameType.NoPermissionInfo:
|
|
return getNoPermissionInfoFrame();
|
|
}
|
|
|
|
throw new NotImplementedException("ViewBuilder: Frame nicht implementiert");
|
|
}
|
|
|
|
private UserControl getLoginView()
|
|
{
|
|
var login = new LoginView();
|
|
|
|
login.Loaded += CheckForAutoLogin;
|
|
login.LoginSuccessful += ViewBehavior.LoginSuccessful;
|
|
|
|
return login;
|
|
}
|
|
|
|
private FrameBase getNoPermissionInfoFrame()
|
|
{
|
|
var noper = new InfoFrame();
|
|
|
|
noper.Title = "Keine Rechte auf Speicherort!";
|
|
noper.Text = "Es liegt eine neue Version. Sie besitzen aber nicht die benötigten Rechte, um diese anzuwenden. Bitte wenden Sie sich an Ihren System-Administrator!";
|
|
|
|
noper.Button1Click += ViewBehavior.BackToLogin;
|
|
|
|
return noper;
|
|
}
|
|
|
|
private FrameBase getLoadingScreenFrame()
|
|
{
|
|
var loading = new LoadingScreen();
|
|
|
|
loading.Loaded += (s,e)=> ViewController.LaunchBehavior.LaunchPlaner();
|
|
|
|
return loading;
|
|
}
|
|
|
|
private FrameBase getUninstallSuccessfulFrame()
|
|
{
|
|
var uninstallSuccessful = new InfoFrame();
|
|
|
|
uninstallSuccessful.Title = "Deinstallation erfolgreich!";
|
|
uninstallSuccessful.Text = "Kehre zum Login zurück...";
|
|
uninstallSuccessful.CollapseCopyButton();
|
|
|
|
uninstallSuccessful.Button1Click += ViewBehavior.BackToLogin;
|
|
|
|
return uninstallSuccessful;
|
|
}
|
|
|
|
private FrameBase getUninstallFailedFrame()
|
|
{
|
|
var uninstallFailed = new InfoFrame();
|
|
|
|
uninstallFailed.Title = "Deinstallation fehlgeschlagen!";
|
|
uninstallFailed.Text = Error.ToString();
|
|
|
|
uninstallFailed.Button1Click += ViewBehavior.BackToLogin;
|
|
|
|
return uninstallFailed;
|
|
}
|
|
|
|
private FrameBase getUninstallProgressFrame()
|
|
{
|
|
var progress = new ProgressFrame(LauncherMode.Update);
|
|
|
|
progress.Successful += ViewBehavior.UninstallSuccess;
|
|
progress.Exception += ViewBehavior.UninstallFailed;
|
|
|
|
return progress;
|
|
}
|
|
|
|
private FrameBase getUninstallInfoFrame()
|
|
{
|
|
var uninstall = new UninstallInfoFrame();
|
|
|
|
uninstall.Accept += ViewBehavior.UninstallStarting;
|
|
uninstall.Abort += ViewBehavior.BackToLogin;
|
|
|
|
return uninstall;
|
|
}
|
|
|
|
private FrameBase getUpdateFailedFrame()
|
|
{
|
|
var updateError = new InfoFrame();
|
|
|
|
updateError.Title = "Update fehlgeschlagen!";
|
|
updateError.Text = Error.ToString();
|
|
|
|
updateError.Button1Click += ViewBehavior.BackToLogin;
|
|
|
|
return updateError;
|
|
}
|
|
|
|
private FrameBase getUpdateProgressFrame()
|
|
{
|
|
var progress = new ProgressFrame(LauncherMode.Update);
|
|
|
|
progress.Successful += ViewBehavior.UpdateSuccess;
|
|
progress.Exception += ViewBehavior.UpdateFailed;
|
|
|
|
return progress;
|
|
}
|
|
|
|
private FrameBase getUpdateInfoFrame()
|
|
{
|
|
var update = new UpdateInfoFrame();
|
|
|
|
update.Accept += ViewBehavior.UpdateStarting;
|
|
update.Abort += ViewBehavior.BackToLogin;
|
|
|
|
return update;
|
|
}
|
|
|
|
private FrameBase getInstallFailedFrame()
|
|
{
|
|
var installError = new InfoFrame();
|
|
|
|
installError.Title = "Installation fehlgeschlagen!";
|
|
installError.Text = Error.ToString();
|
|
|
|
installError.Button1Click += ViewBehavior.BackToLogin;
|
|
|
|
return installError;
|
|
}
|
|
|
|
private FrameBase getGenericFailedFrame()
|
|
{
|
|
var genError = new InfoFrame();
|
|
|
|
genError.Title = "Loader fehlgeschlagen!";
|
|
genError.Text = Error.ToString();
|
|
|
|
genError.Button1Click += ViewBehavior.BackToLogin;
|
|
|
|
return genError;
|
|
}
|
|
|
|
private FrameBase getInstallProgressFrame()
|
|
{
|
|
var progress = new ProgressFrame(LauncherMode.Install);
|
|
|
|
progress.Successful += ViewBehavior.InstallSuccesss;
|
|
progress.Exception += ViewBehavior.InstallFailed;
|
|
|
|
return progress;
|
|
}
|
|
|
|
private FrameBase getInstallInfoFrame()
|
|
{
|
|
var install = new InstallInfoFrame();
|
|
|
|
install.Accept += ViewBehavior.InstallInfoAccept;
|
|
install.Abort += ViewBehavior.BackToLogin;
|
|
|
|
return install;
|
|
}
|
|
}
|
|
}
|