예제 #1
0
        public static void SetRangeFormat(MySpreadsheet my, ReoGridControl workbook)
        {
            var fmt = new Dialogs.Format.NumberDate();

            fmt.StartPosition = FormStartPosition.Manual;
            fmt.Location      = new Point(my.Location.X + 20, my.Location.Y + 40);

            if (fmt.ShowDialog(my) == DialogResult.OK)
            {
                var currentSheet = workbook.CurrentWorksheet;
                var range        = currentSheet.SelectionRange;
                switch (fmt.Flag)
                {
                case CellDataFormatFlag.Number:
                    FormatNumber(fmt, currentSheet, range);
                    break;

                case CellDataFormatFlag.DateTime:
                    FormatDate(currentSheet, range);
                    break;

                case CellDataFormatFlag.Text:
                    FormatText(currentSheet, range);
                    break;

                default:
                    FormatNumber(fmt, currentSheet, range);
                    break;
                }
            }
        }
        public Form1()
        {
            InitializeComponent();
            MySpreadsheet = new MySpreadsheet(50, 26);
            MySpreadsheet.CellPropertyChanged += new PropertyChangedEventHandler(SpreadSheetPropertyChanged);
            //Move the following into data-grid initialization
            //Populates the data grid with columns 'A' through 'Z'
            for (char col = 'A'; col <= 'Z'; ++col)
            {
                dataGridView1.Columns.Add("Column" + col, col.ToString());
            }
            //Creates 50 rows in the datagridview and numbers each row
            dataGridView1.Rows.Add(50);
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                row.HeaderCell.Value = (row.Index + 1).ToString();
            }

            //Fires when an event occurs which requires updating the UI cells, hacky use of PropertyChangedEventArgs parameter
            //used to pass the row and column of the cell which needs to be updated
            void SpreadSheetPropertyChanged(object sender, PropertyChangedEventArgs e)
            {
                AbstractCell cell   = (AbstractCell)sender;
                int          row    = cell.RowIndex;
                int          column = cell.ColumnIndex;

                dataGridView1[column, row].Value = MySpreadsheet.getCell(row, column).EvaluatedValue;
            }
        }
예제 #3
0
        public static void SetColors(MySpreadsheet my, ReoGridControl workbook)
        {
            var color = new Dialogs.Format.Color();

            color.StartPosition = FormStartPosition.Manual;
            color.Location      = new Point(my.Location.X + 20, my.Location.Y + 40);
            var currentSheet = workbook.CurrentWorksheet;
            var range        = currentSheet.SelectionRange;

            color.Initialize(currentSheet.GetRangeStyles(range));

            if (color.ShowDialog(my) == DialogResult.OK)
            {
                currentSheet.SetRangeStyles(currentSheet.SelectionRange, color.Colors);
            }
        }
예제 #4
0
        public static void SetBorder(MySpreadsheet my, ReoGridControl workbook)
        {
            var borderStyle = new Dialogs.Format.Borders();

            borderStyle.StartPosition = FormStartPosition.Manual;
            borderStyle.Location      = new Point(my.Location.X + 20, my.Location.Y + 40);
            var currentSheet = workbook.CurrentWorksheet;
            var range        = currentSheet.SelectionRange;

            if (borderStyle.ShowDialog(my) == DialogResult.OK)
            {
                currentSheet.SetRangeBorders(currentSheet.SelectionRange, borderStyle.BorderPosition,
                                             new RangeBorderStyle
                {
                    Color = borderStyle.BorderColor,
                    Style = borderStyle.LineStyle,
                });
            }
        }