diff --git a/PROMS/Volian.Controls.Library/DisplayItem.cs b/PROMS/Volian.Controls.Library/DisplayItem.cs index 1384170d..308d774f 100644 --- a/PROMS/Volian.Controls.Library/DisplayItem.cs +++ b/PROMS/Volian.Controls.Library/DisplayItem.cs @@ -31,6 +31,7 @@ namespace Volian.Controls.Library //public delegate void vlnCSLARTBLinkEvent(object sender, vlnCSLARTBLinkEventArgs args); public partial class DisplayItem : UserControl { + private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); #region Events //public event vlnCSLARTBLinkEvent LinkClicked; //private void OnLinkClicked(object sender, vlnCSLARTBLinkEventArgs args) @@ -194,7 +195,7 @@ namespace Volian.Controls.Library { string line2 = Regex.Replace(line, @"\\.*? ", ""); // Remove RTF Commands //if (line != line2) - // Console.WriteLine("'{0}' <> '{1}'", line, line2); + // if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("'{0}' <> '{1}'", line, line2); SizeF siz = g.MeasureString(line2, fnt,pnt,StringFormat.GenericTypographic) ; if (siz.Width+ _Panel.Settings.TableWidthAdjust > max) max = siz.Width + _Panel.Settings.TableWidthAdjust; } @@ -233,7 +234,7 @@ namespace Volian.Controls.Library get { return Width - lblTab.Left; } set { - //Console.Write("\r\nItemWidth"); + //if(_MyLog.IsDebugEnabled)_MyLog.Debug("ItemWidth"); Width = value + lblTab.Left; } } @@ -242,7 +243,7 @@ namespace Volian.Controls.Library get { return _DisplayRTB.Width; } set { - //Console.Write("\r\nTextWidth"); + //if(_MyLog.IsDebugEnabled)_MyLog.Debug("TextWidth"); Width = value + lblTab.Left + lblTab.Width; } } @@ -383,7 +384,7 @@ namespace Volian.Controls.Library if ((Expanding != ExpandingStatus.No || Expanded) & _After != null) tmpa = _After[_After.Count - 1].BottomMost; if (tmpr == null) return tmpa; - //Console.Write("\r\nLeft {0}, Right {1}", tmpa.Bottom, tmpr.Bottom); + //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("Left {0}, Right {1}", tmpa.Bottom, tmpr.Bottom); if (tmpa.Bottom >= tmpr.Bottom) return tmpa; return tmpr; @@ -500,7 +501,7 @@ namespace Volian.Controls.Library } if (expand) vlnExp.ShowExpanded(); _Panel = panel; - panel.ItemLookup.Add(item.ItemID, this); + if(item != null)panel.ItemLookup.Add(item.ItemID, this); _Relation = relationType; if(parent != null)RNOLevel = parent.RNOLevel; //List siblings; @@ -558,8 +559,20 @@ namespace Volian.Controls.Library { Name = string.Format("Item-{0}", item.ItemID); // Don't allow substeps to expand - CanExpand = (TemporaryFormat.IsHigh(item) || ((_Type >= 10000) && (_Type < 20000))) && - (item.MyContent.ContentPartCount != 0); + switch (_Type / 10000) + { + case 1: + //CanExpand = (item.MyContent.ContentPartCount != 0); + CanExpand = true; + vlnExp.Attachment = (item.MyContent.ContentPartCount == 0); + break; + case 2: + CanExpand = TemporaryFormat.IsHigh(item); ; + break; + default: + CanExpand = false; + break; + } //CanExpand = (item.MyContent.ContentPartCount != 0); if(expand && (item.MyContent.ContentPartCount != 0)) // If it should expand and it can expand Expand(true); @@ -822,6 +835,10 @@ namespace Volian.Controls.Library } } } + private void vlnExp_AttachmentClick(object sender, vlnExpanderEventArgs args) + { + _Panel.OnAttachmentClicked(sender, new DisplayPanelAttachmentEventArgs(this)); + } public void Expand(bool expand) { //// TIMING: vlnCSLARTB.TimeIt("Expand Start"); @@ -857,7 +874,7 @@ namespace Volian.Controls.Library //if (args.Mode == vlnExpanderMode.ExpandAll) // ExpandChildren(args); //_Panel.ResumeLayout(); - if (!vlnExp.Expanded) + if (!vlnExp.Expanded) vlnExp.ShowExpanded(); } Expanding = ExpandingStatus.Done; @@ -900,7 +917,7 @@ namespace Volian.Controls.Library get { //if (this.MyID == _WatchFor) - // Console.Write("\r\n {0}", _WatchFor); + // if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("{0}", _WatchFor); DisplayItem tmp = this; if (tmp.Next == null && FirstSibling._Relation == ChildRelation.Before) return UpOne; @@ -914,7 +931,7 @@ namespace Volian.Controls.Library if (tmp.Expanding == ExpandingStatus.Expanding || tmp.Moving) // Parent Expanding or Moving - Wait return null; DisplayItem btm = tmp.BottomMost; - //Console.Write("\r\n'BottomMost',{0},'{1}'", btm.MyID, btm.MyText); + //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("'BottomMost',{0},'{1}'", btm.MyID, btm.MyText); if (this != btm) { if (tmp.Next != null && tmp.Next.TopMost.Top != btm.Bottom) @@ -946,7 +963,7 @@ namespace Volian.Controls.Library private void AdjustLocation() { //if (this.MyID == _WatchFor) - // Console.Write("\r\n {0}",_WatchFor); + // if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("{0}",_WatchFor); DisplayItem tmp = NextItem; if (tmp == null) return; //if(tmp.Top > _Panel.Height && Bottom > _Panel.Height){ @@ -956,7 +973,7 @@ namespace Volian.Controls.Library //} if (tmp != null && !tmp.Moving && tmp.Top != Bottom ) { - //Console.Write("\r\n'Adjust Location',{0},'Move',{1}", MyID, tmp.MyID); + //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("'Adjust Location',{0},'Move',{1}", MyID, tmp.MyID); //tmp.TopMost.Top = Bottom; _Panel.Scrolling++; tmp.Top = Bottom; @@ -980,7 +997,7 @@ namespace Volian.Controls.Library // DateTime tNow = DateTime.Now; // if (!dicTiming.ContainsKey(p)) dicTiming[p] = 0; // dicTiming[p] += (tNow.Ticks - tLast.Ticks); - // //Console.Write("\t{0}\t{1:0.000}", p, tNow - tLast); + // //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("\t{0}\t{1:0.000}", p, tNow - tLast); // tLast = tNow; //} //public static void TimeItList() @@ -989,39 +1006,39 @@ namespace Volian.Controls.Library // long total = 0; // foreach (string s in dicTiming.Keys) // { - // //Console.Write("{0}\"{1}\"",sep, s); + // //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("{0}\"{1}\"",sep, s); // total += dicTiming[s]; // //sep = "\t"; // } // //sep = "\r\n"; // foreach (string s in dicTiming.Keys) // { - // //Console.Write("{0}{1}", sep, (dicTiming[s]*100)/total ); + // //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("{0}{1}", sep, (dicTiming[s]*100)/total ); // //sep = "\t"; // long i = (dicTiming[s]*10000)/total; - // Console.WriteLine("\"{0}\"\t{1}\t{2}\t\"{3}\"", s, dicTiming[s], ((float)i) / 100, "".PadRight((int)(i / 100), 'X')); + // if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("\"{0}\"\t{1}\t{2}\t\"{3}\"", s, dicTiming[s], ((float)i) / 100, "".PadRight((int)(i / 100), 'X')); // } - // //Console.Write("\r\n{0:0.000}", tNow - tLast); + // //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("\r\n{0:0.000}", tNow - tLast); //} //public static void TimeItSetup() //{ // dicTiming = new Dictionary(); // DateTime tNow = DateTime.Now; // // Reset all Counts - // //Console.Write("\r\n{0:0.000}", tNow - tLast); + // //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("{0:0.000}", tNow - tLast); // tLast = tNow; //} - public DisplayRTB TextBox + public IDisplayRTB TextBox { - get { return _DisplayRTB; } + get { return (IDisplayRTB)_DisplayRTB; } } private void vlnCSLARTB_Resize(object sender, EventArgs e) { //return; //TimeIt("ResizeStart"); if (_MyItem == null) return; - //Console.Write("\r\n'Resize',{0},{1},{2},{3},{4}", MyID, Top, Left, Height, Width); + //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("'Resize',{0},{1},{2},{3},{4}", MyID, Top, Left, Height, Width); //SetToolTip(); AdjustLocation(); //TimeIt("ResizeEnd"); @@ -1030,7 +1047,7 @@ namespace Volian.Controls.Library { //return; if (_Panel.Scrolling == 0) return; - //Console.Write("'Move',{0},{1},{2},{3},{4}", MyID, Top, Left, Height, Width); + //_MyLog.DebugFormat("'Move',{0},{1},{2},{3},{4}", MyID, Top, Left, Height, Width); if (_MyItem == null) return; //if (_Panel.Scrolling) return; if (Expanding == ExpandingStatus.Expanding) return; @@ -1045,7 +1062,7 @@ namespace Volian.Controls.Library //if (ShowMoves) //if (MyID == 367) //{ - // Console.Write(",{0},{1},{2},{3},'{4}'", MyID, tmp.MyID, Top, Left, e.GetType().Name); + // if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat(",{0},{1},{2},{3},'{4}'", MyID, tmp.MyID, Top, Left, e.GetType().Name); // //ShowMoves = true; //} //SetToolTip(); @@ -1054,7 +1071,7 @@ namespace Volian.Controls.Library //{ // if (_After[0].TopMost.Top != Bottom) // { - // Console.Write("\r\n'Adjust After',{0},'{1}'", MyID, MyText); + // if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("'Adjust After',{0},'{1}'", MyID, MyText); // _After[0].TopMost.Top = Bottom; // } //} @@ -1062,7 +1079,7 @@ namespace Volian.Controls.Library { if (_RNO[0].TopMost.Top != Top) { - //Console.Write("\r\n'Adjust RNO',{0},'Move',{1}", MyID, _RNO[0].MyID); + //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("\r\n'Adjust RNO',{0},'Move',{1}", MyID, _RNO[0].MyID); if (RNOLevel >= _Panel.MaxRNO) { DisplayItem tmpBottom = this; @@ -1082,7 +1099,6 @@ namespace Volian.Controls.Library _Moving = false; BottomMost.AdjustLocation(); } - //private void veRichTextBoxText_LinkClicked(object sender, LinkClickedEventArgs e) //{ // //MessageBox.Show(e.LinkText); @@ -1090,7 +1106,7 @@ namespace Volian.Controls.Library //} void _DisplayRTB_LinkGoTo(object sender, System.Windows.Forms.LinkClickedEventArgs e) { - Console.WriteLine("_DisplayRTB_LinkGoTO " + e.LinkText); + _MyLog.DebugFormat("_DisplayRTB_LinkGoTo " + e.LinkText); _Panel.OnLinkClicked(sender, new DisplayLinkEventArgs(this, e)); } private void lblTab_MouseDown(object sender, MouseEventArgs e) @@ -1107,7 +1123,7 @@ namespace Volian.Controls.Library } private void veRichTextBoxText_Resize(object sender, EventArgs e) { - //Console.Write("\r\n'Resize Text',{0},{1},{2},{3},{4}", MyID, Top, Left, Height, Width); + //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("'Resize Text',{0},{1},{2},{3},{4}", MyID, Top, Left, Height, Width); } } } diff --git a/PROMS/Volian.Controls.Library/DisplayPanel.cs b/PROMS/Volian.Controls.Library/DisplayPanel.cs index 57895bc4..7957ec77 100644 --- a/PROMS/Volian.Controls.Library/DisplayPanel.cs +++ b/PROMS/Volian.Controls.Library/DisplayPanel.cs @@ -12,6 +12,7 @@ namespace Volian.Controls.Library { public partial class DisplayPanel : Panel { + private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); #region Events public event DisplayPanelEvent ItemClick; internal void OnItemClick(object sender, DisplayPanelEventArgs args) @@ -24,17 +25,23 @@ namespace Volian.Controls.Library if (LinkClicked != null) LinkClicked(sender, args); else MessageBox.Show(args.LinkInfo.LinkText, "Unhandled Link Click", MessageBoxButtons.OK, MessageBoxIcon.Information); } + public event DisplayPanelAttachmentEvent AttachmentClicked; + internal void OnAttachmentClicked(object sender, DisplayPanelAttachmentEventArgs args) + { + if (AttachmentClicked != null) AttachmentClicked(sender, args); + else MessageBox.Show(args.MyDisplayItem.MyItem.MyContent.MyEntry.MyDocument.DocumentTitle, "Unhandled Attachment Click", MessageBoxButtons.OK, MessageBoxIcon.Information); + } #endregion #region Constructors public DisplayPanel() { InitializeComponent(); - this.Paint += new PaintEventHandler(vlnCSLAPanel_Paint); - this.DoubleClick += new EventHandler(vlnCSLAPanel_DoubleClick); + this.Paint += new PaintEventHandler(DisplayPanel_Paint); + this.DoubleClick += new EventHandler(DisplayPanel_DoubleClick); this.AutoScroll = true; } - void vlnCSLAPanel_DoubleClick(object sender, EventArgs e) + void DisplayPanel_DoubleClick(object sender, EventArgs e) { ShowLines = !ShowLines; Refresh(); @@ -44,25 +51,33 @@ namespace Volian.Controls.Library Pen bluePen = new Pen(Color.CornflowerBlue,1); g.DrawLine(bluePen, x, 0, x, this.Height); } - void vlnCSLAPanel_Paint(object sender, PaintEventArgs e) + void DisplayPanel_Paint(object sender, PaintEventArgs e) { if (ShowLines) { - VerticalLine(e.Graphics, 60); - VerticalLine(e.Graphics, 102); - VerticalLine(e.Graphics, 415); + //int fifth = Height / 5; + //Rectangle r1 = new Rectangle(0, 0, Width, Height - fifth); + ////Brush b = new System.Drawing.Drawing2D.LinearGradientBrush(r1, Color.FromArgb(128, 0, 32), Color.FromArgb(96, 0, 16), 90); + //Brush b = new System.Drawing.Drawing2D.LinearGradientBrush(r1, Color.FromArgb(255,128, 0, 32), Color.FromArgb(255,96, 0, 16),System.Drawing.Drawing2D.LinearGradientMode.Vertical); + //e.Graphics.FillRectangle(b, r1); + //r1 = new Rectangle(0, Height - fifth, Width, fifth); + //b = new System.Drawing.Drawing2D.LinearGradientBrush(r1, Color.FromArgb(255,96, 0, 16), Color.FromArgb(255,128, 0, 32), 90); + //e.Graphics.FillRectangle(b, r1); + //VerticalLine(e.Graphics, 60); + //VerticalLine(e.Graphics, 102); + //VerticalLine(e.Graphics, 415); } } public DisplayPanel(IContainer container) { container.Add(this); InitializeComponent(); - this.Paint += new PaintEventHandler(vlnCSLAPanel_Paint); - this.BackColorChanged += new EventHandler(vlnCSLAPanel_BackColorChanged); - this.DoubleClick += new EventHandler(vlnCSLAPanel_DoubleClick); + this.Paint += new PaintEventHandler(DisplayPanel_Paint); + this.BackColorChanged += new EventHandler(DisplayPanel_BackColorChanged); + this.DoubleClick += new EventHandler(DisplayPanel_DoubleClick); this.AutoScroll = true; } - void vlnCSLAPanel_BackColorChanged(object sender, EventArgs e) + void DisplayPanel_BackColorChanged(object sender, EventArgs e) { // Walk through controls & set colors InactiveColor = PanelColor = BackColor; @@ -89,8 +104,8 @@ namespace Volian.Controls.Library if(value != null) _Layout = _MyItem.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData; //// TIMING: vlnCSLARTB.TimeIt("pMyItem Layout"); - //this.Layout += new LayoutEventHandler(vlnCSLAPanel_Layout); - //this.Scroll += new ScrollEventHandler(vlnCSLAPanel_Scroll); + //this.Layout += new LayoutEventHandler(DisplayPanel_Layout); + //this.Scroll += new ScrollEventHandler(DisplayPanel_Scroll); //// TIMING: vlnCSLARTB.TimeIt("pMyItem Scroll"); Controls.Clear(); ItemLookup = new Dictionary(); @@ -158,13 +173,13 @@ namespace Volian.Controls.Library } set { _Settings = value;} } - //void vlnCSLAPanel_Layout(object sender, LayoutEventArgs e) + //void DisplayPanel_Layout(object sender, LayoutEventArgs e) // { - // //Console.Write("\r\nlayout {0} {1} {2} {3}", e.AffectedComponent.GetType().Name,e.AffectedControl.Name,e.AffectedProperty, sender.GetType().Name); + // //if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("layout {0} {1} {2} {3}", e.AffectedComponent.GetType().Name,e.AffectedControl.Name,e.AffectedProperty, sender.GetType().Name); // } - //void vlnCSLAPanel_Scroll(object sender, ScrollEventArgs e) + //void DisplayPanel_Scroll(object sender, ScrollEventArgs e) //{ - // //Console.Write("\r\nscroll {0} {1} {2} {3}", e.OldValue, e.NewValue, e.ScrollOrientation,sender.GetType().Name); + // //if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("scroll {0} {1} {2} {3}", e.OldValue, e.NewValue, e.ScrollOrientation,sender.GetType().Name); // Scrolling = false; //} //public void AdjustOutOfRangeControls(int yAdjust) @@ -288,14 +303,13 @@ namespace Volian.Controls.Library public void ListControls() { // Walk through the controls and find the next control for each - //Console.Clear(); - Console.WriteLine("'Item','Next'"); + if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("'Item','Next'"); foreach (Control control in Controls) if (control.GetType().Name == "vlnCSLARTB") { DisplayItem rtb = (DisplayItem)control; DisplayItem nxt = rtb.NextItem; - Console.WriteLine("{0},{1}", rtb.MyID, nxt == null ? 0 : nxt.MyID); + if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("{0},{1}", rtb.MyID, nxt == null ? 0 : nxt.MyID); } } #endregion @@ -306,6 +320,7 @@ namespace Volian.Controls.Library [TypeConverter(typeof(ExpandableObjectConverter))] public partial class DisplayPanelSettings { + private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); public DisplayPanelSettings(DisplayPanel panel) { _Panel = panel; @@ -479,20 +494,22 @@ namespace Volian.Controls.Library _MyMouseEventArgs = myMouseEventArgs; } } - #region enums - public enum ParsedLinkType : int + public partial class DisplayPanelAttachmentEventArgs { - NotParsed = 0, - Transition = 1, - TransitionRange = 2, - ReferencedObject = 3 + private DisplayItem _MyDisplayItem; // Volian Property Snippet + public DisplayItem MyDisplayItem + { + get { return _MyDisplayItem; } + set { _MyDisplayItem = value; } + } + public DisplayPanelAttachmentEventArgs(DisplayItem myDisplayItem) + { + _MyDisplayItem = myDisplayItem; + } } - #endregion - public delegate void DisplayPanelEvent(object sender, DisplayPanelEventArgs args); - public delegate void DisplayPanelLinkEvent(object sender, DisplayLinkEventArgs args); - #region DisplayLinkEventArgs public partial class DisplayLinkEventArgs : EventArgs { + private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private DisplayItem _LinkedRTB; // Volian Property Snippet public DisplayItem LinkedRTB { @@ -509,7 +526,7 @@ namespace Volian.Controls.Library { LinkedRTB = linkedRTB; LinkInfo = linkInfo; - Console.WriteLine("\r\n DisplayLinkEventArgs in DisplayPanel: LinkInfo '{0}'\r\n", linkInfo.LinkText); + //if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("\r\n LinkInfo '{0}'\r\n", linkInfo.LinkText); } private void ParseLink() { @@ -527,10 +544,14 @@ namespace Volian.Controls.Library case "Transition": case "TransitionRange": _Type = (ParsedLinkType)Enum.Parse(_Type.GetType(), m.Groups[1].Value); + if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("Link String - '{0}'", m.Groups[2].Value); int transitionID = Convert.ToInt32(m.Groups[2].Value.Split(" ".ToCharArray())[1]); foreach (TransitionInfo ti in _LinkedRTB.MyItem.MyContent.ContentTransitions) + { + if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("Transition ID = '{0}'", ti.TransitionID); if (ti.TransitionID == transitionID) _MyTransition = ti; + } break; } } @@ -565,6 +586,17 @@ namespace Volian.Controls.Library } } + #region enums + public enum ParsedLinkType : int + { + NotParsed = 0, + Transition = 1, + TransitionRange = 2, + ReferencedObject = 3 + } #endregion + public delegate void DisplayPanelEvent(object sender, DisplayPanelEventArgs args); + public delegate void DisplayPanelLinkEvent(object sender, DisplayLinkEventArgs args); + public delegate void DisplayPanelAttachmentEvent(object sender, DisplayPanelAttachmentEventArgs args); public delegate void DisplayRTBLinkEvent(object sender, LinkClickedEventArgs e); }