/// <summary>
        /// Provides content for the column header cells.
        /// </summary>
        public override void CreateColumnHeaderContent(C1FlexGrid grid, Border bdr, CellRange range)
        {
            base.CreateColumnHeaderContent(grid, bdr, range);
            if (range.Row == 0)
            {
                // create alphabetical header content
                var tb = new TextBlock();
                tb.VerticalAlignment   = VerticalAlignment.Center;
                tb.HorizontalAlignment = HorizontalAlignment.Center;
                tb.Text     = C1FlexGridBook.GetAlphaColumnHeader(range.Column);
                bdr.Padding = _thickness;

                // preserve outline bar if it's there
                if (grid.ShowOutlineBar && range.Column == 0)
                {
                    var g = bdr.Child as Grid;
                    if (g != null && g.Children.Count > 0)
                    {
                        var index = g.Children.Count - 1;
                        tb.SetValue(Grid.ColumnProperty, index);
                        g.Children[index] = tb;
                        return;
                    }
                }

                // or simply set the content to the new textblock
                bdr.Child = tb;
            }
        }
Exemple #2
0
        public NewSheet()
        {
            var img = new Image();

            img.Stretch = Stretch.None;
            img.Source  = C1FlexGridBook.LoadBitmap("NewSheet.png");
            Header      = img;
        }
        //-------------------------------------------------------------------------
        #region ** ctor

        public SortAction(C1FlexGridBook flex)
        {
            _flex       = flex;
            _rowsBefore = new List <Row>();
            foreach (var row in _flex.Rows)
            {
                _rowsBefore.Add(row);
            }
        }
        //-------------------------------------------------------------------------
        #region ** ctor

        public InsertDeleteRowAction(C1FlexGridBook flex)
        {
            _flex    = flex;
            _oldSel  = _flex.Selection;
            _oldRows = new List <Row>();
            foreach (var row in _flex.Rows)
            {
                _oldRows.Add(row);
            }
        }
        //-------------------------------------------------------------------------
        #region ** ctor

        public InsertDeleteColumnAction(C1FlexGridBook flex)
        {
            _flex       = flex;
            _oldSel     = _flex.Selection;
            _oldColumns = new List <Column>();
            foreach (var col in _flex.Columns)
            {
                _oldColumns.Add(col);
            }
        }
        //-------------------------------------------------------------------------
        #region ** ctor

        /// <summary>
        /// Initializes a new instance of a <see cref="ExcelUndoStack"/>.
        /// </summary>
        /// <param name="flex"><see cref="C1FlexGrid"/> that owns this undo stack.</param>
        public ExcelUndoStack(C1FlexGridBook flex)
        {
            _flex = flex;
            flex.PrepareCellForEdit += flex_PrepareCellForEdit;
            flex.CellEditEnded      += flex_CellEditEnded;
            flex.ResizingColumn     += flex_ResizingColumn;
            flex.ResizedColumn      += flex_ResizedColumn;
            flex.ResizingRow        += flex_ResizingRow;
            flex.ResizedRow         += flex_ResizedRow;
            flex.SortingColumn      += flex_SortingColumn;
        }
        //---------------------------------------------------------------------------
        #region ** ctor

        /// <summary>
        /// Initializes a new instance of an <see cref="ExcelContextMenu"/>.
        /// </summary>
        /// <param name="grid"><see cref="C1FlexGridBook"/> that owns this context menu.</param>
        internal ExcelContextMenu(C1FlexGridBook grid)
        {
            // save reference to parent grid
            _grid = grid;

            // build menu
            Reset();

            // set up event handlers for context menu
            _grid.MouseMove            += _grid_MouseMove;
            _grid.MouseRightButtonDown += _grid_MouseRightButtonDown;
            _grid.MouseRightButtonUp   += _grid_MouseRightButtonUp;
        }
        /// <summary>
        /// Initializes a new instance of a <see cref="SortDialog"/>.
        /// </summary>
        public SortDialog(C1FlexGridBook owner)
            : this()
        {
            // save reference to owner grid (the one being sorted)
            _owner = owner;

            // initialize sort descriptors
            _sdc.Clear();
            var sel = _owner.Selection;

            if (sel.IsValid)
            {
                for (int c = sel.LeftColumn; c <= sel.RightColumn; c++)
                {
                    var sd = new UnboundSortDescription(_owner.Columns[c], ListSortDirection.Ascending);
                    _sdc.Add(sd);
                }
            }
            else
            {
                _sdc.Add(new UnboundSortDescription());
            }

            // update UI when the collection/selection change
            _flex.SelectionChanged += _flex_SelectionChanged;

            // add data map to "Column" column
            var col       = _flex.Columns["Column"];
            var dctColumn = new Dictionary <Column, string>();

            foreach (var c in _owner.Columns)
            {
                dctColumn[c] = GetColumnName(c);
            }
            col.ValueConverter = new ColumnValueConverter(dctColumn);

            // add data map to "Direction" column
            col = _flex.Columns["Direction"];
            var dctOrder = new Dictionary <ListSortDirection, string>();

            dctOrder[ListSortDirection.Ascending]  = "Ascending";
            dctOrder[ListSortDirection.Descending] = "Descending";
            col.ValueConverter = new ColumnValueConverter(dctOrder);

            // show sort descriptors on grid
            _flex.ItemsSource = _sdc;
        }
Exemple #9
0
        // ** ctor
        public ExcelCalcEngine(C1FlexGridBook grid)
        {
            // save reference to parent grid
            _flex = grid;

            // parse multi-cell range references ($A2:B$4)
            IdentifierChars = "$:";

            // register Hyperlink function (returns a HyperlinkButton)
            CacheExpressions = false;
            RegisterFunction("hyperlink", 2, (parms) =>
            {
                var h = new HyperlinkButton();
                //h.NavigateUri = new Uri((string)parms[0]);
                h.Content             = (string)parms[1];
                h.BorderThickness     = new Thickness(0);
                h.BorderBrush         = null;
                h.VerticalAlignment   = VerticalAlignment.Center;
                h.HorizontalAlignment = HorizontalAlignment.Left;
                h.Foreground          = _brLinkForeground;
                //h.TargetName = "_blank";
                return(h);
            });
        }
Exemple #10
0
        //--------------------------------------------------------------------------
        #region ** ctor

        internal SheetCollection(C1FlexGridBook book)
        {
            _book = book;
            book.Tabs.ItemsChanged     += Tabs_ItemsChanged;
            book.Tabs.SelectionChanged += Tabs_SelectionChanged;
        }
        //-------------------------------------------------------------------------
        #region ** ctor

        public ColumnResizeAction(C1FlexGridBook flex)
        {
            _flex    = flex;
            _oldCols = _flex.ColumnLayout;
            _range   = _flex.Selection;
        }
        //-------------------------------------------------------------------------
        #region ** ctor

        /// <summary>
        /// Initializes a new instance of an <see cref="PasteAction"/>.
        /// </summary>
        public PasteAction(C1FlexGridBook flex)
        {
            _flex   = flex;
            _oldSel = _newSel = flex.Selection;
        }
        //-------------------------------------------------------------------------
        #region ** ctor

        public EditAction(C1FlexGridBook flex)
        {
            _flex     = flex;
            _range    = _flex.Selection;
            _oldValue = GetValue();
        }
        //-------------------------------------------------------------------------
        #region ** ctor

        public RowResizeAction(C1FlexGridBook flex, CellRangeEventArgs e)
        {
            _flex    = flex;
            _row     = e.Row;
            _oldSize = _flex.Rows[_row].Height;
        }
        // get a column name suitable for showing in the drop-down
        string GetColumnName(Column c)
        {
            var colName = C1FlexGridBook.GetAlphaColumnHeader(c.Index);

            return(string.Format("Column {0}", colName));
        }