示例#1
0
        public void ExecuteOrientationCommand(int ActiveTabIndex)
        {
            SampleGridControl ActiveGrid = ((Tab1.Items[ActiveTabIndex] as TabItem).Content as ScrollViewer).Content as SampleGridControl;

            if (!ActiveGrid.CurrentCell.HasCurrentCell)
            {
                return;
            }

            if (ActiveGrid != null && !ActiveGrid.Model.CurrentCellState.GridControl.CurrentCell.IsInMoveTo)
            {
                foreach (GridRangeInfo range in ActiveGrid.Model.SelectedRanges)
                {
                    for (int row = range.Top; row <= range.Bottom; row++)
                    {
                        for (int col = range.Left; col <= range.Right; col++)
                        {
                            GridStyleInfo cell = ActiveGrid.Model[row, col];
                            cell.Font.Orientation += 90;
                        }
                    }
                    ActiveGrid.Model.InvalidateCell(range);
                }
            }
        }
示例#2
0
        public void ExecuteFontSizeCommand(int ActiveTabIndex, bool IsIncrement)
        {
            SampleGridControl ActiveGrid = ((Tab1.Items[ActiveTabIndex] as TabItem).Content as ScrollViewer).Content as SampleGridControl;

            // Skip if the current cell is not set.
            if (!ActiveGrid.CurrentCell.HasCurrentCell)
            {
                return;
            }

            if (ActiveGrid != null && !ActiveGrid.Model.CurrentCellState.GridControl.CurrentCell.IsInMoveTo)
            {
                foreach (GridRangeInfo range in ActiveGrid.Model.SelectedRanges)
                {
                    for (int row = range.Top; row <= range.Bottom; row++)
                    {
                        for (int col = range.Left; col <= range.Right; col++)
                        {
                            if (IsIncrement)
                            {
                                ActiveGrid.Model[row, col].Font.FontSize += 1;
                            }
                            else
                            {
                                ActiveGrid.Model[row, col].Font.FontSize -= 1;
                            }
                        }
                    }
                    ActiveGrid.Model.InvalidateCell(range);
                }
            }
        }
示例#3
0
        public void ExecuteRedoCommand(int ActiveTabIndex)
        {
            SampleGridControl ActiveGrid = ((Tab1.Items[ActiveTabIndex] as TabItem).Content as ScrollViewer).Content as SampleGridControl;

            if (!ActiveGrid.Model.CommandStack.InTransaction)
            {
                ActiveGrid.Model.CommandStack.Redo();
            }
        }
示例#4
0
        public void ExecutePasteCommand(int ActiveTabIndex)
        {
            SampleGridControl ActiveGrid = ((Tab1.Items[ActiveTabIndex] as TabItem).Content as ScrollViewer).Content as SampleGridControl;

            if (ActiveGrid != null)
            {
                string CliboardText = Clipboard.GetText();
                ActiveGrid.Model.TextDataExchange.PasteTextFromBuffer(CliboardText, ActiveGrid.Model.SelectedRanges);
            }
        }
示例#5
0
        public void ExecuteCutCommand(int ActiveTabIndex)
        {
            SampleGridControl ActiveGrid = ((Tab1.Items[ActiveTabIndex] as TabItem).Content as ScrollViewer).Content as SampleGridControl;

            if (ActiveGrid != null)
            {
                string CliboardText;
                int    row, col;
                ActiveGrid.Model.TextDataExchange.CopyTextToBuffer(out CliboardText, ActiveGrid.Model.SelectedRanges, out row, out col, true);
                Clipboard.SetText(CliboardText);
            }
        }
示例#6
0
        private void ForegroundColorPicker_SelectedBrushChanged(object sender, SelectedBrushChangedEventArgs e)
        {
            var color = this.ForegroundColorPicker.Color;
            SampleGridControl ActiveGrid = ((Tab1.SelectedItem as TabItem).Content as ScrollViewer).Content as SampleGridControl;

            if (ActiveGrid != null)
            {
                GridRangeInfoList rangeList = ActiveGrid.Model.SelectedRanges;
                foreach (GridRangeInfo range in rangeList)
                {
                    for (int row = range.Top; row <= range.Bottom; row++)
                    {
                        for (int col = range.Left; col <= range.Right; col++)
                        {
                            ActiveGrid.Model[row, col].Foreground = new SolidColorBrush(color);
                        }
                    }
                    ActiveGrid.InvalidateCell(range);
                }
                ActiveGrid.InvalidateVisual();
            }
            this.ForeColorSplitButton.IsDropDownOpen = false;
        }
示例#7
0
        public void ExecuteIndentCommand(int ActiveTabIndex, bool IsIncrement)
        {
            SampleGridControl ActiveGrid = ((Tab1.Items[ActiveTabIndex] as TabItem).Content as ScrollViewer).Content as SampleGridControl;

            if (!ActiveGrid.CurrentCell.HasCurrentCell)
            {
                return;
            }

            if (ActiveGrid != null && !ActiveGrid.Model.CurrentCellState.GridControl.CurrentCell.IsInMoveTo)
            {
                foreach (GridRangeInfo range in ActiveGrid.Model.SelectedRanges)
                {
                    for (int row = range.Top; row <= range.Bottom; row++)
                    {
                        for (int col = range.Left; col <= range.Right; col++)
                        {
                            GridStyleInfo cell = ActiveGrid.Model[row, col];
                            double        left = 0.0;
                            if (cell.HasTextMargins)
                            {
                                left = cell.TextMargins.Left;
                            }
                            if (IsIncrement)
                            {
                                cell.TextMargins = new CellMarginsInfo(left + 10, 0, 0, 0);
                            }
                            else if (left >= 10)
                            {
                                cell.TextMargins = new CellMarginsInfo(left - 10, 0, 0, 0);
                            }
                        }
                    }
                    ActiveGrid.Model.InvalidateCell(range);
                }
            }
        }
示例#8
0
        public void CurrentCellStyleChanged(int ActiveTabIndex, string propertyName, object value)
        {
            SampleGridControl ActiveGrid = ((Tab1.Items[ActiveTabIndex] as TabItem).Content as ScrollViewer).Content as SampleGridControl;

            if (!ActiveGrid.CurrentCell.HasCurrentCell)
            {
                return;
            }

            if (ActiveGrid != null && !ActiveGrid.Model.CurrentCellState.GridControl.CurrentCell.IsInMoveTo)
            {
                foreach (GridRangeInfo range in ActiveGrid.Model.SelectedRanges)
                {
                    for (int row = range.Top; row <= range.Bottom; row++)
                    {
                        for (int col = range.Left; col <= range.Right; col++)
                        {
                            switch (propertyName)
                            {
                            case "FontFamily":
                                ActiveGrid.Model[row, col].Font.FontFamily = (FontFamily)value;
                                break;

                            case "FontSize":
                            {
                                ActiveGrid.Model[row, col].Font.FontSize = (double)value;
                                ActiveGrid.Model.ResizeRowsToFit(GridRangeInfo.Cell(row, col), GridResizeToFitOptions.None);
                            }
                            break;

                            case "FontWeight":
                                ActiveGrid.Model[row, col].Font.FontWeight = (FontWeight)value;
                                break;

                            case "FontStyle":
                                ActiveGrid.Model[row, col].Font.FontStyle = (FontStyle)value;
                                break;

                            case "TextDecorations":
                                ActiveGrid.Model[row, col].Font.TextDecorations = (TextDecorationCollection)value;
                                break;

                            case "Background":
                                ActiveGrid.Model[row, col].Background = new SolidColorBrush(BackgroundColorPicker.Color);
                                break;

                            case "Foreground":
                                ActiveGrid.Model[row, col].Foreground = new SolidColorBrush(ForegroundColorPicker.Color);
                                break;

                            case "HorizontalAlignment":
                                ActiveGrid.Model[row, col].HorizontalAlignment = (HorizontalAlignment)value;
                                break;

                            case "VerticalAlignment":
                                ActiveGrid.Model[row, col].VerticalAlignment = (VerticalAlignment)value;
                                break;

                            default:
                                break;
                            }
                        }
                    }
                    ActiveGrid.Model.InvalidateCell(range);
                }
            }
        }
示例#9
0
        public void ExecutePrintCommand(int ActiveTabIndex)
        {
            SampleGridControl ActiveGrid = ((Tab1.Items[ActiveTabIndex] as TabItem).Content as ScrollViewer).Content as SampleGridControl;

            ActiveGrid.Print();
        }