Exemple #1
0
        private void BtRemoveData_Click(object sender, RoutedEventArgs e)
        {
            tbDataLoad.Text            = resources.GetString("LOCHowLongToBeatProgressBarTag");
            pbDataLoad.IsIndeterminate = true;

            DataLoad.Visibility   = Visibility.Visible;
            spSettings.Visibility = Visibility.Hidden;

            tokenSource = new CancellationTokenSource();
            ct          = tokenSource.Token;

            var taskSystem = Task.Run(() =>
            {
                ct.ThrowIfCancellationRequested();

                HowLongToBeatData.ClearAllData(PluginUserDataPath);

                foreach (Game game in PlayniteApi.Database.Games)
                {
                    HowLongToBeatData.RemoveAllTag(PlayniteApi, game);

                    if (ct.IsCancellationRequested)
                    {
                        ct.ThrowIfCancellationRequested();
                    }
                }
            }, tokenSource.Token)
                             .ContinueWith(antecedent =>
            {
                Application.Current.Dispatcher.Invoke(new Action(() => {
                    DataLoad.Visibility   = Visibility.Collapsed;
                    spSettings.Visibility = Visibility.Visible;
                }));
            });
        }
Exemple #2
0
        // To add new main menu items override GetMainMenuItems
        public override List <MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs args)
        {
            string MenuInExtensions = string.Empty;

            if (settings.MenuInExtensions)
            {
                MenuInExtensions = "@";
            }

            List <MainMenuItem> mainMenuItems = new List <MainMenuItem>
            {
                new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCHowLongToBeat"),
                    Description = resources.GetString("LOCCommonGetAllDatas"),
                    Action      = (mainMenuItem) =>
                    {
                        HowLongToBeatData.GetAllDataFromMain(PlayniteApi, this.GetPluginUserDataPath(), settings);
                    }
                },
                new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCHowLongToBeat"),
                    Description = resources.GetString("LOCCommonClearAllDatas"),
                    Action      = (mainMenuItem) =>
                    {
                        HowLongToBeatData.ClearAllData(this.GetPluginUserDataPath(), PlayniteApi);
                    }
                },
                new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCHowLongToBeat"),
                    Description = resources.GetString("LOCCommonAddAllTags"),
                    Action      = (mainMenuItem) =>
                    {
                        HowLongToBeatData.AddAllTagFromMain(PlayniteApi, this.GetPluginUserDataPath());
                    }
                },
                new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCHowLongToBeat"),
                    Description = resources.GetString("LOCCommonRemoveAllTags"),
                    Action      = (mainMenuItem) =>
                    {
                        HowLongToBeatData.RemoveAllTagFromMain(PlayniteApi, this.GetPluginUserDataPath());
                    }
                }
            };

#if DEBUG
            mainMenuItems.Add(new MainMenuItem
            {
                MenuSection = MenuInExtensions + resources.GetString("LOCHowLongToBeat"),
                Description = "Test",
                Action      = (mainMenuItem) => { }
            });
#endif

            return(mainMenuItems);
        }