Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cell"></param>
        /// <param name="e"></param>
        /// <param name="handled"></param>
        protected override void PaintCellForeground(Xceed.Grid.Cell cell, Xceed.Grid.GridPaintEventArgs e, ref bool handled)
        {
            if ((Control.MouseButtons == MouseButtons.Left) &&
                (cell.RectangleToScreen(e.ClientRectangle).Contains(Control.MousePosition)))
            {
                ControlPaint.DrawButton(e.Graphics, e.DisplayRectangle, ButtonState.Pushed);
            }
            else
            {
                ControlPaint.DrawButton(e.Graphics, e.DisplayRectangle, ButtonState.Normal);
            }

            //using (SolidBrush brush = new SolidBrush(cell.GetDisplayVisualStyle(VisualGridElementState.Idle).ForeColor))
            //{
            //    Rectangle textRectangle = e.DisplayRectangle;
            //    textRectangle.Inflate(-2, -2);

            //    if ((textRectangle.Height > 0) && (textRectangle.Width > 0))
            //    {
            //        // Paint a fixed text
            //        e.Graphics.DrawString(m_text, cell.Font, brush, textRectangle);

            //        // For text that follows the value of the cell, you could do someting like the following :
            //        // e.Graphics.DrawString( this.GetTextToPaint(), this.Font, brush, textRectangle );
            //    }
            //}
        }
Пример #2
0
        /// <summary>
        /// Add a new string into the string table.
        /// </summary>
        private void AddString()
        {
            int locID = GetNextLocID();

            if (locID == 0)
            {
                MessageBox.Show(this, "Oops. Could not get the next string ID.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Xceed.Grid.DataRow row = gridControl1.DataRows.AddNew();
            row.BeginEdit();

            Xceed.Grid.Cell cell = row.Cells["_locID"];
            cell.Value = locID;

            cell       = row.Cells["String_text"];
            cell.Value = "Insert Text Here";

            cell       = row.Cells["Language_Id"];
            cell.Value = "0";

            cell       = row.Cells["subtitle"];
            cell.Value = false;

            row.EndEdit();

            // If we have the filter enabled, we are going to add the string to group so that it shows up
            // in the view to avoid the "Hey, where's my string I just added?" issues that surely will arise
            if (m_filtered)
            {
                // Make sure that each parent group of the found data row are expanded.
                if ((row.ParentGroup != null) && row.ParentGroup.Collapsed)
                {
                    Group parentGroup = row.ParentGroup as Group;

                    while (parentGroup != null)
                    {
                        parentGroup.Expand();
                        parentGroup = parentGroup.ParentGroup as Group;
                    }
                }

                // Highlight the found data row by changing its back color
//         row.BackColor = Color.AliceBlue;
                // Highlight the found data row's parent groups by changing their
                // GroupManagerRow's back color.
                this.TagGroups(row);
                m_foundRows.Add(row);
            }

            gridControl1.UpdateGrouping();

            gridControl1.Scroll(Xceed.Grid.ScrollDirection.BottomPage);

            gridControl1.SelectedRows.Clear();
            gridControl1.SelectedRows.Add(row);
            gridControl1.CurrentRow = row;
        }
        // 表格配置用.xmlg,搜索窗口配置用.xmls
        void contextMenuStrip2_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            Xceed.Grid.Cell cell = m_contextMenuManagerColumnCell;
            if (cell == null)
            {
                return;
            }
            GridColumnInfo columnInfo = cell.ParentColumn.Tag as GridColumnInfo;

            if (columnInfo.EnableCopy.HasValue)
            {
                tsmCopyColumn.Visible = columnInfo.EnableCopy.Value;
            }

            GridInfo gridInfo = ADInfoBll.Instance.GetGridInfo(m_grid.GridName);

            if (!Authority.AuthorizeByRule(gridInfo.AllowInnerFilter))
            {
                tsmFilter.Visible = false;
            }
            else
            {
                tsmFilter.Checked = m_grid.GetFilterRowVisible();
            }

            tsmGroup.Checked = (m_grid.GetGroupByRow() != null);

            if (m_masterGrid != null &&
                tsmPresetLayout.DropDownItems.Count == 0)
            {
                string[] folders = new string[] { m_masterGrid.GetGridDefaultDataDirectory(), m_masterGrid.GetGridGlobalDataDirectory() };

                foreach (string folder in folders)
                {
                    if (!System.IO.Directory.Exists(folder))
                    {
                        continue;
                    }
                    foreach (string fileName in System.IO.Directory.GetFiles(folder, "*.xmlg"))
                    {
                        ToolStripMenuItem item = new ToolStripMenuItem();
                        item.Text   = System.IO.Path.GetFileName(fileName).Replace(".xmlg", "");
                        item.Tag    = fileName;
                        item.Click += new EventHandler(tsmPresetSubitem_Click);
                        tsmPresetLayout.DropDownItems.Add(item);
                    }
                }

                if (tsmPresetLayout.DropDownItems.Count == 0)
                {
                    tsmPresetLayout.Visible = false;
                }
            }
        }
        void cell_EditLeft(object sender, EditLeftEventArgs e)
        {
            Xceed.Grid.Cell cell = sender as Xceed.Grid.Cell;

            if (!Feng.Utils.ReflectionHelper.ObjectEquals(m_originalSelectedDataValue, cell.Value))
            {
                GridColumnInfo info = cell.ParentColumn.Tag as GridColumnInfo;
                string         s    = info != null ? info.GridColumnName : cell.ParentColumn.FieldName;
                m_cm.DisplayManager.OnSelectedDataValueChanged(new SelectedDataValueChangedEventArgs(s, cell));
            }
        }
Пример #5
0
 void tsmCopy_Click(object sender, System.EventArgs e)
 {
     if (m_contextCell != null)
     {
         MyGrid.CopySelectedCellsToClipboard(m_contextCell);
         m_contextCell = null;
     }
     else if (m_contextSelector != null)
     {
         MyGrid.CopySelectedRowsToClipboard(m_contextSelector.Row);
         m_contextSelector = null;
     }
 }
Пример #6
0
        private bool FindCell(Xceed.Grid.Cell currentCell)
        {
            if (m_grid.DataRows.Count == 0)
            {
                return(false);
            }

            int startx, starty;

            DetailGrid currentGrid;

            if (currentCell == null)
            {
                startx      = 0;
                starty      = 0;
                currentGrid = m_grid.DataRows[0].ParentGrid;
            }
            else
            {
                startx      = (currentCell.ParentRow as Xceed.Grid.DataRow).Index;
                starty      = !rbDirectionUp.Checked ? currentCell.ParentColumn.Index + 1 : currentCell.ParentColumn.Index - 1;
                currentGrid = currentCell.ParentColumn.ParentGrid;
            }

            if (!rbDirectionUp.Checked)
            {
                bool ret = CheckGridAsc(currentGrid, startx, starty);
                if (!ret)
                {
                    return(CheckGridAsc(currentGrid, 0, 0));
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                bool ret = CheckGridDesc(currentGrid, startx, starty);
                if (!ret)
                {
                    return(CheckGridDesc(currentGrid, currentGrid.DataRows.Count - 1, currentGrid.Columns.Count - 1));
                }
                else
                {
                    return(true);
                }
            }
        }
Пример #7
0
 void tsmShowCellContent_Click(object sender, System.EventArgs e)
 {
     if (m_contextCell != null)
     {
         if (m_contextCell.CellViewerManager != null && m_contextCell.CellViewerManager is Feng.Grid.Viewers.MultiLineViewer)
         {
             Xceed.Editors.WinTextBox textBox = Feng.Grid.Viewers.MultiLineViewer.GetMemoTextBox(m_contextCell.GridControl);
             if (textBox != null)
             {
                 textBox.Location = m_contextCell.ClientPointToGrid(new Point(0, 0));
                 (textBox.DropDownControl as Xceed.Editors.WinTextBox).TextBoxArea.Text = m_contextCell.Value == null ? null : m_contextCell.Value.ToString();
                 textBox.DroppedDown = true;
             }
         }
         m_contextCell = null;
     }
 }
Пример #8
0
 internal void cell_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         m_contextSelector = null;
         m_contextCell     = sender as Xceed.Grid.DataCell;
         if (m_contextCell.CellViewerManager != null && m_contextCell.CellViewerManager is Feng.Grid.Viewers.MultiLineViewer)
         {
             tsmShowCellContent.Visible = true;
         }
         else
         {
             tsmShowCellContent.Visible = false;
         }
         contextMenuStripForCell.Show(m_contextCell.PointToScreen(new System.Drawing.Point(e.X, e.Y)));
     }
 }
        private void tsm默认本列_Click(object sender, EventArgs e)
        {
            Xceed.Grid.Cell contextMenuCell = m_grid.GridHelper.ContextCell;

            if (contextMenuCell == null)
            {
                return;
            }

            if (contextMenuCell.IsBeingEdited)
            {
                contextMenuCell.LeaveEdit(true);
            }
            if (contextMenuCell.ParentRow.IsBeingEdited)
            {
                contextMenuCell.ParentRow.EndEdit();
            }

            BatchSetCellValueCommand.Execute(contextMenuCell, new ExecutedEventArgs(this));
        }
Пример #10
0
        internal void Cell_MouseEnter(object sender, System.EventArgs e)
        {
            m_toolTip.RemoveAll();

            Xceed.Grid.Cell cell = sender as Xceed.Grid.Cell;

            if (cell.Value != null && !string.IsNullOrEmpty(cell.Value.ToString()))
            {
                if (cell.ParentColumn.Width < cell.GetFittedWidth())
                {
                    m_toolTip.SetToolTip(cell.GridControl, cell.GetDisplayText());
                }
                else if (cell.CellViewerManager != null)
                {
                    if (cell.CellViewerManager.GetType() == typeof(Viewers.MultiLineViewer))
                    {
                        //if (cell.GetDisplayText().Contains("..."))
                        //{
                        //    m_toolTip.SetToolTip(cell.GridControl,
                        //                         cell.Value.ToString().Substring(0, Math.Min(cell.Value.ToString().Length, 500)));
                        //}
                        if (cell.Value != null && cell.Value.ToString().Contains(System.Environment.NewLine))
                        {
                            m_toolTip.SetToolTip(cell.GridControl, cell.Value.ToString());
                        }
                    }
                    else if (cell.CellViewerManager.GetType() == typeof(Viewers.ImageTextViewer))
                    {
                        m_toolTip.SetToolTip(cell.GridControl, cell.Value.ToString());
                    }
                }
            }


            //if (CellMouseEnter != null)
            //{
            //    CellMouseEnter(sender, e);
            //}
        }
Пример #11
0
 private void SetCurrentCell(Xceed.Grid.Cell currentCell)
 {
     m_grid.CurrentCell           = currentCell;
     m_grid.CurrentCell.BackColor = ColorSettings.Setting.LocatedRow;
     m_grid.CurrentCell.BringIntoView();
 }
Пример #12
0
 internal void cell_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         m_contextSelector = null;
         m_contextCell = sender as Xceed.Grid.DataCell;
         if (m_contextCell.CellViewerManager != null && m_contextCell.CellViewerManager is Feng.Grid.Viewers.MultiLineViewer)
         {
             tsmShowCellContent.Visible = true;
         }
         else
         {
             tsmShowCellContent.Visible = false;
         }
         contextMenuStripForCell.Show(m_contextCell.PointToScreen(new System.Drawing.Point(e.X, e.Y)));
     }
 }
        private static void OnBatchSetCellValueCommand(object sender, ExecutedEventArgs e)
        {
            Xceed.Grid.Cell   contextMenuCell = sender as Xceed.Grid.DataCell;
            ArchiveGridHelper gridHelper      = e.Parameter as ArchiveGridHelper;

            string fieldName = contextMenuCell.ParentColumn.FieldName;

            // 开始操作

            gridHelper.m_grid.DisplayManager.BeginBatchOperation();
            List <Xceed.Grid.DataRow> modifiedRows = new List <Xceed.Grid.DataRow>();

            gridHelper.m_grid.GridControl.SuspendLayout();

            //bool userBreak = false;
            foreach (Xceed.Grid.DataRow row in gridHelper.m_grid.GridControl.SelectedRows)
            {
                if (!row.Visible)
                {
                    continue;
                }
                if (row == contextMenuCell.ParentRow)
                {
                    continue;
                }

                if (row.Cells[fieldName].ReadOnly)
                {
                    continue;
                }

                if (row.Cells[fieldName].Value == null && contextMenuCell.Value == null)
                {
                    continue;
                }

                if (row.Cells[fieldName].Value != null && contextMenuCell.Value != null &&
                    row.Cells[fieldName].Value.ToString() == contextMenuCell.Value.ToString())
                {
                    continue;
                }

                bool doit = true;
                if (row.Cells[fieldName].Value != null)
                {
                    if (gridHelper.m_allowSetListWarning)
                    {
                        DialogResult dialogResult = System.Windows.Forms.MessageBox.Show("已有值 \"" + row.Cells[fieldName].GetDisplayText() + "\",是否改变?", "确认", System.Windows.Forms.MessageBoxButtons.YesNoCancel, System.Windows.Forms.MessageBoxIcon.Information);
                        if (dialogResult == DialogResult.Cancel)
                        {
                            //userBreak = true;
                            break;
                        }
                        else
                        {
                            doit = (dialogResult == DialogResult.Yes);
                        }
                    }
                }

                if (doit)
                {
                    try
                    {
                        row.BeginEdit();
                        object oldValue = row.Cells[fieldName].Value;

                        // 设置目标列值
                        row.Cells[fieldName].Value = contextMenuCell.Value;

                        if (row.Cells[fieldName].Value == oldValue)
                        {
                            continue;
                        }

                        // 有些因为Combo的原因,设置值有限制
                        row.Cells[fieldName].EnterEdit();
                        row.Cells[fieldName].LeaveEdit(true);
                        if (row.Cells[fieldName].Value == null && contextMenuCell.Value != null)
                        {
                            row.Cells[fieldName].Value = oldValue;
                            row.CancelEdit();
                            continue;
                        }
                        try
                        {
                            row.EndEdit();
                        }
                        catch (Exception)
                        {
                            // 当保存不进去的时候,cancel
                            row.CancelEdit();
                        }

                        modifiedRows.Add(row);

                        gridHelper.m_grid.ControlManager.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, row.Index));

                        //CancelEventArgs ee = new CancelEventArgs();
                        //row_EndingEdit(row, ee);
                    }
                    // 不知道
                    //// when in 批量费用登记(有分组的界面)
                    //catch (Xceed.Grid.GridValidationException)
                    //{
                    //}
                    catch (Exception ex)
                    {
                        row.CancelEdit();

                        ExceptionProcess.ProcessWithNotify(ex);

                        if (!MessageForm.ShowYesNo("出现错误,是否继续?"))
                        {
                            break;
                        }
                    }
                }
            }

            // 即使用户取消,也要保存先前的内容
            //if (userBreak)
            //{
            //}
            //else
            //{
            IBatchDao batchDao = gridHelper.m_grid.ControlManager.Dao as IBatchDao;

            if (batchDao == null)
            {
                ServiceProvider.GetService <IMessageBox>().ShowWarning("不支持批量保存,将逐条保存!");
            }
            try
            {
                if (batchDao != null)
                {
                    batchDao.SuspendOperation();
                }

                foreach (Xceed.Grid.DataRow row in modifiedRows)
                {
                    object entity = row.Tag;
                    foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(gridHelper.m_grid.GridName))
                    {
                        if (row.Cells[info.GridColumnName] != null && !string.IsNullOrEmpty(info.PropertyName))
                        {
                            if (row.Cells[info.GridColumnName].ReadOnly)
                            {
                                continue;
                            }

                            if (info.GridColumnType == GridColumnType.Normal)
                            {
                                EntityScript.SetPropertyValue(entity, info.Navigator, info.PropertyName,
                                                              row.Cells[info.GridColumnName].Value);
                            }
                        }
                    }
                    gridHelper.m_grid.ControlManager.Dao.Update(entity);
                }
                if (batchDao != null)
                {
                    batchDao.ResumeOperation();
                }
            }
            catch (Exception ex)
            {
                if (batchDao != null)
                {
                    batchDao.CancelSuspendOperation();
                }
                ExceptionProcess.ProcessWithNotify(ex);

                gridHelper.m_grid.ReloadData();
            }
            finally
            {
            }

            gridHelper.m_grid.GridControl.ResumeLayout();

            gridHelper.m_grid.DisplayManager.EndBatchOperation();

            MyGrid.SetCurrentRow(gridHelper.m_grid.GridControl, gridHelper.m_grid.DataRows[gridHelper.m_grid.DisplayManager.Position]);
            MyGrid.SyncSelectedRowToCurrentRow(gridHelper.m_grid.GridControl);
        }
Пример #14
0
 void tsmCopy_Click(object sender, System.EventArgs e)
 {
     if (m_contextCell != null)
     {
         MyGrid.CopySelectedCellsToClipboard(m_contextCell);
         m_contextCell = null;
     }
     else if (m_contextSelector != null)
     {
         MyGrid.CopySelectedRowsToClipboard(m_contextSelector.Row);
         m_contextSelector = null;
     }
 }
 void cell_EditEntered(object sender, EventArgs e)
 {
     Xceed.Grid.Cell cell = sender as Xceed.Grid.Cell;
     m_originalSelectedDataValue = cell.Value;
 }
Пример #16
0
 void tsmShowCellContent_Click(object sender, System.EventArgs e)
 {
     if (m_contextCell != null)
     {
         if (m_contextCell.CellViewerManager != null && m_contextCell.CellViewerManager is Feng.Grid.Viewers.MultiLineViewer)
         {
             Xceed.Editors.WinTextBox textBox = Feng.Grid.Viewers.MultiLineViewer.GetMemoTextBox(m_contextCell.GridControl);
             if (textBox != null)
             {
                 textBox.Location = m_contextCell.ClientPointToGrid(new Point(0, 0));
                 (textBox.DropDownControl as Xceed.Editors.WinTextBox).TextBoxArea.Text = m_contextCell.Value == null ? null : m_contextCell.Value.ToString();
                 textBox.DroppedDown = true;
             }
         }
         m_contextCell = null;
     }
 }
Пример #17
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cell"></param>
 protected override void SetControlValueCore(Xceed.Grid.Cell cell)
 {
     ((Button)this.Control).Text = m_text;
 }
Пример #18
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cell"></param>
 /// <param name="mode"></param>
 /// <param name="cellDisplayWidth"></param>
 /// <param name="graphics"></param>
 /// <param name="printing"></param>
 /// <returns></returns>
 protected override int GetFittedHeightCore(Xceed.Grid.Cell cell, Xceed.Grid.AutoHeightMode mode, int cellDisplayWidth, System.Drawing.Graphics graphics, bool printing)
 {
     return((int)Math.Ceiling(cell.Font.GetHeight()) + 4);
 }
Пример #19
0
 internal void RowSelector_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         m_contextSelector = sender as Xceed.Grid.RowSelector;
         m_contextCell = null;
         tsmShowCellContent.Visible = false;
         contextMenuStripForCell.Show(m_contextSelector.PointToScreen(new System.Drawing.Point(e.X, e.Y)));
     }
 }