// 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.");
        }
Beispiel #2
0
        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();
        }