Exemple #1
0
        private ChartItemCollection CreateCollection(string id, IEnumerable <ChartItem> chartItems, IEnumerable <ChartItem> chartItems2, ChartItemType type, IPen pen1, IPen pen2, IPen[] otherPens)
        {
            CollectionId        cId  = new CollectionId(id);
            ChartItemCollection coll = CreateSingleStockCollection(type, chartItems, chartItems2, cId, pen1, pen2, otherPens);

            return(coll);
        }
Exemple #2
0
        private ChartItemCollection CreateCollection(string id, IEnumerable <ChartItem> chartItems, ChartItemType type, IPen pen1, IPen pen2)
        {
            CollectionId        cId  = new CollectionId(id);
            ChartItemCollection coll = CreateChartItemCollection(type, chartItems, cId, pen1, pen2);

            return(coll);
        }
Exemple #3
0
        private void Update(EvaluationContext context)
        {
            var search         = Search.GetValue(context);
            var collectionId   = CollectionId.GetValue(context);
            var triggerRequest = TriggerRequest.GetValue(context);

            if (triggerRequest && (search != _searchQuery || collectionId != _collectionId))
            {
                TriggerRequest.Value = false;
                TriggerRequest.TypedInputValue.Value = false;
                TriggerRequest.DirtyFlag.Invalidate();
                _maxResultCount = MaxResultCount.GetValue(context);
                _apiToken       = ApiToken.GetValue(context);
                _searchQuery    = search;
                _collectionId   = collectionId;
                _request        = SearchImagesTask();
            }

            var photoIndex = GetPhotoIndex.GetValue(context);

            if (photoIndex != _photoIndex)
            {
                _photoIndex = photoIndex;
                if (_photos != null && _photos.Count != 0)
                {
                    var index = Math.Abs(_photoIndex) % _photos.Count;
                    PhotoAuthor.Value = _photos[index].User.Name;
                    PhotoUrl.Value    = _photos[index].Urls.Regular;
                    Log.Debug($"Update photo properties: Author {PhotoAuthor.Value}   Url {PhotoUrl.Value}");
                }
            }
        }
Exemple #4
0
        private ChartItemCollection CreateCollection(string id, IEnumerable <ChartItem>[] chartItemsList, IPen[] pens)
        {
            CollectionId        cId  = new CollectionId(id);
            ChartItemCollection coll = CreateMultipleItemCollection(chartItemsList, cId, pens);

            return(coll);
        }
Exemple #5
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((CollectionId.GetHashCode() * 397) ^ Key.GetHashCode());
     }
 }
Exemple #6
0
        public ChartItemCollection CreateCollection(ChartItemType type, IPen pen1, IPen pen2)
        {
            //if (currentStock == null)
            {
                if (type != ChartItemType.Timely && type != ChartItemType.TimelyVolumn && type != ChartItemType.TimelyAverage)
                {
                    currentStock = LoadStock(shareId);
                }
                else
                {
                    currentStock = LoadMinStock(shareId, type == ChartItemType.TimelyAverage);
                }

                if (Stock.IsNullOrEmpty(currentStock))
                {
                    return(null);
                }
            }


            CollectionId id = new CollectionId(currentStock.id, GetMarketId());

            var chartItems           = CreateChartItemFromStock(currentStock, type);
            ChartItemCollection coll = CreateChartItemCollection(type, chartItems, id, pen1, pen2);

            return(coll);
        }
Exemple #7
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="id">集合ID。</param>
        /// <param name="items">数据列表。</param>
        /// <param name="pens">画笔数组。</param>
        /// <param name="settings">时刻,时间段,交易数设置。</param>
        public SymmetricMultipleChartItemCollection(CollectionId id, IEnumerable <MultipleChartItem> items, IPen[] pens, SymmetricCommonSettings settings)
            : base(id, items, pens)
        {
            sValue            = valueNA;
            FixedVisibleCount = settings.TradingCount;
            IsScalesOptimized = false;

            Settings = settings;
        }
Exemple #8
0
        /// <summary>
        /// 构造函数。
        /// </summary>
        /// <param name="id">集合ID。</param>
        /// <param name="items">数据集合列表。</param>
        /// <param name="penRaise">上升画笔。<see cref="DrawingObjectFactory.CreatePen(Brush, double)"></see></param>
        /// <param name="penFall">下降画笔。<see cref="DrawingObjectFactory.CreatePen(Brush, double)"></see></param>
        /// <param name="settings">时刻,时间段,交易数设置。</param>
        public SymmetricVolumnItemCollection(CollectionId id, IEnumerable <VolumnItem> items, IPen penRaise, IPen penFall, SymmetricCommonSettings settings)
            : base(id, items, penRaise, penFall, false)
        {
            FixedVisibleCount = settings.TradingCount;
            VolumnItemStyle   = VolumnItemStyle.Slim;

            IsScalesOptimized = false;

            Settings = settings;
        }
Exemple #9
0
        /// <summary>
        /// 构造函数。
        /// </summary>
        /// <param name="id">集合ID。</param>
        /// <param name="items">数据集合列表。</param>
        /// <param name="penRaise">上升画笔。<see cref="DrawingObjectFactory.CreatePen(Brush, double)"></see></param>
        /// <param name="penFall">下降画笔。<see cref="DrawingObjectFactory.CreatePen(Brush, double)"></see></param>
        /// <param name="isItemDynamic">是否动态加载数据集合中的数据项。缺省值是false,表示不动态加载。</param>
        public VolumnItemCollection(CollectionId id, IEnumerable <VolumnItem> items, IPen penRaise, IPen penFall, bool isItemDynamic = false)
            : base(id, items, penRaise, null, false, isItemDynamic)
        {
            if (penFall == null)
            {
                throw new ArgumentNullException("penFall");
            }

            FallPen = penFall;
        }
        /// <summary>
        /// 构造函数。
        /// </summary>
        /// <param name="id">集合ID。</param>
        /// <param name="items">数据项列表。</param>
        /// <param name="penRaise">上升画笔。<see cref="DrawingObjectFactory.CreatePen(Brush, double)"/></param>
        /// <param name="penFall">下降画笔。<see cref="DrawingObjectFactory.CreatePen(Brush, double)"/></param>
        /// <param name="fill">填充画刷。</param>
        /// <param name="isItemDynamic">是否动态加载数据集合中的数据项。缺省值是false,表示不动态加载。</param>
        public StockItemCollection(CollectionId id, IEnumerable <StockItem> items, IPen penRaise, IPen penFall, Brush fill, bool isItemDynamic = false)
            : base(id, items, penRaise, fill, false, isItemDynamic)
        {
            if (penFall == null)
            {
                throw new ArgumentNullException("penFall");
            }

            RaisePen = penRaise;
            FallPen  = penFall;
        }
Exemple #11
0
        /// <summary>
        /// 构造函数。
        /// </summary>
        /// <param name="id">集合ID。</param>
        /// <param name="items">数据集合列表。</param>
        /// <param name="pen">画笔</param>
        /// <param name="fill">填充颜色,暂时不用</param>
        /// <param name="settings">时刻,时间段,交易数设置。</param>
        public SymmetricChartItemCollection(CollectionId id, IEnumerable <ChartItem> items, IPen pen, Brush fill, SymmetricCommonSettings settings)
            : base(id, items, pen, fill)
        {
            sValue            = valueNA;
            FixedVisibleCount = settings.TradingCount;
            IsScalesOptimized = false;

            StartDate = DateTime.Now;

            Settings = settings;
        }
Exemple #12
0
        /// <summary>
        /// 构造函数。
        /// </summary>
        /// <param name="id">ID。</param>
        /// <param name="items">多值数据项列表。<see cref="MultipleChartItem"/></param>
        /// <param name="pens">画笔数组。<see cref="IPen"/> <see cref="DrawingObjectFactory.CreatePen(Brush, double)"/></param>
        /// <param name="isItemConnected">数据集合中点之间的连接线是否需要绘制。缺省值是true,表示绘制。</param>
        /// <param name="isItemDynamic">是否动态加载数据集合中的数据项。缺省值是false,表示不动态加载。</param>
        public MultipleChartItemCollection(CollectionId id, IEnumerable <MultipleChartItem> items, IPen[] pens, bool isItemConnected = true, bool isItemDynamic = false)
            : base(id, items, (pens != null && pens.Length != 0 ? pens[0] : null), null, isItemConnected, isItemDynamic)
        {
            if (pens != null && pens.Length > 1)
            {
                Pens = new IPen[pens.Length - 1];

                for (int i = 1; i < pens.Length; i++)
                {
                    Pens[i - 1] = CopyPen(pens[i], PenLineCap.Round);
                }
            }
        }
Exemple #13
0
        public StockValuesItemCollection CreateSingleStockCollection(IPen pen1, IPen pen2, IPen contrastPen)
        {
            var itemList = CreateSingleStockItemList();

            if (itemList != null)
            {
                CollectionId id = new CollectionId(shareId, GetMarketId());
                StockValuesItemCollection collection = new StockValuesItemCollection(id, itemList, pen1, pen2, null, new IPen[] { contrastPen });
                return(collection);
            }

            return(null);
        }
Exemple #14
0
        public StockValuesItemCollection(CollectionId id, IEnumerable <StockValuesItem> items, IPen penRaise, IPen penFall, Brush fill, IPen[] pens, bool isItemDynamic = false)
            : base(id, items, penRaise, penFall, fill, isItemDynamic)
        {
            if (pens != null && pens.Length >= 1)
            {
                Pens = new IPen[pens.Length];

                for (int i = 0; i < pens.Length; i++)
                {
                    Pens[i] = CopyPen(pens[i], PenLineCap.Round);
                }
            }
        }
        private void CreateChartView2(IEnumerable <Stock> stocks, string marketId)
        {
            ChartItemCollection main = null;

            foreach (var stock in stocks)
            {
                var        closeList = new List <ChartItem>();
                CandleData cdPre     = stock.Items.FirstOrDefault();
                foreach (var cd in stock.Items)
                {
                    closeList.Add(new ChartItem()
                    {
                        Value       = cd.close,
                        Date        = cd.DateTime,
                        ValueChange = (cd.close - cdPre.close) / cdPre.close
                    });

                    cdPre = cd;
                }

                IPen pen;
                if (main == null)
                {
                    pen = raisePen;
                }
                else
                {
                    pen = fallPen;
                }

                CollectionId        id   = new CollectionId(stock.id, marketId);
                ChartItemCollection coll = new ChartItemCollection(id, closeList, pen, null, true, isDynamic);

                if (main == null)
                {
                    main = coll;

                    price.SetMainCollection(coll);
                }
                else
                {
                    price.AddAssistCollection(coll, true);
                }
            }

            price.YScaleDock  = YScaleDock.Left;
            volumn.YScaleDock = YScaleDock.Left;
            price.AddConnection(volumn);

            price.ForceDraw();
        }
Exemple #16
0
        private void BuildInMemoryIndex(ulong docId, long keyId, VectorNode index, IEnumerable <string> tokens)
        {
            var count = 0;

            using (var vectorStream = SessionFactory.CreateAppendStream(
                       Path.Combine(SessionFactory.Dir, string.Format("{0}.{1}.vec", CollectionId.ToHash(), keyId))))
            {
                foreach (var token in tokens)
                {
                    index.Add(new VectorNode(token, docId), vectorStream);
                    count++;
                }
            }
        }
Exemple #17
0
        public ChartItemCollection CreateStatisticCollection(IPen pen)
        {
            var mb = GetMarketBoardFromId();

            if (mb == MarketBoard.Unknown)
            {
                return(null);
            }

            var          statisticList = LoadStatistic(mb);
            var          chartItems    = CreateChartItemFromSZStatistic(statisticList);
            CollectionId id            = new CollectionId(currentStock.id, GetMarketId());

            return(new ChartItemCollection(id, chartItems, pen, null, true));
        }
        public void CreateCurve()
        {
            string id = "000001";
            //Load chart items
            IList <ChartItem> chartItems = loader.GetChartItems(id);
            //Create collection id
            CollectionId collId = new CollectionId(id);

            //Create pen
            IPen pen = DrawingObjectFactory.CreatePen(Brushes.Black, 1);
            //Create chart item collection
            ChartItemCollection collection = new ChartItemCollection(collId, chartItems, pen, null);

            //Set main collection
            priceControl.SetMainCollection(collection);
        }
Exemple #19
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = CollectionId.GetHashCode();
         hashCode = (hashCode * 397) ^ CreatedAt.GetHashCode();
         hashCode = (hashCode * 397) ^ DiscountAmount.GetHashCode();
         hashCode = (hashCode * 397) ^ (DiscountType != null ? DiscountType.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Id.GetHashCode();
         hashCode = (hashCode * 397) ^ (Images != null ? Images.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ ProductId.GetHashCode();
         hashCode = (hashCode * 397) ^ ShopifyProductId.GetHashCode();
         hashCode = (hashCode * 397) ^ (SubscriptionDefaults != null ? SubscriptionDefaults.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Title != null ? Title.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ UpdatedAt.GetHashCode();
         return(hashCode);
     }
 }
Exemple #20
0
        public ChartItemCollection CreateEmptyTimeCollection(ChartItemType type, IPen pen1, IPen pen2, out StockTradeDetails std)
        {
            std = null;

            Stock s = null;

            if (type == ChartItemType.Timely)
            {
                s   = LoadStock(shareId);
                std = LoadDetailDatas();
                if (Stock.IsNullOrEmpty(s))
                {
                    return(null);
                }
            }

            CollectionId        id   = new CollectionId(shareId, GetMarketId());
            ChartItemCollection coll = null;

            switch (type)
            {
            case ChartItemType.Timely:
                var tColl = new SymmetricChartItemCollection(id, null, pen1, null, SymmetricCommonSettings.CNSettings2);
                tColl.StartValue = s.Items.Last().close;
                coll             = tColl;
                break;

            case ChartItemType.TimelyAverage:
                coll = new SymmetricChartItemCollection(id, null, pen1, null, SymmetricCommonSettings.CNSettings2);
                break;

            case ChartItemType.TimelyVolumn:
                coll = new SymmetricVolumnItemCollection(id, null, pen1, pen2, SymmetricCommonSettings.CNSettings2);
                break;

            default:
                break;
            }

            return(coll);
        }
Exemple #21
0
        public IEnumerable <ChartItemCollection> CreateMVCollections()
        {
            for (int i = mvStart; i < mvStart + mvCount; i++)
            {
                var maPeriod = mvUnits[i];
                var ma60     = currentStock.MA(maPeriod);

                List <ChartItem> mv60Items = new List <ChartItem>(ma60.Count);
                for (int j = 0; j < ma60.Count; j++)
                {
                    mv60Items.Add(new ChartItem()
                    {
                        Value = ma60[j], Date = currentStock.Data[j + maPeriod - 1].DateTime
                    });
                }

                var id = new CollectionId(currentStock.id, GetMarketId());
                ChartItemCollection collMa60 = new ChartItemCollection(id, mv60Items, DrawingObjectFactory.CreatePen(mvBrushs[i], 1), null, true, false);
                yield return(collMa60);
            }
        }
Exemple #22
0
        public IEnumerable <ChartItemCollection> CreateMACollections(List <StockItem> chartItems, int mvStart = 0)
        {
            for (int i = mvStart; i < mvStart + mvCount; i++)
            {
                var maPeriod = mvUnits[i];
                var maData   = MA(maPeriod, chartItems);

                List <ChartItem> mvItems = new List <ChartItem>(maData.Count);
                for (int j = 0; j < maData.Count; j++)
                {
                    mvItems.Add(new ChartItem()
                    {
                        Value = maData[j], Date = chartItems[j + maPeriod - 1].Date
                    });
                }

                var id = new CollectionId(maPeriod.ToString());
                ChartItemCollection collMa = new ChartItemCollection(id, mvItems, DrawingObjectFactory.CreatePen(mvBrushs[i], 1), null, true, false);
                yield return(collMa);
            }
        }
Exemple #23
0
        public MultipleChartItemCollection CreateMultipleStatisticCollection()
        {
            const int size = 4;

            CollectionId id = new CollectionId("AveragePE", "SZ");

            var mItemList = CreateMultipleChartItemList(size);

            Brush[] brushes = new Brush[size] {
                Brushes.Black, Brushes.Red, Brushes.Blue, Brushes.Yellow
            };
            IPen[] pens = new IPen[brushes.Length];

            for (int i = 0; i < brushes.Length; i++)
            {
                pens[i] = DrawingObjectFactory.CreatePen(brushes[i], 1);
            }

            MultipleChartItemCollection coll = new MultipleChartItemCollection(id, mItemList, pens, true);

            return(coll);
        }
        public void CreateCandle()
        {
            string id = "000001";
            //Load chart items
            StockVolumnList svList = loader.GetStockItems(id);
            //Create collection id
            CollectionId collId = new CollectionId(id);
            //Create pens
            IPen raisePen = DrawingObjectFactory.CreatePen(Brushes.Red, 1);
            IPen fallPen  = DrawingObjectFactory.CreatePen(Brushes.Green, 1);
            //Create stock item collection
            StockItemCollection stockColl = new StockItemCollection(collId, svList.Prices, raisePen, fallPen, null);

            //Set main collection
            priceControl.SetMainCollection(stockColl);
            //Create volumn item collection
            VolumnItemCollection volumnColl = new VolumnItemCollection(collId, svList.Volumns, raisePen, fallPen);

            //Set main collection
            volumnControl.SetMainCollection(volumnColl);
            //Connect two controls
            priceControl.AddConnection(volumnControl);
        }
        private void CreateChartView(Stock stock, string marketId)
        {
            if (stock != null)
            {
                var closeList = stock.Items.Select(cd => new ChartItem()
                {
                    Value = cd.close, Date = cd.DateTime
                }).ToList();
                CollectionId        id   = new CollectionId(stock.id, marketId);
                ChartItemCollection coll = new ChartItemCollection(id, closeList, raisePen, null, true, isDynamic);

                price.SetMainCollection(coll);

                for (int i = mvStart; i < mvStart + mvCount; i++)
                {
                    var maPeriod = mvUnits[i];
                    var ma60     = stock.MA(maPeriod);

                    List <ChartItem> mv60Items = new List <ChartItem>(ma60.Count);
                    for (int j = 0; j < ma60.Count; j++)
                    {
                        mv60Items.Add(new ChartItem()
                        {
                            Value = ma60[j], Date = stock.Data[j + maPeriod - 1].DateTime
                        });
                    }

                    id = new CollectionId(stock.id, marketId);
                    ChartItemCollection collMa60 = new ChartItemCollection(id, mv60Items,
                                                                           DrawingObjectFactory.CreatePen(mvBrushs[i], 1), null, true, isDynamic);

                    price.AddAssistCollection(collMa60);
                }

                price.ForceDraw();
            }
        }
        private void CreateChartViewInMultipleChartItemCollectionPercentage(List <Stock> stocks, string marketId)
        {
            if (stocks != null)
            {
                var multItemList = CreateFrom(stocks);

                CollectionId id   = new CollectionId(stocks.FirstOrDefault().id, marketId);
                List <IPen>  pens = new List <IPen>();
                pens.Add(DrawingObjectFactory.CreatePen(Brushes.Black, 1));
                pens.AddRange(mvBrushs.Skip(mvStart).Take(mvCount).Select(mvBrush => DrawingObjectFactory.CreatePen(mvBrush, 1)));
                MultipleChartItemCollection multipleColl = new MultipleChartItemCollection(id, multItemList, pens.ToArray(), true, false);
                price.SetMainCollection(multipleColl);
            }
            else
            {
                price.SetMainCollection(null);
                volumn.SetMainCollection(null);
            }
            price.YScaleDock  = YScaleDock.Right;
            volumn.YScaleDock = YScaleDock.Right;
            price.AddConnection(volumn);

            price.ForceDraw();
        }
Exemple #27
0
        public async Task Write(IndexingJob job)
        {
            try
            {
                var timer = new Stopwatch();
                timer.Start();

                var docCount = 0;

                foreach (var doc in job.Documents)
                {
                    docCount++;

                    await Write(doc);
                }

                _log.Log(string.Format("build in-memory index from {0} docs in {1}", docCount, timer.Elapsed));

                await Serialize();

                var collectionId = CollectionId.ToHash();

                foreach (var index in _dirty)
                {
                    SessionFactory.Publish(collectionId, index.Key, index.Value);
                }

                _log.Log(string.Format("indexed {0} docs in {1}", docCount, timer.Elapsed));
            }
            catch (Exception ex)
            {
                _log.Log(ex);

                throw;
            }
        }
        public void CreateTime()
        {
            string id = "600100";

            StockVolumnList svList = timeLoader.GetStockItems(id);

            //Create collection id
            CollectionId collId = new CollectionId(id);
            //Create pens
            IPen raisePen = DrawingObjectFactory.CreatePen(Brushes.Red, 1);
            IPen fallPen  = DrawingObjectFactory.CreatePen(Brushes.Green, 1);
            //Create stock item collection
            SymmetricChartItemCollection stockColl = new SymmetricChartItemCollection(collId, svList.Prices, raisePen, null, SymmetricCommonSettings.CNSettings);

            //Set main collection
            priceControl.SetMainCollection(stockColl);
            //Create volumn item collection
            SymmetricVolumnItemCollection volumnColl = new SymmetricVolumnItemCollection(collId, svList.Volumns, raisePen, fallPen, SymmetricCommonSettings.CNSettings);

            //Set main collection
            volumnControl.SetMainCollection(volumnColl);
            //Connect two controls
            priceControl.AddConnection(volumnControl);
        }
 private ChartItemCollection CreateCollection(string id, IEnumerable<ChartItem> chartItems, ChartItemType type, IPen pen1, IPen pen2)
 {
     CollectionId cId = new CollectionId(id);
     ChartItemCollection coll = CreateChartItemCollection(type, chartItems, cId, pen1, pen2);
     return coll;
 }
 private ChartItemCollection CreateTimeMACollection(List<ChartItem> cItems, string id)
 {
     CollectionId cId = new CollectionId(id);
     return CreateChartItemCollection(ChartItemType.Time, cItems, cId, DrawingObjectFactory.CreatePen(model.FallBrush, 1), null);
 }
        private ChartItemCollection CreateSingleStockCollection(ChartItemType type, IEnumerable<ChartItem> chartItems, IEnumerable<ChartItem> chartItems2, CollectionId id, IPen pen1, IPen pen2, IPen[] otherPens)
        {
            List<StockValuesItem> ssItems = new List<StockValuesItem>(chartItems.Count());

            var it = chartItems2.GetEnumerator();
            
            foreach (var cItem in chartItems)
            {
                it.MoveNext();
                var sItem = cItem as StockItem;
                StockValuesItem ssItem = new StockValuesItem()
                {
                    Date = sItem.Date,
                    High = sItem.High,
                    Low = sItem.Low,
                    Open = sItem.Open,
                    Close = sItem.Close,
                    CloseChange = sItem.CloseChange,
                    Values = new List<double>(new double[] { it.Current.Value }),
                    ValueChanges = new List<double>(new double[] { it.Current.ValueChange })
                };

                ssItems.Add(ssItem);
            }
            var coll = new StockValuesItemCollection(id, ssItems, pen1, pen2, null, otherPens);
            
                
            return coll;
        }
 private ChartItemCollection CreateChartItemCollection(ChartItemType type, IEnumerable<ChartItem> chartItems, CollectionId id, IPen pen1, IPen pen2)
 {
     ChartItemCollection coll = null;
     if (type == ChartItemType.Linear)
     {
         coll = new ChartItemCollection(id, chartItems, pen1, null, true);
     }
     else if (type == ChartItemType.Candle)
     {
         coll = new StockItemCollection(id, chartItems.OfType<StockItem>(), pen1, pen2, null);
     }
     else if (type == ChartItemType.Volumn)
     {
         coll = new VolumnItemCollection(id, chartItems.OfType<VolumnItem>(), pen1, pen2);
     }
     else if (type == ChartItemType.Time)
     {
         coll = new SymmetricChartItemCollection(id, chartItems, pen1, null, SymmetricCommonSettings.CNSettings2);
     }
     else if (type == ChartItemType.TimeVolumn)
     {
         coll = new SymmetricVolumnItemCollection(id, chartItems != null ? chartItems.OfType<VolumnItem>() : null, pen1, pen2, SymmetricCommonSettings.CNSettings2);
     }
     return coll;
 }
 public Task Verify(CollectionId id, IMediator mediator) {
     return _controller.Install(FindCollection(id), mediator);
 }
 public Task Launch(CollectionId id, IMediator mediator) {
     return _controller.Launch(new[] {FindCollection(id)}, mediator);
 }
 private ChartItemCollection CreateCollection(string id, IEnumerable<ChartItem> chartItems, IEnumerable<ChartItem> chartItems2, ChartItemType type, IPen pen1, IPen pen2, IPen[] otherPens)
 {
     CollectionId cId = new CollectionId(id);
     ChartItemCollection coll = CreateSingleStockCollection(type, chartItems, chartItems2, cId, pen1, pen2, otherPens);
     return coll;
 }
 private ChartItemCollection CreateCollection(string id, IEnumerable<ChartItem>[] chartItemsList, IPen[] pens)
 {
     CollectionId cId = new CollectionId(id);
     ChartItemCollection coll = CreateMultipleItemCollection(chartItemsList, cId, pens);
     return coll;
 }
Exemple #37
0
        private ChartItemCollection CreateSingleStockCollection(ChartItemType type, IEnumerable <ChartItem> chartItems, IEnumerable <ChartItem> chartItems2, CollectionId id, IPen pen1, IPen pen2, IPen[] otherPens)
        {
            List <StockValuesItem> ssItems = new List <StockValuesItem>(chartItems.Count());

            var it = chartItems2.GetEnumerator();

            foreach (var cItem in chartItems)
            {
                it.MoveNext();
                var             sItem  = cItem as StockItem;
                StockValuesItem ssItem = new StockValuesItem()
                {
                    Date         = sItem.Date,
                    High         = sItem.High,
                    Low          = sItem.Low,
                    Open         = sItem.Open,
                    Close        = sItem.Close,
                    CloseChange  = sItem.CloseChange,
                    Values       = new List <double>(new double[] { it.Current.Value }),
                    ValueChanges = new List <double>(new double[] { it.Current.ValueChange })
                };

                ssItems.Add(ssItem);
            }
            var coll = new StockValuesItemCollection(id, ssItems, pen1, pen2, null, otherPens);


            return(coll);
        }
        private ChartItemCollection CreateMultipleItemCollection(IEnumerable<ChartItem>[] chartItemsList, CollectionId id, IPen[] pens)
        {
            List<MultipleChartItem> mItems = new List<MultipleChartItem>(chartItemsList[0].Count());

            IEnumerator<ChartItem>[] its = new IEnumerator<ChartItem>[chartItemsList.Length];

            for (int i = 1; i < chartItemsList.Length; i++)
            {
                its[i] = chartItemsList[i].GetEnumerator();
                its[i].MoveNext();
            }

            double[] invalidValues = new double[chartItemsList.Length - 1];
            for(int i = 0; i < invalidValues.Length; i ++)
            {
                invalidValues[i] = ChartItemCollection.valueNA;
            }
            foreach (var cItem in chartItemsList[0])
            {
                MultipleChartItem mItem = new MultipleChartItem()
                {
                    Date = cItem.Date,
                    Value = cItem.Value,
                    ValueChange = cItem.ValueChange,
                    Values = new List<double>(invalidValues),
                    ValueChanges = new List<double>(invalidValues)
                };

                for(int i = 1; i < chartItemsList.Length; i ++)
                {
                    if (its[i].Current.Date > cItem.Date)
                    {
                        continue;
                    }

                    mItem.Values[i - 1] = its[i].Current.Value;
                    mItem.ValueChanges[i - 1] = its[i].Current.ValueChange;
                    its[i].MoveNext();
                }
                mItems.Add(mItem);
            }

            return new MultipleChartItemCollection(id, mItems, pens);    
        }
Exemple #39
0
 protected override int GetHashCodeInternal()
 {
     return((CollectionId?.GetHashCode() ?? 0) * 19 + ReferenceId.GetHashCode());
 }
        public IEnumerable<ChartItemCollection> CreateMACollections(List<StockItem> chartItems, int mvStart = 0)
        {
            for (int i = mvStart; i < mvStart + mvCount; i++)
            {
                var maPeriod = mvUnits[i];
                var maData = MA(maPeriod, chartItems);

                List<ChartItem> mvItems = new List<ChartItem>(maData.Count);
                for (int j = 0; j < maData.Count; j++)
                {
                    mvItems.Add(new ChartItem() { Value = maData[j], Date = chartItems[j + maPeriod - 1].Date });
                }

                var id = new CollectionId(maPeriod.ToString());
                ChartItemCollection collMa = new ChartItemCollection(id, mvItems, DrawingObjectFactory.CreatePen(mvBrushs[i], 1), null, true, false);
                yield return collMa;
            }
        }
 Collection<ArmaGameData, RealVirtualityLaunchGlobalState> FindCollection(CollectionId id) {
     return _collectionContainers.SelectMany(x => x.List).First(x => x.Id == id.Id);
 }