コード例 #1
0
        void PopulateFinancialGrid()
        {
            _financialData = FinancialData.GetFinancialData();
            var view = new MyCollectionView(_financialData);

            _flexFinancial.ItemsSource              = view;
            _flexFinancial.FrozenColumns            = 1;
            _flexFinancial.Columns[0].AllowDragging = false;

            // show company info
            UpdateCompanyStatus();
            view.CollectionChanged += financial_CollectionChanged;

            UpdateCellFactory();
        }
コード例 #2
0
        // 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 ZipArchive(asm.GetManifestResourceStream(resName));
                    using (var sr = new StreamReader(zip.Entries.First(e => e.Name == "StockSymbols.txt").Open()))
                    {
                        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.");
        }