Exemplo n.º 1
1
        private void Form1_Load(object sender, System.EventArgs e)
        {
            grid1.Redim(10, 5);
            grid1.SelectionMode = SourceGrid.GridSelectionMode.Row;

            //Setup the controllers
            CellClickEvent clickController  = new CellClickEvent();
            PopupMenu      menuController   = new PopupMenu();
            CellCursor     cursorController = new CellCursor();

            SourceGrid.Cells.Controllers.ToolTipText toolTipController = new SourceGrid.Cells.Controllers.ToolTipText();
            toolTipController.ToolTipTitle = "ToolTip example";
            toolTipController.ToolTipIcon  = ToolTipIcon.Info;
            toolTipController.IsBalloon    = true;
            ValueChangedEvent valueChangedController = new ValueChangedEvent();

            for (int r = 0; r < grid1.Rows.Count; r++)
            {
                if (r == 0)
                {
                    grid1[r, 0] = new SourceGrid.Cells.ColumnHeader("Click event");
                    grid1[r, 1] = new SourceGrid.Cells.ColumnHeader("Custom Cursor");
                    grid1[r, 2] = new SourceGrid.Cells.ColumnHeader("ContextMenu");
                    grid1[r, 3] = new SourceGrid.Cells.ColumnHeader("ToolTip");
                    grid1[r, 4] = new SourceGrid.Cells.ColumnHeader("ValueChanged");
                }
                else
                {
                    grid1[r, 0]             = new SourceGrid.Cells.Cell("Value " + r.ToString(), typeof(string));
                    grid1[r, 1]             = new SourceGrid.Cells.Cell(DateTime.Now, typeof(DateTime));
                    grid1[r, 2]             = new SourceGrid.Cells.Cell("Right click");
                    grid1[r, 3]             = new SourceGrid.Cells.Cell("Value " + r.ToString());
                    grid1[r, 3].ToolTipText = "Example of tooltip, bla bla bla ....\n Row: " + r.ToString();
                    grid1[r, 4]             = new SourceGrid.Cells.Cell("Value " + r.ToString(), typeof(string));
                }

                grid1[r, 0].AddController(clickController);
                grid1[r, 1].AddController(cursorController);
                grid1[r, 2].AddController(menuController);
                grid1[r, 3].AddController(toolTipController);
                grid1[r, 4].AddController(valueChangedController);
            }

            grid1.AutoSizeCells();

            //Add the key controller to all the cells
            grid1.Controller.AddController(new KeyEvent(this));
        }
Exemplo n.º 2
0
        private void btLoad_Click(object sender, System.EventArgs e)
        {
            grid.Redim(0, 0);
            //Visual properties shared between all the cells
            SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
            view.BackColor = Color.Snow;

            //Editor (IDataModel) shared between all the cells
            SourceGrid.Cells.Editors.TextBox editor = new
                                                      SourceGrid.Cells.Editors.TextBox(typeof(string));

            grid.Redim(int.Parse(txtRows.Text), int.Parse(txtCols.Text));

            if (chkAddHeaders.Checked && grid.RowsCount > 0 &&
                grid.ColumnsCount > 0)
            {
                grid.FixedRows    = 1;
                grid.FixedColumns = 1;

                for (int r = grid.FixedRows; r < grid.RowsCount; r++)
                {
                    grid[r, 0] = new SourceGrid.Cells.RowHeader(r);
                }
                for (int c = grid.FixedColumns; c < grid.ColumnsCount; c++)
                {
                    SourceGrid.Cells.ColumnHeader header = new
                                                           SourceGrid.Cells.ColumnHeader(c);
                    header.AutomaticSortEnabled = false;
                    grid[0, c] = header;
                }
                grid[0, 0] = new SourceGrid.Cells.Header();
            }
            else
            {
                grid.FixedRows    = 0;
                grid.FixedColumns = 0;
            }

            for (int r = grid.FixedRows; r < grid.RowsCount; r++)
            {
                for (int c = grid.FixedColumns; c < grid.ColumnsCount; c++)
                {
                    grid[r, c] = new SourceGrid.Cells.Cell(r.ToString() + "," +
                                                           c.ToString());
                    grid[r, c].Editor = editor;
                    grid[r, c].View   = view;
                }
            }
            grid.Selection.Focus(new SourceGrid.Position(0, 0), true);
        }
Exemplo n.º 3
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            grid1.Redim(10, 10);
            grid2.Redim(10, 10);
            Random rnd = new Random();

            for (int r = 0; r < grid1.RowsCount; r++)
            {
                for (int c = 0; c < grid1.ColumnsCount; c++)
                {
                    grid1[r, c] = new SourceGrid.Cells.Cell(rnd.NextDouble(), typeof(double));
                }
            }

            for (int r = 0; r < grid2.RowsCount; r++)
            {
                for (int c = 0; c < grid2.ColumnsCount; c++)
                {
                    grid2[r, c] = new SourceGrid.Cells.Cell("str" + r.ToString(), typeof(string));
                }
            }


            grid1.ClipboardMode = SourceGrid.ClipboardMode.All;
            grid2.ClipboardMode = SourceGrid.ClipboardMode.All;
        }
Exemplo n.º 4
0
        private void Form1_Load(object sender, System.EventArgs e)
        {
            grid1.Redim(10, 3);

            CellClickEvent clickController  = new CellClickEvent();
            PopupMenu      menuController   = new PopupMenu();
            CellCursor     cursorController = new CellCursor();

            for (int r = 0; r < grid1.Rows.Count; r++)
            {
                if (r == 0)
                {
                    grid1[r, 0] = new SourceGrid.Cells.ColumnHeader("Click event");
                    grid1[r, 1] = new SourceGrid.Cells.ColumnHeader("Custom Cursor");
                    grid1[r, 2] = new SourceGrid.Cells.ColumnHeader("ContextMenu");
                }
                else
                {
                    grid1[r, 0] = new SourceGrid.Cells.Cell("Value " + r.ToString(), typeof(string));
                    grid1[r, 1] = new SourceGrid.Cells.Cell(DateTime.Now, typeof(DateTime));
                    grid1[r, 2] = new SourceGrid.Cells.Cell("Right click");
                }

                grid1[r, 0].AddController(clickController);
                grid1[r, 1].AddController(cursorController);
                grid1[r, 2].AddController(menuController);
            }

            grid1.AutoSizeCells();
        }
Exemplo n.º 5
0
        private void frmSample17_Load(object sender, System.EventArgs e)
        {
            grid1.Redim(40, 40);
            grid1.FixedColumns = 1;
            grid1.FixedRows    = 1;

            grid1[0, 0] = new SourceGrid.Cells.Header(null);
            for (int c = 1; c < grid1.ColumnsCount; c++)
            {
                SourceGrid.Cells.ColumnHeader header = new SourceGrid.Cells.ColumnHeader("Header " + c.ToString());
                header.AutomaticSortEnabled = false;

                //header.ColumnSelectorEnabled = true;
                //header.ColumnFocusEnabled = true;

                grid1[0, c] = header;
            }

            Random rnd = new Random();

            for (int r = 1; r < grid1.RowsCount; r++)
            {
                grid1[r, 0] = new SourceGrid.Cells.RowHeader("Header " + r.ToString());
                for (int c = 1; c < grid1.ColumnsCount; c++)
                {
                    if (rnd.NextDouble() > 0.20)
                    {
                        grid1[r, c] = new SourceGrid.Cells.Cell(r * c, typeof(int));
                    }
                    else
                    {
                        grid1[r, c] = null;
                    }
                }
            }

            var selection = grid1.Selection as SelectionBase;

            cPickSelBackColor.SelectedColor = Color.FromArgb(selection.BackColor.R, selection.BackColor.G, selection.BackColor.B);
            cPckBorderColor.SelectedColor   = selection.Border.Top.Color;
            trackSelectionAlpha.Value       = (int)selection.BackColor.A;
            trackBorderWidth.Value          = (int)selection.Border.Top.Width;

            cPickFocusBackColor.SelectedColor = Color.FromArgb(selection.FocusBackColor.R, selection.FocusBackColor.G, selection.FocusBackColor.B);
            trackFocusBackColorTrans.Value    = selection.FocusBackColor.A;


            this.cPickSelBackColor.SelectedColorChanged   += new System.EventHandler(this.cPickSelBackColor_SelectedColorChanged);
            this.cPckBorderColor.SelectedColorChanged     += new System.EventHandler(this.cPckBorderColor_SelectedColorChanged);
            this.trackSelectionAlpha.ValueChanged         += new System.EventHandler(this.trackSelectionAlpha_ValueChanged);
            this.trackBorderWidth.ValueChanged            += new System.EventHandler(this.trackBorderWidth_ValueChanged);
            this.trackFocusBackColorTrans.ValueChanged    += new System.EventHandler(this.trackFocusBackColorTrans_ValueChanged);
            this.cPickFocusBackColor.SelectedColorChanged += new System.EventHandler(this.cPickFocusBackColor_SelectedColorChanged);

            cbDashStyle.Validator = new DevAge.ComponentModel.Validator.ValidatorTypeConverter(typeof(System.Drawing.Drawing2D.DashStyle));
            cbDashStyle.Value     = selection.Border.Top.DashStyle;
        }
Exemplo n.º 6
0
        private void frmSample17_Load(object sender, System.EventArgs e)
        {
            grid1.Redim(100, 40);
            grid1.FixedColumns = 0;
            grid1.FixedRows    = 0;

            grid1[0, 0] = new SourceGrid.Cells.Header(null);
            for (int c = 1; c < grid1.ColumnsCount; c++)
            {
                SourceGrid.Cells.ColumnHeader header = new SourceGrid.Cells.ColumnHeader("Header " + c.ToString());
                header.AutomaticSortEnabled = false;

                //header.ColumnSelectorEnabled = true;
                //header.ColumnFocusEnabled = true;

                grid1[0, c] = header;
            }

            Random rnd = new Random();

            for (int r = 1; r < grid1.RowsCount; r++)
            {
                grid1[r, 0] = new SourceGrid.Cells.RowHeader("Header " + r.ToString());
                for (int c = 1; c < grid1.ColumnsCount; c++)
                {
                    if (rnd.NextDouble() > 0.20)
                    {
                        grid1[r, c] = new SourceGrid.Cells.Cell(r * c, typeof(int));
                    }
                    else
                    {
                        grid1[r, c] = null;
                    }
                }
            }

            var selection = grid1.Selection as SelectionBase;

            for (int i = 0; i < 100; i++)
            {
                grid1[i, 0] = new Cell(i);
            }

            for (int i = 30; i < 70; i++)
            {
                grid1.Rows.ShowRow(i, false);
            }
        }
Exemplo n.º 7
0
        private void SetGrid(SourceGrid.Grid grid, Dictionary <string, bool> dic, string c1, string c2)
        {
            grid.BorderStyle = BorderStyle.FixedSingle;
            grid.Redim(dic.Count + 1, 2);

            AddOneRow(grid, 0, c1, c2, true);
            int i = 0;

            foreach (KeyValuePair <string, bool> pair in dic)
            {
                string showState = pair.Value ? "on" : "off";
                AddOneRow(grid, i++ + 1, pair.Key, showState, false);
            }

            grid.Selection.SelectRow(1, true);
            grid.Selection.EnableMultiSelection = false;
        }
Exemplo n.º 8
0
        private void btLoad_Click(object sender, System.EventArgs e)
        {
            //Visual properties shared between all the cells
            SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
            view.BackColor = Color.Snow;

            //Editor (IDataModel) shared between all the cells
            SourceGrid.Cells.Editors.TextBox editor = new SourceGrid.Cells.Editors.TextBox(typeof(string));

            grid.Redim(int.Parse(txtRows.Text), int.Parse(txtCols.Text));

            for (int r = 0; r < grid.RowsCount; r++)
            {
                for (int c = 0; c < grid.ColumnsCount; c++)
                {
                    grid[r, c]        = new SourceGrid.Cells.Cell(r.ToString() + "," + c.ToString());
                    grid[r, c].Editor = editor;
                    grid[r, c].View   = view;
                }
            }
        }
Exemplo n.º 9
0
        private void frmSample19_Load(object sender, System.EventArgs e)
        {
            grid1.Redim(20, 20);

            grid1.BackgroundImage           = Properties.Resources.BackGround;
            grid1.ScrollablePanel.BackColor = Color.Transparent;

            Random rnd = new Random();

            SourceGrid.Cells.Views.Cell transparentView = new SourceGrid.Cells.Views.Cell();
            transparentView.BackColor = Color.Transparent;
            SourceGrid.Cells.Views.Cell semiTransparentView = new SourceGrid.Cells.Views.Cell();
            semiTransparentView.BackColor = Color.FromArgb(50, Color.Blue);

            for (int r = 0; r < grid1.RowsCount; r++)
            {
                for (int c = 0; c < grid1.ColumnsCount; c++)
                {
                    if (rnd.Next(0, 100) < 50)
                    {
                        grid1[r, c] = new SourceGrid.Cells.Cell("Opaque");
                    }
                    else if (rnd.Next(0, 100) < 75)
                    {
                        SourceGrid.Cells.Cell l_Cell = new SourceGrid.Cells.Cell("Transparent");
                        l_Cell.View = transparentView;
                        grid1[r, c] = l_Cell;
                    }
                    else
                    {
                        SourceGrid.Cells.Cell l_Cell = new SourceGrid.Cells.Cell("Transparent 50");
                        l_Cell.View = semiTransparentView;
                        grid1[r, c] = l_Cell;
                    }
                }
            }

            grid1.AutoSizeCells();
        }
Exemplo n.º 10
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            grid1.Redim(10, 10);
            grid2.Redim(10, 10);
            Random rnd = new Random();

            for (int r = 0; r < grid1.RowsCount; r++)
            {
                for (int c = 0; c < grid1.ColumnsCount; c++)
                {
                    grid1[r, c] = new SourceGrid.Cells.Cell(rnd.NextDouble(), typeof(double));
                }
            }

            for (int r = 0; r < grid2.RowsCount; r++)
            {
                for (int c = 0; c < grid2.ColumnsCount; c++)
                {
                    grid2[r, c] = new SourceGrid.Cells.Cell(rnd.NextDouble(), typeof(double));
                }
            }


            grid1.GridController.AddController(SourceGrid.Controllers.SelectionDrag.Cut);
            grid2.GridController.AddController(SourceGrid.Controllers.SelectionDrag.Cut);

            grid1.GridController.AddController(SourceGrid.Controllers.SelectionDrop.Default);
            grid2.GridController.AddController(SourceGrid.Controllers.SelectionDrop.Default);

            grid1.GridController.AddController(SourceGrid.Controllers.SelectionDelete.Default);
            grid2.GridController.AddController(SourceGrid.Controllers.SelectionDelete.Default);

            grid1.GridController.AddController(SourceGrid.Controllers.SelectionClipboard.CopyCut);
            grid2.GridController.AddController(SourceGrid.Controllers.SelectionClipboard.CopyCut);
        }
Exemplo n.º 11
0
        private void frmSample14_Load(object sender, System.EventArgs e)
        {
            grid1.Redim(20, 10);
            grid1.FixedRows = 2;

            //1 Header Row
            grid1[0, 0]            = new MyHeader("3 Column Header");
            grid1[0, 0].ColumnSpan = 3;
            grid1[0, 3]            = new MyHeader("5 Column Header");
            grid1[0, 3].ColumnSpan = 5;
            grid1[0, 8]            = new MyHeader("1 Column Header");
            grid1[0, 9]            = new MyHeader("1 Column Header");

            //2 Header Row
            grid1[1, 0] = new MyHeader("1");
            grid1[1, 1] = new MyHeader("2");
            grid1[1, 2] = new MyHeader("3");
            grid1[1, 3] = new MyHeader("4");
            grid1[1, 4] = new MyHeader("5");
            grid1[1, 5] = new MyHeader("6");
            grid1[1, 6] = new MyHeader("7");
            grid1[1, 7] = new MyHeader("8");
            grid1[1, 8] = new MyHeader("9");
            grid1[1, 9] = new MyHeader("10");

            SourceGrid.Cells.Views.Cell viewImage = new SourceGrid.Cells.Views.Cell();

            SourceGrid.Cells.Controllers.CustomEvents clickEvent = new SourceGrid.Cells.Controllers.CustomEvents();
            clickEvent.Click += new EventHandler(clickEvent_Click);

            for (int r = 2; r < grid1.RowsCount; r = r + 2)
            {
                grid1[r, 0]            = new SourceGrid.Cells.Cell(r.ToString(), typeof(string));
                grid1[r, 0].ColumnSpan = 2;

                grid1[r + 1, 0]            = new SourceGrid.Cells.Cell(DateTime.Today.AddDays(r), typeof(DateTime));
                grid1[r + 1, 0].ColumnSpan = 2;

                grid1[r, 2]            = new SourceGrid.Cells.CheckBox("CheckBox Column/Row Span", false);
                grid1[r, 2].ColumnSpan = 2;
                grid1[r, 2].RowSpan    = 2;

                grid1[r, 4]            = new SourceGrid.Cells.Link("Link Column/Row Span");
                grid1[r, 4].ColumnSpan = 2;
                grid1[r, 4].RowSpan    = 2;
                grid1[r, 4].AddController(clickEvent);

                grid1[r, 6]            = new SourceGrid.Cells.Button("Button Column/Row Span");
                grid1[r, 6].ColumnSpan = 2;
                grid1[r, 6].RowSpan    = 2;
                grid1[r, 6].AddController(clickEvent);

                grid1[r, 8]            = new SourceGrid.Cells.Cell("Image Column/Row Span");
                grid1[r, 8].View       = viewImage;
                grid1[r, 8].Image      = Properties.Resources.FACE02.ToBitmap();
                grid1[r, 8].ColumnSpan = 2;
                grid1[r, 8].RowSpan    = 2;
            }

            grid1.AutoSizeCells();
        }
Exemplo n.º 12
0
        private void btLoad_Click(object sender, System.EventArgs e)
        {
            using (var counter = new PerformanceCounter())
            {
                grid.Redim(0, 0);
                //Visual properties shared between all the cells
                SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
                view.BackColor = Color.Snow;

                //Editor (IDataModel) shared between all the cells
                SourceGrid.Cells.Editors.TextBox editor = new
                                                          SourceGrid.Cells.Editors.TextBox(typeof(string));

                grid.Redim(int.Parse(txtRows.Text), int.Parse(txtCols.Text));

                if (chkAddHeaders.Checked && grid.RowsCount > 0 &&
                    grid.ColumnsCount > 0)
                {
                    grid.FixedRows    = 1;
                    grid.FixedColumns = 1;

                    for (int r = grid.FixedRows; r < grid.RowsCount; r++)
                    {
                        grid[r, 0] = new SourceGrid.Cells.RowHeader(r);
                    }

                    for (int c = grid.FixedColumns; c < grid.ColumnsCount; c++)
                    {
                        SourceGrid.Cells.ColumnHeader header = new
                                                               SourceGrid.Cells.ColumnHeader(c);
                        header.AutomaticSortEnabled = false;
                        grid[0, c] = header;
                    }
                    grid[0, 0] = new SourceGrid.Cells.Header();
                }
                else
                {
                    grid.FixedRows    = 0;
                    grid.FixedColumns = 0;
                }

                for (int r = grid.FixedRows; r < grid.RowsCount; r++)
                {
                    for (int c = grid.FixedColumns; c < grid.ColumnsCount; c++)
                    {
                        grid[r, c] = new SourceGrid.Cells.Cell(r.ToString() + "," +
                                                               c.ToString());
                        grid[r, c].Editor = editor;
                        grid[r, c].View   = view;
                        var span = 3;
                        if (chkAddColspan.Checked && (c + span < grid.ColumnsCount))
                        {
                            if (r % 2 == 0)
                            {
                                grid[r, c].ColumnSpan = span;
                                c += span;
                            }
                        }
                    }
                }
                grid.Selection.Focus(new SourceGrid.Position(0, 0), true);
                this.toolStripStatusLabelBuildTime.Text = string.Format(
                    "Rows added in {0} ms", counter.GetMilisec());
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// 初始化 Grid。
        /// </summary>
        /// <param name="popupMenuClickHandler">在 Grid 上點滑鼠右鍵出現 popup 選單時,使用者點擊其中某 menuitem 的事件處理常式。</param>
        public void InitializeGrid(SourceGrid.CellContextEventHandler popupMenuClickHandler)
        {
            if (m_IsInitialized)
            {
                return;
            }

            // 設定 grid 預設的欄寬與列高
            brGrid.DefaultWidth  = 30;
            brGrid.DefaultHeight = 20;

            // 設定 grid 列數與行數。
            int maxCol = m_BrDoc.CellsPerLine;              // brDoc.LongestLine.Words.Count;

            brGrid.Redim(m_BrDoc.LineCount * 3 + FixedRows, maxCol + FixedColumns);

            // 設定欄寬最小限制,以免呼叫 AutoSizeView 時,欄寬被縮得太小。
            for (int i = 1; i < brGrid.ColumnsCount; i++)
            {
                brGrid.Columns[i].MinimalWidth = 24;
            }
            brGrid.Columns[0].MinimalWidth = 40;                // 第 0 欄要顯示列號,需要寬些.


            // 標題欄
            if (m_HeaderView == null)
            {
                m_HeaderView = new SourceGrid.Cells.Views.Header
                {
                    Font = new Font(brGrid.Font, FontStyle.Regular)
                };
            }

            if (m_HeaderView2 == null)
            {
                m_HeaderView2 = new SourceGrid.Cells.Views.RowHeader();
                DevAge.Drawing.VisualElements.RowHeader backHeader = new DevAge.Drawing.VisualElements.RowHeader
                {
                    BackColor = Color.Blue
                };
                m_HeaderView2.Background = backHeader;
                m_HeaderView2.Font       = m_HeaderView.Font;
            }

            CreateFixedArea();

            // view for 點字
            if (m_BrView == null)
            {
                m_BrView              = new SourceGrid.Cells.Views.Cell();
                m_BrView.BackColor    = Color.Snow;
                m_BrView.Font         = new Font("SimBraille", DefaultBrailleFontSize);
                m_BrView.TrimmingMode = SourceGrid.TrimmingMode.None;
            }

            // view for 明眼字
            if (m_MingView == null)
            {
                m_MingView = new SourceGrid.Cells.Views.Cell
                {
                    BackColor = Color.Snow,
                    Font      = new Font("Arial Unicode MS", DefaultTextFontSize, FontStyle.Regular, GraphicsUnit.Point, 1)
                };
            }
            if (m_MingViewCJK == null)
            {
                m_MingViewCJK                  = new SourceGrid.Cells.Views.Cell();
                m_MingViewCJK.BackColor        = Color.Snow;
                m_MingViewCJK.Font             = new Font("PMingLiU", DefaultTextFontSize, FontStyle.Regular, GraphicsUnit.Point, 1);
                m_MingViewCJK.ElementText.Font = m_MingView.Font;
            }

            // view for 注音符號
            if (m_PhonFont == null)
            {
                m_PhonFont = new Font("PMingLiU", DefaultPhoneticFontSize, FontStyle.Regular, GraphicsUnit.Point, 1);
            }

            if (m_PhonView == null)
            {
                m_PhonView = new SourceGrid.Cells.Views.Cell
                {
                    BackColor    = Color.YellowGreen,
                    Font         = m_PhonFont,
                    TrimmingMode = SourceGrid.TrimmingMode.None
                };
            }

            // view for 破音字的注音符號
            if (m_PhonView2 == null)
            {
                m_PhonView2 = new SourceGrid.Cells.Views.Cell
                {
                    BackColor    = Color.Yellow,
                    Font         = m_PhonFont,
                    TrimmingMode = SourceGrid.TrimmingMode.None
                };
            }
            // view for 容易判斷錯誤的破音字注音符號
            if (m_PhonView3 == null)
            {
                m_PhonView3 = new SourceGrid.Cells.Views.Cell
                {
                    BackColor    = Color.Red,
                    Font         = m_PhonFont,
                    TrimmingMode = SourceGrid.TrimmingMode.None
                };
            }

            // 設置 controllers
            if (m_MenuController == null && popupMenuClickHandler != null)
            {
                m_MenuController = new PopupMenuController();
                m_MenuController.PopupMenuClick += popupMenuClickHandler;
            }

            m_IsInitialized = true;
        }