/// <summary> /// Handle our panel being painted /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PanelPaint(object sender, PaintEventArgs e) { try { if (Data_Integration.SimulatorStatus != MM_Simulation_Time.enumSimulationStatus.Running && (DateTime.Now.Second % 2) == 0) { e.Graphics.Clear(Color.FromArgb(50, 0, 0)); } //Determine our zoom e.Graphics.ScaleTransform(ZoomLevel, ZoomLevel); //Draw our header bar Rectangle HeaderRect = new Rectangle(pnlElements.DisplayRectangle.Left, pnlElements.DisplayRectangle.Top, pnlElements.DisplayRectangle.Width, 40); if (HeaderRect.IntersectsWith(e.ClipRectangle)) { MM_OneLine_Element.DrawHeader(e.Graphics, HeaderRect, BaseElement); } e.Graphics.TranslateTransform(pnlElements.AutoScrollPosition.X, pnlElements.AutoScrollPosition.Y); //Draw our arrows if (arrowsToolStripMenuItem.Checked) { foreach (MM_OneLine_Element Elem in DisplayElements.Values) { if (Elem.DescriptorArrow || (Elem.Descriptor != null && Elem.Descriptor.DescriptorArrow)) { if (Elem.ParentElement != null) { MM_OneLine_Element.DrawArrow(e.Graphics, Elem.ParentElement.Bounds, Elem.Bounds); } if (Elem.Descriptor != null) { MM_OneLine_Element.DrawArrow(e.Graphics, Elem.Bounds, Elem.Descriptor.Bounds); } if (Elem.SecondaryDescriptor != null) { MM_OneLine_Element.DrawArrow(e.Graphics, Elem.Bounds, Elem.SecondaryDescriptor.Bounds); } } } } //Write out our node paths foreach (MM_OneLine_Node Node in DisplayNodes.Values) { if (Node.NodePaths != null) { Node.DetermineAssociatedBus(); if (mnuNodeToElementLines.Checked) { foreach (KeyValuePair <MM_OneLine_Element, GraphicsPath> gpNode in Node.NodePaths) { MM_AlarmViolation_Type WorstViol = null; if (IsFlashing && MM_Repository.OverallDisplay.NodeToElementViolations) { foreach (MM_AlarmViolation Viol in gpNode.Key.BaseElement.Violations.Values) { if (WorstViol == null || Viol.Type.Priority < WorstViol.Priority) { WorstViol = Viol.Type; } } MM_Bus NearBus = gpNode.Key.BaseElement.NearBus; MM_Bus FarBus = gpNode.Key.BaseElement.FarBus; if (NearBus != null) { foreach (MM_AlarmViolation Viol in NearBus.Violations.Values) { if (WorstViol == null || Viol.Type.Priority < WorstViol.Priority) { WorstViol = Viol.Type; } } } if (FarBus != null) { foreach (MM_AlarmViolation Viol in FarBus.Violations.Values) { if (WorstViol == null || Viol.Type.Priority < WorstViol.Priority) { WorstViol = Viol.Type; } } } } Color DrawColor = WorstViol == null ? Node.KVLevel.Energized.ForeColor : WorstViol.ForeColor; using (Pen DrawPen = new Pen(DrawColor)) e.Graphics.DrawPath(DrawPen, gpNode.Value); } } } } //Write out our elements, nodes, and unlinked elements foreach (MM_OneLine_Element Elem in DisplayElements.Values) { // if (e.ClipRectangle.IntersectsWith(Elem.Bounds)) Elem.PaintElement(e.Graphics, this, IsFlashing); } foreach (MM_OneLine_Node Node in DisplayNodes.Values) { // if (e.ClipRectangle.IntersectsWith(Node.Bounds)) Node.PaintElement(e.Graphics, this, IsFlashing); } foreach (MM_OneLine_Element UnlinkedElem in UnlinkedElements) { // if (e.ClipRectangle.IntersectsWith(UnlinkedElem.Bounds)) UnlinkedElem.PaintElement(e.Graphics, this, IsFlashing); } //Write out our descriptors and secondary descriptors foreach (MM_OneLine_Element Elem in Descriptors.Values) { // if (e.ClipRectangle.IntersectsWith(Elem.Bounds)) Elem.PaintElement(e.Graphics, this, IsFlashing); } foreach (MM_OneLine_Element Elem in SecondaryDescriptors.Values) { //if (e.ClipRectangle.IntersectsWith(Elem.Bounds)) Elem.PaintElement(e.Graphics, this, IsFlashing); } //If we have a highlighted element, let's make it visible int HighlightRadius = 20; if (HighlightedElement != null) { using (Pen HighlightPen = new Pen(Color.White, 3) { DashStyle = DashStyle.Custom, DashPattern = IsFlashing ? new float[] { 1, 2, 3 } : new float[] { 3, 2, 1 } }) e.Graphics.DrawEllipse(HighlightPen, HighlightedElement.Bounds.Left - HighlightRadius, HighlightedElement.Bounds.Top - HighlightRadius, HighlightedElement.Bounds.Width + HighlightRadius + HighlightRadius, HighlightedElement.Bounds.Height + HighlightRadius + HighlightRadius); } //Highlight any elements with pending changes MM_OneLine_Element FoundElem; if (ValueChanges.Count > 0) { using (Pen HighlightPen = new Pen(Color.White, 3)) foreach (MM_Element Elem in ValueChanges.Keys.ToArray()) { if (DisplayElements.TryGetValue(Elem, out FoundElem)) { e.Graphics.DrawRectangle(HighlightPen, FoundElem.Bounds.Left - HighlightRadius, FoundElem.Bounds.Top - HighlightRadius, FoundElem.Bounds.Width + HighlightRadius + HighlightRadius, FoundElem.Bounds.Height + HighlightRadius + HighlightRadius); e.Graphics.DrawLine(HighlightPen, FoundElem.Bounds.Left - HighlightRadius, FoundElem.Bounds.Top - HighlightRadius, FoundElem.Bounds.Left, FoundElem.Bounds.Top); e.Graphics.DrawLine(HighlightPen, FoundElem.Bounds.Right + HighlightRadius, FoundElem.Bounds.Top - HighlightRadius, FoundElem.Bounds.Right, FoundElem.Bounds.Top); e.Graphics.DrawLine(HighlightPen, FoundElem.Bounds.Left - HighlightRadius, FoundElem.Bounds.Bottom + HighlightRadius, FoundElem.Bounds.Left, FoundElem.Bounds.Bottom); e.Graphics.DrawLine(HighlightPen, FoundElem.Bounds.Right + HighlightRadius, FoundElem.Bounds.Bottom + HighlightRadius, FoundElem.Bounds.Right, FoundElem.Bounds.Bottom); } } } e.Graphics.TranslateTransform(-pnlElements.AutoScrollPosition.X, -pnlElements.AutoScrollPosition.Y); } catch { } }