Exemple #1
0
 internal void Setup(GraphPanel g)
 {
     _graphPanel       = g;
     _graphParameters  = _graphPanel.GraphParameters;
     _graphicsTabPanel = _graphPanel.GraphParameters.GraphTabPanel;
     _graphBoundary    = _graphPanel.GraphParameters.GraphBoundary;
     _tabMouse         = new TabMouseOps(g);
 }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="gType"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        internal void UpdateContextMenu(GraphType gType, string title)
        {
            if (_graphParams.MissFromContextMenu)
            {
                return;
            }

            if (GrBoundary.IsAnyMarkerOrBoundary(gType))
            {
                UpdateContextBoundary(title);
                return;
            }

            var menuI = new MenuItem(title)
            {
                Tag = CreateMenuTag(_graphPanel.Gdata.AbsoluteGraphTag, 0, GraphOption.TopLevelGraph)
            };

            AddCMenuItems(menuI, _graphPanel.Gdata.AbsoluteGraphTag, 0, true);
            menuI.MenuItems[0].Checked = _graphParams.InitiallyVisible;
            _graphTabPanel.Cst.MainPan.ConMenu.MenuItems.Add(menuI);

            if (_graphTabPanel.Cst.SubPan == null)
            {
                return;
            }
            var panelTag = 1;

            foreach (var t in _graphTabPanel.Cst.SubPan)
            {
                menuI = new MenuItem(title)
                {
                    Tag = CreateMenuTag(_graphPanel.Gdata.AbsoluteGraphTag, panelTag, GraphOption.TopLevelGraph)
                };
                AddCMenuItems(menuI, _graphPanel.Gdata.AbsoluteGraphTag, panelTag, true);
                menuI.MenuItems[0].Checked = _graphParams.InitiallyVisible;
                t.ConMenu.MenuItems.Add(menuI);
                ++panelTag;
            }
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pts"></param>
        /// <param name="title"></param>
        /// <param name="source"></param>
        /// <param name="gType"></param>
        /// <param name="objectTag"></param>
        private void AddTNewGraph(DPoint[] pts, string title, string source,
                                  GraphType gType, GraphManipulationTag objectTag)
        {
            var tid    = 0;
            var id     = 0;
            var remTag = 0;

            if (_graphTabPanel.Cst.MainPan.TagList != null)
            {
                tid = _graphTabPanel.Cst.MainPan.TagList.Length;
            }

            if (_useOffsetTag)
            {
                remTag           = AbsoluteGraphTag;
                AbsoluteGraphTag = _offsetTagValue;
            }

            Array.Resize(ref _graphTabPanel.Cst.MainPan.TagList, tid + 1);
            _graphTabPanel.Cst.MainPan.TagList[tid] = new GraphControl(AbsoluteGraphTag, _presetColours[tid % _presetColours.Length])
            {
                Visible      = _graphParameters.InitiallyVisible,
                CanBeVisible = _graphParameters.InitiallyVisible,
                Master       = false
            };


            if (_graphTabPanel.Cst.Graphs != null)
            {
                id = _graphTabPanel.Cst.Graphs.Length;
            }

            objectTag.GraphTag = AbsoluteGraphTag;
            Array.Resize(ref _graphTabPanel.Cst.Graphs, id + 1);
            _graphTabPanel.Cst.Graphs[id] = new GraphSurface
            {
                PtCount     = 0,
                DyScale     = 1.0,
                MaxPtCount  = Math.Max(pts.Length, InitialAllocation),
                GType       = gType,
                ObjectTag   = objectTag,
                Name        = title,
                Source      = source,
                TagId       = AbsoluteGraphTag,
                GxAxisTitle = _graphTabPanel.Cst.MainPan.XAxisTitle,
                GyAxisTitle = _graphTabPanel.Cst.MainPan.YAxisTitle,
            };
            _graphTabPanel.Cst.Graphs[id].DPts = new DPoint[_graphTabPanel.Cst.Graphs[id].MaxPtCount];

            for (var i = 0; i < pts.Length; i++)
            {
                _graphTabPanel.Cst.Graphs[id].DPts[i] = pts[i];
            }

            _graphTabPanel.Cst.Graphs[id].DPts[0].StartPt = true;

            _graphTabPanel.Cst.Graphs[id].PtCount = pts.Length;
            if (_graphParameters.ResetPointCount)
            {
                _graphTabPanel.Cst.Graphs[id].PtCount = 0;
            }

            double max = pts[0].Y;
            var    min = 0.0;

            if (max < min)
            {
                min = max;
            }

            if (GrBoundary.IsAnyMarkerOrBoundary(gType))
            {
                max = 1.0;
            }
            else
            {
                switch (_graphTabPanel.Cst.MainPan.YAxisType)
                {
                case YAxisType.Free:
                    for (var i = 1; i < pts.Length; i++)
                    {
                        if (pts[i].Y > max)
                        {
                            max = pts[i].Y;
                        }
                        if (pts[i].Y < min)
                        {
                            min = pts[i].Y;
                        }
                    }
                    break;

                case YAxisType.MinMax:
                    min = _graphTabPanel.Cst.MainPan.YAxisMin;
                    max = _graphTabPanel.Cst.MainPan.YAxisMax;
                    break;

                default:
                    max = _graphPanel.GetMaxOnTab(1, _graphTabPanel.Cst.MainPan);
                    min = _graphPanel.GetMinOnTab(1, _graphTabPanel.Cst.MainPan);
                    break;
                }
            }
            if ((max - min) < 1E-06)
            {
                max = min + 1.0;
            }


            _graphTabPanel.Cst.Graphs[id].MaxD = max;
            _graphTabPanel.Cst.Graphs[id].MinD = min;
            if (!GrBoundary.IsAnyMarkerOrBoundary(gType))
            {
                SetMasterGraph(ref _graphTabPanel.Cst.MainPan, 0);
                SetMasterGraph(ref _graphTabPanel.Cst.MainPan, id);
            }

            _graphParameters.ContextMenu.UpdateContextMenu(gType, title);
            _graphParameters.ContextMenu.SetGraphMenuColourTick(AbsoluteGraphTag, _graphTabPanel.Cst.MainPan.TagList[tid].Colour);
            for (var i = 0; i <= tid; i++)
            {
                _graphTabPanel.Cst.MainPan.TagList[i].Master = false;
            }
            for (var i = 0; i <= tid; i++)
            {
                if (!_graphTabPanel.Cst.MainPan.TagList[i].Visible)
                {
                    continue;
                }
                GpContextMenu.SetMaster(_graphTabPanel.Cst.MainPan.ConMenu, _graphTabPanel.Cst.MainPan.TagList[i].Tag);
                _graphTabPanel.Cst.MainPan.TagList[i].Master = true;
                _graphParameters.MasterCallBack();
                break;
            }
            if (_useOffsetTag)
            {
                AbsoluteGraphTag = remTag;
                _offsetTagValue += 1;
            }
            else
            {
                AbsoluteGraphTag += 1;
            }
        }