Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SecurityGrid"/>.
        /// </summary>
        public SecurityGrid()
        {
            InitializeComponent();

            var itemsSource = new ObservableCollectionEx <SecurityItem>();

            ItemsSource = itemsSource;

            _securities = new ConvertibleObservableCollection <Security, SecurityItem>(new ThreadSafeObservableCollection <SecurityItem>(itemsSource), CreateItem);

            _selectedSecurities = new SelectedSecurityList(this);
        }
        /// <summary>
        /// Создать <see cref="SecurityGrid"/>.
        /// </summary>
        public SecurityGrid()
        {
            InitializeComponent();

            var itemsSource = new ObservableCollectionEx <SecurityItem>();

            //var itemsSource = new ObservableCollection<SecurityItem>();
            //itemsSource.CollectionChanged += (sender, args) =>
            //{
            //	var newCount = args.NewItems == null ? 0 : args.NewItems.Count;
            //	var oldCount = args.OldItems == null ? 0 : args.OldItems.Count;
            //	Console.WriteLine("{0:X4} ColChange={1} NewCnt={2} OldCnt={3} NewIdx={4} OldIdx={5}",
            //		GetHashCode(), args.Action, newCount, oldCount,
            //		args.NewStartingIndex, args.OldStartingIndex);
            //};
            //((INotifyPropertyChanged)itemsSource).PropertyChanged += (sender, args) =>
            //{
            //	Console.WriteLine("{0:X4} PropChange {1}", GetHashCode(), args.PropertyName);
            //};
            ItemsSource = itemsSource;

            _securities = new ConvertibleObservableCollection <Security, SecurityItem>(new ThreadSafeObservableCollection <SecurityItem>(itemsSource), CreateItem);

            _selectedSecurities = new SelectedSecurityList(this);

            MarketDataProvider = ConfigManager.TryGetService <IMarketDataProvider>();

            if (MarketDataProvider == null)
            {
                ConfigManager.ServiceRegistered += (t, s) =>
                {
                    if (MarketDataProvider != null || typeof(IMarketDataProvider) != t)
                    {
                        return;
                    }

                    MarketDataProvider = (IMarketDataProvider)s;

                    itemsSource.ForEach(item => UpdateData(item.Security, item));
                };
            }
        }