Пример #1
0
        protected void LoadData()
        {
            // In this prototype, the orders will not change... but the market data will
            OrderAgreementListC records = new OrderAgreementListC();

            for (int i = 0; i < Program.NumberOfRows; i++)
            {
                OrderAgreementC orderAgreement = OrderAgreementC.GenerateRandom();
                records.Add(orderAgreement);
            }

            DataTable table = GridC.CreateDataTable(records);

            grid.BindToCurrencyManager = false;
            grid.AllowSwapDataViewWithDataTableList = true;
            grid.DataSource = table;

            symbolColumn = grid.TableDescriptor.Fields["Symbol"];
            openColumn   = grid.TableDescriptor.Fields["Opn"];
            bidColumn    = grid.TableDescriptor.Fields["Bid"];
            askColumn    = grid.TableDescriptor.Fields["Ask"];
            lastColumn   = grid.TableDescriptor.Fields["Last"];

            // Cache symbol -> records map for faster market data updates
            int count = grid.Table.Records.Count;

            for (int n = 0; n < count; n++)
            {
                Record record = grid.Table.Records[n];
                string symbol = (string)record.GetValue(symbolColumn);
                if (symbol == null)
                {
                    continue;
                }

                RecordList recordList;
                if (symbolRecordMap.ContainsKey(symbol))
                {
                    recordList = symbolRecordMap[symbol];
                }
                else
                {
                    recordList = new RecordList();
                    symbolRecordMap.Add(symbol, recordList);
                }
                recordList.Add(record);
            }
            this.grid.GridVisualStyles     = GridVisualStyles.Metro;
            this.grid.GridOfficeScrollBars = OfficeScrollBars.Metro;
            quotesUpdateDelegate           = new QuoteManagerC.QuotesUpdatedDelegate(QuotesUpdate);
        }
Пример #2
0
        public static DataTable CreateDataTable(OrderAgreementListC ocList)
        {
            DataTable table = new DataTable();

            if (ocList == null)
            {
                return(table);
            }

            OrderAgreementC record;

            if (ocList.Count == 0)
            {
                record = new OrderAgreementC();
            }
            else
            {
                record = ocList[0];
            }

            TypeSystemC.FidEnum[] recordKeys = new TypeSystemC.FidEnum[record.Count];
            record.Keys.CopyTo(recordKeys, 0);

#if SyncfusionFramework2_0
            foreach (TypeSystemC.FidEnum fid in recordKeys)
            {
#else
            for (int n = recordKeys.Length - 1; n >= 0; n--)
            {
                TypeSystemC.FidEnum fid = recordKeys[n];
#endif
                //foreach (TypeSystemC.FidEnum fid in record.Keys)
                //{
                string name = TypeSystemC.FidName(fid);
                Type   type = TypeSystemC.FidType(fid);

                DataColumn col = new DataColumn(name, type);
                table.Columns.Add(col);
            }

            foreach (OrderAgreementC oc in ocList)
            {
                object[] row = new object[oc.Count];

#if SyncfusionFramework2_0
                int i = 0;
                foreach (object o in oc.Values)
                {
                    row[i++] = o;
                }
#else
                int i = oc.Count - 1;
                foreach (object o in oc.Values)
                {
                    row[i--] = o;
                }
#endif

                table.Rows.Add(row);
            }

            return(table);
        }