Ejemplo n.º 1
0
        private SecurityEntry GetSecurity(SpreadMatrixData smd, SpreadMatrixDataCell cell)
        {
            int r = Grid.GetRow(cell);
            int c = Grid.GetColumn(cell);
            if (r > c)
                r--;

            DateTime date1 = smd.MinYearMonth.AddMonths(r);
            DateTime date2 = smd.MinYearMonth.AddMonths(c);

            MDDatePair datePair = new MDDatePair(date1, date2);

            return smd.Get(datePair);
        }
Ejemplo n.º 2
0
        public void CreateGrid(SpreadMatrixData smd)
        {
            ClearGrid();

            int dMonth = GetDeltaMonth(smd.MinYearMonth, smd.MaxYearMonth);

            if (smd.MaxYearMonth == new DateTime())
                return;

            for (int i = 0; i < dMonth; i++)
            {
                ColumnDefinition col = new ColumnDefinition();
                col.Width = new GridLength(CellWidth);
                grid.ColumnDefinitions.Add(col);
            }

            for (int i = 0; i < dMonth + 1; i++)
            {
                RowDefinition row = new RowDefinition();
                row.Height = new GridLength(CellHeight);
                grid.RowDefinitions.Add(row);
            }

            for (int c = 0; c < dMonth + 1; c++)
            {
                ColumnDefinition col = new ColumnDefinition();
                col.Width = new GridLength(CellWidth);
                gridHeader.ColumnDefinitions.Add(col);

                SpreadMatrixCell cellHeaderDate = new SpreadMatrixCell
                                                     {
                                                         Width = CellWidth,
                                                         Height = CellHeight/2
                                                     };
                cellHeaderDate.FillData(smd.MinYearMonth.AddMonths(c));

                Grid.SetRow(cellHeaderDate, 2);
                Grid.SetColumn(cellHeaderDate, c);

                SpreadMatrixDataCell cellHeader = new SpreadMatrixDataCell
                                             {
                                                 Width = CellWidth,
                                                 Height = CellHeight,
                                                 //AskPx = "?",
                                                 //AskCount = "?",
                                                 //BidPx = "?",
                                                 //BidCount = "?"
                                             };

                Grid.SetRow(cellHeader, 1);
                Grid.SetColumn(cellHeader, c);

                SpreadMatrixCell cellHeaderElm = new SpreadMatrixCell { Width = CellWidth, Height = CellHeight };

                Grid.SetRow(cellHeaderElm, 0);
                Grid.SetColumn(cellHeaderElm, c);
                cellHeaderElm.FillData("?");

                gridHeader.Children.Add(cellHeaderDate);
                gridHeader.Children.Add(cellHeader);
                gridHeader.Children.Add(cellHeaderElm);
            }

            for (int r = 0; r < dMonth; r++)
            {
                SpreadMatrixCell cellDate = new SpreadMatrixCell { Width = CellWidth, Height = CellHeight };

                Grid.SetRow(cellDate, r);
                Grid.SetColumn(cellDate, r);
                cellDate.FillData(smd.MinYearMonth.AddMonths(r));
                grid.Children.Add(cellDate);

                for (int c = r; c < dMonth; c++)
                {
                    MDDatePair datePair = new MDDatePair(smd.MinYearMonth.AddMonths(r), smd.MinYearMonth.AddMonths(c));
                    SpreadMatrixDataCell cell = smd.GetDataCell(datePair) ?? new SpreadMatrixDataCell();

                    cell.MouseDown += cell_MouseDown;

                    cell.Width = CellWidth;
                    cell.Height = CellHeight;
                    Grid.SetRow(cell, r == c ? r + 1 : r);
                    Grid.SetColumn(cell, c);
                    cellPosDictionary.SetValue(r, c, cell);
                    grid.Children.Add(cell);
                }
            }
            InvalidateVisual();
        }
Ejemplo n.º 3
0
 void SetMinYearMonth(MDDatePair datePair)
 {
     if (minYearMonth == new DateTime())
         minYearMonth = datePair.GetMinDate();
     else
         minYearMonth = MDDatePair.GetMinDate(minYearMonth, datePair.GetMinDate());
 }
Ejemplo n.º 4
0
 void SetMaxYearMonth(MDDatePair datePair)
 {
     if (maxYearMonth == new DateTime())
         maxYearMonth = datePair.GetMaxDate();
     else
         maxYearMonth = MDDatePair.GetMaxDate(maxYearMonth, datePair.GetMaxDate());
 }
Ejemplo n.º 5
0
        public SpreadMatrixDataCell GetDataCell(MDDatePair datePair)
        {
            lock (LockObject)
            {
                SecurityEntry entry = spreadMatrixEntries.GetValue(datePair.GetMinDate(), datePair.GetMaxDate());

                if (entry != null)
                {
                    SpreadMatrixDataCell cell = new SpreadMatrixDataCell();
                    cell.FillData(entry);
                    return cell;
                }

                return null;
            }
        }
Ejemplo n.º 6
0
 public SecurityEntry Get(MDDatePair datePair)
 {
     lock (LockObject)
     {
         return spreadMatrixEntries.GetValue(datePair.Date1, datePair.Date2);
     }
 }
Ejemplo n.º 7
0
        public MDDatePair GetDatePair()
        {
            switch (SubContractCount)
            {
                case 0:
                    return new MDDatePair(MaturityMonthYear, MaturityMonthYear);
                case 1:
                    return new MDDatePair(GetSubContract(0).MaturityMonthYear, GetSubContract(0).MaturityMonthYear);
                case 2:
                    MDDatePair datePair = new MDDatePair(GetSubContract(0).MaturityMonthYear,
                                                         GetSubContract(1).MaturityMonthYear);
                    return new MDDatePair(datePair.GetMinDate(), datePair.GetMaxDate());
            }

            throw new Exception("Contracts that contains more than 2 subcontracts detected. These contracts currently not supported.");
        }