async Task ExecuteLoadItemsCommand(IDataStore <Item> DataStore) { if (IsBusy) { return; } IsBusy = true; try { AllItems.Clear(); List <Item> items = await DataStore.GetItemsAsync(); foreach (var item in items) { AllItems.Add(item); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
private void OpenSettings_Click(object sender, RoutedEventArgs e) { Console.WriteLine("Opening Settings File..."); OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = System.Windows.Forms.Application.StartupPath; if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Console.WriteLine(" " + openFileDialog.FileName); SettingsFile = Settings.LoadFromFile(openFileDialog.FileName); AllItems.Clear(); foreach (Item item in SettingsFile.BasicAugments.Concat(SettingsFile.CoreAugs).Concat(SettingsFile.PrimaryWeapons).Concat(SettingsFile.Prototypes)) { AllItems.Add(item); } List <Item> removeItems = AllItems.Where((item) => item.Name == String.Empty || item.Lockable == false).ToList(); foreach (Item item in removeItems) { AllItems.Remove(item); // <-- remove placeholders and non-lockable items } SettingsPathToUse = openFileDialog.FileName; Console.WriteLine(" File Opened."); } }
protected override void UpdateContent() { AllItems.Clear(); IList <Item> all_items = FindAllItems(mSearchField, mSearchValue); foreach (Item item in all_items) { AllItems.Add(item); } SoldItems.Clear(); IList <Item> sold_items = FindSoldItems(mSearchField, mSearchValue); foreach (Item item in sold_items) { SoldItems.Add(item); } BoughtItems.Clear(); IList <Item> bought_items = FindBoughtItems(mSearchField, mSearchValue); foreach (Item item in bought_items) { BoughtItems.Add(item); } InventoriedItems.Clear(); IList <Item> inventoried_items = FindInventoriedItems(mSearchField, mSearchValue); foreach (Item item in inventoried_items) { InventoriedItems.Add(item); } }
void Load() { cbNode.Items.Clear(); AllItems.Clear(); lvChilds.ItemsSource = SelectedChildLinks; lvVariants.ItemsSource = Variants; cbNode.Items.Add("Add new..."); foreach (var node in knowlegeBaseManager.Base.Nodes) { AllItems.Add(new ContentControl() { Content = node.Id.ToString(), Tag = node.Id }); } foreach (var node in knowlegeBaseManager.Base.Nodes) { cbNode.Items.Add(new ContentControl() { Content = node.Id.ToString(), Tag = node.Id }); } cbNode.SelectedIndex = 0; tbVariantTitle.Clear(); tbVariantlinkname.Clear(); }
protected override void OnVehicleSelected() { AttentionItems.Clear(); AllItems.Clear(); var svc = Infrastructure.Container.GetInstance <IVtsWebService>(); try { List <VehicleEventViewModel> vms = svc.GetVehicleEvents(SelectedVehicle.Vin). Select(VehicleEventAssembler.FromDtoToDomainObject). Select(v => new VehicleEventViewModel(v, SelectedVehicle.Model)). ToList(); foreach (VehicleEventViewModel viewModel in vms.OrderByDescending(v => v.Date)) { AllItems.Add(viewModel); if (RequiresAttention(viewModel, vms)) { AttentionItems.Add(viewModel); } } } catch (Exception e) { ErrorWindow w = new ErrorWindow(e, "Cannot get vehicle events"); w.ShowDialog(); Log.Error(e, "Cannot get vehicle events"); } finally { StopWaiting(); } }
public async void GetWeather(string text) { Windows.Data.Json.JsonObject total_json = await service.GetWeatherItem(text); if (total_json == null) { MessageDialog dialog = new MessageDialog("搜索不到相关城市信息\n请检查输入是否无误"); await dialog.ShowAsync(); return; } StringBuilder message = new StringBuilder(""); if (total_json.GetNamedNumber("showapi_res_code") != 0) { message.AppendLine(total_json.GetNamedString("showapi_res_error")); MessageDialog dialog = new MessageDialog(message.ToString()); await dialog.ShowAsync(); } else { json = total_json.GetNamedObject("showapi_res_body"); current_item.Area = json.GetNamedObject("cityInfo").GetNamedString("c9") + json.GetNamedObject("cityInfo").GetNamedString("c7") + "省" + json.GetNamedObject("cityInfo").GetNamedString("c3") + "市"; current_item.Json = json.GetNamedObject("now"); AllItems.Clear(); for (int i = 1; i <= 7; i++) { AllItems.Add(new WeatherItem(json.GetNamedObject("f" + i))); } } }
private static void LoadItems() { try { string json = File.ReadAllText(DataFilePath); _dataFileMD5 = json.Md5Sum(); Dictionary <string, object> data = Json.Deserialize(json) as Dictionary <string, object>; AllItems.Clear(); string error; foreach (KeyValuePair <string, object> pair in data) { if (pair.Key.StartsWith(GDEConstants.SchemaPrefix)) { continue; } AddItem(pair.Key, pair.Value as Dictionary <string, object>, out error); } ItemsNeedSave = false; } catch (Exception ex) { Debug.LogException(ex); } }
public void LoadFirstPage() { LastSearch = string.Empty; CurrentPage = 1; AllItems.Clear(); IsLoading = true; DoLoad(); }
/// <summary> /// Clear all child nodes and attributes from this node. /// Deriving classes should override this and clear their stuff, /// but call base.Clear() within. /// </summary> public virtual void Clear() { Attribs.Clear(); Children.Clear(); Unknown.Clear(); AllItems.Clear(); Name = ""; }
public void Clear() { lock (_lock) { AllItems.Clear(); SingleItems.Clear(); RepeatedItems.Clear(); } }
public void LoadSearch(string text) { SearchCount++; LastSearch = text; CurrentPage = 1; AllItems.Clear(); IsLoading = true; DoLoad(); }
public Task LoadFirstPageAsync() { LastSearch = string.Empty; CurrentPage = 0; HasMoreData = true; AllItems.Clear(); IsLoading = true; return(DoLoadAsync()); }
public Task LoadItemsAsync(string text) { LastSearch = text; CurrentPage = 0; HasMoreData = true; AllItems.Clear(); IsLoading = true; return(DoLoadAsync()); }
private async Task DoLoadAsync() { IsBusy = true; bool couldLoad = false; try { // Need to define the action to call var data = await LoadPageFromNetworkAsync(); foreach (T item in data) { AllItems.Add(item); } couldLoad = true; DataLocation = DataLoadLocation.RemoteService; } catch (Exception e) { HandleLoadException(e); couldLoad = false; } if (!couldLoad) { DataLocation = DataLoadLocation.Cache; try { AllItems.Clear(); var data = await LoadDataFromCacheAsync(); foreach (T item in data) { AllItems.Add(item); } HasMoreData = false; } catch (Exception e) { HandleLoadException(e); } DataLocation = DataLoadLocation.Cache; } UpdateOfflineIndicator(); IsBusy = false; IsLoading = false; }
protected override void Search() { new ChildWindow(new SearchViewModel(this), 300, 220).ShowDialog(); AllItems.Clear(); System.Collections.Generic.List <SupplierViewModel> results = this.Create(_repository.GetSupplier(_fieldName, _searchValue)); for (int i = 0; i < results.Count; i++) { AllItems.Add(results[i]); } _fieldName = _searchValue = null; }
private void HandleInventoryUpdate(Action callback) { AllItems.Clear(); AllItems.AddRange(VirtualItems); AllItems.AddRange(Subscriptions); UpdateVirtualCurrencyBalanceEvent?.Invoke(Balance); UpdateItemsEvent?.Invoke(VirtualItems); UpdateSubscriptionsEvent?.Invoke(Subscriptions); RefreshEvent?.Invoke(); callback?.Invoke(); }
public static void ClearAll() { AllItems.Clear(); AllSchemas.Clear(); ListByFieldName.Clear(); ItemListBySchema.Clear(); FilterSchemaKeyArray = null; SchemaKeyArray = null; ItemsNeedSave = true; SchemasNeedSave = true; }
private async Task UpdateReportsAsync() { var allReport = await _incidentService.GetAllAsync(); AllItems.Clear(); if (allReport != null && allReport.Any()) { foreach (var report in allReport.Where(x => x.IsUploaded)) { AllItems.Add(report); } } FilterItems(); }
public bool LoadReportItems() { AllItems.Clear(); DataSources.Clear(); var service = Service; var rootItem = new ReportItem { Name = "/", Path = "/", ItemType = ItemTypeEnum.Unknown }; RootItem = rootItem; return(LoadReportItems(service, rootItem)); }
private void PreviewItems(string entity, string action, string channel) { if (AllItems == null) { return; } AllItems.Clear(); var httpWebRequest = (HttpWebRequest)WebRequest.Create(MainModel.UrlBase + entity + "/" + action + "/" + channel); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "GET"; var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); int found = 0; int added = 0; using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { var data = streamReader.ReadToEnd(); var items = JsonConvert.DeserializeObject <List <NoteEntity> >(data); foreach (var item in items) { found++; if (!File.Exists(BasePath + item.RowKey)) { // File.WriteAllText(BasePath + item.Title, item.Content); File.WriteAllText(BasePath + item.RowKey, item.Content); added++; } item.Content = string.Empty; // File.WriteAllText(BasePath + item.RowKey + ".meta", JsonConvert.SerializeObject(item)); AllItems.Add(new MyItem() { Author = item.Author, Name = item.Title, Key = item.RowKey, Synced = DateTime.Now, Label = string.Empty }); } } FilterNotes(string.Empty); StatusBartextBlock.Text = "Found " + added + " new items from " + found; }
private void UpdateAll() { //Fetch from DB var items = new[] { new Item { Id = 1, Name = "Item 1", Approver = "Lance" }, new Item { Id = 2, Name = "Item 2", Approver = "John" } }; AllItems.Clear(); foreach (var item in items) { AllItems.Add(item); } }
async Task ExecuteLoadItemsCommand(IDataStore <Item> DataStore) { try { AllItems.Clear(); List <Item> items = await DataStore.GetItemsAsync(); foreach (var item in items) { AllItems.Add(item); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { } }
public void ClearItems() { AllItems.Clear(); Items.Clear(); }