示例#1
0
        /// <summary>
        /// Grid popup menu 點擊事件處裡常式。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void GridMenu_Click(object sender, SourceGrid.CellContextEventArgs e)
        {
            PopupMenuController menuCtrl = (PopupMenuController)sender;

            SourceGrid.CellContext cell = e.CellContext;
            SourceGrid.Grid        grid = (SourceGrid.Grid)cell.Grid;
            int row = cell.Position.Row;
            int col = cell.Position.Column;

            switch (menuCtrl.Command)
            {
            case "Edit":
                EditCell(grid, row, col);
                break;

            case "Insert":
                InsertCell(grid, row, col);
                break;

            case "InsertBlank":                      // 插入空方
                InsertBlankCell(grid, row, col, 1);
                break;

            case "Append":                      // 在列尾插入空方
                AppendCell(grid, row, col);
                break;

            case "InsertLine":                      // 插入一列
                InsertLine(grid, row, col);
                break;

            case "Delete":
                DeleteCell(grid, row, col);
                break;

            case "Backspace":
                BackspaceCell(grid, row, col);
                break;

            case "DeleteLine":
                DeleteLine(grid, row, col, true);
                break;

            default:
                break;
            }
        }
示例#2
0
        private void InitializeGrid()
        {
            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.Lines.Count * 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();
                m_HeaderView.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();
                backHeader.BackColor     = Color.Blue;
                m_HeaderView2.Background = backHeader;
                m_HeaderView2.Font       = m_HeaderView.Font;
            }

            CreateFixedArea();

            // Font objects

            if (m_PhonFont == null)
            {
                m_PhonFont = new Font("PMingLiU", DualEditForm.DefaultPhoneticFontSize, FontStyle.Regular, GraphicsUnit.Point, 1);
            }

            if (m_MingFont == null)
            {
                m_MingFont = new Font("Arial Unicode MS", DualEditForm.DefaultTextFontSize, FontStyle.Regular, GraphicsUnit.Point, 0);
                // Note: 原本為新細明體,可是為了顯示英文音標等特殊符號,必須使用 Arial Unicode MS 字型。
            }
            if (m_MingFontCJK == null)
            {
                m_MingFontCJK = new Font("PMingLiU", DualEditForm.DefaultTextFontSize, FontStyle.Regular, GraphicsUnit.Point, 1);
            }

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

            // view for 明眼字
            if (m_MingView == null)
            {
                m_MingView                  = new SourceGrid.Cells.Views.Cell();
                m_MingView.BackColor        = Color.Snow;
                m_MingView.Font             = m_MingFont;
                m_MingView.ElementText.Font = m_MingFont;
            }

            if (m_MingViewCJK == null)
            {
                m_MingViewCJK                  = new SourceGrid.Cells.Views.Cell();
                m_MingViewCJK.BackColor        = Color.Snow;
                m_MingViewCJK.Font             = m_MingFontCJK;
                m_MingViewCJK.ElementText.Font = m_MingFontCJK;
            }

            // view for 注音符號
            if (m_PhonView == null)
            {
                m_PhonView              = new SourceGrid.Cells.Views.Cell();
                m_PhonView.BackColor    = Color.YellowGreen;
                m_PhonView.Font         = m_PhonFont;
                m_PhonView.TrimmingMode = SourceGrid.TrimmingMode.None;
            }

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

            // 設置 controllers
            if (m_MenuController == null)
            {
                m_MenuController = new PopupMenuController();
                m_MenuController.PopupMenuClick += new SourceGrid.CellContextEventHandler(GridMenu_Click);
            }

            if (m_ClickController == null)
            {
                m_ClickController = new CellClickEvent(this);
            }

            m_IsInitialized = true;
        }