using System; using System.Windows; using DevExpress.XtraGrid; using DevExpress.XtraGrid.Views.Grid; using System.Drawing; using System.ComponentModel; using System.Windows.Forms; using System.Drawing.Imaging; using System.Drawing.Drawing2D; using DevExpress.XtraGrid.Columns; using System.Collections.Generic; using System.Linq; using System.IO; using System.Xml; using DevExpress.XtraGrid.Views.Grid.ViewInfo; using DevExpress.XtraEditors.Repository; using DevExpress.XtraEditors; using DevExpress.Utils; using System.Reflection; using DevExpress.XtraGrid.Views.Base; using DevExpress.XtraGrid.Registrator; namespace WMS.Ctrl { [System.ComponentModel.ComplexBindingProperties("DataSource", "DataMember")] //添加到自定义UI绑定里 public class GridControlCustom : GridControl { #region 定义变量 private Bitmap _Image = null; private Bitmap _ImageOld = null; private Boolean showRowID = true; private int indicatorWidth = 40; bool addEvent = false; GridHitInfo hitInfoPopupMenu = null; #endregion #region 右键菜单 Boolean isMouseClieck = false; private System.Windows.Forms.ContextMenuStrip contextMenuGridControlCustom; //private System.Windows.Forms.ToolStripMenuItem tCut; private System.Windows.Forms.ToolStripMenuItem tDeleteRow;//删除行 private System.Windows.Forms.ToolStripMenuItem tCopy; private System.Windows.Forms.ToolStripMenuItem tCopyData; private System.Windows.Forms.ToolStripMenuItem tCopyRow; //private System.Windows.Forms.ToolStripMenuItem tPaste; private System.Windows.Forms.ToolStripSeparator tStripSeparator1; private System.Windows.Forms.ToolStripMenuItem tFixedTrue; private System.Windows.Forms.ToolStripMenuItem tFixedAllFalse; private System.Windows.Forms.ToolStripMenuItem tFixedLeft; /// /// 显示脚区 /// private System.Windows.Forms.ToolStripMenuItem tShowFooter; private IContainer components; private System.Windows.Forms.ToolStripSeparator tStripSeparator2; private System.Windows.Forms.ToolStripMenuItem tSaveStyle; private System.Windows.Forms.ToolStripMenuItem tCloseStyle; //缺货 private System.Windows.Forms.ToolStripSeparator tStripSeparator3; private System.Windows.Forms.ToolStripMenuItem tSelectAll; //全选 private System.Windows.Forms.ToolStripMenuItem tUnSelectAll; //全取消 private System.Windows.Forms.ToolStripMenuItem tExportLayout; //全取消 private ToolStripSeparator tStripSeparator4; private ToolStripMenuItem tExpandAll; private ToolStripMenuItem tCollapseAll; private ToolStripMenuItem tColFind; private ToolStripMenuItem tColGroup; private ToolStripSeparator tStripSeparator5; #endregion #region 属性定义 /// /// 是否显示行号 /// [Category("自定义属性"), Description("显示行号")] public Boolean ShowRowID { get { return showRowID; } set { showRowID = value; } } /// /// 默认行号宽度 /// [Category("自定义属性"), Description("行号宽度")] public int IndicatorWidth { get { return indicatorWidth; } set { indicatorWidth = value; } } private string colorVerifyFlagColumn; /// /// 审核标志列名 /// [Category("自定义属性"), Description("审核标志列名")] public string ColorVerifyFlagColumn { get { return colorVerifyFlagColumn; } set { colorVerifyFlagColumn = value; } } private string colorShortageFlagColumn; /// /// 警示标志列名 /// [Category("自定义属性"), Description("警示标志列名")] public string ColorShortageFlagColumn { get { return colorShortageFlagColumn; } set { colorShortageFlagColumn = value; } } private bool enableAppearanceEvenRow = true;//是否允许隔行显示 /// /// 是否允许隔行显示 /// [Category("自定义属性"), Description("是否允许隔行显示")] public bool EnableAppearanceEvenRow { get { return enableAppearanceEvenRow; } set { enableAppearanceEvenRow = value; this.Invalidate(); } } #endregion #region 颜色设置 /// /// 选中行颜色 /// private Color colorSelectedRow = System.Drawing.Color.Empty; private Color colorSelectedRowDefault = ColorCustom.SelectedRow; /// /// 选中行颜色 /// [Category("自定义属性"), Description("选中行颜色")] public Color ColorSelectedRow { get { return colorSelectedRow; } set { colorSelectedRow = value; } } private Color colorVerify = System.Drawing.Color.Empty; //已审核 private Color colorVerifyDefault = ColorCustom.Verify; //已审核 /// /// 已审核:1 默认颜色:Lime /// [Category("自定义属性"), Description("已审核:1 默认颜色:Lime")] public Color ColorVerify { get { return colorVerify; } set { colorVerify = value; if (colorVerify != System.Drawing.Color.Empty) { colorVerifyDefault = colorVerify; } } } private string colorVerifyValue; private string colorVerifyValueDefault = "1"; /// /// 已审核标志值,默认值:1 /// [Category("自定义属性"), Description("已审核标志值,默认值:1")] public string ColorVerifyValue { get { return colorVerifyValue; } set { colorVerifyValue = value; if (!string.IsNullOrWhiteSpace(colorVerifyValue)) { colorVerifyValueDefault = colorVerifyValue; } } } private Color colorUnExecute = System.Drawing.Color.Empty; //审核未执行 private Color colorUnExecuteDefault = ColorCustom.UnExecute; //审核未执行 /// /// 审核未执行:2 默认颜色:Cyan /// [Category("自定义属性"), Description("审核未执行:2 默认颜色:Cyan")] public Color ColorUnExecute { get { return colorUnExecute; } set { colorUnExecute = value; if (colorUnExecute != System.Drawing.Color.Empty) { colorUnExecuteDefault = colorUnExecute; } } } private string colorUnExecuteValue; private string colorUnExecuteValueDefault = "2"; /// /// 审核未执行标志值,默认值:2 /// [Category("自定义属性"), Description("审核未执行标志值,默认值:2")] public string ColorUnExecuteValue { get { return colorUnExecuteValue; } set { colorUnExecuteValue = value; if (!string.IsNullOrWhiteSpace(colorUnExecuteValue)) { colorUnExecuteValueDefault = colorUnExecuteValue; } } } private Color colorApprove = System.Drawing.Color.Empty; //审批中 private Color colorApproveDefault = ColorCustom.Approve; //审批中 /// /// 审批中:3 默认颜色:LightCyan /// [Category("自定义属性"), Description("审批中:3 默认颜色:LightCyan")] public Color ColorApprove { get { return colorApprove; } set { colorApprove = value; if (colorApprove != System.Drawing.Color.Empty) { colorApproveDefault = colorApprove; } } } private string colorApproveValue; private string colorApproveValueDefault = "3"; /// /// 审批中标志值,默认值:3 /// [Category("自定义属性"), Description("审批中标志值,默认值:3")] public string ColorApproveValue { get { return colorApproveValue; } set { colorApproveValue = value; if (!string.IsNullOrWhiteSpace(colorApproveValue)) { colorApproveValueDefault = colorApproveValue; } } } private Color colorUnPass = System.Drawing.Color.Empty; //未通过 private Color colorUnPassDefault = ColorCustom.UnPass; //未通过 /// /// 未通过:4 默认颜色:SandyBrown /// [Category("自定义属性"), Description("未通过:4 默认颜色:SandyBrown")] public Color ColorUnPass { get { return colorUnPass; } set { colorUnPass = value; if (colorUnPass != System.Drawing.Color.Empty) { colorUnPassDefault = colorUnPass; } } } private string colorUnPassValue; private string colorUnPassValueDefault = "4"; /// /// 未通过标志值,默认值:4 /// [Category("自定义属性"), Description("未通过标志值,默认值:4")] public string ColorUnPassValue { get { return colorUnPassValue; } set { colorUnPassValue = value; if (!string.IsNullOrWhiteSpace(colorUnPassValue)) { colorUnPassValueDefault = colorUnPassValue; } } } private Color colorPass = System.Drawing.Color.Empty; //通过 private Color colorPassDefault = ColorCustom.Pass; //通过 /// /// 通过:5 默认颜色:DeepSkyBlue /// [Category("自定义属性"), Description("通过:5 默认颜色:DeepSkyBlue")] public Color ColorPass { get { return colorPass; } set { colorPass = value; if (colorPass != System.Drawing.Color.Empty) { colorPassDefault = colorPass; } } } private string colorPassValue; private string colorPassValueDefault = "5"; /// /// 通过标志值,默认值:5 /// [Category("自定义属性"), Description("通过标志值,默认值:5")] public string ColorPassValue { get { return colorPassValue; } set { colorPassValue = value; if (!string.IsNullOrWhiteSpace(colorPassValue)) { colorPassValueDefault = colorPassValue; } } } private Color colorRepeal = System.Drawing.Color.Empty; //废除 private Color colorRepealDefault = ColorCustom.Repeal; //废除 /// /// 废除:6 默认颜色:Gainsboro /// [Category("自定义属性"), Description("废除:6 默认颜色:Gainsboro")] public Color ColorRepeal { get { return colorRepeal; } set { colorRepeal = value; if (colorRepeal != System.Drawing.Color.Empty) { colorRepealDefault = colorRepeal; } } } private string colorRepealValue; private string colorRepealValueDefault = "6"; /// /// 废除标志值,默认值:6 /// [Category("自定义属性"), Description("废除标志值,默认值:6")] public string ColorRepealValue { get { return colorRepealValue; } set { colorRepealValue = value; if (!string.IsNullOrWhiteSpace(colorRepealValue)) { colorRepealValueDefault = colorRepealValue; } } } private Color colorReWork = System.Drawing.Color.Empty; private Color colorReWorkDefault = ColorCustom.ReWork; //缺货 /// /// 驳回:7 默认颜色:PaleTurquoise /// [Category("自定义属性"), Description("驳回:7 默认颜色:PaleTurquoise")] public Color ColorReWork { get { return colorReWork; } set { colorReWork = value; if (colorReWork != System.Drawing.Color.Empty) { colorReWorkDefault = colorReWork; } } } private string colorReWorkValue; private string colorReWorkValueDefault = "7"; /// /// 驳回标志值,默认值:7 /// [Category("自定义属性"), Description("驳回标志值,默认值:7")] public string ColorReWorkValue { get { return colorReWorkValue; } set { colorReWorkValue = value; if (!string.IsNullOrWhiteSpace(colorReWorkValue)) { colorReWorkValueDefault = colorReWorkValue; } } } private Color colorShortage = System.Drawing.Color.Empty; private Color colorShortageDefault = ColorCustom.Shortage; //缺货 /// /// 缺货:8 默认颜色:WMStyRose /// [Category("自定义属性"), Description("缺货:8 默认颜色:WMStyRose")] public Color ColorShortage { get { return colorShortage; } set { colorShortage = value; if (colorShortage != System.Drawing.Color.Empty) { colorShortageDefault = colorShortage; } } } private string colorShortageValue; private string colorShortageValueDefault = "8"; /// /// 缺货标志值,默认值:8 /// [Category("自定义属性"), Description("缺货标志值,默认值:8")] public string ColorShortageValue { get { return colorShortageValue; } set { colorShortageValue = value; if (!string.IsNullOrWhiteSpace(colorShortageValue)) { colorShortageValueDefault = colorShortageValue; } } } private Color colorWarning = System.Drawing.Color.Empty; private Color colorWarningDefault = ColorCustom.Warning; //缺货 /// /// 警示:9 默认颜色:Red /// [Category("自定义属性"), Description("警示:9 默认颜色:Red")] public Color ColorWarning { get { return colorWarning; } set { colorWarning = value; if (colorWarning != System.Drawing.Color.Empty) { colorWarningDefault = colorWarning; } } } private string colorWarningValue; private string colorWarningValueDefault = "9"; /// /// 警示标志值,默认值:9 /// [Category("自定义属性"), Description("警示标志值,默认值:9")] public string ColorWarningValue { get { return colorWarningValue; } set { colorWarningValue = value; if (!string.IsNullOrWhiteSpace(colorWarningValue)) { colorWarningValueDefault = colorWarningValue; } } } #endregion #region 构造函数 /// /// 构造函数 /// public GridControlCustom() { InitializeComponent(); } /// /// 构造控件 /// private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.contextMenuGridControlCustom = new System.Windows.Forms.ContextMenuStrip(this.components); this.tDeleteRow = new System.Windows.Forms.ToolStripMenuItem(); this.tCopy = new System.Windows.Forms.ToolStripMenuItem(); this.tCopyData = new System.Windows.Forms.ToolStripMenuItem(); this.tCopyRow = new System.Windows.Forms.ToolStripMenuItem(); this.tStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.tFixedTrue = new System.Windows.Forms.ToolStripMenuItem(); this.tFixedLeft = new System.Windows.Forms.ToolStripMenuItem(); this.tFixedAllFalse = new System.Windows.Forms.ToolStripMenuItem(); this.tShowFooter = new System.Windows.Forms.ToolStripMenuItem(); this.tStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.tSaveStyle = new System.Windows.Forms.ToolStripMenuItem(); this.tCloseStyle = new System.Windows.Forms.ToolStripMenuItem(); this.tExportLayout = new System.Windows.Forms.ToolStripMenuItem(); this.tStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); this.tSelectAll = new System.Windows.Forms.ToolStripMenuItem(); this.tUnSelectAll = new System.Windows.Forms.ToolStripMenuItem(); this.tColFind = new System.Windows.Forms.ToolStripMenuItem(); this.tColGroup = new System.Windows.Forms.ToolStripMenuItem(); this.tStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); this.tExpandAll = new System.Windows.Forms.ToolStripMenuItem(); this.tCollapseAll = new System.Windows.Forms.ToolStripMenuItem(); this.tStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); // // contextMenuGridControlCustom // this.contextMenuGridControlCustom.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.tDeleteRow, this.tCopy, this.tCopyData, this.tCopyRow, this.tStripSeparator1, this.tFixedTrue, this.tFixedLeft, this.tFixedAllFalse, this.tShowFooter, this.tStripSeparator2, this.tSaveStyle, this.tCloseStyle, this.tExportLayout, this.tStripSeparator3, this.tSelectAll, this.tUnSelectAll, this.tStripSeparator5, this.tColFind, this.tColGroup, this.tStripSeparator4, this.tExpandAll, this.tCollapseAll }); this.contextMenuGridControlCustom.Name = "contextMenuGridControlCustom1"; this.contextMenuGridControlCustom.RenderMode = System.Windows.Forms.ToolStripRenderMode.System; this.contextMenuGridControlCustom.Size = new System.Drawing.Size(171, 358); this.contextMenuGridControlCustom.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuGridControlCustom_Opening); // // tDeleteRow // this.tDeleteRow.Image = global::WMS.Ctrl.Properties.Resources.delete; this.tDeleteRow.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.tDeleteRow.Name = "tDeleteRow"; this.tDeleteRow.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C))); this.tDeleteRow.Size = new System.Drawing.Size(170, 22); this.tDeleteRow.Text = "删除"; this.tDeleteRow.Click += new System.EventHandler(this.tDeleteRow_Click); this.tDeleteRow.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tMouseDown_Click); // // tCopy // this.tCopy.Image = global::WMS.Ctrl.Properties.Resources.Copy; this.tCopy.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.tCopy.Name = "tCopy"; this.tCopy.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C))); this.tCopy.Size = new System.Drawing.Size(170, 22); this.tCopy.Text = "复制"; this.tCopy.Click += new System.EventHandler(this.tCopy_Click); this.tCopy.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tMouseDown_Click); // // tCopyData // this.tCopyData.Image = global::WMS.Ctrl.Properties.Resources.CopyData; this.tCopyData.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.tCopyData.Name = "tCopyData"; this.tCopyData.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.D))); this.tCopyData.Size = new System.Drawing.Size(170, 22); this.tCopyData.Text = "复制数据"; this.tCopyData.Click += new System.EventHandler(this.tCopyData_Click); this.tCopyData.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tMouseDown_Click); // // tCopyRow // this.tCopyRow.Image = global::WMS.Ctrl.Properties.Resources.TableMultiple; this.tCopyRow.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.tCopyRow.Name = "tCopyRow"; this.tCopyRow.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E))); this.tCopyRow.Size = new System.Drawing.Size(170, 22); this.tCopyRow.Text = "复制行"; this.tCopyRow.Click += new System.EventHandler(this.tCopyRow_Click); this.tCopyRow.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tMouseDown_Click); // // tStripSeparator1 // this.tStripSeparator1.Name = "tStripSeparator1"; this.tStripSeparator1.Size = new System.Drawing.Size(167, 6); // // tFixedTrue // this.tFixedTrue.Image = global::WMS.Ctrl.Properties.Resources.FixedTreu; this.tFixedTrue.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.tFixedTrue.Name = "tFixedTrue"; this.tFixedTrue.Size = new System.Drawing.Size(170, 22); this.tFixedTrue.Text = "锁定当前列"; this.tFixedTrue.Click += new System.EventHandler(this.tFixedTrue_Click); this.tFixedTrue.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tMouseDown_Click); // // tFixedLeft // // this.tFixedLeft.Image = global::Erp.Ctrl.Properties.Resources.tFixedLeft; this.tFixedLeft.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.tFixedLeft.Name = "tFixedLeft"; this.tFixedLeft.Size = new System.Drawing.Size(170, 22); this.tFixedLeft.Text = "锁定左侧列"; this.tFixedLeft.Click += new System.EventHandler(this.tFixedLeft_Click); this.tFixedLeft.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tMouseDown_Click); // // tFixedAllFalse // this.tFixedAllFalse.Image = global::WMS.Ctrl.Properties.Resources.tFixedFalse; this.tFixedAllFalse.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.tFixedAllFalse.Name = "tFixedAllFalse"; this.tFixedAllFalse.Size = new System.Drawing.Size(170, 22); this.tFixedAllFalse.Text = "解除全部锁定"; this.tFixedAllFalse.Click += new System.EventHandler(this.tFixedAllFalse_Click); this.tFixedAllFalse.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tMouseDown_Click); // // tShowFooter // this.tShowFooter.Checked = true; this.tShowFooter.CheckState = System.Windows.Forms.CheckState.Checked; this.tShowFooter.Image = global::WMS.Ctrl.Properties.Resources.Footer; this.tShowFooter.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.tShowFooter.Name = "tShowFooter"; this.tShowFooter.Size = new System.Drawing.Size(170, 22); this.tShowFooter.Text = "显示合计区"; this.tShowFooter.Click += new System.EventHandler(this.tShowFooter_Click); this.tShowFooter.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tMouseDown_Click); // // tStripSeparator2 // this.tStripSeparator2.Name = "tStripSeparator2"; this.tStripSeparator2.Size = new System.Drawing.Size(167, 6); // // tSaveStyle // this.tSaveStyle.Image = global::WMS.Ctrl.Properties.Resources.AlignToGridHS; this.tSaveStyle.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.tSaveStyle.Name = "tSaveStyle"; this.tSaveStyle.Size = new System.Drawing.Size(170, 22); this.tSaveStyle.Text = "记忆样式"; this.tSaveStyle.Click += new System.EventHandler(this.tSaveStyle_Click); this.tSaveStyle.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tMouseDown_Click); // // tCloseStyle // this.tCloseStyle.Image = global::WMS.Ctrl.Properties.Resources.DeleteHS; this.tCloseStyle.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.tCloseStyle.Name = "tCloseStyle"; this.tCloseStyle.Size = new System.Drawing.Size(170, 22); this.tCloseStyle.Text = "清除样式"; this.tCloseStyle.Click += new System.EventHandler(this.tCloseStyle_Click); this.tCloseStyle.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tMouseDown_Click); // // tExportLayout // this.tExportLayout.Image = global::WMS.Ctrl.Properties.Resources.SaveAsWebPageHS; this.tExportLayout.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.tExportLayout.Name = "tExportLayout"; this.tExportLayout.Size = new System.Drawing.Size(170, 22); this.tExportLayout.Text = "导出布局"; this.tExportLayout.Click += new System.EventHandler(this.tExportLayout_Click); this.tExportLayout.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tMouseDown_Click); // // tStripSeparator3 // this.tStripSeparator3.Name = "tStripSeparator3"; this.tStripSeparator3.Size = new System.Drawing.Size(167, 6); // // tSelectAll // this.tSelectAll.Image = global::WMS.Ctrl.Properties.Resources.tFixedFalse; this.tSelectAll.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.tSelectAll.Name = "tSelectAll"; this.tSelectAll.Size = new System.Drawing.Size(170, 22); this.tSelectAll.Text = "全选"; this.tSelectAll.Click += new System.EventHandler(this.tSelectAll_Click); this.tSelectAll.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tMouseDown_Click); // // tUnSelectAll // this.tUnSelectAll.Image = global::WMS.Ctrl.Properties.Resources.tFixedFalse; this.tUnSelectAll.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.tUnSelectAll.Name = "tUnSelectAll"; this.tUnSelectAll.Size = new System.Drawing.Size(170, 22); this.tUnSelectAll.Text = "全取消"; this.tUnSelectAll.Click += new System.EventHandler(this.tUnSelectAll_Click); this.tUnSelectAll.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tMouseDown_Click); // // tColFind // this.tColFind.Image = global::WMS.Ctrl.Properties.Resources.Find; this.tColFind.Name = "tColFind"; this.tColFind.Size = new System.Drawing.Size(170, 22); this.tColFind.Text = "列筛选"; this.tColFind.Click += new System.EventHandler(this.tColFind_Click); // // tColGroup // this.tColGroup.Image = global::WMS.Ctrl.Properties.Resources.Formula; this.tColGroup.Name = "tColGroup"; this.tColGroup.Size = new System.Drawing.Size(170, 22); this.tColGroup.Text = "列表汇总"; this.tColGroup.Click += new System.EventHandler(this.tColGroup_Click); // // tStripSeparator4 // this.tStripSeparator4.Name = "tStripSeparator4"; this.tStripSeparator4.Size = new System.Drawing.Size(167, 6); // // tExpandAll // this.tExpandAll.Image = global::WMS.Ctrl.Properties.Resources.Book_openHS; this.tExpandAll.Name = "tExpandAll"; this.tExpandAll.Size = new System.Drawing.Size(170, 22); this.tExpandAll.Text = "全展开"; this.tExpandAll.Click += new System.EventHandler(this.tExpandAll_Click); // // tCollapseAll // this.tCollapseAll.Image = global::WMS.Ctrl.Properties.Resources.Book_angleHS; this.tCollapseAll.Name = "tCollapseAll"; this.tCollapseAll.Size = new System.Drawing.Size(170, 22); this.tCollapseAll.Text = "全收缩"; this.tCollapseAll.Click += new System.EventHandler(this.tCollapseAll_Click); // // tStripSeparator5 // this.tStripSeparator5.Name = "tStripSeparator5"; this.tStripSeparator5.Size = new System.Drawing.Size(167, 6); // // GridControlCustom // this.ContextMenuStrip = this.contextMenuGridControlCustom; this.Load += new System.EventHandler(this.GridControlCustom_Load); this.Paint += new System.Windows.Forms.PaintEventHandler(this.GridControlCustom_Paint); } #endregion #region 初始化 /// /// 初始化 /// /// /// private void GridControlCustom_Load(object sender, EventArgs e) { try { GridView gvGridControlCustom = this.MainView as GridView; // gvGridControlCustom.OptionsBehavior.Editable = false; gvGridControlCustom.OptionsView.ShowGroupPanel = false; // gvGridControlCustom.OptionsView.ColumnAutoWidth = false; if (gvGridControlCustom == null) return; //隔行色显示 if (EnableAppearanceEvenRow) { gvGridControlCustom.OptionsView.EnableAppearanceEvenRow = true; gvGridControlCustom.Appearance.EvenRow.BackColor = Color.FromArgb(240, 240, 250); } gvGridControlCustom.OptionsView.ColumnAutoWidth = false; //焦点行颜色 gvGridControlCustom.Appearance.FocusedRow.BackColor = colorSelectedRow; gvGridControlCustom.Appearance.SelectedRow.BackColor = colorSelectedRow; //点击事件 gvGridControlCustom.PopupMenuShowing += new DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventHandler(this.gridView_PopupMenuShowing); //设置审核Status颜色事件 和焦点行变色 gvGridControlCustom.RowCellStyle -= new DevExpress.XtraGrid.Views.Grid.RowCellStyleEventHandler(this.gridView_RowCellStyle); gvGridControlCustom.RowCellStyle += new DevExpress.XtraGrid.Views.Grid.RowCellStyleEventHandler(this.gridView_RowCellStyle); //列表行号显示 if (ShowRowID) { //gvGridControlCustom.IndicatorWidth = this.IndicatorWidth; gvGridControlCustom.CustomDrawRowIndicator -= new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(this.gridView_CustomDrawRowIndicator); gvGridControlCustom.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(this.gridView_CustomDrawRowIndicator); gvGridControlCustom.RowCountChanged -= new EventHandler(this.gridView_RowCountChanged); gvGridControlCustom.RowCountChanged += new EventHandler(this.gridView_RowCountChanged); // } if (!addEvent) { if (gvGridControlCustom != null && _Image != null) { gvGridControlCustom.LeftCoordChanged += new EventHandler(gvGridControlCustom_LeftCoordChanged); gvGridControlCustom.TopRowChanged += new EventHandler(gvGridControlCustom_TopRowChanged); gvGridControlCustom.RowCellStyle += new RowCellStyleEventHandler(gvGridControlCustom_RowCellStyle); gvGridControlCustom.MouseWheel += new MouseEventHandler(gvGridControlCustom_MouseWheel); addEvent = true; } } //加载样式 LoadStyle(); } catch { } } /// /// 初始化列标题 /// private void InitColumnHead() { try { } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } #endregion #region 设置审核标识图片 /// /// 设置审核标识图片 /// /// 审核标识 public void SetVerifyFlagImage(string flag) { try { if (!addEvent) { GridView gvGridControlCustom = (DevExpress.XtraGrid.Views.Grid.GridView)this.MainView; if (gvGridControlCustom != null) { gvGridControlCustom.LeftCoordChanged += new EventHandler(gvGridControlCustom_LeftCoordChanged); gvGridControlCustom.TopRowChanged += new EventHandler(gvGridControlCustom_TopRowChanged); gvGridControlCustom.RowCellStyle += new RowCellStyleEventHandler(gvGridControlCustom_RowCellStyle); gvGridControlCustom.MouseWheel += new MouseEventHandler(gvGridControlCustom_MouseWheel); addEvent = true; } } if (flag == "0") { _Image = WMS.Ctrl.Properties.Resources.未审核; } else if (flag == "1") { _Image = WMS.Ctrl.Properties.Resources.已审核; } else if (flag == "2") { _Image = WMS.Ctrl.Properties.Resources.审核未执行; } else if (flag == "3") { _Image = WMS.Ctrl.Properties.Resources.审批中; } else if (flag == "4") { _Image = WMS.Ctrl.Properties.Resources.未通过; } else if (flag == "5") { _Image = WMS.Ctrl.Properties.Resources.已通过; } else if (flag == "6") { _Image = WMS.Ctrl.Properties.Resources.作废; } else if (flag == "7") { _Image = WMS.Ctrl.Properties.Resources.驳回; } else if (flag == "8") { _Image = WMS.Ctrl.Properties.Resources.关闭; } this.Invalidate(); } catch (Exception ex) { throw ex; } } /// /// 设置审核标识图片 /// ///// 图片 public void SetVerifyFlagImage(Bitmap image) { try { _Image = image; this.Invalidate(); } catch (Exception ex) { throw ex; } } #endregion #region 清空审核标识图片 /// /// 清空审核标识图片 /// /// 审核标识 public void ClearVerifyFlagImage() { try { _Image = null; if (addEvent) { GridView gvGridControlCustom = (DevExpress.XtraGrid.Views.Grid.GridView)this.MainView; if (gvGridControlCustom != null) { gvGridControlCustom.LeftCoordChanged -= new EventHandler(gvGridControlCustom_LeftCoordChanged); gvGridControlCustom.TopRowChanged -= new EventHandler(gvGridControlCustom_TopRowChanged); gvGridControlCustom.RowCellStyle -= new RowCellStyleEventHandler(gvGridControlCustom_RowCellStyle); gvGridControlCustom.MouseWheel -= new MouseEventHandler(gvGridControlCustom_MouseWheel); } addEvent = false; } this.Invalidate(); } catch (Exception ex) { throw ex; } } #endregion #region 绘图事件 /// /// 界面绘制事件 /// /// /// private void GridControlCustom_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { try { if (_Image == null) { return; } Graphics g = e.Graphics; int x = Convert.ToInt32(this.Width - (_Image.Width / Math.Sqrt(2) + _Image.Width / 2 * Math.Sqrt(2)) / 2 - _Image.Width / 2) + 20; int y = Convert.ToInt32(this.Height - (_Image.Width / Math.Sqrt(2) + _Image.Width / 2 * Math.Sqrt(2)) / 2 - _Image.Height / 2) + 20; int width = _Image.Width; int height = _Image.Height; ImageAttributes imageAttr = new ImageAttributes(); ColorMatrix matrix = new ColorMatrix(); matrix.Matrix33 = 0.5f; //透明度 imageAttr.SetColorMatrix(matrix); Rectangle rect = new Rectangle(0, 0, width, height); Point[] points = { new Point(0 - width / 2, 0 - height / 2), new Point(width - width / 2, 0 - height / 2), new Point(0 - width / 2, height - height / 2) }; Matrix matrixRotate = new Matrix(1, 0, 0, 1, x + width / 2, y + height / 2);// 定义一个UNIT矩阵,坐标原点在(x,y) matrixRotate.Rotate(-45); // 逆时针旋转45度 //matrix.Scale((float)2, (float)2); // X 和 Y 方向分别乘以0.63和0.6比例因子 matrixRotate.TransformPoints(points);// 用该矩阵转换points g.DrawImage(_Image, points, rect, GraphicsUnit.Pixel, imageAttr); } catch { } } #endregion #region 右键菜单 private void contextMenuGridControlCustom_Opening(object sender, CancelEventArgs e) { try { //(sender as ContextMenuStrip).Tag = (sender as ContextMenuStrip).SourceControl; GridView gv = this.MainView as GridView; if (gv == null) { this.tStripSeparator3.Visible = false; this.tSelectAll.Visible = false; this.tUnSelectAll.Visible = false; return; } if (gv.OptionsView.ShowFooter) { this.tShowFooter.Text = "隐藏合计区"; } else { this.tShowFooter.Text = "显示合计区"; } if (gv == null || gv.SelectedRowsCount <= 0) { this.tCopyRow.Enabled = false; } else { this.tCopyRow.Enabled = true; } if (gv.FocusedColumn == null) { this.tStripSeparator3.Visible = false; this.tSelectAll.Visible = false; this.tUnSelectAll.Visible = false; return; } DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit chkEdit = gv.FocusedColumn.ColumnEdit as DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit; if (chkEdit == null) { this.tStripSeparator3.Visible = false; this.tSelectAll.Visible = false; this.tUnSelectAll.Visible = false; return; } if (gv.OptionsBehavior.Editable == false || gv.OptionsBehavior.ReadOnly == true || gv.FocusedColumn.OptionsColumn.AllowEdit == false || gv.FocusedColumn.OptionsColumn.ReadOnly == true) { this.tStripSeparator3.Visible = false; this.tSelectAll.Visible = false; this.tUnSelectAll.Visible = false; return; } else { this.tStripSeparator3.Visible = true; this.tSelectAll.Visible = true; this.tUnSelectAll.Visible = true; } } catch (Exception ex) { } } private void gridView_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e) { hitInfoPopupMenu = e.HitInfo; } /// /// 点击事件之前执行事件 /// /// /// private void tBefore_Click(object sender, EventArgs e) { isMouseClieck = false; } /// /// 复制 /// /// /// private void tMouseDown_Click(object sender, MouseEventArgs e) { isMouseClieck = true; } /// /// 删除行 /// /// /// private void tDeleteRow_Click(object sender, EventArgs e) { try { GridView gvGridControlCustom = (DevExpress.XtraGrid.Views.Grid.GridView)this.MainView; if (gvGridControlCustom == null) { return; } int rowHandle = -1; rowHandle = gvGridControlCustom.FocusedRowHandle; if (rowHandle >= 0) { gvGridControlCustom.DeleteRow(rowHandle); } } catch (Exception) { } } /// /// 复制 /// /// /// private void tCopy_Click(object sender, EventArgs e) { try { GridView gvGridControlCustom = (DevExpress.XtraGrid.Views.Grid.GridView)this.MainView; if (gvGridControlCustom == null) { return; } //如果是编辑Status,则复制选择的文本 if (gvGridControlCustom.IsEditing) { TextEdit editor = gvGridControlCustom.ActiveEditor as TextEdit; if (editor != null) { if (editor.SelectionLength > 0) { Clipboard.SetText(editor.SelectedText); } else { Clipboard.SetText(editor.Text); } return; } } int rowHandle = -1; GridColumn gridColumn = null; if (isMouseClieck) { //如果是右键弹出调用 if (hitInfoPopupMenu == null) return; if (hitInfoPopupMenu.RowHandle < 0 || !hitInfoPopupMenu.InRowCell) { return; } rowHandle = hitInfoPopupMenu.RowHandle; gridColumn = hitInfoPopupMenu.Column; } else { //如果是快捷键调用 if (gvGridControlCustom.FocusedRowHandle < 0 || gvGridControlCustom.FocusedColumn == null) { return; } rowHandle = gvGridControlCustom.FocusedRowHandle; gridColumn = gvGridControlCustom.FocusedColumn; } string value = gvGridControlCustom.GetRowCellDisplayText(rowHandle, gridColumn); if (value == null) { Clipboard.SetText(""); } else { Clipboard.SetText(value); } } catch (Exception) { } } /// /// 复制 /// /// /// private void tCopyData_Click(object sender, EventArgs e) { try { GridView gvGridControlCustom = (DevExpress.XtraGrid.Views.Grid.GridView)this.MainView; if (gvGridControlCustom == null) { return; } int rowHandle = -1; GridColumn gridColumn = null; if (isMouseClieck) { //如果是右键弹出调用 if (hitInfoPopupMenu == null) return; if (hitInfoPopupMenu.RowHandle < 0 || !hitInfoPopupMenu.InRowCell) { return; } rowHandle = hitInfoPopupMenu.RowHandle; gridColumn = hitInfoPopupMenu.Column; } else { //如果是快捷键调用 if (gvGridControlCustom.FocusedRowHandle < 0 || gvGridControlCustom.FocusedColumn == null) { return; } rowHandle = gvGridControlCustom.FocusedRowHandle; gridColumn = gvGridControlCustom.FocusedColumn; } object value = gvGridControlCustom.GetRowCellValue(rowHandle, gridColumn); if (value == null) { Clipboard.SetText(""); } else { Clipboard.SetText(Convert.ToString(value)); } } catch (Exception) { } } /// /// 复制选择行数据 /// /// /// private void tCopyRow_Click(object sender, EventArgs e) { try { GridView gvGridControlCustom = (DevExpress.XtraGrid.Views.Grid.GridView)this.MainView; if (gvGridControlCustom == null) { return; } gvGridControlCustom.CopyToClipboard(); } catch (Exception) { } } /// /// 剪切 /// /// /// private void tCut_Click(object sender, EventArgs e) { try { } catch (Exception) { } } /// /// 复制 /// /// /// private void tPaste_Click(object sender, EventArgs e) { try { } catch (Exception) { } } /// /// 锁定当前列 /// /// /// private void tFixedTrue_Click(object sender, EventArgs e) { try { if (hitInfoPopupMenu == null) return; if (hitInfoPopupMenu.Column == null) return; GridView gvGridControlCustom = (DevExpress.XtraGrid.Views.Grid.GridView)this.MainView; if (gvGridControlCustom == null) { return; } hitInfoPopupMenu.Column.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Left; } catch (Exception) { } } /// /// 锁定左侧列 /// /// /// private void tFixedLeft_Click(object sender, EventArgs e) { try { if (hitInfoPopupMenu == null) return; if (hitInfoPopupMenu.Column == null) return; GridView gvGridControlCustom = (DevExpress.XtraGrid.Views.Grid.GridView)this.MainView; if (gvGridControlCustom == null) { return; } List cols = new List(); int visibleIndex = hitInfoPopupMenu.Column.VisibleIndex; for (int i = 0; i < gvGridControlCustom.Columns.Count; i++) { if (gvGridControlCustom.Columns[i].VisibleIndex <= visibleIndex) { cols.Add(gvGridControlCustom.Columns[i]); } } var list = from t in cols orderby t.VisibleIndex select t; foreach (var col in list) { col.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Left; } } catch (Exception) { } } /// /// 解锁所以锁定 /// /// /// private void tFixedAllFalse_Click(object sender, EventArgs e) { try { if (hitInfoPopupMenu == null) return; if (hitInfoPopupMenu.Column == null) return; GridView gvGridControlCustom = (DevExpress.XtraGrid.Views.Grid.GridView)this.MainView; if (gvGridControlCustom == null) { return; } List cols = new List(); for (int i = 0; i < gvGridControlCustom.Columns.Count; i++) { if (gvGridControlCustom.Columns[i].Fixed != DevExpress.XtraGrid.Columns.FixedStyle.None) { cols.Add(gvGridControlCustom.Columns[i]); } } var list = from t in cols orderby t.VisibleIndex descending select t; foreach (var col in list) { col.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.None; } } catch (Exception) { } } /// /// 显示过滤 /// /// /// private void tShowFooter_Click(object sender, EventArgs e) { try { GridView gvGridControlCustom = (DevExpress.XtraGrid.Views.Grid.GridView)this.MainView; if (gvGridControlCustom == null) { return; } if (gvGridControlCustom.OptionsView.ShowFooter) { gvGridControlCustom.OptionsView.ShowFooter = false; } else { gvGridControlCustom.OptionsView.ShowFooter = true; } } catch (Exception) { } } /// /// 保存样式 /// /// /// private void tSaveStyle_Click(object sender, EventArgs e) { try { GridView gvGridControlCustom = (DevExpress.XtraGrid.Views.Grid.GridView)this.MainView; if (gvGridControlCustom == null) { return; } string layoutXml = Application.StartupPath + @"\Layout"; if (Directory.Exists(layoutXml) == false) { Directory.CreateDirectory(layoutXml); } layoutXml = layoutXml + @"\" + GetSaveConFingName() + ".xml"; gvGridControlCustom.SaveLayoutToXml(layoutXml); } catch (Exception) { } } /// /// 保存样式 /// /// /// private void tExportLayout_Click(object sender, EventArgs e) { try { GridView gvGridControlCustom = (DevExpress.XtraGrid.Views.Grid.GridView)this.MainView; if (gvGridControlCustom == null) { return; } System.Windows.Forms.SaveFileDialog fileSave = new System.Windows.Forms.SaveFileDialog(); fileSave.Filter = "布局文件(*.xml)|*.xml"; fileSave.RestoreDirectory = true; fileSave.FilterIndex = 1; if (fileSave.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; gvGridControlCustom.SaveLayoutToXml(fileSave.FileName, OptionsLayoutBase.FullLayout); } catch (Exception) { } } /// /// 清除样式 /// /// /// private void tCloseStyle_Click(object sender, EventArgs e) { try { string layoutXml = Application.StartupPath + @"\Layout\" + GetSaveConFingName() + ".xml"; if (File.Exists(layoutXml)) { File.Delete(layoutXml); } MessageBox.Show("控件配置信息已经清除,请重新打开此窗口", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception) { } } /// /// 全选 /// /// /// private void tSelectAll_Click(object sender, EventArgs e) { isMouseClieck = false; try { GridView gv = this.MainView as GridView; if (gv == null) { return; } if (gv.FocusedColumn == null) { return; } DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit chkEdit = gv.FocusedColumn.ColumnEdit as DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit; if (chkEdit == null) { return; } if (gv.OptionsBehavior.Editable == false || gv.OptionsBehavior.ReadOnly == true || gv.FocusedColumn.OptionsColumn.AllowEdit == false || gv.FocusedColumn.OptionsColumn.ReadOnly == true) { return; } if (chkEdit.ValueChecked is string) { for (int i = 0; i < gv.RowCount; i++) { gv.SetRowCellValue(i, gv.FocusedColumn, "1"); } } else if (chkEdit.ValueChecked is bool) { for (int i = 0; i < gv.RowCount; i++) { gv.SetRowCellValue(i, gv.FocusedColumn, true); } } } catch (Exception ex) { // SystemCommon.ShowInfoMessageBox(ex.Message.ToString()); } } /// /// 全取消 /// /// /// private void tUnSelectAll_Click(object sender, EventArgs e) { isMouseClieck = false; try { GridView gv = this.MainView as GridView; if (gv == null) { return; } if (gv.FocusedColumn == null) { return; } DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit chkEdit = gv.FocusedColumn.ColumnEdit as DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit; if (chkEdit == null) { return; } if (gv.OptionsBehavior.Editable == false || gv.OptionsBehavior.ReadOnly == true || gv.FocusedColumn.OptionsColumn.AllowEdit == false || gv.FocusedColumn.OptionsColumn.ReadOnly == true) { return; } if (chkEdit.ValueChecked is string) { for (int i = 0; i < gv.RowCount; i++) { gv.SetRowCellValue(i, gv.FocusedColumn, "0"); } } else if (chkEdit.ValueChecked is bool) { for (int i = 0; i < gv.RowCount; i++) { gv.SetRowCellValue(i, gv.FocusedColumn, false); } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } /// /// 全展开 /// /// /// private void tExpandAll_Click(object sender, EventArgs e) { try { GridView gv = this.MainView as GridView; if (gv == null) { return; } gv.ExpandAllGroups(); } catch (Exception) { } } /// /// 全收缩 /// /// /// private void tCollapseAll_Click(object sender, EventArgs e) { try { GridView gv = this.MainView as GridView; if (gv == null) { return; } gv.CollapseAllGroups(); } catch (Exception) { } } /// /// 列筛选 /// /// /// private void tColFind_Click(object sender, EventArgs e) { try { GridView gv = this.MainView as GridView; if (gv == null) { return; } FrmGridViewColFind frm = new FrmGridViewColFind(gv); if (frm.ShowDialog() == DialogResult.OK) { gv.RefreshData(); } } catch (Exception) { } } /// /// 列表汇总 /// /// /// private void tColGroup_Click(object sender, EventArgs e) { try { GridView gv = this.MainView as GridView; if (gv == null) { return; } string configName = GetSaveConFingName(); FrmGridViewColSelect frm = new FrmGridViewColSelect(gv, configName); if (frm.ShowDialog() == DialogResult.OK) { FrmGroupList frm2 = new FrmGroupList(frm.MyGroupDTable); Form form = this.FindForm(); if (form != null) { if (form.MdiParent != null) frm2.MdiParent = form.MdiParent; } frm2.Show(); } } catch (Exception) { } } #endregion #region 加载样式 /// /// 加载样式 /// private void LoadStyle() { try { GridView gvGridControlCustom = (DevExpress.XtraGrid.Views.Grid.GridView)this.MainView; if (gvGridControlCustom == null) { return; } string layoutXml = Application.StartupPath + @"\Layout\" + GetSaveConFingName() + ".xml"; if (!File.Exists(layoutXml)) return; Dictionary dicVisible = new Dictionary(); //付林林 2012-09-02 //Visible属性不记忆,记忆导入布局前Visible属性 foreach (GridColumn column in gvGridControlCustom.Columns) { dicVisible.Add(column.Name, column.Visible); } gvGridControlCustom.RestoreLayoutFromXml(layoutXml); //恢复导入布局前Visible属性 foreach (GridColumn column in gvGridControlCustom.Columns) { if (dicVisible.ContainsKey(column.Name) && dicVisible[column.Name] != column.Visible) { column.Visible = dicVisible[column.Name]; } } } catch (Exception) { } } #endregion #region 行号事件 /// /// 行号事件 /// /// /// private void gridView_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e) { if (e.Info.IsRowIndicator && e.RowHandle >= 0) e.Info.DisplayText = (e.RowHandle + 1).ToString(); } private void gridView_RowCountChanged(object sender, EventArgs e) { try { GridView gridView = (DevExpress.XtraGrid.Views.Grid.GridView)sender; int rc = gridView.RowCount; if (rc < 100) { gridView.IndicatorWidth = 34; } else if (rc >= 1000000) { gridView.IndicatorWidth = 74; } else if (rc >= 100000) { gridView.IndicatorWidth = 66; } else if (rc >= 10000) { gridView.IndicatorWidth = 58; } else if (rc >= 1000) { gridView.IndicatorWidth = 50; } else if (rc >= 100) { gridView.IndicatorWidth = 42; } } catch { } } #endregion #region 设置行颜色 /// /// 根据审核标志颜色区分 /// /// /// private void gridView_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e) { try { GridView gridView = (DevExpress.XtraGrid.Views.Grid.GridView)sender; if (gridView.FocusedRowHandle == e.RowHandle) { e.Appearance.BackColor = (colorSelectedRow == System.Drawing.Color.Empty ? colorSelectedRowDefault : colorSelectedRow); //e.Appearance.Font = new Font(e.Appearance.Font, FontStyle.Bold); return; } if (gridView.IsRowSelected(e.RowHandle)) { e.Appearance.BackColor = (colorSelectedRow == System.Drawing.Color.Empty ? colorSelectedRowDefault : colorSelectedRow); return; } //确定审核标志 if (!string.IsNullOrWhiteSpace(colorVerifyFlagColumn)) { string verifyFlag = gridView.GetRowCellValue(e.RowHandle, colorVerifyFlagColumn) as string; if (string.Equals(verifyFlag, colorVerifyValueDefault)) { //已审核 e.Appearance.BackColor = colorVerifyDefault;//colorVerify; } else if (string.Equals(verifyFlag, colorUnExecuteValueDefault)) { //审核未执行 e.Appearance.BackColor = colorUnExecuteDefault;//ColorUnExecute; } else if (string.Equals(verifyFlag, colorApproveValueDefault)) { //审批中 e.Appearance.BackColor = colorApproveDefault;//colorApprove; } else if (string.Equals(verifyFlag, colorUnPassValueDefault)) { //未通过 e.Appearance.BackColor = colorUnPassDefault;//colorUnPass; } else if (string.Equals(verifyFlag, colorPassValueDefault)) { //已通过 e.Appearance.BackColor = colorPassDefault;//colorPass; } else if (string.Equals(verifyFlag, colorRepealValueDefault)) { //作废 Font font = e.Appearance.Font; font = new Font(font.Name, font.Size, FontStyle.Strikeout); e.Appearance.Font = font; e.Appearance.BackColor = colorRepealDefault;//colorRepeal; } else if (string.Equals(verifyFlag, colorReWorkValueDefault)) { //驳回 e.Appearance.BackColor = colorReWorkDefault;//colorReWork; } else if (string.Equals(verifyFlag, colorShortageValueDefault)) { //缺货 e.Appearance.BackColor = colorShortageDefault;//colorShortage; } else if (string.Equals(verifyFlag, colorWarningValueDefault)) { //警示色 e.Appearance.BackColor = colorWarningDefault;//colorWarning; } } //再设置缺货标志颜色 //确定审核标志 if (!string.IsNullOrWhiteSpace(colorShortageFlagColumn)) { string shortageFlag = gridView.GetRowCellValue(e.RowHandle, colorShortageFlagColumn) as string; if (string.Equals(shortageFlag, colorVerifyValueDefault)) { //已审核 e.Appearance.BackColor = colorVerifyDefault;//colorVerify; } else if (string.Equals(shortageFlag, colorUnExecuteValueDefault)) { //审核未执行 e.Appearance.BackColor = colorUnExecuteDefault;//ColorUnExecute; } else if (string.Equals(shortageFlag, colorApproveValueDefault)) { //审批中 e.Appearance.BackColor = colorApproveDefault;//colorApprove; } else if (string.Equals(shortageFlag, colorUnPassValueDefault)) { //未通过 e.Appearance.BackColor = colorUnPassDefault;//colorUnPass; } else if (string.Equals(shortageFlag, colorPassValueDefault)) { //已通过 e.Appearance.BackColor = colorPassDefault;//colorPass; } else if (string.Equals(shortageFlag, colorRepealValueDefault)) { //作废 Font font = e.Appearance.Font; font = new Font(font.Name, font.Size, FontStyle.Strikeout); e.Appearance.Font = font; e.Appearance.BackColor = colorRepealDefault;//colorRepeal; } else if (string.Equals(shortageFlag, colorReWorkValueDefault)) { //驳回 e.Appearance.BackColor = colorReWorkDefault;//colorReWork; } else if (string.Equals(shortageFlag, colorShortageValueDefault)) { //缺货 e.Appearance.BackColor = colorShortageDefault;//colorShortage; } else if (string.Equals(shortageFlag, colorWarningValueDefault)) { //警示色 e.Appearance.BackColor = colorWarningDefault;//colorWarning; } } } catch { } } #endregion #region 显示导出对话框 /// /// 显示导出对话框 /// public void ShowExportDialog() { try { GridView gv = this.MainView as GridView; if (gv == null) return; System.Windows.Forms.SaveFileDialog fileSave = new System.Windows.Forms.SaveFileDialog(); //fileSave.InitialDirectory = System.Windows.Forms.Application.StartupPath; fileSave.Filter = "Excel文件(*.XLS)|*.xls|Excel文件(2007/2010)(*.XLSX)|*.xlsx|文本文件(*.TXT)|*.txt|CSV文件(*.CSV)|*.csv|Pdf文件(*.Pdf)|*.pdf|Html文件(*.Html)|*.html"; fileSave.RestoreDirectory = true; fileSave.FilterIndex = 1; if (fileSave.ShowDialog() == System.Windows.Forms.DialogResult.OK) { DevExpress.XtraPrinting.ExportTarget ls_type = DevExpress.XtraPrinting.ExportTarget.Xls; string fName = fileSave.FileName; if (fileSave.FileName.ToLower().EndsWith(".txt")) { ls_type = DevExpress.XtraPrinting.ExportTarget.Text; } else if (fileSave.FileName.ToLower().EndsWith(".xls")) { ls_type = DevExpress.XtraPrinting.ExportTarget.Xls; } else if (fileSave.FileName.ToLower().EndsWith(".xlsx")) { ls_type = DevExpress.XtraPrinting.ExportTarget.Xlsx; } else if (fileSave.FileName.ToLower().EndsWith(".csv")) { ls_type = DevExpress.XtraPrinting.ExportTarget.Csv; } else if (fileSave.FileName.ToLower().EndsWith(".html")) { ls_type = DevExpress.XtraPrinting.ExportTarget.Html; } else if (fileSave.FileName.ToLower().EndsWith(".Pdf")) { ls_type = DevExpress.XtraPrinting.ExportTarget.Pdf; } gv.Export(ls_type, fName); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } #endregion #region 移动滚动条时刷新 /// /// 左侧列表纵向滚动条拖动 /// /// /// private void gvGridControlCustom_MouseWheel(object sender, EventArgs e) { this.Invalidate(); } /// /// 左侧列表纵向滚动条拖动 /// /// /// private void gvGridControlCustom_LeftCoordChanged(object sender, EventArgs e) { this.Invalidate(); } /// /// 左侧列表横向滚动条拖动 /// /// /// private void gvGridControlCustom_TopRowChanged(object sender, EventArgs e) { this.Invalidate(); } void gvGridControlCustom_RowCellStyle(object sender, RowCellStyleEventArgs e) { this.Invalidate(); } #endregion #region 获取保存配置文件名称 /// /// 获取保存配置文件名称 /// /// private string GetSaveConFingName() { string frmName = ""; Form form = this.FindForm(); if (form == null) return "From"; frmName = form.Name; string moduleId = ""; try { object objModuleId = form.GetType().InvokeMember( "GetModuleId", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, form, new object[] { }); if (objModuleId != null) { moduleId = objModuleId.ToString(); } } catch(Exception ex) { } return frmName + "." + moduleId + "." + this.Name; } #endregion } }