public void Add(CellControl cell,
            int columnIndex,
            int rowIndex)
        {
            if (cell != null && cell.Cell != null)
            {
                m_CellsViewCache[cell.Cell] = cell;
            }

            Dictionary<int, CellControl> columnDict = null;
            if (this.m_CellsCache.ContainsKey(rowIndex))
            {
                columnDict = this.m_CellsCache[rowIndex];
            }

            if (columnDict == null)
            {
                columnDict = new Dictionary<int, CellControl>();
                this.m_CellsCache.Add(rowIndex, columnDict);
            }

            if (!columnDict.ContainsKey(columnIndex))
            {
                columnDict.Add(columnIndex, cell);
            }
            else
            {
                columnDict[columnIndex] = cell;
            }
        }
        public void Initialize(CellControl cell)
        {
            Text = String.Empty;
            if (cell != null && cell.Cell != null)
            {
                if (cell.NotRecalculatedChange != null && cell.NotRecalculatedChange.HasError)
                {
                    Caption = cell.NotRecalculatedChange.Error;
                }
                else
                {
                    if (cell.Cell.CellDescr != null && cell.Cell.CellDescr.Value != null && cell.Cell.CellDescr.Value.Value != null)
                    {
                        Caption = cell.Cell.CellDescr.Value.DisplayValue;
                    }
                    else
                    {
                        Caption = "(null)";
                    }
                }

                Text += cell.Cell.GetShortTupleToStr();
            }
            else
            {
                Caption = String.Empty;
                Text = String.Empty;
            }
        }
 public FocusedCellChangedEventArgs(object owner,
     CellControl oldFocusedCell,
     CellControl newFocusedCell)
 {
     this.Owner = owner;
     this.OldFocusedCell = oldFocusedCell;
     this.NewFocusedCell = newFocusedCell;
 }
示例#4
0
        public CellControl this[
            int columnIndex,
            int rowIndex]
        {
            get
            {
                CellControl res = null;
                Dictionary <int, CellControl> columnDict = null;
                if (this.m_CellsCache.ContainsKey(rowIndex))
                {
                    columnDict = this.m_CellsCache[rowIndex];
                }
                if (columnDict != null)
                {
                    if (columnDict.ContainsKey(columnIndex))
                    {
                        res = columnDict[columnIndex];
                    }
                }

                return(res);
            }
        }
 private void Raise_FocusedCellChanged(CellControl oldFocusedCell, CellControl newFocusedCell)
 {
     FocusedCellChangedEventHandler handler = this.FocusedCellChanged;
     if (handler != null)
     {
         handler(this, new FocusedCellChangedEventArgs(this, oldFocusedCell, newFocusedCell));
     }
 }
 public void ChangeSelectionAreaTo(CellControl cell)
 {
     if (cell != null)
     {
         IList<CellInfo> area = ProcessCellsArea(FocusedCellView, cell.Cell);
         SelectionManager.ChangeSelectionArea(area);
     }
 }
 void OnCellControlMouseDown(CellControl cell)
 {
     // Если нажат Shift и ячейка ч фокусом уже есть, то нужно изменить выбранную область,
     // Ячейка с фокусом при этои не меняется
     if (((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) && FocusedCellView != null)
     {
         SelectionManager.ChangeSelectionArea(ProcessCellsArea(FocusedCellView, cell.Cell));
         m_PrevAreaBorderCell = cell.Cell;
     }
     else
     {
         FocusedCellView = cell.Cell;
     }
 }
        void InitializeFocusedCell(CellControl old_FocusedCell)
        {
            if (old_FocusedCell != null)
            {
                old_FocusedCell.IsFocused = false;

                IDictionary<String, MemberInfo> old_tuple = new Dictionary<String, MemberInfo>();
                if (old_FocusedCell != null && old_FocusedCell.Cell != null)
                {
                    old_tuple = old_FocusedCell.Cell.GetTuple();
                }

                CellControl new_FocusedCell = null;

                // Пытаемся получить ячейку на которую хотим установить фокус
                for (int i = 0; i < m_CellControls_Cache.Columns_Size; i++)
                {
                    if (new_FocusedCell != null)
                        break;
                    for (int j = 0; j < m_CellControls_Cache.Rows_Size; j++)
                    {
                        CellControl cell_Control = m_CellControls_Cache.RemoveAt(i, j);
                        if (cell_Control != null && cell_Control.Cell != null)
                        {
                            if (cell_Control.Cell.CompareByTuple(old_tuple))
                            {
                                new_FocusedCell = cell_Control;
                                break;
                            }
                        }
                    }
                }

                if (new_FocusedCell != null)
                {
                    //FocusedCell = new_FocusedCell;
                }
            }
        }
        void BuildCellsArea()
        {
            DateTime start = DateTime.Now;

            #region Настройка области ячеек
            int added = 0;
            for (int layout_column_indx = ColumnsArea_BeginColumnIndex, column_indx = 0; layout_column_indx <= ColumnsArea_EndColumnIndex; layout_column_indx++, column_indx++)
            {
                for (int layout_row_indx = RowsArea_BeginRowIndex, row_indx = 0; layout_row_indx <= RowsArea_EndRowIndex; layout_row_indx++, row_indx++)
                {
                    CellControl cell_control = null;
                    cell_control = m_CellControls_Cache[column_indx, row_indx];
                    if (cell_control == null)
                    {
                        cell_control = new CellControl(this);
                        cell_control.MouseEnter += new MouseEventHandler(cell_control_MouseEnter);
                        cell_control.Click += new RoutedEventHandler(cell_control_Click);
                        cell_control.MouseDoubleClick += new EventHandler(CellControl_MouseDoubleClick);
                        cell_control.Cell = null;
                        m_CellControls_Cache.Add(cell_control, column_indx, row_indx);
                        ItemsLayoutRoot.Children.Add(cell_control);
                        Grid.SetColumn(cell_control, layout_column_indx);
                        Grid.SetRow(cell_control, layout_row_indx);
                    }
                    else
                    {
                        // Сбросим при инициализации cell_control.Cell = null;
                    }
                    added++;
                }
            }

            // удаляем лишние по строкам и столбцам
            for (int i = 0; i < m_CellControls_Cache.Columns_Size; i++)
            {
                for (int j = 0; j < m_CellControls_Cache.Rows_Size; j++)
                {
                    if (i >= ColumnsArea_ColumnsCount ||
                        j >= RowsArea_RowsCount)
                    {
                        CellControl cell_Control = m_CellControls_Cache.RemoveAt(i, j);
                        if (cell_Control != null)
                            ItemsLayoutRoot.Children.Remove(cell_Control);
                    }
                }
            }


            DateTime stop = DateTime.Now;
            System.Diagnostics.Debug.WriteLine(" BuildCellsArea time: " + (stop - start).ToString());

            #endregion Настройка области ячеек
        }
示例#10
0
 public CellClickEventArgs(
     CellControl cell, Point point)
     : this(cell)
 {
     this.Position = point;
 }
示例#11
0
 public CellClickEventArgs(
     CellControl cell)
 {
     this.Cell = cell;
 }
 public CellClickEventArgs(
     CellControl cell, Point point)
     : this(cell)
 {
     this.Position = point;
 }
 public CellClickEventArgs(
     CellControl cell)
 {
     this.Cell = cell;
 }