From d29f45d322cf5b7a110b94a21095198a9ec1fa94 Mon Sep 17 00:00:00 2001 From: Rich Date: Tue, 4 Dec 2012 23:08:43 +0000 Subject: [PATCH] Handles displaying grid this is not enabled Added MyDisablePanel vlnPanel control Added ApplDisplayMode property to StepPanel class Added vlnPanel class --- .../GridItem.Designer.cs | 9 +++++ PROMS/Volian.Controls.Library/GridItem.cs | 39 ++++++++++++++++++- PROMS/Volian.Controls.Library/StepPanel.cs | 25 +++++++++++- .../VlnFlexGrid.Designer.cs | 35 ++++++++++++++++- PROMS/Volian.Controls.Library/VlnFlexGrid.cs | 33 ++++++++++++++++ 5 files changed, 138 insertions(+), 3 deletions(-) diff --git a/PROMS/Volian.Controls.Library/GridItem.Designer.cs b/PROMS/Volian.Controls.Library/GridItem.Designer.cs index a96438c1..58198bd8 100644 --- a/PROMS/Volian.Controls.Library/GridItem.Designer.cs +++ b/PROMS/Volian.Controls.Library/GridItem.Designer.cs @@ -35,6 +35,7 @@ namespace Volian.Controls.Library this.lblTab = new System.Windows.Forms.Label(); this._MyToolTip = new DevComponents.DotNetBar.SuperTooltip(); this._MyFlexGrid = new Volian.Controls.Library.VlnFlexGrid(this.components); + this._MyDisablePanel = new vlnPanel(); ((System.ComponentModel.ISupportInitialize)(this._MyFlexGrid)).BeginInit(); this.SuspendLayout(); // @@ -69,12 +70,19 @@ namespace Volian.Controls.Library this._MyFlexGrid.Size = new System.Drawing.Size(314, 66); this._MyFlexGrid.StyleInfo = resources.GetString("_MyFlexGrid.StyleInfo"); this._MyFlexGrid.TabIndex = 4; + // + // _MyDisablePanel + // + _MyDisablePanel.BackColor = System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.ButtonFace); + _MyDisablePanel.SendToBack(); + _MyDisablePanel.Visible = false; // // GridItem // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this._MyFlexGrid); + this.Controls.Add(this._MyDisablePanel); this.Controls.Add(this.lblTab); this.Margin = new System.Windows.Forms.Padding(2); this.Name = "GridItem"; @@ -89,5 +97,6 @@ namespace Volian.Controls.Library private System.Windows.Forms.Label lblTab; private DevComponents.DotNetBar.SuperTooltip _MyToolTip; private VlnFlexGrid _MyFlexGrid; + private vlnPanel _MyDisablePanel; } } diff --git a/PROMS/Volian.Controls.Library/GridItem.cs b/PROMS/Volian.Controls.Library/GridItem.cs index 6a5a3950..c31f28b8 100644 --- a/PROMS/Volian.Controls.Library/GridItem.cs +++ b/PROMS/Volian.Controls.Library/GridItem.cs @@ -360,7 +360,44 @@ namespace Volian.Controls.Library #endregion #region Override Method and Properties public override int BorderWidth { get { return (MyFlexGrid.Width - MyFlexGrid.ClientRectangle.Width); } } - + //private bool _OnlyOnce = false; + //protected override void OnPaint(PaintEventArgs e) + //{ + // base.OnPaint(e); + // if (!this.Enabled && !_OnlyOnce) + // { + // _OnlyOnce = true; + // _MyDisablePanel.SendToBack(); + // _MyDisablePanel.BringToFront(); + // _OnlyOnce = false; + // } + //} + protected override void OnEnabledChanged(EventArgs e) + { + base.OnEnabledChanged(e); + if (this.Enabled) + { + _MyDisablePanel.SendToBack(); + _MyDisablePanel.Visible = false; + } + else + { + _MyDisablePanel.Visible = true; + Rectangle rect = new Rectangle(0, 0, this.MyFlexGrid.Width, this.MyFlexGrid.Height); + Bitmap bmp = new Bitmap(this.MyFlexGrid.Width, this.MyFlexGrid.Height); + this.MyFlexGrid.DrawToBitmap(bmp, rect); + using (Graphics gr = Graphics.FromImage(bmp)) + { + gr.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; + gr.FillRectangle(new SolidBrush(Color.FromArgb(128, Color.FromKnownColor(KnownColor.ButtonFace))), rect); + //gr.FillEllipse(Brushes.Red, 10, 10, 10, 10); + } + _MyDisablePanel.Location = this.MyFlexGrid.Location; + _MyDisablePanel.Size = this.MyFlexGrid.Size; + _MyDisablePanel.BackgroundImage = bmp; + _MyDisablePanel.BringToFront(); + } + } public override Point ContentLocation { get { return new Point(Location.X + MyFlexGrid.Left, Location.Y); } diff --git a/PROMS/Volian.Controls.Library/StepPanel.cs b/PROMS/Volian.Controls.Library/StepPanel.cs index 5fd9ab3f..e6393d5d 100644 --- a/PROMS/Volian.Controls.Library/StepPanel.cs +++ b/PROMS/Volian.Controls.Library/StepPanel.cs @@ -48,7 +48,30 @@ namespace Volian.Controls.Library if (!_LookupEditItems.ContainsKey(itemInfo.ItemID)) return null; return _LookupEditItems[itemInfo.ItemID]; } - + private int _ApplDisplayMode = -1; + public int ApplDisplayMode + { + get { return _ApplDisplayMode; } + set + { + if(_ApplDisplayMode == value) return; + _ApplDisplayMode = value; + foreach (Control c in Controls) + { + EditItem ei = c as EditItem; + if (ei != null) + { + ei.Enabled = ei.MyItemInfo.IsApplicable(value); + //IItemConfig cfg = ei.MyItemInfo.MyConfig as IItemConfig; + //List apples = cfg.MasterSlave_Applicability.GetFlags(); + //if (value == -1 || apples.Count == 0) + // ei.Enabled = true; + //else + // ei.Enabled = apples.Contains(value); + } + } + } + } /// /// Currently selected ItemInfo /// diff --git a/PROMS/Volian.Controls.Library/VlnFlexGrid.Designer.cs b/PROMS/Volian.Controls.Library/VlnFlexGrid.Designer.cs index 956bec6d..fe3114ca 100644 --- a/PROMS/Volian.Controls.Library/VlnFlexGrid.Designer.cs +++ b/PROMS/Volian.Controls.Library/VlnFlexGrid.Designer.cs @@ -2,7 +2,40 @@ using System; namespace Volian.Controls.Library { - partial class VlnFlexGrid + partial class vlnPanel + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } + partial class VlnFlexGrid { /// /// Required designer variable. diff --git a/PROMS/Volian.Controls.Library/VlnFlexGrid.cs b/PROMS/Volian.Controls.Library/VlnFlexGrid.cs index f6928aec..1ec1b029 100644 --- a/PROMS/Volian.Controls.Library/VlnFlexGrid.cs +++ b/PROMS/Volian.Controls.Library/VlnFlexGrid.cs @@ -22,6 +22,39 @@ namespace Volian.Controls.Library public delegate void VlnFlexGridCursorMovementEvent(object sender, VlnFlexGridCursorMovementEventArgs args); public delegate string VlnFlexGridPasteEvent(object sender, VlnFlexGridPasteEventArgs args); public delegate void VlnFlexGridkeyEvent(object sender, KeyEventArgs args); + public partial class vlnPanel : Panel + { + private int _Opacity = 128; + //public int Opacity + //{ + // get { return _Opacity; } + // set { _Opacity = value; } + //} + + public vlnPanel() + { + InitializeComponent(); + } + + public vlnPanel(IContainer container) + { + container.Add(this); + InitializeComponent(); + } + //protected override CreateParams CreateParams + //{ + // get + // { + // CreateParams prams = base.CreateParams; + // prams.ExStyle |= 0x020; // transparent + // return prams; + // } + //} + //protected override void OnPaint(PaintEventArgs pe) + //{ + // pe.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(_Opacity, this.BackColor)), this.ClientRectangle); + //} + } public partial class VlnFlexGrid : C1.Win.C1FlexGrid.C1FlexGrid {