Esempio n. 1
0
        public LootBoxVM(ILootBox lootBox)
        {
            #region Commands init
            Update = new DelegateCommand(() =>
            {
                RaisePropertyChanged(nameof(Icon));

                RaisePropertyChanged(nameof(Name));

                RaisePropertyChanged(nameof(ProfitWithBundle));
                RaisePropertyChanged(nameof(ProfitWithBundleColor));

                RaisePropertyChanged(nameof(ProfitWithoutBundle));
                RaisePropertyChanged(nameof(ProfitWithoutBundleColor));

                RaisePropertyChanged(nameof(BackgroundColor));

                RaisePropertyChanged(nameof(NumItems));
                RaisePropertyChanged(nameof(NumLoadedItems));
                RaisePropertyChanged(nameof(NumErrors));
            });

            DoubleClick = new DelegateCommand(() =>
            {
                RequestsUtil.OpenInBrowser(LootBox);
            });
            #endregion

            LootBox = lootBox;

            LootBox.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == nameof(ILootBox.State))
                {
                    switch (LootBox.State)
                    {
                    case LootBoxState.NotLoaded:
                        break;

                    case LootBoxState.Queue:
                        break;

                    case LootBoxState.DescriptionLoaded:
                        RaisePropertyChanged("OnDescriptionLoaded");
                        break;

                    case LootBoxState.LoadStarted:
                        break;

                    case LootBoxState.ItemsLoaded:
                        break;

                    case LootBoxState.PricesLoaded:
                        break;
                    }

                    RaisePropertyChanged(nameof(ILootBox.State));
                    RaisePropertyChanged(nameof(BackgroundColor));
                }

                if (e.PropertyName == "OnItemLoaded")
                {
                    var item = LootBox.Items?.Last();

                    if (item != null)
                    {
                        MarketItemListVM.AddLootBox(item);
                    }

                    Update.Execute();

                    RaisePropertyChanged("OnItemLoaded");
                }

                if (e.PropertyName == "OnPriceLoaded")
                {
                    if (LootBox.Count > 0 && LootBox.Items.ToArray().Count(x => x.Price == 0) == 0)
                    {
                        if (LootBox.State != LootBoxState.PricesLoaded)
                        {
                            LootBox.State = LootBoxState.PricesLoaded;
                        }
                    }

                    Update.Execute();
                }

                if (e.PropertyName == "OnIconLoaded")
                {
                    RaisePropertyChanged(nameof(Icon));
                }
            };


            MarketItemListVM = new MarketItemListVM(this, LootBox.Items?
                                                    .Select(x => new MarketItemVM(x)));

            Update.Execute();

            if (LootBox.State >= LootBoxState.DescriptionLoaded)
            {
                RaisePropertyChanged("OnDescriptionLoaded");
            }
        }
Esempio n. 2
0
        public MainVM()
        {
            CreateTempDirectory();

            ProxyVM       = new ProxyVM();
            LootBoxListVM = new LootBoxListVM();

            LootBoxListVM.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "OnLootBoxSelected")
                {
                    if (LootBoxListVM.SelectedLootBox == null)
                    {
                        return;
                    }

                    Task.Run(async() =>
                    {
                        lootBox = LootBoxListVM.SelectedLootBox.LootBox;

                        LootBoxVM = LootBoxListVM.SelectedLootBox;

                        await Task.Delay(275);

                        RaisePropertyChanged(nameof(LootBoxVM));
                        RaisePropertyChanged(nameof(MarketItemListVM));

                        RaisePropertyChanged(nameof(Descriptions));
                    });
                }

                if (e.PropertyName == "OnItemLoaded")
                {
                    RaisePropertyChanged(nameof(LootBoxVM));
                    RaisePropertyChanged(nameof(MarketItemListVM));
                }

                if (e.PropertyName == "OnDescriptionLoaded")
                {
                    RaisePropertyChanged(nameof(Descriptions));
                }
            };

            SearchCommand = new DelegateCommand(() =>
            {
                if (LootBoxListVM.SelectedLootBox == null)
                {
                    return;
                }

                lootBox.Update();
            });

            Exit = new DelegateCommand(() =>
            {
                lock (new object())
                {
                    LootBoxListVM.Save.Execute();
                }
            });
        }
Esempio n. 3
0
 public static void OpenInBrowser(ILootBox lootBox)
 {
     Process.Start($"https://steamcommunity.com/market/listings/232090/{lootBox.Name.Replace("#", "%23")}");
 }