コード例 #1
0
ファイル: Marker.cs プロジェクト: jimnash/GraphLib
        internal void DrawMarkers(PanelControl pan)
        {
            if (Hide)
            {
                return;
            }
            if (pan.TagList == null)
            {
                return;
            }

            var yOffset = 0;
            var pp      = new Pen(Color.Black);
            int y       = 2;

            foreach (var t in pan.TagList)
            {
                if (!t.Visible)
                {
                    continue;
                }
                var gs = _graphPanel.GetGraphSurfaceFromTag(t.Tag);
                if (gs == null)
                {
                    continue;
                }
                if (!IsAnyMarker(gs.GType))
                {
                    continue;
                }

                pp.Color = t.Colour.Color;
                pp.Width = t.Highlight ? 2 : 1;

                DrawBoundaryMarkers(gs, pan, pp, y, ref yOffset);
                y = y == 2 ? 16 : 2;
            }
        }
コード例 #2
0
ファイル: GrBoundary.cs プロジェクト: jimnash/GraphLib
        internal void FillBoundaries(PanelControl pan)
        {
            if (_graphTabPanel.Cst.Graphs == null)
            {
                return;
            }
            if (pan.TagList == null)
            {
                return;
            }

            var pp  = new Pen(Color.Black);
            var hbr = new HatchBrush(HatchStyle.Percent50, Color.Wheat, Color.Transparent);

            foreach (var t in pan.TagList)
            {
                var gs = _graphPanel.GetGraphSurfaceFromTag(t.Tag);
                if (!IsGraphSurfaceBoundaryOk(gs))
                {
                    continue;
                }

                if (gs.ObjectTag.TypeId == GraphManipulationType.MeasurementMarker)
                {
                    if (gs.ObjectTag.Values == null)
                    {
                        continue;
                    }
                    if (gs.ObjectTag.Values[0] < 0.0)
                    {
                        continue;
                    }
                }

                pp.Color = t.Colour.Color;
                pp.Width = t.Highlight ? 2 : 1;

                for (var j = 0; j < gs.PtCount - 1; j += 2)
                {
                    var xx1 = gs.DPts[j].X;
                    var xx2 = gs.DPts[j + 1].X;
                    var x1  = Params.GetXScreenPoint(pan, gs, xx1);
                    int x2;
                    if (xx2 > xx1)
                    {
                        x2 = Params.GetXScreenPoint(pan, gs, xx2);
                    }
                    else
                    {
                        x2 = Params.GetXScreenPoint(pan, gs, 360);
                        pan.GrSurface.FillRectangle(hbr, x1, 0, x2 - x1, pan.GPan.Height);
                        x1 = Params.GetXScreenPoint(pan, gs, 0);
                        x2 = Params.GetXScreenPoint(pan, gs, xx2);
                    }
                    pan.GrSurface.FillRectangle(hbr, x1, 0, x2 - x1, pan.GPan.Height);
                }
            }
        }
コード例 #3
0
ファイル: GraphData.cs プロジェクト: jimnash/GraphLib
        /// <summary>
        ///
        /// </summary>
        /// <param name="pan"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public bool NearGraph(PanelControl pan, int x, int y)
        {
            LastNearString = null;
            LastNearGtag   = -1;
            if (pan.TagList == null)
            {
                return(false);
            }

            foreach (var t in pan.TagList)
            {
                if (!t.Visible)
                {
                    continue;
                }

                var gs = _graphPanel.GetGraphSurfaceFromTag(t.Tag);

                if (gs == null)
                {
                    continue;
                }

                if (gs.GType != GraphType.Graph && gs.GType != GraphType.Live)
                {
                    continue;
                }

                for (var j = 0; j < t.ScrPCount - 1; j++)
                {
                    var x1 = t.ScrPoints[j].X - 5;
                    var x2 = t.ScrPoints[j + 1].X + 5;

                    if (x < x1 - 5)
                    {
                        break;
                    }

                    if (x > x2 + 5)
                    {
                        continue;
                    }

                    var y1 = t.ScrPoints[j].Y;
                    var y2 = t.ScrPoints[j + 1].Y;

                    if (y1 > y2)
                    {
                        var tempY = y1;
                        y1 = y2;
                        y2 = tempY;
                    }

                    if (y < y1 - 5 || y > y2 + 5)
                    {
                        continue;
                    }

                    y1 = t.ScrPoints[j].Y;
                    y2 = t.ScrPoints[j + 1].Y;
                    x1 = t.ScrPoints[j].X;
                    x2 = t.ScrPoints[j + 1].X;
                    if (!(ShortestDistance(x, y, x1, y1, x2, y2) < 10))
                    {
                        continue;
                    }
                    if (gs.Source.Length > 0)
                    {
                        LastNearString = gs.Name + " [" + gs.Source + "]";
                    }
                    else
                    {
                        LastNearString = gs.Name;
                    }
                    LastNearGtag = t.Tag;
                    return(true);
                }
            }
            return(false);
        }
コード例 #4
0
        private void FillLegend2(PanelControl panelControl)
        {
            if (panelControl.TagList == null)
            {
                return;
            }
            if (panelControl.TagList.Length <= 0)
            {
                return;
            }
            const int lineStep    = 25;
            var       tWidth      = 0;
            var       j           = -1;
            var       y           = 0;
            var       foundMaster = false;

            DoNotUpdate = true;
            ResetData();

            for (var i = 0; i < panelControl.TagList.Length; i++)
            {
                if (!panelControl.TagList[i].Visible)
                {
                    continue;
                }

                var gs = _graphPanel.GetGraphSurfaceFromTag(panelControl.TagList[i].Tag);
                if (gs == null)
                {
                    continue;
                }
                if (gs.GType != GraphType.Graph && gs.GType != GraphType.Live)
                {
                    continue;
                }

                j += 1;
                y += lineStep;

                var hb = new CheckBox
                {
                    Checked = false,
                    Left    = LHLLab.Left + 4,
                    Top     = y - 4,
                    Text    = "",
                    Width   = 25,
                    Tag     = new HlTag(gs.TagId, panelControl)
                };

                if (panelControl.TagList[i].Highlight)
                {
                    hb.Checked = true;
                }
                hb.CheckedChanged += _events.HighlightChanged;
                _highlightBox.Add(hb);

                var sb = new CheckBox
                {
                    Checked = true,
                    Left    = LabSolid.Left + 4,
                    Top     = y - 4,
                    Text    = "",
                    Width   = 25,
                    Tag     = new HlTag(gs.TagId, panelControl)
                };

                if (panelControl.TagList[i].AsPoint)
                {
                    sb.Checked = false;
                }
                sb.CheckedChanged += _events.SolidChanged;
                _solidBox.Add(sb);

                var yc = new CheckBox
                {
                    Checked = false,
                    Left    = YMaster.Left + 20,
                    Top     = y - 4,
                    Text    = "",
                    Width   = 25,
                    Tag     = new HlTag(gs.TagId, panelControl)
                };

                if (panelControl.TagList[i].Master)
                {
                    yc.Checked  = true;
                    foundMaster = true;
                }

                yc.CheckedChanged += _events.YControlChanged;
                YControlBox.Add(yc);

                var colourBox = new PictureBox
                {
                    BackColor   = panelControl.TagList[i].Colour.Color,
                    Left        = Lcollab.Left + 4,
                    Top         = y,
                    Width       = 28,
                    Height      = 15,
                    BorderStyle = BorderStyle.Fixed3D
                };

                var toolTip = new ToolTip {
                    InitialDelay = 200
                };
                toolTip.SetToolTip(colourBox, "Single Click Here To Make A Temporary Change To The Colour");
                colourBox.Tag    = new HlTag(i, panelControl);
                colourBox.Click += _events.ColClick;
                _colorBox.Add(colourBox);

                var ys = SetYScaleBox(y, i, panelControl);
                _yScaleBox.Add(ys);

                var minL = CreateLabel(Lminlab.Left, y, gs.MinD.ToString(CultureInfo.InvariantCulture));
                _minLabel.Add(minL);

                var maxL = CreateLabel(Lmaxlab.Left, y, gs.MaxD.ToString(CultureInfo.InvariantCulture));
                _maxLabel.Add(maxL);

                var lastL = CreateLabel(Llastslab.Left, y, " ");
                _lastValueLabel.Add(lastL);

                var txt  = GetLegendNameLabel(gs);
                var namL = CreateLabel(Lnamelab.Left, y, txt);
                namL.Width = GetTextWidth(txt);
                _nameLabel.Add(namL);

                var w = namL.Width + Lnamelab.Left;
                if (w > tWidth)
                {
                    tWidth = w;
                }
            }

            if (j < 0)
            {
                DoNotUpdate = false;
                return;
            }


            for (j = 0; j < _solidBox.Count; ++j)
            {
                Controls.Add(_minLabel[j]);
                Controls.Add(_maxLabel[j]);
                Controls.Add(_lastValueLabel[j]);
                Controls.Add(_colorBox[j]);
                Controls.Add(_nameLabel[j]);
                Controls.Add(_highlightBox[j]);
                Controls.Add(YControlBox[j]);
                Controls.Add(_yScaleBox[j]);
                Controls.Add(_solidBox[j]);
            }

            Height = y + 75;
            if (Height > 500)
            {
                AutoScroll = true;
                Height     = 500;
                Width      = tWidth + 100;
            }
            else
            {
                AutoScroll = false;
                Width      = tWidth;
            }

            //Check we have a master
            if (foundMaster)
            {
                DoNotUpdate = false;
                return;
            }

            if (YControlBox == null)
            {
                return;
            }
            if (YControlBox.Count <= 0)
            {
                return;
            }
            YControlBox[0].Checked = true;

            var tt = (HlTag)YControlBox[0].Tag;

            Params.SetGraphMasterPan(tt.PanelControl, tt.GraphTagId, true);
            DoNotUpdate = false;
        }