Beispiel #1
0
        private async Task <bool> ExistingSettingLogin(SettingsV3Model setting)
        {
            Result result = await ChannelSession.ConnectUser(setting);

            if (result.Success)
            {
                if (await ChannelSession.InitializeSession())
                {
                    return(true);
                }
            }
            else
            {
                await DialogHelper.ShowMessage(result.Message);
            }
            return(false);
        }
        public NewUserWizardWindowViewModel()
        {
            this.DiscordCommand = this.CreateCommand((parameter) => { ProcessHelper.LaunchLink("https://mixitupapp.com/discord"); return(Task.FromResult(0)); });
            this.TwitterCommand = this.CreateCommand((parameter) => { ProcessHelper.LaunchLink("https://twitter.com/MixItUpApp"); return(Task.FromResult(0)); });
            this.YouTubeCommand = this.CreateCommand((parameter) => { ProcessHelper.LaunchLink("https://www.youtube.com/channel/UCcY0vKI9yqcMTgh8OzSnRSA"); return(Task.FromResult(0)); });
            this.WikiCommand    = this.CreateCommand((parameter) => { ProcessHelper.LaunchLink("https://github.com/SaviorXTanren/mixer-mixitup/wiki"); return(Task.FromResult(0)); });

            this.Twitch.StartLoadingOperationOccurred += (sender, eventArgs) => { this.StartLoadingOperation(); };
            this.Twitch.EndLoadingOperationOccurred   += (sender, eventArgs) => { this.EndLoadingOperation(); };

            this.SetBackupLocationCommand = this.CreateCommand((parameter) =>
            {
                string folderPath = ChannelSession.Services.FileService.ShowOpenFolderDialog();
                if (!string.IsNullOrEmpty(folderPath) && Directory.Exists(folderPath))
                {
                    this.SettingsBackupLocation = folderPath;
                }

                if (this.SelectedSettingsBackupOption == SettingsBackupRateEnum.None)
                {
                    this.SelectedSettingsBackupOption = SettingsBackupRateEnum.Monthly;
                }

                this.NotifyPropertyChanged("IsBackupLocationSet");

                return(Task.FromResult(0));
            });

            this.NextCommand = this.CreateCommand(async(parameter) =>
            {
                this.StatusMessage = string.Empty;

                if (this.IntroPageVisible)
                {
                    this.IntroPageVisible            = false;
                    this.StreamerAccountsPageVisible = true;
                    this.CanBack = true;
                }
                else if (this.StreamerAccountsPageVisible)
                {
                    if (!this.Twitch.IsUserAccountConnected)
                    {
                        this.StatusMessage = "Twitch Streamer account must be signed in.";
                        return;
                    }

                    this.StreamerAccountsPageVisible = false;
                    this.CommandActionsPageVisible   = true;
                }
                else if (this.CommandActionsPageVisible)
                {
                    this.CommandActionsPageVisible = false;
                    this.FinalPageVisible          = true;
                }
                else if (this.FinalPageVisible)
                {
                    if (!await ChannelSession.InitializeSession())
                    {
                        await DialogHelper.ShowMessage(Resources.SessionInitializationFailed);
                        return;
                    }

                    ChannelSession.Settings.ReRunWizard            = false;
                    ChannelSession.Settings.SettingsBackupLocation = this.SettingsBackupLocation;
                    ChannelSession.Settings.SettingsBackupRate     = this.SelectedSettingsBackupOption;

                    this.WizardComplete = true;
                    this.WizardCompleteEvent(this, new EventArgs());
                }

                this.StatusMessage = string.Empty;
            });

            this.BackCommand = this.CreateCommand((parameter) =>
            {
                if (this.StreamerAccountsPageVisible)
                {
                    this.StreamerAccountsPageVisible = false;
                    this.IntroPageVisible            = true;
                    this.CanBack = false;
                }
                else if (this.CommandActionsPageVisible)
                {
                    this.CommandActionsPageVisible   = false;
                    this.StreamerAccountsPageVisible = true;
                }
                else if (this.FinalPageVisible)
                {
                    this.FinalPageVisible          = false;
                    this.CommandActionsPageVisible = true;
                }

                this.StatusMessage = string.Empty;
                return(Task.FromResult(0));
            });
        }
        public NewUserWizardWindowViewModel()
        {
            this.DiscordCommand = this.CreateCommand((parameter) => { ProcessHelper.LaunchLink("https://mixitupapp.com/discord"); return(Task.FromResult(0)); });
            this.TwitterCommand = this.CreateCommand((parameter) => { ProcessHelper.LaunchLink("https://twitter.com/MixItUpApp"); return(Task.FromResult(0)); });
            this.YouTubeCommand = this.CreateCommand((parameter) => { ProcessHelper.LaunchLink("https://www.youtube.com/channel/UCcY0vKI9yqcMTgh8OzSnRSA"); return(Task.FromResult(0)); });
            this.WikiCommand    = this.CreateCommand((parameter) => { ProcessHelper.LaunchLink("https://github.com/SaviorXTanren/mixer-mixitup/wiki"); return(Task.FromResult(0)); });

            this.Twitch.StartLoadingOperationOccurred += (sender, eventArgs) => { this.StartLoadingOperation(); };
            this.Twitch.EndLoadingOperationOccurred   += (sender, eventArgs) => { this.EndLoadingOperation(); };

            this.ScorpBotDirectoryBrowseCommand = this.CreateCommand((parameter) =>
            {
                string folderPath = ChannelSession.Services.FileService.ShowOpenFolderDialog();
                if (!string.IsNullOrEmpty(folderPath))
                {
                    this.ScorpBotDirectory = folderPath;
                }
                return(Task.FromResult(0));
            });

            this.StreamlabsChatbotDirectoryBrowseCommand = this.CreateCommand((parameter) =>
            {
                string filePath = ChannelSession.Services.FileService.ShowOpenFileDialog("Excel File|*.xlsx");
                if (!string.IsNullOrEmpty(filePath))
                {
                    this.StreamlabsChatbotDirectory = filePath;
                }
                return(Task.FromResult(0));
            });

            this.SetBackupLocationCommand = this.CreateCommand((parameter) =>
            {
                string folderPath = ChannelSession.Services.FileService.ShowOpenFolderDialog();
                if (!string.IsNullOrEmpty(folderPath) && Directory.Exists(folderPath))
                {
                    this.SettingsBackupLocation = folderPath;
                }

                if (this.SelectedSettingsBackupOption == SettingsBackupRateEnum.None)
                {
                    this.SelectedSettingsBackupOption = SettingsBackupRateEnum.Monthly;
                }

                this.NotifyPropertyChanged("IsBackupLocationSet");

                return(Task.FromResult(0));
            });

            this.NextCommand = this.CreateCommand(async(parameter) =>
            {
                this.StatusMessage = string.Empty;

                if (this.IntroPageVisible)
                {
                    this.IntroPageVisible            = false;
                    this.StreamerAccountsPageVisible = true;
                    this.CanBack = true;
                }
                else if (this.StreamerAccountsPageVisible)
                {
                    if (!this.Twitch.IsUserAccountConnected)
                    {
                        this.StatusMessage = "Twitch Streamer account must be signed in.";
                        return;
                    }

                    this.StreamerAccountsPageVisible = false;
                    //this.ScorpBotPageVisible = true;

                    this.CommandActionsPageVisible = true;
                }
                else if (this.ScorpBotPageVisible)
                {
                    if (!string.IsNullOrEmpty(this.ScorpBotDirectory))
                    {
                        this.StatusMessage = "Gathering ScorpBot Data...";
                        this.ScorpBot      = await ScorpBotDataModel.GatherScorpBotData(this.ScorpBotDirectory);
                        if (this.ScorpBot == null)
                        {
                            this.StatusMessage = "Failed to import ScorpBot data, please ensure that you have selected the correct directory. If this continues to fail, please contact Mix it Up support for assistance.";
                            return;
                        }
                    }

                    this.ScorpBotPageVisible          = false;
                    this.StreamlabsChatbotPageVisible = true;
                }
                else if (this.StreamlabsChatbotPageVisible)
                {
                    if (!string.IsNullOrEmpty(this.StreamlabsChatbotDirectory))
                    {
                        this.StatusMessage     = "Gathering Streamlabs ChatBot Data...";
                        this.StreamlabsChatBot = await StreamlabsChatBotDataModel.GatherStreamlabsChatBotSettings(StreamingPlatformTypeEnum.Twitch, this.StreamlabsChatbotDirectory);
                        if (this.StreamlabsChatBot == null)
                        {
                            this.StatusMessage = "Failed to import Streamlabs Chat Bot data, please ensure that you have selected the correct data file & have Microsoft Excel installed. If this continues to fail, please contact Mix it Up support for assistance.";
                            return;
                        }
                    }

                    this.StreamlabsChatbotPageVisible = false;
                    this.CommandActionsPageVisible    = true;
                }
                else if (this.CommandActionsPageVisible)
                {
                    this.CommandActionsPageVisible = false;
                    this.FinalPageVisible          = true;
                }
                else if (this.FinalPageVisible)
                {
                    if (!await ChannelSession.InitializeSession())
                    {
                        await DialogHelper.ShowMessage("Failed to initialize session. If this continues please, visit the Mix It Up Discord for assistance.");
                        return;
                    }

                    if (this.ScorpBot != null)
                    {
                        this.ScorpBot.ImportSettings();
                    }

                    if (this.StreamlabsChatBot != null)
                    {
                        await this.StreamlabsChatBot.ImportSettings();
                    }

                    ChannelSession.Settings.ReRunWizard            = false;
                    ChannelSession.Settings.SettingsBackupLocation = this.SettingsBackupLocation;
                    ChannelSession.Settings.SettingsBackupRate     = this.SelectedSettingsBackupOption;

                    this.WizardComplete = true;
                    this.WizardCompleteEvent(this, new EventArgs());
                }

                this.StatusMessage = string.Empty;
            });

            this.BackCommand = this.CreateCommand((parameter) =>
            {
                if (this.StreamerAccountsPageVisible)
                {
                    this.StreamerAccountsPageVisible = false;
                    this.IntroPageVisible            = true;
                    this.CanBack = false;
                }
                else if (this.ScorpBotPageVisible)
                {
                    this.ScorpBotPageVisible         = false;
                    this.StreamerAccountsPageVisible = true;
                }
                else if (this.StreamlabsChatbotPageVisible)
                {
                    this.StreamlabsChatbotPageVisible = false;
                    this.ScorpBotPageVisible          = true;
                }
                else if (this.CommandActionsPageVisible)
                {
                    this.CommandActionsPageVisible = false;
                    //this.StreamlabsChatbotPageVisible = true;
                    this.StreamerAccountsPageVisible = true;
                }
                else if (this.FinalPageVisible)
                {
                    this.FinalPageVisible          = false;
                    this.CommandActionsPageVisible = true;
                }

                this.StatusMessage = string.Empty;
                return(Task.FromResult(0));
            });
        }