Inheritance: LibraryBase.Wpf.ViewModel.BindableBase, ICsvExport, ICsvImport
Beispiel #1
0
        public void BuildRecipe(HotItemController c)
        {
            this.IsExpanded = true;
            if (c.ItemIdToDataId.ContainsKey(CreatedItemId))
            {
                Name        = "loading...";
                this.DataId = c.ItemIdToDataId[CreatedItemId];
            }

            if (!IsRoot)
            {
                if (c.CreatedIdToRecipe.ContainsKey(ItemId))
                {
                    List <Recipe> tempList = new List <Recipe>();
                    for (int i = 0; i < c.CreatedIdToRecipe[ItemId].RecipeItems.Count; i++)
                    {
                        var    r      = c.CreatedIdToRecipe[ItemId].RecipeItems[i];
                        Recipe recipe = new Recipe(r.DataId, r.Quantity * this.Quantity);
                        recipe.ItemId        = r.ItemId;
                        recipe.CreatedItemId = r.CreatedItemId;
                        recipe.RecipeItems   = r.RecipeItems;
                        recipe.Name          = "loading...";
                        tempList.Add(recipe);
                    }
                    RecipeItems = new ObservableCollection <Recipe>(tempList);
                }
            }

            c.RegisterRecipeItem(this);
            for (int i = 0; i < RecipeItems.Count; i++)
            {
                RecipeItems[i].BuildRecipe(c);
            }
        }
Beispiel #2
0
 public void UnbuildRecipe(HotItemController c)
 {
     c.UnregisterRecipeItem(DataId);
     for (int i = 0; i < RecipeItems.Count; i++)
     {
         RecipeItems[i].UnbuildRecipe(c);
     }
 }
 public SettingsViewModel(HotItemController controller)
 {
     this._controller = controller;
     this._controller.GuildWars2StatusChanged += _controller_GuildWars2StatusChanged;
     if (SelectedLanguage == null && Languages.Count > 0)
     {
         SelectedLanguage = Languages[0];
     }
 }
        public MainWindowViewModel(MainWindow mainWindow)
        {
            this.MainWindow = mainWindow;
            MainWindowViewModel.Dispatcher = mainWindow.Dispatcher;

            HotItem.AddItemRequest += new EventHandler<EventArgs<HotItem>>(HotItemViewModel_AddItemRequest);
            HotItem.RemoveItemRequest += new EventHandler<EventArgs<HotItem>>(HotItemViewModel_RemoveItemRequest);

            _fileSaveProvider = new FileSaveViewModel();
            _fileSaveProvider.Filter = "CSV Files|*.csv";
            _fileSaveProvider.PathSelected += fileSave_PathSelected;

            _fileOpenProvider = new FileOpenViewModel();
            _fileOpenProvider.Filter = "CSV Files|*csv";
            _fileOpenProvider.PathSelected += _fileOpenProvider_PathSelected;

            HotItemController = new HotItemController();

            HotItemController.GuildWars2StatusChanged += HotItemController_GuildWars2StatusChanged;

            NotifiactionViewModel = new NotificationViewModel(this);

            SoldViewModel = new TransactionViewModel(this, TransactionType.Sold);
            SoldViewModel.DisplayName = "Sold Items";

            BoughtViewModel = new TransactionViewModel(this, TransactionType.Bought);
            BoughtViewModel.DisplayName = "Bought Items";

            BuyingViewModel = new TransactionViewModel(this, TransactionType.Buying);
            BuyingViewModel.DisplayName = "Buying Items";

            SellingViewModel = new TransactionViewModel(this, TransactionType.Selling);
            SellingViewModel.DisplayName = "Selling Items";

            MessageViewModel = new MessageViewModel(this);

            SettingsViewModel = new SettingsViewModel(HotItemController);
            SearchViewModel = new SearchViewModel(HotItemController, this);
            RecipeViewModel = new RecipeViewModel(HotItemController);
            ChartViewModel = new ChartViewModel(this);
            GemViewModel = new GemViewModel(this);

            LoadConfig();
            Config.IsTradingPostDataProvider = true;
            Config.FirstTimeStarted = false;
            HotItemController.Config = this.Config;
            HotItemController.StartWorker();

            //workerThread = new Thread(Worker);
            //workerThread.Start();

            //Timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, new EventHandler(timerTick), MainWindowViewModel.Dispatcher);
        }
        public SearchViewModel(HotItemController hotItemController, MainWindowViewModel mainViewModel)
        {
            ParseCategories();
            ParseRarities();
            this._mainViewModel = mainViewModel;
            this._hotItemController = hotItemController;
            this._hotItemController.GuildWars2StatusChanged += _hotItemController_GuildWars2StatusChanged;
            this._hotItemController.SearchFinished += new EventHandler<EventArgs<SearchResult>>(HotItemController_SearchFinished);

            Pager.RequestNext += Pager_RequestNext;
            Pager.RequestPrevious += Pager_RequestPrevious;
            Pager.RequestSelectPage += Pager_RequestSelectPage;
        }
        public SearchViewModel(HotItemController hotItemController, MainWindowViewModel mainViewModel)
        {
            LoadJsonFiles();

            this._mainViewModel = mainViewModel;
            this._hotItemController = hotItemController;
            this._hotItemController.GuildWars2StatusChanged += _hotItemController_GuildWars2StatusChanged;
            this._searchService.SearchFinished += HotItemController_SearchFinished;

            Pager.RequestNext += Pager_RequestNext;
            Pager.RequestPrevious += Pager_RequestPrevious;
            Pager.RequestSelectPage += Pager_RequestSelectPage;
        }
Beispiel #7
0
        public static SearchResult ParseSearchResult(IEnumerable <Item> items)
        {
            var result = new SearchResult();

            result.JsonResultType = JsonResultType.Search;

            result.Items.Clear();
            var hotItems = new List <HotItem>();

            foreach (var itemDetail in items)
            {
                var item = HotItemController.FromDataId(itemDetail.Id);
                if (item != null)
                {
                    hotItems.Add(item);
                }
            }
            HotItemController.UpdatePricesMultiple(hotItems);
            result.Items = hotItems;
            return(result);
        }
Beispiel #8
0
 public void UnbuildRecipe(HotItemController c)
 {
     c.UnregisterRecipeItem(DataId);
     for (int i = 0; i < RecipeItems.Count; i++)
     {
         RecipeItems[i].UnbuildRecipe(c);
     }
 }
Beispiel #9
0
        public void BuildRecipe(HotItemController c)
        {
            this.IsExpanded = true;
            if (c.ItemIdToDataId.ContainsKey(CreatedItemId))
            {
                Name = "loading...";
                this.DataId = c.ItemIdToDataId[CreatedItemId];
            }

            if (!IsRoot)
            {
                if (c.CreatedIdToRecipe.ContainsKey(ItemId))
                {
                    List<Recipe> tempList = new List<Recipe>();
                    for (int i = 0; i < c.CreatedIdToRecipe[ItemId].RecipeItems.Count; i++)
                    {
                        var r = c.CreatedIdToRecipe[ItemId].RecipeItems[i];
                        Recipe recipe = new Recipe(r.DataId, r.Quantity * this.Quantity);
                        recipe.ItemId = r.ItemId;
                        recipe.CreatedItemId = r.CreatedItemId;
                        recipe.RecipeItems = r.RecipeItems;
                        recipe.Name = "loading...";
                        tempList.Add(recipe);
                    }
                    RecipeItems = new ObservableCollection<Recipe>(tempList);
                }
            }

            c.RegisterRecipeItem(this);
            for (int i = 0; i < RecipeItems.Count; i++)
            {
                RecipeItems[i].BuildRecipe(c);
            }
        }
 public TransactionController(HotItemController hotItemController)
 {
     this.HotItemController = hotItemController;
 }
 public RecipeViewModel(HotItemController hotItemController)
 {
     this.HotItemController = hotItemController;
     HotItemController.RecipesLoaded += HotItemController_RecipesLoaded;
 }