Example #1
0
        public void UpdateCellRenderFont(Cell cell, Core.UpdateFontReason reason)
        {
            var sheet = cell.Worksheet;

            if (sheet == null)
            {
                return;
            }

            var style = cell.InnerStyle;

            var fontStyle = StyleUtility.CreateFontStyle(style);

            // unknown bugs happened here (several times)
            // cell.Style is null (cell.Style.FontSize is zero)
            if (style.FontSize <= 0)
            {
                style.FontSize = 6f;
            }

            float fontSize = (float)Math.Round(style.FontSize * sheet.renderScaleFactor, 1);

            var renderFont = cell.RenderFont;

            if (renderFont == null ||
                renderFont.Name != style.FontName ||
                renderFont.Size != fontSize ||
                renderFont.Style != (System.Drawing.FontStyle)fontStyle)
            {
                cell.RenderFont = this.resourceManager.GetFont(style.FontName, fontSize,
                                                               (System.Drawing.FontStyle)fontStyle);
            }
        }
        void OnGUI()
        {
            if (this.plugins == null)
            {
                this.plugins = CreatePlugins();
            }

            var scrollStack = LayoutUtility.ScrollStack(ref this.scrollPosition);

            for (var i = 0; i < this.plugins.Length; i++)
            {
                var plugin = this.plugins[i];
                using (LayoutUtility.VerticalStack(StyleUtility.GetColoredBoxStyle(this.plugins.Length, i))) {
                    plugin.Update();
                    var pluginVisible = UpdatePluginVisibility(plugin);
                    if (!pluginVisible)
                    {
                        continue;
                    }
                    if (!plugin.Render())
                    {
                        GUIUtility.ExitGUI();
                    }
                }
            }
            scrollStack.Dispose();
        }
        public void LoadPage()
        {
            var sheet = this.grid.CurrentWorksheet;

            WorksheetRangeStyle style = sheet.GetRangeStyles(sheet.SelectionRange);

            colorPanel.SolidColor = backupBackColor = style.BackColor;

            if (StyleUtility.HasStyle(style, PlainStyleFlag.FillPattern))
            {
                patternColorComboBox.SolidColor      = style.FillPatternColor;
                patternStyleComboBox.PatternStyle    = (HatchStyle)style.FillPatternStyle;
                patternStyleComboBox.HasPatternStyle = true;
            }

            backupPatternColor    = patternColorComboBox.SolidColor;
            backupPatternStyle    = patternStyleComboBox.PatternStyle;
            backuphasPatternStyle = patternStyleComboBox.HasPatternStyle;
        }
Example #4
0
        internal PartialGrid GetPartialGrid(RangePosition range, PartialGridCopyFlag flag, ExPartialGridCopyFlag exFlag,
                                            bool checkIntersectedRange = false)
        {
            range = FixRange(range);

            if (checkIntersectedRange)
            {
                var intersectedRange = CheckIntersectedMergingRange(range);
                if (intersectedRange != RangePosition.Empty)
                {
                    throw new RangeIntersectionException(intersectedRange);
                }
            }

            int rows = range.Rows;
            int cols = range.Cols;

            PartialGrid data = new PartialGrid()
            {
                Columns = cols,
                Rows    = rows,
            };

            if ((flag & PartialGridCopyFlag.CellData) == PartialGridCopyFlag.CellData ||
                (flag & PartialGridCopyFlag.CellStyle) == PartialGridCopyFlag.CellStyle)
            {
                data.Cells = new CellArray();

                for (int r = range.Row; r <= range.EndRow; r++)
                {
                    for (int c = range.Col; c <= range.EndCol; c++)
                    {
                        var cell = this.cells[r, c];

                        int toRow = r - range.Row;
                        int toCol = c - range.Col;

                        //if (cell == null && data.Cells[toRow, toCol] == null)
                        //{
                        //	c++;
                        //	continue;
                        //}

                        Cell toCell = null;

                        if (cell != null)
                        {
                            toCell = new Cell(this);
                            CellUtility.CopyCell(toCell, cell);
                        }
                        else
                        {
                            StyleParentKind pKind = StyleParentKind.Own;
                            var             style = StyleUtility.FindCellParentStyle(this, r, c, out pKind);

                            style = StyleUtility.DistinctStyle(style, Worksheet.DefaultStyle);

                            if (style != null)
                            {
                                toCell                 = new Cell(this);
                                toCell.Colspan         = 1;
                                toCell.Rowspan         = 1;
                                toCell.InnerStyle      = style;
                                toCell.StyleParentKind = StyleParentKind.Own;
                            }
                        }

                        if (toCell != null)
                        {
                            data.Cells[toRow, toCol] = toCell;
                        }

                        //c += (cell == null || cell.Colspan < 1) ? 1 : cell.Colspan;
                    }
                }
            }

            if ((flag & PartialGridCopyFlag.HBorder) == PartialGridCopyFlag.HBorder)
            {
                data.HBorders = new HBorderArray();

                hBorders.Iterate(range.Row, range.Col, rows + 1, cols, true, (r, c, hBorder) =>
                {
                    // only copy borders they belong to the cell (unless BorderOutsideOwner is specified)
                    if (((exFlag & ExPartialGridCopyFlag.BorderOutsideOwner) == ExPartialGridCopyFlag.BorderOutsideOwner) ||
                        (hBorder != null && hBorder.Pos == HBorderOwnerPosition.None) ||
                        (
                            (r != range.Row ||
                             (hBorder != null &&
                              (hBorder.Pos & HBorderOwnerPosition.Top) == HBorderOwnerPosition.Top))
                            &&
                            (r != range.EndRow + 1 ||
                             (hBorder != null &&
                              (hBorder.Pos & HBorderOwnerPosition.Bottom) == HBorderOwnerPosition.Bottom)))
                        )
                    {
                        int toCol = c - range.Col;
                        ReoGridHBorder thBorder = ReoGridHBorder.Clone(hBorder);
                        if (thBorder != null && thBorder.Span > cols - toCol)
                        {
                            thBorder.Span = cols - toCol;
                        }
                        data.HBorders[r - range.Row, toCol] = thBorder;
                    }
                    return(1);
                });
            }

            if ((flag & PartialGridCopyFlag.VBorder) == PartialGridCopyFlag.VBorder)
            {
                data.VBorders = new VBorderArray();

                vBorders.Iterate(range.Row, range.Col, rows, cols + 1, true, (r, c, vBorder) =>
                {
                    // only copy borders they belong to the cell (unless BorderOutsideOwner is specified)
                    if (((exFlag & ExPartialGridCopyFlag.BorderOutsideOwner) == ExPartialGridCopyFlag.BorderOutsideOwner) ||
                        (vBorder != null && vBorder.Pos == VBorderOwnerPosition.None) ||
                        (
                            (c != range.Col ||
                             (vBorder != null &&
                              (vBorder.Pos & VBorderOwnerPosition.Left) == VBorderOwnerPosition.Left))
                            &&
                            (c != range.EndCol + 1 ||
                             (vBorder != null &&
                              (vBorder.Pos & VBorderOwnerPosition.Right) == VBorderOwnerPosition.Right)))
                        )
                    {
                        int toRow = r - range.Row;
                        ReoGridVBorder tvBorder = ReoGridVBorder.Clone(vBorder);
                        if (tvBorder != null && tvBorder.Span > rows - toRow)
                        {
                            tvBorder.Span = rows - toRow;
                        }
                        data.VBorders[toRow, c - range.Col] = tvBorder;
                    }
                    return(1);
                });
            }

            return(data);
        }