Пример #1
0
        public LoginWindowViewModel(UserControl view)
        {
            _view = view as LoginView;

            ForceRefresh = Settings.UserSettings.ContainsKey("ForceRefresh") ?
                           bool.Parse(Settings.UserSettings["ForceRefresh"]) : true;

            Email = Settings.UserSettings["AccountLogin"];

            if (!string.IsNullOrEmpty(Settings.UserSettings["AccountPassword"]))
            {
                _view.txtPassword.Password = string.Empty.PadLeft(8); //For the visuals
            }
            _view.txtPassword.PasswordChanged += new RoutedEventHandler(TxtPassword_PasswordChanged);
            PropertyChanged += LoginWindow_PropertyChanged;

            _characterInjector = new CharacterTabInjector();

            _statusController = new StatusController(_view.StatusBox);

            ApplicationState.Model.Authenticating += Model_Authenticating;
            ApplicationState.Model.Throttled      += Model_Throttled;
            ApplicationState.InitializeFont(Properties.Resources.fontin_regular_webfont);
            ApplicationState.InitializeFont(Properties.Resources.fontin_smallcaps_webfont);

            _statusController.DisplayMessage(ApplicationState.Version + " Initialized.\r");

            VersionChecker.CheckForUpdates();

            //Todo: Feed this in from a setting so that console players will have their preference remembered
            SelectedRealm = AvailableRealms.First();
        }
Пример #2
0
        public LoginWindowViewModel(UserControl view)
        {
            this.view = view as LoginView;

            UseSession = Settings.UserSettings.ContainsKey("UseSessionID") ? bool.Parse(Settings.UserSettings["UseSessionID"]) : false;

            Email            = Settings.UserSettings["AccountLogin"];
            this.formChanged = string.IsNullOrEmpty(Settings.UserSettings["AccountPassword"]);

            if (!this.formChanged)
            {
                this.view.txtPassword.Password = string.Empty.PadLeft(8); //For the visuals
            }
            this.view.txtPassword.PasswordChanged += new System.Windows.RoutedEventHandler(txtPassword_PasswordChanged);

            statusController = new StatusController(this.view.StatusBox);

            ApplicationState.Model.Authenticating += model_Authenticating;
            ApplicationState.Model.Throttled      += model_Throttled;
            ApplicationState.InitializeFont(Properties.Resources.fontin_regular_webfont);
            ApplicationState.InitializeFont(Properties.Resources.fontin_smallcaps_webfont);

            statusController.DisplayMessage(ApplicationState.Version + " Initialized.\r");

            VersionChecker.CheckForUpdates();
        }
Пример #3
0
        public LoginWindowViewModel(UserControl view)
        {
            this.view = view as LoginView;

            UseSession = Settings.UserSettings.ContainsKey("UseSessionID") ?
                         bool.Parse(Settings.UserSettings["UseSessionID"]) : false;
            ForceRefresh = Settings.UserSettings.ContainsKey("ForceRefresh") ?
                           bool.Parse(Settings.UserSettings["ForceRefresh"]) : true;

            Email = Settings.UserSettings["AccountLogin"];

            if (!string.IsNullOrEmpty(Settings.UserSettings["AccountPassword"]))
            {
                this.view.txtPassword.Password = string.Empty.PadLeft(8); //For the visuals
            }
            this.view.txtPassword.PasswordChanged += new RoutedEventHandler(txtPassword_PasswordChanged);
            PropertyChanged += loginWindow_PropertyChanged;

            characterInjector = new CharacterTabInjector();

            statusController = new StatusController(this.view.StatusBox);

            ApplicationState.Model.Authenticating += model_Authenticating;
            ApplicationState.Model.Throttled      += model_Throttled;
            ApplicationState.InitializeFont(Properties.Resources.fontin_regular_webfont);
            ApplicationState.InitializeFont(Properties.Resources.fontin_smallcaps_webfont);

            statusController.DisplayMessage($"WTF is {ApplicationState.Version} Initialized. RIP TotalBiscuit.\r");

            VersionChecker.CheckForUpdates();
        }
        public void Start(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += HandleUnhandledException;

            if (args.Length > 0)
            {
                int port;
                if (int.TryParse(args[0], out port))
                {
                    Settings.Instance.Server.Port = port;
                }
                else
                {
                    if (args[0].StartsWith("--"))
                    {
                        ProcessCommand(args[0].TrimStart('-'), args.Skip(1).ToArray(), true);
                    }
                    else
                    {
                    }
                }
            }

            Console.Title = string.Format(TitleFormat, Settings.Instance.Server.ServerName, 0);
            Logger.Instance.Log($"Beat Saber Multiplayer Server v{serverVersion}");

            VersionChecker.CheckForUpdates();

            Logger.Instance.Log($"Hosting Server @ {Settings.Instance.Server.IP}:{Settings.Instance.Server.Port}");

            Logger.Instance.Log("Downloading songs from BeatSaver...");
            DownloadSongs();

            StartServer();

            ShutdownEventCatcher.Shutdown += OnServerShutdown;

            Logger.Instance.Warning($"Use [Help] to display commands");
            Logger.Instance.Warning($"Use [Quit] to exit");
            while (Thread.CurrentThread.IsAlive)
            {
                var x = Console.ReadLine();
                if (x == string.Empty)
                {
                    continue;
                }
                var comParts = x?.Split(' ');
                var comName  = comParts[0];
                var comArgs  = comParts.Skip(1).ToArray();

                ProcessCommand(comName, comArgs, false);
            }
        }
Пример #5
0
        private void CheckForNewVersionInBackground()
        {
            ViewModel.UserMessage = "Checking for updates ...";
            Task task = Task.Factory.StartNew(() =>
            {
                IsNewVersionAvailable = VersionChecker.CheckForUpdates();
            });


            task.ContinueWith((antecedent) =>
            {
                ViewModel.UserMessage = "";

                if (IsNewVersionAvailable)
                {
                    StartUpdateTimerToOpenWindow();
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Пример #6
0
        void Start(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += HandleUnhandledException;

            if (args.Length > 0)
            {
                if (args[0].StartsWith("--"))
                {
                    ProcessCommand(args[0].TrimStart('-'), args.Skip(1).ToArray(), true);
                }
                else
                {
                }
            }

            ShutdownEventCatcher.Shutdown += OnShutdown;
            IP = GetPublicIPv4();

            Logger.Instance.Log($"Beat Saber Multiplayer ServerHub v{Assembly.GetEntryAssembly().GetName().Version}");

            VersionChecker.CheckForUpdates();

            Logger.Instance.Log($"Hosting ServerHub @ {IP}:{Settings.Instance.Server.Port}");

            Listener.StartAsync();
            Logger.Instance.Warning($"Use [Help] to display commands");
            Logger.Instance.Warning($"Use [Quit] to exit");
            while (Listener.Listen)
            {
                var x = Console.ReadLine();
                if (x == string.Empty)
                {
                    continue;
                }
                var      comParts = x?.Split(' ');
                string   comName  = comParts[0];
                string[] comArgs  = comParts.Skip(1).ToArray();

                ProcessCommand(comName, comArgs, false);
            }
        }
Пример #7
0
        private void CheckForNewVersionInBackground()
        {
            bool isNewVersionAvailable = false;

            ViewModel.UserMessage = "Checking for updates ...";
            Task task = Task.Factory.StartNew(() =>
            {
                isNewVersionAvailable = VersionChecker.CheckForUpdates();
            });

            task.ContinueWith((antecedent) =>
            {
                ViewModel.UserMessage = "";

                if (isNewVersionAvailable)
                {
                    MessageBoxResult result = System.Windows.MessageBox.Show("There is a new version available. Click 'Yes' to download the latest version (the program will close and re-open).",
                                                                             "Update Available!",
                                                                             MessageBoxButton.YesNo,
                                                                             MessageBoxImage.Question,
                                                                             MessageBoxResult.Yes);

                    if (result == MessageBoxResult.Yes)
                    {
                        ViewModel.UserMessage = "Updating app ...";
                        VersionChecker.AppUpdater.ReportProgress += AppUpdater_ReportProgress;

                        Task updateTask = Task.Factory.StartNew(() =>
                        {
                            VersionChecker.UpdateApplication();
                        });

                        updateTask.ContinueWith((updateAntecedent) =>
                        {
                            VersionChecker.AppUpdater.ReportProgress -= AppUpdater_ReportProgress;
                        });
                    }
                }
            });
        }