private void LoadCampaigns() { //Получение кампаний из кабинета if (CampaingStack.Children.Count > 0) { CampaingStack.Children.RemoveRange(0, CampaingStack.Children.Count); } API = new VkAPI(Properties.Settings.Default.AccessToken); Refresh_Budget(); GetCampaingResponse load = API.GetCampaings(); if (load.response != null) { for (int i = 0; i < load.response.Count; i++) { System.Threading.Thread.Sleep(500); CampaingViewer viewer = new CampaingViewer(load.response[i].id); GetAdsResponse ads = API.GetAds(load.response[i].id.ToString()); viewer.Click += Choose_Camp; viewer.campaingTitle.Content = load.response[i].name; viewer.DayLim.Content = load.response[i].day_limit; viewer.AllLim.Content = load.response[i].all_limit; viewer.SetStatus(load.response[i].status); if (ads.response == null) { viewer.AdsCount.Content = "err:" + ads.error.error_code; } else { viewer.AdsCount.Content = ads.response.Count; } CampaingStack.Children.Add(viewer); } } }
private void Add_Campaing(CreateCampaingResponse response) { GetCampaingResponse add = API.GetCampaing(response.response[0].id); CampaingViewer viewer = new CampaingViewer(add.response[0].id); viewer.Click += Choose_Camp; viewer.campaingTitle.Content = add.response[0].name; viewer.DayLim.Content = add.response[0].day_limit; viewer.AllLim.Content = add.response[0].all_limit; CampaingStack.Children.Add(viewer); }