Example #1
0
 private void SetDisplayState(DisplayState newDisplayState)
 {
     if (_zoomLocked && _displayState.GetType() == newDisplayState.GetType())
     {
         foreach (var pane in GraphControl.MasterPane.PaneList)
         {
             pane.CurveList.Clear();
             pane.GraphObjList.Clear();
         }
         _displayState.ZoomStateValid = true;
         return;
     }
     while (GraphControl.MasterPane.PaneList.Count > 1)
     {
         // Remove all but the first graph pane so that the zoom state stack is preserved.
         GraphControl.MasterPane.PaneList.RemoveRange(1, GraphControl.MasterPane.PaneList.Count - 1);
         using (var graphics = GraphControl.CreateGraphics())
         {
             GraphControl.MasterPane.SetLayout(graphics, PaneLayout.SingleColumn);
         }
     }
     GraphControl.GraphPane.CurveList.Clear();
     GraphControl.GraphPane.GraphObjList.Clear();
     newDisplayState.ZoomStateValid = newDisplayState.CanUseZoomStateFrom(_displayState);
     newDisplayState.ApplySettingsToGraphPane(GraphControl.GraphPane);
     _displayState = newDisplayState;
 }
Example #2
0
        public void FinishedAddingChromatograms(IEnumerable <RetentionTimeValues> bestPeaks, bool forceZoom)
        {
            var bestPeakList = bestPeaks.Where(peak => null != peak).ToList();

            if (!_zoomLocked)
            {
                if (forceZoom || !_displayState.ZoomStateValid)
                {
                    var chromDisplayState = _displayState as ChromDisplayState;
                    if (chromDisplayState != null)
                    {
                        AutoZoomChromatograms(bestPeakList);
                    }
                }
            }
            using (var graphics = GraphControl.CreateGraphics())
            {
                foreach (MSGraphPane graphPane in GraphControl.MasterPane.PaneList)
                {
                    // This sets the scale, but also gets point annotations.  So, it
                    // needs to be called every time, but only once for efficiency.
                    graphPane.SetScale(graphics);
                }
            }
            GraphControl.AxisChange();
            GraphControl.Invalidate();
        }
Example #3
0
 public void FinishedAddingChromatograms(double bestStartTime, double bestEndTime, bool forceZoom,
                                         double leftPeakWidth = 0, double rightPeakWidth = 0)
 {
     if (!_zoomLocked)
     {
         if (forceZoom || !_displayState.ZoomStateValid)
         {
             var chromDisplayState = _displayState as ChromDisplayState;
             if (chromDisplayState != null)
             {
                 AutoZoomChromatograms(bestStartTime, bestEndTime, leftPeakWidth, rightPeakWidth);
             }
         }
     }
     using (var graphics = GraphControl.CreateGraphics())
     {
         foreach (MSGraphPane graphPane in GraphControl.MasterPane.PaneList)
         {
             // This sets the scale, but also gets point annotations.  So, it
             // needs to be called every time, but only once for efficiency.
             graphPane.SetScale(graphics);
         }
     }
     GraphControl.AxisChange();
     GraphControl.Invalidate();
 }
Example #4
0
        private void graphPane_AxisChangeEvent(GraphPane target)  //控制两个坐标轴的显示比例,前提条件是zde控件的外形必修是正方形
        {
            GraphPane graphPane = GraphControl.GraphPane;

            // Correct the scale so that the two axes are 1:1 aspect ratio
            double scalex2 = (graphPane.XAxis.Scale.Max - graphPane.XAxis.Scale.Min) / graphPane.Rect.Width;
            double scaley2 = (graphPane.YAxis.Scale.Max - graphPane.YAxis.Scale.Min) / graphPane.Rect.Height;

            if (scalex2 > scaley2)
            {
                double diff     = graphPane.YAxis.Scale.Max - graphPane.YAxis.Scale.Min;
                double new_diff = graphPane.Rect.Height * scalex2;
                graphPane.YAxis.Scale.Min -= (new_diff - diff) / 2.0;
                graphPane.YAxis.Scale.Max += (new_diff - diff) / 2.0;
            }
            else if (scaley2 > scalex2)
            {
                double diff     = graphPane.XAxis.Scale.Max - graphPane.XAxis.Scale.Min;
                double new_diff = graphPane.Rect.Width * scaley2;
                graphPane.XAxis.Scale.Min -= (new_diff - diff) / 2.0;
                graphPane.XAxis.Scale.Max += (new_diff - diff) / 2.0;
            }

            // Recompute the grid lines
            float    scaleFactor = graphPane.CalcScaleFactor();
            Graphics g           = GraphControl.CreateGraphics();

            graphPane.XAxis.Scale.PickScale(graphPane, g, scaleFactor);
            graphPane.YAxis.Scale.PickScale(graphPane, g, scaleFactor);
        }