Exemple #1
0
        public override void OnGameSelected(OnGameSelectedEventArgs args)
        {
            try
            {
                if (args.NewValue?.Count == 1)
                {
                    Game GameSelected = args.NewValue[0];

                    List <ItemFeature> itemFeatures = IcoFeatures.GetAvailableItemFeatures(PluginSettings, GameSelected);

                    PluginSettings.Settings.HasData   = itemFeatures.Count > 0;
                    PluginSettings.Settings.DataCount = itemFeatures.Count;
                    PluginSettings.Settings.DataList  = itemFeatures;
                }
            }
            catch (Exception ex)
            {
                Common.LogError(ex, false, true, "LibraryManagement");
            }
        }
        public override void SetData(Game newContext)
        {
            List <ItemFeature> itemFeatures           = IcoFeatures.GetAvailableItemFeatures(PluginSettings, newContext);
            ObservableCollection <ItemList> itemLists = new ObservableCollection <ItemList>();

            itemLists = itemFeatures.Select(x => new ItemList {
                Name = x.NameAssociated, Icon = x.IconString
            }).ToObservable();

            if (PluginSettings.Settings.OneForSameIcon)
            {
                itemFeatures.ForEach(x =>
                {
                    string NewName = string.Empty;
                    itemLists.Where(y => x.IconString == y.Icon)?.ToList().ForEach(y =>
                    {
                        if (!y.Name.Contains(Environment.NewLine))
                        {
                            if (NewName.IsNullOrEmpty())
                            {
                                NewName = y.Name;
                            }
                            else
                            {
                                NewName += Environment.NewLine + y.Name;
                            }
                        }
                    });
                    if (!NewName.IsNullOrEmpty())
                    {
                        itemLists.Where(y => x.IconString == y.Icon)?.ToList().ForEach(y => y.Name = NewName);
                    }
                });

                itemLists = itemLists.DistinctBy(x => x.Icon).ToObservable();
            }

            ControlDataContext.CountItems  = itemLists.Count;
            ControlDataContext.ItemsSource = itemLists;
        }