Exemple #1
0
        private void UpdateOwnedShares()
        {
            var collection = new ObservableCollection <OwningShareDTO>();

            foreach (FundDepot depot in Depots)
            {
                foreach (string shareName in depot.Shares.Keys)
                {
                    var infos             = MarketInformation.Where(x => x.FirmName == shareName).ToList();
                    ShareInformation info = infos.FirstOrDefault();
                    if (info != null)
                    {
                        OwningShareDTO s = new OwningShareDTO()
                        {
                            ShareName    = shareName,
                            Amount       = depot.Shares[shareName],
                            StockPrice   = info.PricePerShare,
                            ExchangeName = info.ExchangeName
                        };
                        collection.Add(s);
                    }
                }
            }

            OwnedShares = collection;
        }
        public MarketMonitoringViewModel(MarketInformation marketInformation, DispatcherTimer oneSecIntervalTimer, bool history)
        {
            //установка обработчика событий изменения внутри маркета
            _marketChangeHandler = (sender, e) => RiseCurrentMarketMemberChange();

            MarketID = marketInformation.MarketId;
            Market   = marketInformation;

            //счетчик для вычесления оставшегося до старта рынка времени
            oneSecIntervalTimer.Tick += (s, e) =>
            {
                if (Market?.MarketName == null)
                {
                    TimeLeft = "no";
                }
                else
                {
                    TimeSpan dateDifference = Market.StartMarketTime.Subtract(DateTime.Now);
                    TimeLeft = dateDifference.ToString(@"hh\:mm\:ss");
                }
            };

            //в случае, если окно открыто для посмотра исторических данных,
            //запускаем событие для прорисовки данных в контроле
            //иначе - запускаем WF для мониторинга
            if (history)
            {
                RiseCurrentMarketMemberChange();
            }
            else
            {
                _marketMonitoring_ProxyModel = new MarketMonitoring_ProxyModel(Market);
            }
        }
Exemple #3
0
 private void UpdateShareInformation(ShareInformation info)
 {
     MarketInformation = new ObservableCollection <ShareInformation>(MarketInformation.Where(x => x.FirmName != info.FirmName));
     MarketInformation.Add(info);
     MarketInformation = new ObservableCollection <ShareInformation>(from i in MarketInformation orderby i.FirmName select i);
     UpdateOwnedShares();
 }
Exemple #4
0
        private MarketInformation GetMiFromXML(string filename)
        {
            MarketInformation result = default(MarketInformation);

            try
            {
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(filename);
                string xmlString = xmlDocument.OuterXml;

                using (StringReader read = new StringReader(xmlString))
                {
                    Type outType = typeof(MarketInformation);

                    XmlSerializer serializer = new XmlSerializer(outType);
                    using (XmlReader reader = new XmlTextReader(read))
                    {
                        result = (MarketInformation)serializer.Deserialize(reader);
                        reader.Close();
                    }

                    read.Close();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }

            return(result);
        }
Exemple #5
0
        private void ExecuteLoadMarketMonitoringReport()
        {
            try
            {
                //Получаем имя открываемого файла
                string filename = GetFileName();

                //Если ничего не открыли, уходим из метода
                if (filename == string.Empty)
                {
                    return;
                }

                //Десериализируем
                MarketInformation mi = GetMiFromXML(filename);

                //Создаем и показываем окно
                var vm  = new MarketMonitoringViewModel(mi, OneSecIntervalTimer, THIS_IS_HISTORY);
                var win = new MarketMonitoringWindow();
                win.DataContext = vm;
                win.Show();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Exemple #6
0
        public MainViewModel(MainModel m)
        {
            model          = m;
            _currentMarket = new MarketInformation();

            model.PropertyChanged += (sender, e) => OnPropertyChanged(e.PropertyName);

            commandDataFromDF                 = new DelegateCommand(o => CanExecuteDataFromBF(), o => ExecuteDataFromBF());
            commandClearSheet                 = new DelegateCommand(o => CanExecuteClearSheet(), o => ExecuteClearSheet());
            commandGetAccountInfo             = new DelegateCommand(o => CanExecuteGetAccountInfo(), o => ExecuteGetAccountInfo());
            commandMarketMonitor              = new DelegateCommand(o => CanExecuteMarketMonitor(), o => ExecuteMarketMonitor());
            commandLoadMarketMonitoringReport = new DelegateCommand(o => CanExecuteLoadMarketMonitoringReport(), o => ExecuteLoadMarketMonitoringReport());

            OneSecIntervalTimer = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(1000)
            };
            OneSecIntervalTimer.Tick += (s, e) =>
            {
                if (CurrentMarket?.MarketName == null)
                {
                    TimeLeft = "no";
                }
                else
                {
                    TimeSpan dateDifference = CurrentMarket.StartMarketTime.Subtract(DateTime.Now);
                    TimeLeft = dateDifference.ToString(@"hh\:mm\:ss");
                }
            };
            OneSecIntervalTimer.Start();

            Status   = "Ок.";
            Progress = 0;

            _currentMarketChangeHandler = (sender, e) => _riseCurrentMarketMemberChange();
        }
    private void UpdateOrAddShop(GetShopInfos shopInfo)
    {
        bool flag = false;

        for (int i = 0; i < this.mShopInformations.get_Count(); i++)
        {
            if (this.mShopInformations.get_Item(i).shopInfo.shopId == shopInfo.shopId)
            {
                flag = true;
                this.mShopInformations.get_Item(i).shopInfo = shopInfo;
                this.mShopInformations.get_Item(i).ResetTimeCountDown(shopInfo.remainingRefreshTime);
                break;
            }
        }
        if (!flag)
        {
            MarketInformation marketInformation = new MarketInformation();
            marketInformation.shopInfo = shopInfo;
            marketInformation.ResetTimeCountDown(shopInfo.remainingRefreshTime);
            this.mShopInformations.Add(marketInformation);
        }
        if (ShoppingUIViewModel.Instance != null && ShoppingUIViewModel.Instance.get_gameObject().get_activeSelf())
        {
            ShoppingUIViewModel.Instance.RefreshShop(shopInfo);
        }
    }
Exemple #8
0
        protected override void Execute(CodeActivityContext context)
        {
            if (_m == null)
            {
                _m = CurrentMarket.Get(context);
            }

            _m.UpdateMarket();
        }
        private void OnNewMarketInformationAvailable(ShareInformation nu)
        {
            var tmp = MarketInformation.Where(x => x.FirmName.Equals(nu.FirmName));
            var old = tmp.Count() == 0 ? null : tmp.First();

            if (old != null)
            {
                MarketInformation.Insert(MarketInformation.IndexOf(old), nu);
                MarketInformation.Remove(old);
            }
            else
            {
                MarketInformation.Add(nu);
            }
        }
        private void ExecuteMarketMonitor()
        {
            if (MarketsAreInMonitoring.ContainsKey(CurrentMarketID))
            {
                return;
            }

            MarketMonitoringWindow win = new MarketMonitoringWindow();

            MarketInformation         m  = model.MarketInformationDict[CurrentMarketID];
            MarketMonitoringViewModel vm = new MarketMonitoringViewModel(CurrentMarketID, m, OneSecIntervalTimer);

            win.DataContext = vm;

            //добавляем рынок в список окон мониторинга
            MarketsAreInMonitoring.Add(CurrentMarketID, new Tuple <MarketMonitoringWindow, MarketMonitoringViewModel>(win, vm));

            //при закрытии окна удаляем CurrentMarketID из списка мониторинга
            win.Closed += (sender, e) =>
            {
                MarketMonitoringWindow window = sender as MarketMonitoringWindow;

                string s = string.Empty;
                foreach (var item in MarketsAreInMonitoring)
                {
                    if (item.Value.Item1 != window)
                    {
                        continue;
                    }

                    s = item.Key;
                    break;
                }

                if (s == string.Empty)
                {
                    return;
                }

                MarketsAreInMonitoring[s].Item2.Dispose();
                MarketsAreInMonitoring.Remove(s);
            };

            win.Show();
        }
Exemple #11
0
        public MarketMonitoringViewModel(string marketID, MarketInformation marketInformation, DispatcherTimer oneSecIntervalTimer)
        {
            //установка обработчика событий изменения внутри маркета
            _marketChangeHandler = (sender, e) => _riseCurrentMarketMemberChange();

            MarketID            = marketID;
            _marketControlModel = new MarketControlModel(marketInformation, marketID);
            _marketControlModel.CurrentMarket.PropertyChanged += (sender, e) => Market = new MarketInformation(); //любое присвоение, просто чтобы сработало OnPropertyChanged

            oneSecIntervalTimer.Tick += (s, e) =>
            {
                if (Market?.MarketName == null)
                {
                    TimeLeft = "no";
                }
                else
                {
                    TimeSpan dateDifference = Market.StartMarketTime.Subtract(DateTime.Now);
                    TimeLeft = dateDifference.ToString(@"hh\:mm\:ss");
                }
            };
        }
Exemple #12
0
        private void dg_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataGrid dg = sender as DataGrid;

            CurrentMarket = dg.SelectedItem as MarketInformation;
        }