/// <summary> /// /// </summary> /// <param name="graphTag"></param> /// <param name="panelTag"></param> /// <param name="itemTag"></param> /// <returns></returns> private static MenuTag CreateMenuTag(int graphTag, int panelTag, GraphOption itemTag) { var m = new MenuTag { GraphTag = graphTag, PanelTag = panelTag, ItemTag = itemTag }; return(m); }
/// <summary> /// /// </summary> /// <param name="dest"></param> /// <param name="src"></param> /// <param name="panelTag"></param> internal void CopyMenu(ContextMenu dest, ContextMenu src, int panelTag) { if (src.MenuItems.Count <= 0) { return; } if (dest.MenuItems.Count > 0) { dest.MenuItems.Clear(); } for (var i = 0; i < src.MenuItems.Count; i++) { var sm = src.MenuItems[i]; var m = new MenuItem(sm.Text); var mt = new MenuTag(); var smt = (MenuTag)sm.Tag; mt.GraphTag = smt.GraphTag; mt.PanelTag = panelTag + 1; mt.ItemTag = smt.ItemTag; m.Tag = mt; switch (mt.ItemTag) { case GraphOption.AsYAxis: m.Click += _graphTabPanel.AxisMenuContextClick; break; case GraphOption.Legend: m.Click += _graphTabPanel.LegendMenuContextClick; break; case GraphOption.ShowAllGraphs: m.Click += _graphTabPanel.ShowAllMenuContextClick; break; case GraphOption.HideAllGraphs: m.Click += _graphTabPanel.HideAllMenuContextClick; break; default: m.Click += MenuContextClick; break; } dest.MenuItems.Add(m); if (sm.MenuItems.Count <= 0) { continue; } CopyMenu2(m, sm, panelTag); } }
private MenuItem CreateSubMenu(string title, int gTag, int pTag, GraphOption iTag, GraphColour cTag) { var mTag = new MenuTag { GraphTag = gTag, PanelTag = pTag, ItemTag = iTag, ColourTag = cTag }; var menuItem = new MenuItem(title) { Tag = mTag, Checked = false }; menuItem.Click += MenuContextClick; return(menuItem); }
/// <summary> /// /// </summary> /// <param name="dest"></param> /// <param name="src"></param> /// <param name="panelTag"></param> private void CopyMenu2(Menu dest, Menu src, int panelTag) { foreach (MenuItem sm in src.MenuItems) { var m = new MenuItem(sm.Text); var mt = new MenuTag(); var smt = (MenuTag)sm.Tag; mt.GraphTag = smt.GraphTag; mt.ColourTag = smt.ColourTag; mt.PanelTag = panelTag + 1; mt.ItemTag = smt.ItemTag; m.Tag = mt; switch (mt.ItemTag) { case GraphOption.AsYAxis: m.Click += _graphTabPanel.AxisMenuContextClick; break; case GraphOption.Legend: m.Click += _graphTabPanel.LegendMenuContextClick; break; case GraphOption.ShowAllGraphs: m.Click += _graphTabPanel.ShowAllMenuContextClick; break; case GraphOption.HideAllGraphs: m.Click += _graphTabPanel.HideAllMenuContextClick; break; default: m.Click += MenuContextClick; break; } dest.MenuItems.Add(m); if (sm.MenuItems.Count > 0) { CopyMenu2(m, sm, panelTag); } } }
/// <summary> /// /// </summary> /// <param name="pan"></param> /// <param name="mTag"></param> /// <param name="tagIt"></param> private void TagGraph(PanelControl pan, MenuTag mTag, bool tagIt) { var matchedId = -1; if (pan.TagList == null) { if (tagIt) { pan.TagList = new GraphControl[1]; pan.TagList[0] = new GraphControl(mTag.GraphTag, _graphPanel.GetGraphColour(mTag.GraphTag)); } SetMaster(pan.ConMenu, mTag.GraphTag); _graphParams.MasterCallBack(); _graphParams.GraphicsSet = true; return; } foreach (var t in pan.TagList) { t.Master = false; } var cnt = pan.TagList.Length; for (var i = 0; i < cnt; i++) { if (pan.TagList[i].Tag == mTag.GraphTag) { matchedId = i; break; } } if (matchedId == -1 && tagIt) { for (var i = 0; i < cnt; i++) { pan.TagList[i].Master = false; } Array.Resize(ref pan.TagList, cnt + 1); pan.TagList[cnt] = new GraphControl(mTag.GraphTag, _graphPanel.GetGraphColour(mTag.GraphTag)); SetMaster(pan.ConMenu, mTag.GraphTag); pan.TagList[cnt].Master = true; _graphParams.MasterCallBack(); } else if (matchedId != -1) { pan.TagList[matchedId].Visible = tagIt; pan.TagList[matchedId].CanBeVisible = tagIt; if (tagIt) { SetMaster(pan.ConMenu, pan.TagList[matchedId].Tag); pan.TagList[matchedId].Master = true; _graphParams.MasterCallBack(); } else { var found = pan.TagList.Any(t => t.Master); if (!found) { foreach (var t in pan.TagList.Where(t => t.Visible)) { found = true; SetMaster(pan.ConMenu, t.Tag); t.Master = true; _graphParams.MasterCallBack(); break; } if (!found) { SetMaster(pan.ConMenu, pan.TagList[0].Tag); pan.TagList[0].Master = true; _graphParams.MasterCallBack(); } Params.SetGraphMasterPan(pan, mTag.GraphTag, true); } } } _graphParams.GraphicsSet = true; }