Exemplo n.º 1
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);
        }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
0
        private List <ChartItem> CombineSingleStockItems(List <ChartItem> one, List <ChartItem> other, int j)
        {
            ChartItemComparer comparar = new ChartItemComparer();
            int iOne   = 0;
            int iOther = 0;

            StockValuesItem zeroOneItem = one[0] as StockValuesItem;

            for (; iOther < other.Count; iOther++)
            {
                StockValuesItem iOneItem = one[iOne] as StockValuesItem;
                if (iOne >= one.Count)
                {
                    one.AddRange(other.Skip(iOther).Select(mItem =>
                    {
                        var tempItem = new StockValuesItem()
                        {
                            Value        = ChartItemCollection.valueNA,
                            High         = ChartItemCollection.valueNA,
                            Low          = ChartItemCollection.valueNA,
                            Open         = ChartItemCollection.valueNA,
                            Date         = other[iOther].Date,
                            ValueChange  = ChartItemCollection.valueNA,
                            Values       = zeroOneItem.Values != null ? new List <double>(invalidValues) : null,
                            ValueChanges = zeroOneItem.ValueChanges != null ? new List <double>(invalidValues) : null
                        };

                        tempItem.Values[j]       = mItem.Value;
                        tempItem.ValueChanges[j] = mItem.ValueChange;

                        return(tempItem);
                    }));
                    break;
                }

                if (one[iOne].Date == other[iOther].Date)
                {
                    iOneItem.Values[j]       = other[iOther].Value;
                    iOneItem.ValueChanges[j] = other[iOther].ValueChange;
                    iOne++;
                }
                else if (one[iOne].Date > other[iOther].Date)
                {
                    var tempItem = new StockValuesItem()
                    {
                        Value        = ChartItemCollection.valueNA,
                        High         = ChartItemCollection.valueNA,
                        Low          = ChartItemCollection.valueNA,
                        Open         = ChartItemCollection.valueNA,
                        Date         = other[iOther].Date,
                        ValueChange  = ChartItemCollection.valueNA,
                        Values       = zeroOneItem.Values != null ? new List <double>(invalidValues) : null,
                        ValueChanges = zeroOneItem.ValueChanges != null ? new List <double>(invalidValues) : null
                    };

                    tempItem.Values[j]       = other[iOther].Value;
                    tempItem.ValueChanges[j] = other[iOther].ValueChange;

                    one.Insert(iOne, tempItem);
                    iOne++;
                }
                else
                {
                    int iOneTemp = one.BinarySearch(iOne, one.Count - iOne, other[iOther], comparar);
                    if (iOneTemp < 0)
                    {
                        iOneTemp = ~iOneTemp;

                        if (iOneTemp == one.Count)
                        {
                            one.AddRange(other.Skip(iOther).Select(mItem =>
                            {
                                var tempItem = new StockValuesItem()
                                {
                                    Value        = ChartItemCollection.valueNA,
                                    High         = ChartItemCollection.valueNA,
                                    Low          = ChartItemCollection.valueNA,
                                    Open         = ChartItemCollection.valueNA,
                                    Date         = other[iOther].Date,
                                    ValueChange  = ChartItemCollection.valueNA,
                                    Values       = zeroOneItem.Values != null ? new List <double>(invalidValues) : null,
                                    ValueChanges = zeroOneItem.ValueChanges != null ? new List <double>(invalidValues) : null
                                };

                                tempItem.Values[j]       = mItem.Value;
                                tempItem.ValueChanges[j] = mItem.ValueChange;

                                return(tempItem);
                            }));
                            break;
                        }
                        else
                        {
                            var tempItem = new StockValuesItem()
                            {
                                Value        = ChartItemCollection.valueNA,
                                High         = ChartItemCollection.valueNA,
                                Low          = ChartItemCollection.valueNA,
                                Open         = ChartItemCollection.valueNA,
                                Date         = other[iOther].Date,
                                ValueChange  = ChartItemCollection.valueNA,
                                Values       = zeroOneItem.Values != null ? new List <double>(invalidValues) : null,
                                ValueChanges = zeroOneItem.ValueChanges != null ? new List <double>(invalidValues) : null
                            };
                            tempItem.Values[j]       = other[iOther].Value;
                            tempItem.ValueChanges[j] = other[iOther].ValueChange;

                            one.Insert(iOneTemp, tempItem);
                            iOne = iOneTemp + 1;
                        }
                    }
                    else
                    {
                        StockValuesItem iOneItemTemp = one[iOneTemp] as StockValuesItem;

                        iOneItemTemp.Values[j]       = other[iOther].Value;
                        iOneItemTemp.ValueChanges[j] = other[iOther].ValueChange;
                        iOne = iOneTemp + 1;
                    }
                }
            }

            return(one);
        }