public override void Refresh() { MasterPane mp = msGraphControl.MasterPane; mp.Border.IsVisible = false; //pane.Chart.Border.IsVisible = false; if (mp.PaneList.Count != paneList.Count) { mp.PaneList.Clear(); foreach (Pane logicalPane in paneList) { MSGraphPane pane = new MSGraphPane(); pane.Border.IsVisible = false; pane.IsFontsScaled = false; mp.Add(pane); } //mp.SetLayout( msGraphControl.CreateGraphics(), paneLayout ); } else { for (int i = 0; i < paneList.Count; ++i) { MSGraphPane pane = mp.PaneList[i] as MSGraphPane; pane.Border.IsVisible = false; pane.CurveList.Clear(); pane.GraphObjList.Clear(); } } for (int i = 0; i < paneList.Count; ++i) { Pane logicalPane = paneList[i]; MSGraphPane pane = mp.PaneList[i] as MSGraphPane; pane.IsFontsScaled = false; pane.Border.IsVisible = false; foreach (GraphItem item in logicalPane) { msGraphControl.AddGraphItem(pane, item); } if (mp.PaneList.Count > 1) { //if( i < paneList.Count - 1 ) { pane.XAxis.Title.IsVisible = false; pane.XAxis.Scale.IsVisible = false; pane.Margin.Bottom = 0; pane.Margin.Top = 2; }/* else * { * pane.XAxis.Title.IsVisible = true; * pane.XAxis.Scale.IsVisible = true; * }*/ pane.YAxis.Title.IsVisible = false; pane.YAxis.Scale.IsVisible = false; pane.YAxis.Scale.SetupScaleData(pane, pane.YAxis); } else { pane.XAxis.IsVisible = true; pane.XAxis.Title.IsVisible = true; pane.XAxis.Scale.IsVisible = true; pane.YAxis.Title.IsVisible = true; pane.YAxis.Scale.IsVisible = true; } if (logicalPane.Count == 1) { pane.Legend.IsVisible = false; } else { pane.Legend.IsVisible = true; pane.Legend.Position = ZedGraph.LegendPos.TopCenter; ZedGraph.ColorSymbolRotator rotator = new ColorSymbolRotator(); foreach (CurveItem item in pane.CurveList) { item.Color = rotator.NextColor; } } if (paneList.Count > 0 && paneList[0].Count > 0) { this.Text = paneList[0][0].Id; if (paneList[0][0].IsMassSpectrum) { this.TabText = pwiz.CLI.msdata.id.abbreviate(paneList[0][0].Id); } else { this.TabText = this.Text; } } if (pane.XAxis.Scale.MaxAuto) { msGraphControl.RestoreScale(pane); } else { pane.AxisChange(); } } mp.SetLayout(msGraphControl.CreateGraphics(), paneLayout); /*if( isOverlay ) * { * pane.Legend.IsVisible = true; * pane.Legend.Position = ZedGraph.LegendPos.TopCenter; * for( int i = 0; i < pane.CurveList.Count; ++i ) * { * pane.CurveList[i].Color = overlayColors[i]; * ( pane.CurveList[i] as ZedGraph.LineItem ).Line.Width = 2; * } * } else * { * pane.Legend.IsVisible = false; * currentGraphItem = chromatogram; * }*/ //msGraphControl.RestoreScale( pane ); //msGraphControl.ZoomOutAll( pane ); /*bool isScaleAuto = !pane.IsZoomed; * * if( isScaleAuto ) * pointList.SetScale( bins, pointList[0].X, pointList[pointList.Count - 1].X ); * else * pointList.SetScale( bins, pane.XAxis.Scale.Min, pane.XAxis.Scale.Max );*/ // String.Format( "{0} - {1}", currentDataSource.Name, chromatogram.Id ) if (mp.PaneList.Count > 0 && (focusedPane == null || !mp.PaneList.Contains(focusedPane))) { focusedPane = mp.PaneList[0] as MSGraphPane; } if (mp.PaneList.Count > 0 && mp.PaneList[0].CurveList.Count > 0 && (focusedItem == null || !focusedPane.CurveList.Contains(focusedItem))) { setFocusedItem(mp.PaneList[0].CurveList[0]); } msGraphControl.Refresh(); }
public override void Refresh() { MasterPane mp = msGraphControl.MasterPane; mp.Border.IsVisible = false; //pane.Chart.Border.IsVisible = false; if (mp.PaneList.Count != paneList.Count) { mp.PaneList.Clear(); foreach (Pane logicalPane in paneList) { MSGraphPane pane = new MSGraphPane(); pane.Border.IsVisible = false; pane.IsFontsScaled = false; pane.YAxis.ScaleFormatEvent += YAxis_ScaleFormatEvent; mp.Add(pane); } //mp.SetLayout( msGraphControl.CreateGraphics(), paneLayout ); } else { for (int i = 0; i < paneList.Count; ++i) { MSGraphPane pane = mp.PaneList[i] as MSGraphPane; pane.Border.IsVisible = false; pane.CurveList.Clear(); pane.GraphObjList.Clear(); } } for (int i = 0; i < paneList.Count; ++i) { Pane logicalPane = paneList[i]; MSGraphPane pane = mp.PaneList[i] as MSGraphPane; pane.IsFontsScaled = false; pane.Border.IsVisible = false; bool needSourceNamePrefix = logicalPane.Select(o => o.Source).Distinct().Count() > 1; int maxAutoLegendItems = needSourceNamePrefix ? 5 : 10; foreach (GraphItem item in logicalPane.Take(logicalPane.Count - 1)) { //item.AddSourceToId = needSourceNamePrefix; msGraphControl.AddGraphItem(pane, item, false); } //logicalPane.Last().AddSourceToId = needSourceNamePrefix; msGraphControl.AddGraphItem(pane, logicalPane.Last(), true); if (mp.PaneList.Count > 1) { if (msGraphControl.IsSynchronizeXAxes && i < paneList.Count - 1) { pane.XAxis.Title.IsVisible = false; pane.XAxis.Scale.IsVisible = false; pane.Margin.Bottom = 0; //pane.Margin.Top = 0; } else { //pane.Margin.Top = 0; pane.XAxis.Title.IsVisible = true; pane.XAxis.Scale.IsVisible = true; } pane.YAxis.Title.IsVisible = true; pane.YAxis.Scale.IsVisible = true; pane.YAxis.Title.Text = String.Join(", ", logicalPane.Select(o => o.Title)) + "\n" + pane.YAxis.Title.Text.Split('\n').Last(); pane.YAxis.Scale.SetupScaleData(pane, pane.YAxis); } else { pane.XAxis.IsVisible = true; pane.XAxis.Title.IsVisible = true; pane.XAxis.Scale.IsVisible = true; pane.YAxis.Title.IsVisible = true; pane.YAxis.Scale.IsVisible = true; } if (logicalPane.Count == 1) { pane.Legend.IsVisible = false; } else { pane.Legend.IsVisible = ShowPaneLegends ?? (logicalPane.Count < maxAutoLegendItems); pane.Legend.Position = ZedGraph.LegendPos.TopCenter; ZedGraph.ColorSymbolRotator rotator = new ColorSymbolRotator(); foreach (CurveItem item in pane.CurveList) { item.Color = rotator.NextColor; } } if (paneList.Count > 0 && paneList[0].Count > 0) { this.Text = paneList[0][0].Id; if (paneList[0][0].IsMassSpectrum) { this.TabText = (paneList[0][0] as MassSpectrum).AbbreviatedId; } else { this.TabText = this.Text; } } if (pane.XAxis.Scale.MaxAuto) { using (Graphics g = msGraphControl.CreateGraphics()) { if (msGraphControl.IsSynchronizeXAxes || msGraphControl.IsSynchronizeYAxes) { foreach (GraphPane p in msGraphControl.MasterPane.PaneList) { p.XAxis.ResetAutoScale(p, g); p.X2Axis.ResetAutoScale(p, g); foreach (YAxis axis in p.YAxisList) { axis.ResetAutoScale(p, g); } foreach (Y2Axis axis in p.Y2AxisList) { axis.ResetAutoScale(p, g); } } } else { pane.XAxis.ResetAutoScale(pane, g); pane.X2Axis.ResetAutoScale(pane, g); foreach (YAxis axis in pane.YAxisList) { axis.ResetAutoScale(pane, g); } foreach (Y2Axis axis in pane.Y2AxisList) { axis.ResetAutoScale(pane, g); } } } //msGraphControl.RestoreScale(pane); } else { pane.AxisChange(); } } mp.SetLayout(msGraphControl.CreateGraphics(), paneLayout); /*if( isOverlay ) * { * pane.Legend.IsVisible = true; * pane.Legend.Position = ZedGraph.LegendPos.TopCenter; * for( int i = 0; i < pane.CurveList.Count; ++i ) * { * pane.CurveList[i].Color = overlayColors[i]; * ( pane.CurveList[i] as ZedGraph.LineItem ).Line.Width = 2; * } * } else * { * pane.Legend.IsVisible = false; * currentGraphItem = chromatogram; * }*/ //msGraphControl.RestoreScale( pane ); //msGraphControl.ZoomOutAll( pane ); /*bool isScaleAuto = !pane.IsZoomed; * * if( isScaleAuto ) * pointList.SetScale( bins, pointList[0].X, pointList[pointList.Count - 1].X ); * else * pointList.SetScale( bins, pane.XAxis.Scale.Min, pane.XAxis.Scale.Max );*/ // String.Format( "{0} - {1}", currentDataSource.Name, chromatogram.Id ) if (mp.PaneList.Count > 0 && (focusedPane == null || !mp.PaneList.Contains(focusedPane))) { focusedPane = mp.PaneList[0] as MSGraphPane; } if (mp.PaneList.Count > 0 && mp.PaneList[0].CurveList.Count > 0 && (focusedItem == null || //!focusedPane.CurveList.Contains( focusedItem ) ) ) // somehow focusedItem.Tag can be the same as one of focusedPane.CurveList's Tags, but Contains returns false !focusedPane.CurveList.Any(o => o.Tag == focusedItem.Tag))) { setFocusedItem(mp.PaneList[0].CurveList[0]); } msGraphControl.Refresh(); }