async void PopulateFinancialGrid() { // populate the grid _financialData = await FinancialData.GetFinancialData(); var view = new C1.Xaml.C1CollectionView(_financialData); if (!_loaded) { _financialData.AutoUpdate = false; } _flexFinancial.ItemsSource = view; view.VectorChanged += View_VectorChanged; // configure search box _srchCompanies.View = view; var props = _srchCompanies.FilterProperties; props.Add(typeof(FinancialData).GetRuntimeProperty("Name")); props.Add(typeof(FinancialData).GetRuntimeProperty("Symbol")); // show company info UpdateCompanyStatus(); UpdateCellFactory(); }
// get a default list of financial items public async static Task <FinancialDataList> GetFinancialData() { var list = new FinancialDataList(); var rnd = new Random(0); Uri resourceUri; if (typeof(FinancialData).GetTypeInfo().Module.Name.EndsWith("exe")) { resourceUri = new Uri("ms-appx:///Resources/StockSymbols.txt"); } else { resourceUri = new Uri("ms-appx:///FlexGrid101Lib/Resources/StockSymbols.txt"); } var file = await StorageFile.GetFileFromApplicationUriAsync(resourceUri); var fileStream = await file.OpenAsync(FileAccessMode.Read); using (var sr = new StreamReader(fileStream.AsStream())) { while (!sr.EndOfStream) { var sn = sr.ReadLine().Split('\t'); if (sn.Length > 1 && sn[0].Trim().Length > 0) { var data = new FinancialData(); data.Symbol = sn[0]; data.Name = sn[1]; data.Bid = rnd.Next(1, 1000); data.Ask = data.Bid + (decimal)rnd.NextDouble(); data.LastSale = data.Bid; data.BidSize = rnd.Next(10, 500); data.AskSize = rnd.Next(10, 500); data.LastSize = rnd.Next(10, 500); data.Volume = rnd.Next(10000, 20000); data.QuoteTime = DateTime.Now; data.TradeTime = DateTime.Now; list.Add(data); } } } list.AutoUpdate = true; return(list); }
// get a default list of financial items public static FinancialDataList GetFinancialData() { var list = new FinancialDataList(); var rnd = new Random(0); var asm = Assembly.GetExecutingAssembly(); foreach (string resName in asm.GetManifestResourceNames()) { if (resName.EndsWith("data.zip")) { var zip = new C1.C1Zip.C1ZipFile(asm.GetManifestResourceStream(resName)); using (var sr = new StreamReader(zip.Entries["StockSymbols.txt"].OpenReader())) { while (!sr.EndOfStream) { var sn = sr.ReadLine().Split('\t'); if (sn.Length > 1 && sn[0].Trim().Length > 0) { var data = new FinancialData(); data.Symbol = sn[0]; data.Name = sn[1]; data.Bid = rnd.Next(1, 1000); data.Ask = data.Bid + (decimal)rnd.NextDouble(); data.LastSale = data.Bid; data.BidSize = rnd.Next(10, 500); data.AskSize = rnd.Next(10, 500); data.LastSize = rnd.Next(10, 500); data.Volume = rnd.Next(10000, 20000); data.QuoteTime = DateTime.Now; data.TradeTime = DateTime.Now; list.Add(data); } } } list.AutoUpdate = true; return(list); } } throw new Exception("Can't find 'data.zip' embedded resource."); }
void PopulateFinancialGrid() { _financialData = FinancialData.GetFinancialData(); var view = new MyCollectionView(_financialData); _flexFinancial.ItemsSource = view; _flexFinancial.Columns.Frozen = 1; _flexFinancial.Columns[0].AllowDragging = false; // configure search box _srchCompanies.View = view; var props = _srchCompanies.FilterProperties; props.Add(typeof(FinancialData).GetProperty("Name")); props.Add(typeof(FinancialData).GetProperty("Symbol")); // show company info UpdateCompanyStatus(); view.CollectionChanged += financial_CollectionChanged; UpdateCellFactory(); }