Ejemplo n.º 1
0
 private async void Slider_LostFocus(object sender, System.Windows.RoutedEventArgs e)
 {
     await this.Window.RunAsyncOperation(async() =>
     {
         await ChannelSession.SaveSettings();
     });
 }
        public async Task Save()
        {
            if (this.inventory == null)
            {
                this.inventory = new InventoryModel();
                ChannelSession.Settings.Inventory[this.inventory.ID] = this.inventory;
            }

            this.inventory.Name              = this.Name;
            this.inventory.DefaultMaxAmount  = this.DefaultItemMaxAmount;
            this.inventory.SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(this.inventory.Name);
            this.inventory.Items             = new Dictionary <Guid, InventoryItemModel>(this.Items.ToDictionary(i => i.ID, i => i));

            this.inventory.ShopEnabled = this.ShopEnabled;
            this.inventory.ShopCommand = this.ShopCommandText;
            if (this.SelectedShopCurrency != null)
            {
                this.inventory.ShopCurrencyID = this.SelectedShopCurrency.ID;
            }
            this.inventory.ItemsBoughtCommand = this.ShopBuyCommand;
            this.inventory.ItemsSoldCommand   = this.ShopSellCommand;

            this.inventory.TradeEnabled       = this.TradeEnabled;
            this.inventory.TradeCommand       = this.TradeCommandText;
            this.inventory.ItemsTradedCommand = this.TradeCommand;

            await ChannelSession.SaveSettings();
        }
        private async Task SaveSettings()
        {
            if (this.isLoaded)
            {
                await this.Window.RunAsyncOperation(async() =>
                {
                    ChannelSession.Settings.ModerationUseCommunityFilteredWords = this.CommunityBannedWordsToggleButton.IsChecked.GetValueOrDefault();

                    this.ConvertFilteredTextToWordList(this.FilteredWordsTextBox.Text, ChannelSession.Settings.FilteredWords);
                    this.ConvertFilteredTextToWordList(this.BannedWordsTextBox.Text, ChannelSession.Settings.BannedWords);
                    ChannelSession.Settings.ModerationFilteredWordsExcempt = EnumHelper.GetEnumValueFromString <MixerRoleEnum>((string)this.FilteredWordsExemptComboBox.SelectedItem);

                    ChannelSession.Settings.ModerationCapsBlockCount               = (int)this.MaxCapsSlider.Value;
                    ChannelSession.Settings.ModerationCapsBlockIsPercentage        = (this.MaxCapsTypeComboBox.SelectedIndex == 0);
                    ChannelSession.Settings.ModerationPunctuationBlockCount        = (int)this.MaxPunctuationSymbolsSlider.Value;
                    ChannelSession.Settings.ModerationPunctuationBlockIsPercentage = (this.MaxPunctuationSymbolsTypeComboBox.SelectedIndex == 0);
                    ChannelSession.Settings.ModerationEmoteBlockCount              = (int)this.MaxEmotesSlider.Value;
                    ChannelSession.Settings.ModerationEmoteBlockIsPercentage       = (this.MaxEmotesTypeComboBox.SelectedIndex == 0);
                    ChannelSession.Settings.ModerationChatTextExcempt              = EnumHelper.GetEnumValueFromString <MixerRoleEnum>((string)this.ChatTextModerationExemptComboBox.SelectedItem);

                    ChannelSession.Settings.ModerationBlockLinks        = this.BlockLinksToggleButton.IsChecked.GetValueOrDefault();
                    ChannelSession.Settings.ModerationBlockLinksExcempt = EnumHelper.GetEnumValueFromString <MixerRoleEnum>((string)this.BlockLinksExemptComboBox.SelectedItem);

                    ChannelSession.Settings.ModerationTimeout1MinuteOffenseCount = (int)this.ModerationTimeout1MinAfterSlider.Value;
                    ChannelSession.Settings.ModerationTimeout5MinuteOffenseCount = (int)this.ModerationTimeout5MinAfterSlider.Value;
                    ChannelSession.Settings.ModerationTimeoutExempt = EnumHelper.GetEnumValueFromString <MixerRoleEnum>((string)this.ModerationTimeoutExemptComboBox.SelectedItem);

                    await ChannelSession.SaveSettings();
                });
            }
        }
Ejemplo n.º 4
0
        private async Task ChannelRefreshBackground()
        {
            await BackgroundTaskWrapper.RunBackgroundTask(this.backgroundThreadCancellationTokenSource, async (tokenSource) =>
            {
                tokenSource.Token.ThrowIfCancellationRequested();

                await ChannelSession.RefreshChannel();
                await Task.Delay(30000, tokenSource.Token);

                tokenSource.Token.ThrowIfCancellationRequested();

                await ChannelSession.RefreshChannel();
                await Task.Delay(30000, tokenSource.Token);

                tokenSource.Token.ThrowIfCancellationRequested();

                foreach (UserViewModel user in await ChannelSession.ActiveUsers.GetAllWorkableUsers())
                {
                    user.UpdateMinuteData();
                }

                foreach (UserCurrencyViewModel currency in ChannelSession.Settings.Currencies.Values)
                {
                    await currency.UpdateUserData();
                }

                await ChannelSession.SaveSettings();

                tokenSource.Token.ThrowIfCancellationRequested();
            });
        }
Ejemplo n.º 5
0
        private async void EnableSongRequestsToggleButton_Checked(object sender, System.Windows.RoutedEventArgs e)
        {
            await this.Window.RunAsyncOperation(async() =>
            {
                if (!this.SpotifyToggleButton.IsChecked.GetValueOrDefault() && !this.YouTubeToggleButton.IsChecked.GetValueOrDefault() &&
                    !this.SoundCloudToggleButton.IsChecked.GetValueOrDefault())
                {
                    await MessageBoxHelper.ShowMessageDialog("At least 1 song request service must be set");
                    this.EnableSongRequestsToggleButton.IsChecked = false;
                    return;
                }

                if (this.SpotifyToggleButton.IsChecked.GetValueOrDefault() && ChannelSession.Services.Spotify == null)
                {
                    await MessageBoxHelper.ShowMessageDialog("You must connect to your Spotify account in the Services area");
                    this.EnableSongRequestsToggleButton.IsChecked = false;
                    return;
                }

                if (this.YouTubeToggleButton.IsChecked.GetValueOrDefault() && ChannelSession.Services.OverlayServer == null)
                {
                    await MessageBoxHelper.ShowMessageDialog("You must enable & use the Mix It Up Overlay for YouTube song requests");
                    this.EnableSongRequestsToggleButton.IsChecked = false;
                    return;
                }

                if (this.SoundCloudToggleButton.IsChecked.GetValueOrDefault() && ChannelSession.Services.OverlayServer == null)
                {
                    await MessageBoxHelper.ShowMessageDialog("You must enable & use the Mix It Up Overlay for SoundCloud song requests");
                    this.EnableSongRequestsToggleButton.IsChecked = false;
                    return;
                }

                if (this.SpotifyToggleButton.IsChecked.GetValueOrDefault())
                {
                    ChannelSession.Settings.SongRequestServiceTypes.Add(SongRequestServiceTypeEnum.Spotify);
                }
                if (this.YouTubeToggleButton.IsChecked.GetValueOrDefault())
                {
                    ChannelSession.Settings.SongRequestServiceTypes.Add(SongRequestServiceTypeEnum.YouTube);
                }
                if (this.SoundCloudToggleButton.IsChecked.GetValueOrDefault())
                {
                    ChannelSession.Settings.SongRequestServiceTypes.Add(SongRequestServiceTypeEnum.SoundCloud);
                }

                ChannelSession.Settings.SpotifyAllowExplicit = this.SpotifyAllowExplicitSongToggleButton.IsChecked.GetValueOrDefault();

                await ChannelSession.SaveSettings();

                if (await ChannelSession.Services.SongRequestService.Initialize())
                {
                    await this.RefreshRequestsList();
                }
                else
                {
                    await MessageBoxHelper.ShowMessageDialog("We were unable to initialize the Song Request service, please try again.");
                }
            });
        }
        private async Task SaveSettings()
        {
            if (this.isLoaded)
            {
                await this.Window.RunAsyncOperation(async() =>
                {
                    ChannelSession.Settings.ModerationUseCommunityFilteredWords = this.CommunityBannedWordsToggleButton.IsChecked.GetValueOrDefault();

                    this.ConvertFilteredTextToWordList(this.FilteredWordsTextBox.Text, ChannelSession.Settings.FilteredWords);
                    this.ConvertFilteredTextToWordList(this.BannedWordsTextBox.Text, ChannelSession.Settings.BannedWords);
                    ChannelSession.Settings.ModerationFilteredWordsExcempt      = (UserRoleEnum)this.FilteredWordsExemptComboBox.SelectedItem;
                    ChannelSession.Settings.ModerationFilteredWordsApplyStrikes = this.FilteredWordsApplyStrikesToggleButton.IsChecked.GetValueOrDefault();

                    ChannelSession.Settings.ModerationCapsBlockCount               = (int)this.MaxCapsSlider.Value;
                    ChannelSession.Settings.ModerationCapsBlockIsPercentage        = (this.MaxCapsTypeComboBox.SelectedIndex == 0);
                    ChannelSession.Settings.ModerationPunctuationBlockCount        = (int)this.MaxPunctuationSymbolsEmotesSlider.Value;
                    ChannelSession.Settings.ModerationPunctuationBlockIsPercentage = (this.MaxPunctuationSymbolsEmotesTypeComboBox.SelectedIndex == 0);
                    ChannelSession.Settings.ModerationChatTextExcempt              = (UserRoleEnum)this.ChatTextModerationExemptComboBox.SelectedItem;
                    ChannelSession.Settings.ModerationChatTextApplyStrikes         = this.ChatTextApplyStrikesToggleButton.IsChecked.GetValueOrDefault();

                    ChannelSession.Settings.ModerationBlockLinks             = this.BlockLinksToggleButton.IsChecked.GetValueOrDefault();
                    ChannelSession.Settings.ModerationBlockLinksExcempt      = (UserRoleEnum)this.BlockLinksExemptComboBox.SelectedItem;
                    ChannelSession.Settings.ModerationBlockLinksApplyStrikes = this.BlockLinksApplyStrikesToggleButton.IsChecked.GetValueOrDefault();

                    ChannelSession.Settings.ModerationChatInteractiveParticipation        = (ModerationChatInteractiveParticipationEnum)this.ChatInteractiveParticipationComboBox.SelectedItem;
                    ChannelSession.Settings.ModerationChatInteractiveParticipationExcempt = (UserRoleEnum)this.ChatParticipationExemptComboBox.SelectedItem;

                    ChannelSession.Settings.ModerationResetStrikesOnLaunch = this.ResetStrikesOnLaunchToggleButton.IsChecked.GetValueOrDefault();

                    await ChannelSession.SaveSettings();

                    ChannelSession.Services.Moderation.RebuildCache();
                });
            }
        }
Ejemplo n.º 7
0
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            await this.window.RunAsyncOperation(async() =>
            {
                ActionBase action = this.actionControl.GetAction();
                if (action == null)
                {
                    if (this.actionControl is ChatActionControl)
                    {
                        await MessageBoxHelper.ShowMessageDialog("The chat message must not be empty");
                    }
                    else if (this.actionControl is SoundActionControl)
                    {
                        await MessageBoxHelper.ShowMessageDialog("The sound file path must not be empty");
                    }
                    return;
                }

                EventCommand newCommand = new EventCommand(this.eventType, ChannelSession.Channel);
                newCommand.IsBasic      = true;
                newCommand.Actions.Add(action);

                if (this.command != null)
                {
                    ChannelSession.Settings.EventCommands.Remove(this.command);
                }
                ChannelSession.Settings.EventCommands.Add(newCommand);

                await ChannelSession.SaveSettings();

                this.window.Close();
            });
        }
Ejemplo n.º 8
0
        public AddQuoteChatCommand()
            : base("Add Quote", new List <string>() { "addquote", "quoteadd" }, UserRole.Mod, 5)
        {
            this.Actions.Add(new CustomAction(async(UserViewModel user, IEnumerable <string> arguments) =>
            {
                if (ChannelSession.Settings.QuotesEnabled)
                {
                    StringBuilder quoteBuilder = new StringBuilder();
                    foreach (string arg in arguments)
                    {
                        quoteBuilder.Append(arg + " ");
                    }

                    string quoteText = quoteBuilder.ToString();
                    quoteText        = quoteText.Trim(new char[] { ' ', '\'', '\"' });

                    UserQuoteViewModel quote = new UserQuoteViewModel(quoteText, DateTimeOffset.Now, ChannelSession.Channel.type);
                    ChannelSession.Settings.UserQuotes.Add(quote);
                    await ChannelSession.SaveSettings();

                    GlobalEvents.QuoteAdded(quote);

                    if (ChannelSession.Chat != null)
                    {
                        await ChannelSession.Chat.SendMessage("Added Quote: \"" + quote.ToString() + "\"");
                    }
                }
                else
                {
                    await ChannelSession.Chat.SendMessage("Quotes must be enabled with Mix It Up for this feature to work");
                }
            }));
        }
Ejemplo n.º 9
0
 private async void ExistingEntranceCommandButtons_DeleteClicked(object sender, RoutedEventArgs e)
 {
     await this.RunAsyncOperation(async() =>
     {
         this.viewModel.EntranceCommand = null;
         await ChannelSession.SaveSettings();
     });
 }
Ejemplo n.º 10
0
 private async void CommunityBannedWordsToggleButton_Checked(object sender, System.Windows.RoutedEventArgs e)
 {
     ChannelSession.Settings.ModerationUseCommunityBannedWords = this.CommunityBannedWordsToggleButton.IsChecked.GetValueOrDefault();
     await this.Window.RunAsyncOperation(async() =>
     {
         await ChannelSession.SaveSettings();
     });
 }
Ejemplo n.º 11
0
 private async void IncludeModeratorsToggleButton_Checked(object sender, System.Windows.RoutedEventArgs e)
 {
     ChannelSession.Settings.ModerationIncludeModerators = IncludeModeratorsToggleButton.IsChecked.GetValueOrDefault();
     await this.Window.RunAsyncOperation(async() =>
     {
         await ChannelSession.SaveSettings();
     });
 }
 private async void DisableOverlayButton_Click(object sender, RoutedEventArgs e)
 {
     await this.groupBoxControl.window.RunAsyncOperation(async() =>
     {
         await this.DisconnectOverlayService();
         await ChannelSession.SaveSettings();
     });
 }
Ejemplo n.º 13
0
 public async Task Reset()
 {
     foreach (UserDataViewModel userData in ChannelSession.Settings.UserData.Values)
     {
         userData.ResetInventoryAmount(this);
         ChannelSession.Settings.UserData.ManualValueChanged(userData.ID);
     }
     await ChannelSession.SaveSettings();
 }
Ejemplo n.º 14
0
        public async Task Copy(StreamPassModel streamPass)
        {
            StreamPassModel newStreamPass = new StreamPassModel(streamPass);

            ChannelSession.Settings.StreamPass[newStreamPass.ID] = newStreamPass;
            await ChannelSession.SaveSettings();

            this.Refresh();
        }
Ejemplo n.º 15
0
 private async void UserOnlyChatCommandButtons_DeleteClicked(object sender, RoutedEventArgs e)
 {
     await this.RunAsyncOperation(async() =>
     {
         this.viewModel.RemoveUserOnlyChatCommand(FrameworkElementHelpers.GetDataContext <UserOnlyChatCommandModel>(sender));
         await ChannelSession.SaveSettings();
         ChannelSession.Services.Chat.RebuildCommandTriggers();
     });
 }
Ejemplo n.º 16
0
        public async Task Delete(StreamPassModel streamPass)
        {
            if (await DialogHelper.ShowConfirmation(MixItUp.Base.Resources.ConfirmStreamPassDeletion))
            {
                ChannelSession.Settings.StreamPass.Remove(streamPass.ID);
                await ChannelSession.SaveSettings();

                this.Refresh();
            }
        }
Ejemplo n.º 17
0
        public async Task DeleteWidget(OverlayWidgetModel widget)
        {
            if (widget != null)
            {
                await widget.Disable();

                ChannelSession.Settings.OverlayWidgets.Remove(widget);
                await ChannelSession.SaveSettings();
            }
        }
 private async void EnableOverlayButton_Click(object sender, RoutedEventArgs e)
 {
     await this.groupBoxControl.window.RunAsyncOperation(async() =>
     {
         if (!await this.ConnectOverlayService())
         {
             await MessageBoxHelper.ShowMessageDialog("Failed to start Overlay Connection, this sometimes means our connection got wonky. If this continues to happen, please try restarting Mix It Up.");
         }
         await ChannelSession.SaveSettings();
     });
 }
Ejemplo n.º 19
0
        public async Task Reset()
        {
            foreach (UserDataViewModel userData in ChannelSession.Settings.UserData.Values)
            {
                userData.ResetCurrencyAmount(this);
                ChannelSession.Settings.UserData.ManualValueChanged(userData.ID);
            }
            this.LastReset = new DateTimeOffset(DateTimeOffset.Now.Date);

            await ChannelSession.SaveSettings();
        }
Ejemplo n.º 20
0
 public async Task Reset()
 {
     foreach (UserDataModel user in ChannelSession.Settings.UserData.Values.ToList())
     {
         if (this.GetAmount(user) > 0)
         {
             this.SetAmount(user, 0);
             ChannelSession.Settings.UserData.ManualValueChanged(user.ID);
         }
     }
     await ChannelSession.SaveSettings();
 }
Ejemplo n.º 21
0
 public async Task Reset()
 {
     foreach (UserDataModel user in ChannelSession.Settings.UserData.Values.ToList())
     {
         if (user.InventoryAmounts.ContainsKey(this.ID))
         {
             user.InventoryAmounts[this.ID] = new Dictionary <Guid, int>();
             ChannelSession.Settings.UserData.ManualValueChanged(user.ID);
         }
     }
     await ChannelSession.SaveSettings();
 }
Ejemplo n.º 22
0
 private async void RankUpCommandButtons_DeleteClicked(object sender, RoutedEventArgs e)
 {
     await this.RunAsyncOperation(async() =>
     {
         CustomCommandModel command = ((CommandListingButtonsControl)sender).GetCommandFromCommandButtons <CustomCommandModel>();
         if (command != null)
         {
             this.viewModel.RankChangedCommand = null;
             ChannelSession.Settings.RemoveCommand(command);
             await ChannelSession.SaveSettings();
         }
     });
 }
Ejemplo n.º 23
0
        private async void DisableStreamlabsOBSConnectionButton_Click(object sender, RoutedEventArgs e)
        {
            await this.groupBoxControl.window.RunAsyncOperation(async() =>
            {
                await ChannelSession.Services.DisconnectStreamlabsOBSService();
                ChannelSession.Settings.EnableStreamlabsOBSConnection = false;
                await ChannelSession.SaveSettings();

                this.EnableStreamlabsOBSConnectionButton.Visibility  = Visibility.Visible;
                this.DisableStreamlabsOBSConnectionButton.Visibility = Visibility.Collapsed;
                this.TestStreamlabsOBSConnectionButton.IsEnabled     = false;
            });
        }
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            this.newCommand = await this.GetNewCommand();

            if (this.newCommand != null)
            {
                this.CommandSavedSuccessfully(this.newCommand);

                await this.window.RunAsyncOperation(async() => { await ChannelSession.SaveSettings(); });

                this.window.Close();
            }
        }
 private async void CommandButtons_DeleteClicked(object sender, RoutedEventArgs e)
 {
     await this.RunAsyncOperation(async() =>
     {
         CommandButtonsControl commandButtonsControl = (CommandButtonsControl)sender;
         CustomCommand command = commandButtonsControl.GetCommandFromCommandButtons <CustomCommand>(sender);
         if (command != null)
         {
             this.viewModel.RankChangedCommand = null;
             await ChannelSession.SaveSettings();
         }
     });
 }
        public async Task Save()
        {
            if (this.Currency == null)
            {
                this.Currency = new CurrencyModel();
                ChannelSession.Settings.Currency[this.Currency.ID] = this.Currency;
            }

            this.Currency.Name      = this.Name;
            this.Currency.IsPrimary = this.IsPrimary;
            this.Currency.MaxAmount = (this.MaxAmount != 0 && this.MaxAmount != int.MaxValue) ? this.MaxAmount : int.MaxValue;

            this.Currency.AcquireAmount          = this.OnlineRateAmount;
            this.Currency.AcquireInterval        = this.OnlineRateInterval;
            this.Currency.OfflineAcquireAmount   = this.OfflineRateAmount;
            this.Currency.OfflineAcquireInterval = this.OfflineRateInterval;

            this.Currency.SpecialTracking = CurrencySpecialTrackingEnum.None;
            if (this.OnlineRate == CurrencyAcquireRateTypeEnum.Bits)
            {
                this.Currency.SpecialTracking = CurrencySpecialTrackingEnum.Bits;
            }

            this.Currency.RegularBonus     = this.RegularBonus;
            this.Currency.SubscriberBonus  = this.SubscriberBonus;
            this.Currency.ModeratorBonus   = this.ModeratorBonus;
            this.Currency.OnFollowBonus    = this.OnFollowBonus;
            this.Currency.OnHostBonus      = this.OnHostBonus;
            this.Currency.OnSubscribeBonus = this.OnSubscribeBonus;

            this.Currency.MinimumActiveRate = this.MinimumActiveRate;
            this.Currency.ResetInterval     = this.AutomaticResetRate;
            this.Currency.ResetStartCadence = this.AutomaticResetStartTime;

            this.Currency.SpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(this.Currency.Name);

            if (this.IsRank)
            {
                this.Currency.Ranks = this.Ranks.ToList();
                this.Currency.RankChangedCommand = this.RankChangedCommand;
                this.Currency.RankDownCommand    = this.RankDownCommand;
            }
            else
            {
                this.Currency.Ranks.Clear();
                this.Currency.RankChangedCommand = null;
                this.Currency.RankDownCommand    = null;
            }

            await ChannelSession.SaveSettings();
        }
        private async void EnableSongRequestsToggleButton_Checked(object sender, System.Windows.RoutedEventArgs e)
        {
            await this.Window.RunAsyncOperation(async() =>
            {
                if (!this.SpotifyToggleButton.IsChecked.GetValueOrDefault() && !this.YouTubeToggleButton.IsChecked.GetValueOrDefault())
                {
                    await MessageBoxHelper.ShowMessageDialog("At least 1 song request service must be set");
                    this.EnableSongRequestsToggleButton.IsChecked = false;
                    return;
                }

                if (this.SpotifyToggleButton.IsChecked.GetValueOrDefault() && (ChannelSession.Services.Spotify == null || (await ChannelSession.Services.Spotify.GetCurrentlyPlaying()) == null))
                {
                    await MessageBoxHelper.ShowMessageDialog("You must connect to your Spotify account in the Services area. You must also have Spotify running on your computer and you have played at least one song in the Spotify app."
                                                             + Environment.NewLine + Environment.NewLine + "This is required to be done everytime to let Spotify know that where to send our song requests to.");
                    this.EnableSongRequestsToggleButton.IsChecked = false;
                    return;
                }

                if (this.YouTubeToggleButton.IsChecked.GetValueOrDefault() && ChannelSession.Services.OverlayServers == null)
                {
                    await MessageBoxHelper.ShowMessageDialog("You must enable & use the Mix It Up Overlay for YouTube song requests");
                    this.EnableSongRequestsToggleButton.IsChecked = false;
                    return;
                }

                ChannelSession.Settings.SongRequestServiceTypes.Clear();
                if (this.SpotifyToggleButton.IsChecked.GetValueOrDefault())
                {
                    ChannelSession.Settings.SongRequestServiceTypes.Add(SongRequestServiceTypeEnum.Spotify);
                }
                if (this.YouTubeToggleButton.IsChecked.GetValueOrDefault())
                {
                    ChannelSession.Settings.SongRequestServiceTypes.Add(SongRequestServiceTypeEnum.YouTube);
                }

                ChannelSession.Settings.SpotifyAllowExplicit = this.SpotifyAllowExplicitSongToggleButton.IsChecked.GetValueOrDefault();

                await ChannelSession.SaveSettings();

                if (await ChannelSession.Services.SongRequestService.Initialize())
                {
                    await this.RefreshRequestsList();
                }
                else
                {
                    await MessageBoxHelper.ShowMessageDialog("We were unable to initialize the Song Request service, please try again.");
                    this.EnableSongRequestsToggleButton.IsChecked = false;
                }
            });
        }
 private async void ExistingEntranceCommandButtons_DeleteClicked(object sender, RoutedEventArgs e)
 {
     await this.RunAsyncOperation(async() =>
     {
         CommandButtonsControl commandButtonsControl = (CommandButtonsControl)sender;
         CustomCommand command = commandButtonsControl.GetCommandFromCommandButtons <CustomCommand>(sender);
         if (command != null)
         {
             this.user.Data.EntranceCommand = null;
             await ChannelSession.SaveSettings();
             await this.RefreshData();
         }
     });
 }
 private async void CommandButtons_DeleteClicked(object sender, RoutedEventArgs e)
 {
     await this.Window.RunAsyncOperation(async() =>
     {
         CommandButtonsControl commandButtonsControl = (CommandButtonsControl)sender;
         ActionGroupCommand command = commandButtonsControl.GetCommandFromCommandButtons <ActionGroupCommand>(sender);
         if (command != null)
         {
             ChannelSession.Settings.ActionGroupCommands.Remove(command);
             await ChannelSession.SaveSettings();
             this.RefreshList();
         }
     });
 }
Ejemplo n.º 30
0
        public async Task <bool> Enable()
        {
            return(await SongRequestService.songRequestLock.WaitAndRelease(async() =>
            {
                if (this.IsEnabled)
                {
                    return true;
                }

                this.enabledProviders.Clear();
                foreach (ISongRequestProviderService provider in this.allProviders)
                {
                    if (ChannelSession.Settings.SongRequestServiceTypes.Contains(provider.Type))
                    {
                        if (!await provider.Initialize())
                        {
                            if (provider.Type == SongRequestServiceTypeEnum.Spotify)
                            {
                                await DialogHelper.ShowMessage("You must connect to your Spotify account in the Services area. You must also have Spotify running on your computer and you have played at least one song in the Spotify app."
                                                               + Environment.NewLine + Environment.NewLine + "This is required to be done every time to let Spotify know that where to send our song requests to.");
                            }
                            else
                            {
                                await DialogHelper.ShowMessage(string.Format("Failed to initialize the {0} service, please try again", provider.Type));
                            }
                            return false;
                        }
                        this.enabledProviders.Add(provider);
                    }
                }

                if (enabledProviders.Count() == 0)
                {
                    await DialogHelper.ShowMessage("At least 1 song request service must be enabled in the Settings menu");
                    return false;
                }

                await ChannelSession.SaveSettings();

                this.playlistSongs.Clear();

                await this.RefreshVolumeInternal();

                await this.SkipInternal();

                this.IsEnabled = true;

                return true;
            }));
        }