Esempio n. 1
0
        public RGReusableAction CreateUpdateAction()
        {
            var style = new ReoGridRangeStyle();

            ReoGridHorAlign halign = ReoGridHorAlign.General;
            ReoGridVerAlign valign = ReoGridVerAlign.Middle;

            switch (cmbHorAlign.SelectedIndex)
            {
                default:
                case 0: halign = ReoGridHorAlign.General; break;
                case 1: halign = ReoGridHorAlign.Left; break;
                case 2: halign = ReoGridHorAlign.Center; break;
                case 3: halign = ReoGridHorAlign.Right; break;
                case 4: halign = ReoGridHorAlign.DistributedIndent; break;
            }

            switch (cmbVerAlign.SelectedIndex)
            {
                case 0: valign = ReoGridVerAlign.Top; break;
                default: case 1: valign = ReoGridVerAlign.Middle; break;
                case 2: valign = ReoGridVerAlign.Bottom; break;
            }

            switch (style.VAlign)
            {
                case ReoGridVerAlign.Top:
                    cmbHorAlign.SelectedIndex = 0; break;
                case ReoGridVerAlign.Middle:
                    cmbHorAlign.SelectedIndex = 1; break;
                case ReoGridVerAlign.Bottom:
                    cmbHorAlign.SelectedIndex = 2; break;
            }

            if (backupHorAlign != halign)
            {
                style.Flag |= PlainStyleFlag.HorizontalAlign;
                style.HAlign = halign;
            }

            if (backupVerAlign != valign)
            {
                style.Flag |= PlainStyleFlag.VerticalAlign;
                style.VAlign = valign;
            }

            if (backupTextWrapState != chkWrapText.CheckState)
            {
                style.Flag |= PlainStyleFlag.TextWrap;

                if (chkWrapText.Checked)
                {
                    style.TextWrapMode = TextWrapMode.WordBreak;
                }
                else
                {
                    style.TextWrapMode = TextWrapMode.NoWrap;
                }
            }

            return new RGSetRangeStyleAction(grid.SelectionRange, style);
        }
Esempio n. 2
0
        /// <summary>
        /// Do this action
        /// </summary>
        public override void Do()
        {
            backupData = Grid.GetPartialGrid(Range);

            ReoGridRange range = Range;

            int r1 = Range.Row;
            int c1 = Range.Col;
            int r2 = Range.Row2;
            int c2 = Range.Col2;

            int rowCount = Grid.RowCount;
            int colCount = Grid.ColCount;

            isFullColSelected = range.Rows == rowCount;
            isFullRowSelected = range.Cols == colCount;
            isFullGridSelected = isFullRowSelected && isFullColSelected;

            // update default styles
            if (isFullGridSelected)
            {
                backupRootStyle = ReoGridRangeStyle.Clone(Grid.RootStyle);

                rowStyles = new ReoGridRangeStyle[rowCount];
                colStyles = new ReoGridRangeStyle[colCount];

                // remote styles if it is already setted in full-row
                for (int r = 0; r < rowCount; r++)
                {
                    ReoGridRowHead rowHead = Grid.RetrieveRowHead(r);
                    if (rowHead != null && rowHead.Style != null)
                    {
                        rowStyles[r] = ReoGridRangeStyle.Clone(rowHead.Style);
                    }
                }

                // remote styles if it is already setted in full-col
                for (int c = 0; c < colCount; c++)
                {
                    ReoGridColHead colHead = Grid.RetrieveColHead(c);
                    if (colHead != null && colHead.Style != null)
                    {
                        colStyles[c] = ReoGridRangeStyle.Clone(colHead.Style);
                    }
                }
            }
            else if (isFullRowSelected)
            {
                rowStyles = new ReoGridRangeStyle[r2 - r1 + 1];
                for (int r = r1; r <= r2; r++)
                {
                    rowStyles[r - r1] = ReoGridRangeStyle.Clone(Grid.RetrieveRowHead(r).Style);
                }
            }
            else if (isFullColSelected)
            {
                colStyles = new ReoGridRangeStyle[c2 - c1 + 1];
                for (int c = c1; c <= c2; c++)
                {
                    colStyles[c - c1] = ReoGridRangeStyle.Clone(Grid.RetrieveColHead(c).Style);
                }
            }

            Grid.SetRangeStyle(range, style);
        }
Esempio n. 3
0
 /// <summary>
 /// Create an action that perform set styles to specified range
 /// </summary>
 /// <param name="range">Range to be appiled this action</param>
 /// <param name="style">Style to be set to specified range</param>
 public RGSetRangeStyleAction(ReoGridRange range, ReoGridRangeStyle style)
     : base(range)
 {
     this.style = new ReoGridRangeStyle(style);
 }
Esempio n. 4
0
 /// <summary>
 /// Create an action that perform set styles to specified range
 /// </summary>
 /// <param name="row">number of row</param>
 /// <param name="col">number of col</param>
 /// <param name="rows">number of rows</param>
 /// <param name="cols">number of cols</param>
 /// <param name="style">style to be set</param>
 public RGSetRangeStyleAction(int row, int col, int rows, int cols, ReoGridRangeStyle style)
     : this(new ReoGridRange(row, col, rows, cols), style)
 {
 }
Esempio n. 5
0
        public BuiltInTypesForm()
        {
            InitializeComponent();

            // set grid cursor to windows default
            grid.SetRangeStyle(ReoGridRange.EntireRange, new ReoGridRangeStyle
            {
                Flag = PlainStyleFlag.FontName,
                FontName = "Arial",
            });

            grid.CellsSelectionCursor = Cursors.Default;
            grid.SetSettings(ReoGridSettings.View_ShowGridLine, false);
            grid.SelectionMode = ReoGridSelectionMode.Cell;
            grid.SelectionStyle = ReoGridSelectionStyle.FocusRect;

            var middleStyle = new ReoGridRangeStyle
            {
                Flag = PlainStyleFlag.Padding | PlainStyleFlag.HorizontalAlign,
                Padding = new Padding(2),
                HAlign = ReoGridHorAlign.Center,
            };

            var grayTextStyle = new ReoGridRangeStyle
            {
                Flag = PlainStyleFlag.TextColor,
                TextColor =	Color.DimGray
            };

            grid.MergeRange(1, 1, 1, 6);

            grid.SetRangeStyle(1, 1, 1, 6, new ReoGridRangeStyle
            {
                Flag = PlainStyleFlag.TextColor | PlainStyleFlag.FontSize,
                TextColor = Color.DarkGreen,
                FontSize = 18,
            });

            grid[1, 1] = "Built-in Cell Bodies";

            grid.SetColsWidth(1, 1, 100);
            grid.SetColsWidth(2, 1, 30);
            grid.SetColsWidth(3, 1, 100);
            grid.SetColsWidth(6, 2, 65);

            // button
            grid.MergeRange(3, 2, 1, 2);
            var btn = new ButtonCell("Hello");
            grid[3, 1] = new object[] { "Button: ", btn };
            btn.Click += (s, e) => ShowText("Button clicked.");

            // link
            grid.MergeRange(5, 2, 1, 2);
            var link = new HyperlinkCell("http://www.google.com");
            grid[5, 1] = new object[] { "Hyperlink", link };
            link.Click += (s, e) => System.Diagnostics.Process.Start(grid.GetCellText(5, 2));

            // checkbox
            var checkbox = new CheckBoxCell();
            grid.SetRangeStyle(7, 2, 1, 1, middleStyle);
            grid.SetRangeStyle(8, 2, 1, 1, grayTextStyle);
            grid[7, 1] = new object[] { "Check box", checkbox, "Auto destroy after 5 minutes." };
            grid[8, 2] = "(Keyboard is also supported to change the status of control)";
            checkbox.CheckChanged += (s, e) => ShowText("Check box switch to " + checkbox.ButtonState.ToString());

            // radio & radio group
            grid[10, 1] = "Radio Button";
            grid.SetRangeStyle(10, 2, 3, 1, middleStyle);
            var radioGroup = new RadioButtonGroup();
            grid[10, 2] = new object[,] {
                {new RadioButtonCell() { RadioGroup = radioGroup }, "Apple"},
                {new RadioButtonCell() { RadioGroup = radioGroup }, "Orange"},
                {new RadioButtonCell() { RadioGroup = radioGroup }, "Banana"}
            };
            grid[13, 2] = "(By adding into RadioGroup will make it toggled automatically)";
            grid.SetRangeStyle(13, 2, 1, 1, grayTextStyle);

            // dropdown
            grid.MergeRange(15, 2, 1, 3);
            var dropdown = new DropdownCell(new object[] { "Apple", "Orange", "Banana", "Pear", "Pumpkin", "Cherry", "Coconut" });
            grid[15, 1] = new object[] { "Dropdown", dropdown };
            grid.SetRangeBorder(15, 2, 1, 3, ReoGridBorderPos.Outline, ReoGridBorderStyle.SolidGray);

            // image
            grid.MergeRange(2, 6, 5, 2);
            grid[2, 6] = new ImageCell(Resources.computer_laptop);

            // information cell
            grid.SetRangeBorder(19, 0, 1, 10, ReoGridBorderPos.Top, ReoGridBorderStyle.SolidGray);
        }
Esempio n. 6
0
        public RGReusableAction CreateUpdateAction()
        {
            if (backupBackColor != colorPanel.SolidColor
                || backuphasPatternStyle != patternStyleComboBox.HasPatternStyle
                || backupPatternColor != patternColorComboBox.SolidColor
                || backupPatternStyle != patternStyleComboBox.PatternStyle)
            {
                ReoGridRangeStyle style = new ReoGridRangeStyle();

                style.Flag |= PlainStyleFlag.FillColor;
                style.BackColor = colorPanel.SolidColor;

                style.Flag |= PlainStyleFlag.FillPattern;
                style.FillPatternColor = patternStyleComboBox.HasPatternStyle ? patternColorComboBox.SolidColor : Color.Empty;
                style.FillPatternStyle = patternStyleComboBox.PatternStyle;

                // pattern style need a back color
                // when pattern style setted but back color is not setted, set the backcolor to white
                if (patternStyleComboBox.HasPatternStyle && style.BackColor.IsEmpty)
                {
                    style.BackColor = Color.White;
                    style.Flag |= PlainStyleFlag.FillColor;
                }

                return new RGSetRangeStyleAction(grid.SelectionRange, style);
            }
            else
                return null;
        }