Exemplo n.º 1
0
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            this.mode            = (DimensionDialogMode)navigationContext.Parameters[DimensionDialogViewParameters.DialogModeKey];
            this.selection       = (SpreadsheetSelection)navigationContext.Parameters[FormatAsTableDialogParameters.SelectionKey];
            this.activeWorksheet = (Worksheet)navigationContext.Parameters[FormatAsTableDialogParameters.WorksheetKey];

            SetStrings(this.mode);
            ReadDimension(this.mode, this.selection, this.activeWorksheet);
        }
Exemplo n.º 2
0
        private void SetStrings(DimensionDialogMode dialogMode)
        {
            switch (dialogMode)
            {
            case DimensionDialogMode.RowHeight:
                this.Title = ResourceStrings.ResourceStrings.Text_RowHeightTitle;
                this.DimensionDescription = ResourceStrings.ResourceStrings.Lbl_RowHeight;
                this.IconSource           = "pack://application:,,,/IgExcel.Infrastructure;component/Images/RowHeight.ico";
                break;

            case DimensionDialogMode.ColumnWidth:
                this.Title = ResourceStrings.ResourceStrings.Text_ColumnWidthTitle;
                this.DimensionDescription = ResourceStrings.ResourceStrings.Lbl_ColumnWidth;
                this.IconSource           = "pack://application:,,,/IgExcel.Infrastructure;component/Images/ColumnWidth.ico";
                break;

            case DimensionDialogMode.DeafaultWidth:
                this.Title = ResourceStrings.ResourceStrings.Text_StandartWidth;
                this.DimensionDescription = ResourceStrings.ResourceStrings.Lbl_StandartColumnWidth;
                this.IconSource           = "pack://application:,,,/IgExcel.Infrastructure;component/Images/ColumnWidth.ico";
                break;
            }
        }
Exemplo n.º 3
0
        private void ReadDimension(DimensionDialogMode dialogMode, SpreadsheetSelection selection, Worksheet worksheet)
        {
            switch (dialogMode)
            {
            case DimensionDialogMode.RowHeight:
                var rowHeight = this.activeWorksheet.Rows[this.selection.CellRanges[0].FirstRow].GetCellBoundsInTwips(this.selection.CellRanges[0].FirstColumn).Height;

                foreach (var range in this.selection.CellRanges)
                {
                    for (int i = range.FirstRow; i <= range.LastRow; i++)
                    {
                        var row = this.activeWorksheet.Rows[i];
                        if (rowHeight != row.GetCellBoundsInTwips(range.FirstColumn).Height)
                        {
                            rowHeight = -1;
                            break;
                        }
                    }

                    if (rowHeight == -1)
                    {
                        break;
                    }
                }

                if (rowHeight != -1)
                {
                    this.DimensionValue = rowHeight / 20;
                }
                break;

            case DimensionDialogMode.ColumnWidth:
                var columnWidth = this.activeWorksheet.Columns[this.selection.CellRanges[0].FirstColumn].Width;

                foreach (var range in this.selection.CellRanges)
                {
                    for (int i = range.FirstColumn; i <= range.LastColumn; i++)
                    {
                        if (columnWidth != this.activeWorksheet.Columns[i].Width)
                        {
                            columnWidth = -2;
                        }
                    }

                    if (columnWidth == -2)
                    {
                        break;
                    }
                }

                if (columnWidth == -1)
                {
                    this.DimensionValue = worksheet.GetDefaultColumnWidth(WorksheetColumnWidthUnit.CharacterPaddingExcluded);
                }
                else if (columnWidth != -2)
                {
                    this.DimensionValue = this.activeWorksheet.Columns[this.selection.CellRanges[0].FirstColumn].GetWidth(WorksheetColumnWidthUnit.CharacterPaddingExcluded);
                }
                break;

            case DimensionDialogMode.DeafaultWidth:
                this.DimensionValue = worksheet.GetDefaultColumnWidth(WorksheetColumnWidthUnit.CharacterPaddingExcluded);
                break;
            }
        }