private int? GetDotProductsPointSize(Graphics g)
        {
            for (int pointSize = (int) Settings.Default.AreaFontSize; pointSize > 4; pointSize--)
            {
                var fontLabel = new FontSpec {Size = pointSize};
                var sizeLabel = fontLabel.MeasureString(g, DotpLabelText, CalcScaleFactor());

                float labelWidth = (float) XAxis.Scale.ReverseTransform((XAxis.Scale.Transform(0) + sizeLabel.Width));

                if (labelWidth < 1.2)
                    return pointSize;          
            }
            return null;
        }
Example #2
0
 private void font(ExecutionEnvironment env, FontSpec prevFont, Color defaultColor, Action <FontSpec> setFont)
 {
     using (var fontDlg = new FontDialog())
     {
         if (prevFont != null)
         {
             fontDlg.Font = prevFont.Font;
         }
         if (fontDlg.ShowDialog() == DialogResult.OK)
         {
             setFont(new FontSpec(fontDlg.Font, defaultColor));
             env.IfType((HexagonyEnv e) => { e.UpdateWatch(); });
         }
     }
 }
Example #3
0
        private void LegendRedraw(bool showLegend)
        {
            var myPane = GraphControl.GraphPane;

            foreach (var curve in myPane.CurveList)
            {
                if (curve.Label.FontSpec == null)
                {
                    FontSpec font = new FontSpec("Arial", GraphSettings.AxisFontSize, System.Drawing.Color.Black, false, false, false);
                    curve.Label.FontSpec = font;
                }
                else
                {
                    curve.Label.FontSpec.Angle = GraphSettings.AxisFontSize;
                }
                curve.Label.IsVisible = showLegend;
            }
            GraphControl.Invalidate();
        }
Example #4
0
        /// <summary>
        /// The Copy Constructor
        /// </summary>
        /// <param name="rhs">The XAxis object from which to copy</param>
        public Legend(Legend rhs)
        {
            _rect      = rhs.Rect;
            _position  = rhs.Position;
            _isHStack  = rhs.IsHStack;
            _isVisible = rhs.IsVisible;

            _location = rhs.Location;
            _border   = rhs.Border.Clone();
            _fill     = rhs.Fill.Clone();

            _fontSpec = rhs.FontSpec.Clone();

            _gap = rhs._gap;

            _isReverse = rhs._isReverse;

            _isShowLegendSymbols = rhs._isShowLegendSymbols;
        }
Example #5
0
        private void Init(string text)
        {
            if (text != null)
            {
                _text = text;
            }
            else
            {
                text = "Text";
            }

            _fontSpec = new FontSpec(
                Default.FontFamily, Default.FontSize,
                Default.FontColor, Default.FontBold,
                Default.FontItalic, Default.FontUnderline);

            //this.isWrapped = Default.IsWrapped ;
            _layoutArea = new SizeF(0, 0);
        }
Example #6
0
        /// <summary>
        /// Copy constructor
        /// </summary>
        /// <param name="rhs">the <see cref="Label" /> instance to be copied.</param>
        public Label(Label rhs)
        {
            if (rhs._text != null)
            {
                _text = (string)rhs._text.Clone();
            }
            else
            {
                _text = string.Empty;
            }

            _isVisible = rhs._isVisible;
            if (rhs._fontSpec != null)
            {
                _fontSpec = rhs._fontSpec.Clone();
            }
            else
            {
                _fontSpec = null;
            }
        }
        public ADCTimeDiagram(GlobalUnit unit)
        {
            this.unit = unit;

            InitializeComponent();

            cmbSignalType.DataSource    = Enum.GetNames(typeof(TypesOfSignalEnum));
            cmbSignalType.SelectedIndex = 0;

            cmdMethodOfCalibration.DataSource    = Enum.GetNames(typeof(CalibrationType));
            cmdMethodOfCalibration.SelectedIndex = 0;

            paneCode = zedGraphControl1.GraphPane;

            FontSpec fnt9 = new FontSpec("arial", 9, Color.Black, false, false, false);
            Border   bdr  = new Border(false, Color.Black, 1);

            fnt9.Border = bdr;

            FontSpec fnt12 = new FontSpec("arial", 8, Color.Black, false, false, false);

            fnt12.Border = bdr;

            zedGraphControl1.AutoScaleMode = AutoScaleMode;

            paneCode.Title.FontSpec       = fnt12;
            paneCode.Title.Text           = "Діаграма врівноваження АЦП";
            paneCode.XAxis.Title.FontSpec = fnt9;
            paneCode.XAxis.Title.Text     = "Номер такту";
            paneCode.XAxis.Scale.FontSpec = fnt9;
            FontSpec fnt9Ver = new FontSpec(fnt9);

            fnt9Ver.Angle = 180;
            paneCode.YAxis.Title.FontSpec = fnt9Ver;
            paneCode.YAxis.Title.Text     = "Аналоговий сигнал";
            paneCode.YAxis.Scale.FontSpec = fnt9Ver;

            paneCode.CurveList.Clear();
        }
Example #8
0
        private void AddRetentionTimeAnnotation(MSGraphPane graphPane, Graphics g, GraphObjList annotations,
                                                PointF ptTop, string title, GraphObjType graphObjType, Color color, ScaledRetentionTime retentionTime)
        {
            // ReSharper disable LocalizableElement
            string label = string.Format("{0}\n{1:F01}", title, retentionTime.DisplayTime);
            // ReSharper restore LocalizableElement
            FontSpec fontLabel    = CreateFontSpec(color, _fontSpec.Size);
            SizeF    sizeLabel    = fontLabel.MeasureString(g, label, graphPane.CalcScaleFactor());
            PointF   realTopPoint = ptTop;

            ptTop = new PointF(0, ptTop.Y + sizeLabel.Height + 15);
            float  chartHeightWithLabel   = graphPane.Chart.Rect.Height + sizeLabel.Height + 15;
            double intensityChartFraction = (ptTop.Y - realTopPoint.Y) / chartHeightWithLabel;

            LineObj stick = new LineObj(color, retentionTime.DisplayTime, intensityChartFraction, retentionTime.DisplayTime, 1)
            {
                IsClippedToChartRect = true,
                Location             = { CoordinateFrame = CoordType.XScaleYChartFraction },
                ZOrder = ZOrder.E_BehindCurves,
                Line   = { Width = 1 },
                Tag    = new GraphObjTag(this, graphObjType, retentionTime),
            };

            annotations.Add(stick);

            ptTop = new PointF(0, ptTop.Y - 5);
            intensityChartFraction = (ptTop.Y - realTopPoint.Y) / chartHeightWithLabel;
            TextObj text = new TextObj(label, retentionTime.DisplayTime, intensityChartFraction,
                                       CoordType.XScaleYChartFraction, AlignH.Center, AlignV.Bottom)
            {
                IsClippedToChartRect = true,
                ZOrder   = ZOrder.E_BehindCurves,
                FontSpec = CreateFontSpec(color, _fontSpec.Size),
                Tag      = new GraphObjTag(this, graphObjType, retentionTime),
            };

            annotations.Add(text);
        }
Example #9
0
        /// <summary>
        /// Default constructor that sets all <see c_ref="Legend"/> properties to default
        /// values as defined in the <see c_ref="Default"/> class.
        /// </summary>
        public Legend()
        {
            _position  = Default.Position;
            _isHStack  = Default.IsHStack;
            _isVisible = Default.IsVisible;
            Location   = new Location(0, 0, CoordType.PaneFraction);

            _fontSpec = new FontSpec(Default.FontFamily, Default.FontSize,
                                     Default.FontColor, Default.FontBold,
                                     Default.FontItalic, Default.FontUnderline,
                                     Default.FontFillColor, Default.FontFillBrush,
                                     Default.FontFillType);
            _fontSpec.Border.IsVisible = false;

            _border = new Border(Default.IsBorderVisible, Default.BorderColor, Default.BorderWidth);
            _fill   = new Fill(Default.FillColor, Default.FillBrush, Default.FillType);

            _gap = Default.Gap;

            _isReverse = Default.IsReverse;

            _isShowLegendSymbols = Default.IsShowLegendSymbols;
        }
Example #10
0
        public void createPane2(ZedGraphControl zgc)
        {
            GraphPane myPane = zgc.GraphPane;

            //设置图标标题和x、y轴标题
            myPane.Title.Text       = "实时震动曲线";
            myPane.XAxis.Title.Text = "监测位置:0m处\r\n时间单位:ms";
            myPane.YAxis.Title.Text = "振动幅度";

            //更改标题的字体
            FontSpec myFont = new FontSpec("Arial", 20, Color.Red, false, false, false);

            myPane.Title.FontSpec       = myFont;
            myPane.XAxis.Title.FontSpec = myFont;
            myPane.YAxis.Title.FontSpec = myFont;

            //myPane.XAxis.Scale.Min = 0; //X轴最小值0
            myPane.XAxis.Scale.Max       = uipointnum; //X轴最大2000
            myPane.XAxis.Scale.MinorStep = 1;          //X轴小步长1,也就是小间隔
            myPane.XAxis.Scale.MajorStep = 100;        //X轴大步长为5,也就是显示文字的大间隔

            //改变轴的刻度
            zedGraphControl1.AxisChange();

            // 用list2生产一条曲线,标注是“实时震动曲线”
            LineItem myCurve = myPane.AddCurve("实时震动曲线", list2, Color.Red, SymbolType.None);

            //填充图表颜色
            myPane.Fill = new Fill(Color.White, Color.FromArgb(200, 200, 255), 45.0f);

            myPane.XAxis.Type = AxisType.Text;   //X轴类型
            //画到zedGraphControl1控件中,此句必加
            zgc.AxisChange();

            //重绘控件
            Refresh();
        }
        public GKSharacteristicOfTransformationStraightComb(GlobalUnit unit)
        {
            InitializeComponent();

            cmbxStrategyType.DataSource    = Enum.GetNames(typeof(CalibrationType));
            cmbxStrategyType.SelectedIndex = 0;

            this.unit   = unit;
            graphArrays = new PointPairList[2];

            paneCode = zedGraphControl3.GraphPane;

            FontSpec fnt9 = new FontSpec("arial", 12, Color.Black, false, false, false);
            Border   bdr  = new Border(false, Color.Black, 1);

            fnt9.Border = bdr;

            FontSpec fnt12 = new FontSpec("arial", 11, Color.Black, false, false, false);

            fnt12.Border = bdr;

            zedGraphControl3.AutoScaleMode = AutoScaleMode;

            paneCode.Title.FontSpec       = fnt12;
            paneCode.Title.Text           = "Характеристика перетворення ЦАП";
            paneCode.XAxis.Title.FontSpec = fnt9;
            paneCode.XAxis.Title.Text     = "Цифровий еквівалент";
            paneCode.XAxis.Scale.FontSpec = fnt9;
            FontSpec fnt9Ver = new FontSpec(fnt9);

            fnt9Ver.Angle = 180;
            paneCode.YAxis.Title.FontSpec = fnt9Ver;
            paneCode.YAxis.Title.Text     = "Аналоговий сигнал";
            paneCode.YAxis.Scale.FontSpec = fnt9Ver;

            paneCode.CurveList.Clear();
        }
Example #12
0
        public DistributionOfMistakes(List <KeyValuePair <double, double> > listOfDatas)
        {
            InitializeComponent();

            this.listOfDatas = listOfDatas;

            zedGraphControl1.AutoScaleMode = AutoScaleMode;
            pane = zedGraphControl1.GraphPane;

            pane.XAxis.Cross = 0;
            pane.YAxis.Cross = 0;

            pane.CurveList.Clear();

            pane.Title.Text       = "Розподіл похибок";
            pane.XAxis.Title.Text = "Абсолютне значення похибки";
            pane.YAxis.Title.Text = "Кількість значень";

            FontSpec fnt9 = new FontSpec("arial", 9, Color.Black, false, false, false);
            Border   bdr  = new Border(false, Color.Black, 1);

            fnt9.Border = bdr;
            FontSpec fnt12 = new FontSpec("arial", 8, Color.Black, false, false, false);

            fnt12.Border = bdr;

            pane.Title.FontSpec       = fnt12;
            pane.XAxis.Title.FontSpec = fnt9;
            pane.XAxis.Scale.FontSpec = fnt9;
            FontSpec fnt9Ver = new FontSpec(fnt9);

            fnt9Ver.Angle             = 180;
            pane.YAxis.Title.FontSpec = fnt9Ver;
            pane.YAxis.Scale.FontSpec = fnt9Ver;
            pane.Legend.FontSpec      = fnt9;
        }
Example #13
0
        /// <summary>
        /// Calculate the <see c_ref="Legend"/> rectangle (<see c_ref="Rect"/>),
        /// taking into account the number of required legend
        /// entries, and the legend drawing preferences.
        /// </summary>
        /// <remarks>Adjust the size of the
        /// <see c_ref="Chart.Rect"/> for the parent <see c_ref="GraphPane"/> to accomodate the
        /// space required by the legend.
        /// </remarks>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see c_ref="PaneBase"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see c_ref="GraphPane"/> object using the
        /// <see c_ref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        /// <param name="tChartRect">
        /// The rectangle that contains the area bounded by the axes, in pixel units.
        /// <seealso c_ref="Chart.Rect" />
        /// </param>
        public void CalcRect(Graphics g, PaneBase pane, float scaleFactor,
                             ref RectangleF tChartRect)
        {
            // Start with an empty rectangle
            _rect             = Rectangle.Empty;
            _hStack           = 1;
            _legendItemWidth  = 1;
            _legendItemHeight = 0;

            RectangleF clientRect = pane.CalcClientRect(g, scaleFactor);

            // If the legend is invisible, don't do anything
            if (!_isVisible)
            {
                return;
            }

            int nCurve = 0;

            PaneList paneList = GetPaneList(pane);

            _tmpSize = GetMaxHeight(paneList, g, scaleFactor);

            float halfGap  = _tmpSize / 2.0F,
                  maxWidth = 0,
                  tmpWidth,
                  gapPix = _gap * _tmpSize;

            foreach (GraphPane tmpPane in paneList)
            {
                // Loop through each curve in the curve list
                // Find the maximum width of the legend labels
                //foreach ( CurveItem curve in tmpPane.CurveList )
                //foreach ( CurveItem curve in GetIterator( tmpPane.CurveList, _isReverse ) )
                int count = tmpPane.CurveList.Count;
                for (int i = 0; i < count; i++)
                {
                    CurveItem curve = tmpPane.CurveList[_isReverse ? count - i - 1 : i];
                    if (curve._label._text != string.Empty && curve._label._isVisible)
                    {
                        // Calculate the width of the label save the max width
                        FontSpec tmpFont = (curve._label._fontSpec != null) ?
                                           curve._label._fontSpec : FontSpec;

                        tmpWidth = tmpFont.GetWidth(g, curve._label._text, scaleFactor);

                        if (tmpWidth > maxWidth)
                        {
                            maxWidth = tmpWidth;
                        }

                        // Save the maximum symbol height for line-type curves
                        if (curve is LineItem && ((LineItem)curve).Symbol.Size > _legendItemHeight)
                        {
                            _legendItemHeight = ((LineItem)curve).Symbol.Size;
                        }

                        nCurve++;
                    }
                }

                if (pane is MasterPane && ((MasterPane)pane).IsUniformLegendEntries)
                {
                    break;
                }
            }

            float widthAvail;

            // Is this legend horizontally stacked?

            if (_isHStack)
            {
                // Determine the available space for horizontal stacking
                switch (_position)
                {
                // Never stack if the legend is to the right or left
                case LegendPos.Right:
                case LegendPos.Left:
                    widthAvail = 0;
                    break;

                // for the top & bottom, the axis border width is available
                case LegendPos.Top:
                case LegendPos.TopCenter:
                case LegendPos.Bottom:
                case LegendPos.BottomCenter:
                    widthAvail = tChartRect.Width;
                    break;

                // for the top & bottom flush left, the panerect less margins is available
                case LegendPos.TopFlushLeft:
                case LegendPos.BottomFlushLeft:
                    widthAvail = clientRect.Width;
                    break;

                // for inside the axis area or Float, use 1/2 of the axis border width
                case LegendPos.InsideTopRight:
                case LegendPos.InsideTopLeft:
                case LegendPos.InsideBotRight:
                case LegendPos.InsideBotLeft:
                case LegendPos.Float:
                    widthAvail = tChartRect.Width / 2;
                    break;

                // shouldn't ever happen
                default:
                    widthAvail = 0;
                    break;
                }

                // width of one legend entry
                if (_isShowLegendSymbols)
                {
                    _legendItemWidth = 3.0f * _tmpSize + maxWidth;
                }
                else
                {
                    _legendItemWidth = 0.5f * _tmpSize + maxWidth;
                }

                // Calculate the number of columns in the legend
                // Normally, the legend is:
                //     available width / ( max width of any entry + space for line&symbol )
                if (maxWidth > 0)
                {
                    _hStack = (int)((widthAvail - halfGap) / _legendItemWidth);
                }

                // You can never have more columns than legend entries
                if (_hStack > nCurve)
                {
                    _hStack = nCurve;
                }

                // a saftey check
                if (_hStack == 0)
                {
                    _hStack = 1;
                }
            }
            else
            {
                if (_isShowLegendSymbols)
                {
                    _legendItemWidth = 3.0F * _tmpSize + maxWidth;
                }
                else
                {
                    _legendItemWidth = 0.5F * _tmpSize + maxWidth;
                }
            }

            // legend is:
            //   item:     space  line  space  text   space
            //   width:     wid  4*wid   wid  maxWid   wid
            // The symbol is centered on the line
            //
            // legend begins 3 * wid to the right of the plot rect
            //
            // The height of the legend is the actual height of the lines of text
            //   (nCurve * hite) plus wid on top and wid on the bottom

            // total legend width
            float totLegWidth = _hStack * _legendItemWidth;

            // The total legend height
            _legendItemHeight = _legendItemHeight * scaleFactor + halfGap;
            if (_tmpSize > _legendItemHeight)
            {
                _legendItemHeight = _tmpSize;
            }
            float totLegHeight = (float)Math.Ceiling(nCurve / (double)_hStack)
                                 * _legendItemHeight;

            RectangleF newRect = new RectangleF();

            // Now calculate the legend rect based on the above determined parameters
            // Also, adjust the ChartRect to reflect the space for the legend
            if (nCurve > 0)
            {
                newRect = new RectangleF(0, 0, totLegWidth, totLegHeight);

                // The switch statement assigns the left and top edges, and adjusts the ChartRect
                // as required.  The right and bottom edges are calculated at the bottom of the switch.
                switch (_position)
                {
                case LegendPos.Right:
                    newRect.X = clientRect.Right - totLegWidth;
                    newRect.Y = tChartRect.Top;

                    tChartRect.Width -= totLegWidth + gapPix;
                    break;

                case LegendPos.Top:
                    newRect.X = tChartRect.Left;
                    newRect.Y = clientRect.Top;

                    tChartRect.Y      += totLegHeight + gapPix;
                    tChartRect.Height -= totLegHeight + gapPix;
                    break;

                case LegendPos.TopFlushLeft:
                    newRect.X = clientRect.Left;
                    newRect.Y = clientRect.Top;

                    tChartRect.Y      += totLegHeight + gapPix * 1.5f;
                    tChartRect.Height -= totLegHeight + gapPix * 1.5f;
                    break;

                case LegendPos.TopCenter:
                    newRect.X = tChartRect.Left + (tChartRect.Width - totLegWidth) / 2;
                    newRect.Y = tChartRect.Top;

                    tChartRect.Y      += totLegHeight + gapPix;
                    tChartRect.Height -= totLegHeight + gapPix;
                    break;

                case LegendPos.Bottom:
                    newRect.X = tChartRect.Left;
                    newRect.Y = clientRect.Bottom - totLegHeight;

                    tChartRect.Height -= totLegHeight + gapPix;
                    break;

                case LegendPos.BottomFlushLeft:
                    newRect.X = clientRect.Left;
                    newRect.Y = clientRect.Bottom - totLegHeight;

                    tChartRect.Height -= totLegHeight + gapPix;
                    break;

                case LegendPos.BottomCenter:
                    newRect.X = tChartRect.Left + (tChartRect.Width - totLegWidth) / 2;
                    newRect.Y = clientRect.Bottom - totLegHeight;

                    tChartRect.Height -= totLegHeight + gapPix;
                    break;

                case LegendPos.Left:
                    newRect.X = clientRect.Left;
                    newRect.Y = tChartRect.Top;

                    tChartRect.X     += totLegWidth + halfGap;
                    tChartRect.Width -= totLegWidth + gapPix;
                    break;

                case LegendPos.InsideTopRight:
                    newRect.X = tChartRect.Right - totLegWidth;
                    newRect.Y = tChartRect.Top;
                    break;

                case LegendPos.InsideTopLeft:
                    newRect.X = tChartRect.Left;
                    newRect.Y = tChartRect.Top;
                    break;

                case LegendPos.InsideBotRight:
                    newRect.X = tChartRect.Right - totLegWidth;
                    newRect.Y = tChartRect.Bottom - totLegHeight;
                    break;

                case LegendPos.InsideBotLeft:
                    newRect.X = tChartRect.Left;
                    newRect.Y = tChartRect.Bottom - totLegHeight;
                    break;

                case LegendPos.Float:
                    newRect.Location = Location.TransformTopLeft(pane, totLegWidth, totLegHeight);
                    break;
                }
            }

            _rect = newRect;
        }
Example #14
0
        public ChromGraphItem(TransitionGroupDocNode transitionGroupNode,
                              TransitionDocNode transition,
                              ChromatogramInfo chromatogram,
                              TransitionChromInfo tranPeakInfo,
                              IRegressionFunction timeRegressionFunction,
                              bool[] annotatePeaks,
                              double[] dotProducts,
                              double bestProduct,
                              bool isFullScanMs,
                              bool isSummary,
                              RawTimesInfoItem?displayRawTimes,
                              int step,
                              Color color,
                              float fontSize,
                              int width,
                              FullScanInfo fullScanInfo = null)
        {
            TransitionGroupNode    = transitionGroupNode;
            TransitionNode         = transition;
            Chromatogram           = chromatogram;
            TransitionChromInfo    = tranPeakInfo;
            TimeRegressionFunction = timeRegressionFunction;
            Color        = color;
            FullScanInfo = fullScanInfo;

            _step     = step;
            _fontSpec = CreateFontSpec(color, fontSize);
            _width    = width;

            _dotProducts     = dotProducts;
            _bestProduct     = bestProduct;
            _isFullScanMs    = isFullScanMs;
            _isSummary       = isSummary;
            _displayRawTimes = displayRawTimes;

            _arrayLabelIndexes = new int[annotatePeaks.Length];

            if (chromatogram == null)
            {
                _measuredTimes = new double[0];
                _displayTimes  = _measuredTimes;
                _intensities   = new double[0];
            }
            else
            {
                // Cache values early to avoid accessing slow enumerators
                // which show up under profiling.
                Chromatogram.AsArrays(out _measuredTimes, out _intensities);
                if (TimeRegressionFunction == null)
                {
                    _displayTimes = _measuredTimes;
                }
                else
                {
                    _displayTimes = _measuredTimes.Select(TimeRegressionFunction.GetY).ToArray();
                }
                // Add peak times to hash set for labeling
                int iLastStart = 0;
                for (int i = 0; i < chromatogram.NumPeaks; i++)
                {
                    int maxIndex = -1;
                    if (annotatePeaks[i])
                    {
                        ChromPeak peak = chromatogram.GetPeak(i);
                        maxIndex = GetMaxIndex(peak.StartTime, peak.EndTime, ref iLastStart);
                    }
                    _arrayLabelIndexes[i] = maxIndex;
                    if (maxIndex != -1 && !_annotatedTimes.ContainsKey(maxIndex))
                    {
                        _annotatedTimes.Add(maxIndex, i);
                    }
                }

                // Calculate best peak index
                if (tranPeakInfo != null)
                {
                    iLastStart         = 0;
                    _bestPeakTimeIndex = GetMaxIndex(tranPeakInfo.StartRetentionTime, tranPeakInfo.EndRetentionTime, ref iLastStart);
                }
            }
        }
Example #15
0
 public PointAnnotation(string label, FontSpec fontSpec)
 {
     Label           = label;
     ExtraAnnotation = null;
     FontSpec        = fontSpec;
 }
Example #16
0
 public override void SetWatchWindowFont(FontSpec font)
 {
     _watchFont = font;
     UpdateWatch();
 }
Example #17
0
        public void CreateChart(ZedGraphControl zgc, List <OverViewDataDto> list)
        {
            zgc.GraphPane.CurveList.Clear();
            zgc.GraphPane.GraphObjList.Clear();

            GraphPane myPane = zgc.GraphPane;

            // Set the titles and axis labels
            myPane.Title.Text            = "掘金难度";
            myPane.XAxis.Title.IsVisible = false;
            myPane.YAxis.Title.IsVisible = false;

            FontSpec myFont = new FontSpec("宋体", 20, Color.Gray, false, false, false);

            myPane.Title.FontSpec       = myFont;
            myPane.XAxis.Title.FontSpec = myFont;
            myPane.YAxis.Title.FontSpec = myFont;
            myPane.Legend.FontSpec      = myFont;

            list = list.OrderBy(o => o.Date).ToList();

            string[] labels = new string[list.Count];

            PointPairList list1 = new PointPairList();

            for (int i = 0; i < list.Count; i++)
            {
                var dto = list[i];

                try
                {
                    var showx = dto.Date.Substring(0, 4) + "-" + dto.Date.Substring(4, 2) + "-" + dto.Date.Substring(6, 2);
                    labels[i] = showx;
                }
                catch
                {
                    labels[i] = dto.Date;
                }
                double x  = i;
                double y1 = dto.AllMakeMoneyScore / dto.AllMakeMoney;
                list1.Add(x, y1);
            }

            // Generate a red curve with diamond symbols, and "Velocity" in the legend
            LineItem myCurve = myPane.AddCurve("难度",
                                               list1, Color.Red, SymbolType.Diamond);

            // Fill the symbols with white
            myCurve.Symbol.Fill = new Fill(Color.White);

            // Show the x axis grid
            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.XAxis.Scale.TextLabels    = labels; //X轴文本取值
            myPane.XAxis.Type = AxisType.Text;         //X轴类型

            // Make the Y axis scale red
            myPane.YAxis.Scale.FontSpec.FontColor = Color.Red;
            myPane.YAxis.Title.FontSpec.FontColor = Color.Red;
            // turn off the opposite tics so the Y tics don't show up on the Y2 axis

            // Align the Y axis labels so they are flush to the axis
            myPane.YAxis.Scale.Align = AlignP.Inside;


            // Fill the axis background with a gradient
            myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45.0f);

            zgc.AxisChange();
        }
Example #18
0
 public PointAnnotation()
 {
     Label           = string.Empty;
     ExtraAnnotation = null;
     FontSpec        = new FontSpec();
 }
Example #19
0
 public override void SetWatchWindowFont(FontSpec font)
 {
     if (_txtIpInfo != null)
     {
         _txtIpInfo.Font = font.Font;
         _txtIpInfo.ForeColor = font.Color;
     }
 }
Example #20
0
 private FontSpec GetFontSpec(Color color, ref FontSpec fontSpec)
 {
     return(fontSpec ?? (fontSpec = CreateFontSpec(color, FontSize)));
 }
Example #21
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="TextObj"/> object from which to copy</param>
 public TextObj(TextObj rhs) : base(rhs)
 {
     _text     = rhs.Text;
     _fontSpec = new FontSpec(rhs.FontSpec);
 }
Example #22
0
        /// <summary>
        /// Constructor for deserializing objects
        /// </summary>
        /// <param name="info">A <see cref="SerializationInfo"/> instance that defines the serialized data
        /// </param>
        /// <param name="context">A <see cref="StreamingContext"/> instance that contains the serialized data
        /// </param>
        protected Label( SerializationInfo info, StreamingContext context )
        {
            // The schema value is just a file version parameter.  You can use it to make future versions
            // backwards compatible as new member variables are added to classes
            int sch = info.GetInt32( "schema" );

            _text = info.GetString( "text" );
            _isVisible = info.GetBoolean( "isVisible" );
            _fontSpec = (FontSpec) info.GetValue( "fontSpec", typeof( FontSpec ) );
        }
Example #23
0
        /// <summary>
        /// Copy Constructor.  Create a new <see cref="Scale" /> object based on the specified
        /// existing one.
        /// </summary>
        /// <param name="rhs">The <see cref="Scale" /> object to be copied.</param>
        /// <param name="owner">The <see cref="Axis" /> object that will own the
        /// new instance of <see cref="Scale" /></param>
        public Scale( Scale rhs, Axis owner )
        {
            _ownerAxis = owner;

            _min = rhs._min;
            _max = rhs._max;
            _majorStep = rhs._majorStep;
            _minorStep = rhs._minorStep;
            _exponent = rhs._exponent;
            _baseTic = rhs._baseTic;

            _minAuto = rhs._minAuto;
            _maxAuto = rhs._maxAuto;
            _majorStepAuto = rhs._majorStepAuto;
            _minorStepAuto = rhs._minorStepAuto;
            _magAuto = rhs._magAuto;
            _formatAuto = rhs._formatAuto;

            _minGrace = rhs._minGrace;
            _maxGrace = rhs._maxGrace;

            _mag = rhs._mag;

            _isUseTenPower = rhs._isUseTenPower;
            _isReverse = rhs._isReverse;
            _isPreventLabelOverlap = rhs._isPreventLabelOverlap;
            _isVisible = rhs._isVisible;
            _isSkipFirstLabel = rhs._isSkipFirstLabel;
            _isSkipLastLabel = rhs._isSkipLastLabel;
            _isSkipCrossLabel = rhs._isSkipCrossLabel;

            _majorUnit = rhs._majorUnit;
            _minorUnit = rhs._minorUnit;

            _format = rhs._format;

            _isLabelsInside = rhs._isLabelsInside;
            _align = rhs._align;
            _alignH = rhs._alignH;

            _fontSpec = (FontSpec) rhs._fontSpec.Clone();

            _labelGap = rhs._labelGap;

            if ( rhs._textLabels != null )
                _textLabels = (string[])rhs._textLabels.Clone();
            else
                _textLabels = null;
        }
Example #24
0
 public override void SetWatchWindowFont(FontSpec font)
 {
     _watchFont = font;
     UpdateWatch();
 }
Example #25
0
        /// <summary>
        /// Constructor for deserializing objects
        /// </summary>
        /// <param name="info">A <see cref="SerializationInfo"/> instance that defines the serialized data
        /// </param>
        /// <param name="context">A <see cref="StreamingContext"/> instance that contains the serialized data
        /// </param>
        protected Legend( SerializationInfo info, StreamingContext context )
        {
            // The schema value is just a file version parameter.  You can use it to make future versions
            // backwards compatible as new member variables are added to classes
            int sch = info.GetInt32( "schema" );

            _position = (LegendPos)info.GetValue( "position", typeof( LegendPos ) );
            _isHStack = info.GetBoolean( "isHStack" );
            _isVisible = info.GetBoolean( "isVisible" );
            _fill = (Fill)info.GetValue( "fill", typeof( Fill ) );
            _border = (Border)info.GetValue( "border", typeof( Border ) );
            _fontSpec = (FontSpec)info.GetValue( "fontSpec", typeof( FontSpec ) );
            _location = (Location)info.GetValue( "location", typeof( Location ) );

            _gap = info.GetSingle( "gap" );

            if ( schema >= 11 )
                _isReverse = info.GetBoolean( "isReverse" );

            if ( schema >= 12 )
                _isShowLegendSymbols = info.GetBoolean( "isShowLegendSymbols" );
        }
Example #26
0
        /// <summary>
        /// The Copy Constructor
        /// </summary>
        /// <param name="rhs">The XAxis object from which to copy</param>
        public Legend( Legend rhs )
        {
            _rect = rhs.Rect;
            _position = rhs.Position;
            _isHStack = rhs.IsHStack;
            _isVisible = rhs.IsVisible;

            _location = rhs.Location;
            _border = rhs.Border.Clone();
            _fill = rhs.Fill.Clone();

            _fontSpec = rhs.FontSpec.Clone();

            _gap = rhs._gap;

            _isReverse = rhs._isReverse;

            _isShowLegendSymbols = rhs._isShowLegendSymbols;
        }
Example #27
0
        /// <summary>
        /// Default constructor that sets all <see cref="Legend"/> properties to default
        /// values as defined in the <see cref="Default"/> class.
        /// </summary>
        public Legend()
        {
            _position = Default.Position;
            _isHStack = Default.IsHStack;
            _isVisible = Default.IsVisible;
            this.Location = new Location( 0, 0, CoordType.PaneFraction );

            _fontSpec = new FontSpec( Default.FontFamily, Default.FontSize,
                Default.FontColor, Default.FontBold,
                Default.FontItalic, Default.FontUnderline,
                Default.FontFillColor, Default.FontFillBrush,
                Default.FontFillType );
            _fontSpec.Border.IsVisible = false;

            _border = new Border( Default.IsBorderVisible, Default.BorderColor, Default.BorderWidth );
            _fill = new Fill( Default.FillColor, Default.FillBrush, Default.FillType );

            _gap = Default.Gap;

            _isReverse = Default.IsReverse;

            _isShowLegendSymbols = Default.IsShowLegendSymbols;
        }
Example #28
0
        private void DrawLineJueJin(List <OverViewDataDto> data, ZedGraphControl zgc, DataType type)
        {
            zgc.GraphPane.CurveList.Clear();
            zgc.GraphPane.GraphObjList.Clear();

            GraphPane myPane = zgc.GraphPane;

            switch (type)
            {
            case DataType.AllMoney:
                myPane.Title.Text = "掘金池走势";
                break;

            case DataType.AllScore:
                myPane.Title.Text = "掘金分数走势";
                break;

            case DataType.Bear:
                myPane.Title.Text = "生育金额走势";
                break;

            case DataType.Feed:
                myPane.Title.Text = "投食金额走势";
                break;

            case DataType.Trade:
                myPane.Title.Text = "交易金额走势";
                break;
            }

            myPane.XAxis.Title.IsVisible = false;
            myPane.YAxis.Title.IsVisible = false;

            //更改标题的字体
            FontSpec myFont = new FontSpec("宋体", 20, Color.Gray, false, false, false);

            myPane.Title.FontSpec       = myFont;
            myPane.XAxis.Title.FontSpec = myFont;
            myPane.YAxis.Title.FontSpec = myFont;
            myPane.Legend.FontSpec      = myFont;

            data = data.OrderBy(o => o.Date).ToList();
            var count = data.Count;

            string[] labels = new string[count];

            PointPairList list1 = new PointPairList();

            for (int i = 0; i < count; i++)
            {
                var dto = data[i];
                try
                {
                    var showx = dto.Date.Substring(0, 4) + "-" + dto.Date.Substring(4, 2) + "-" + dto.Date.Substring(6, 2);
                    labels[i] = showx;
                }
                catch
                {
                    labels[i] = dto.Date;
                }

                double x  = i;
                double y1 = 0;

                switch (type)
                {
                case DataType.AllMoney:
                    y1 = dto.AllMakeMoney;
                    break;

                case DataType.AllScore:
                    y1 = dto.AllMakeMoneyScore;
                    break;

                case DataType.Bear:
                    y1 = dto.Bear;
                    break;

                case DataType.Feed:
                    y1 = dto.Feed;
                    break;

                case DataType.Trade:
                    y1 = dto.Trade;
                    break;
                }
                list1.Add(x, y1);
            }

            // 用list1生产一条曲线
            LineItem myCurve = myPane.AddCurve("走势", list1, Color.Red, SymbolType.Circle);

            //填充图表颜色
            myPane.Fill = new Fill(Color.White, Color.FromArgb(200, 200, 255), 45.0f);

            myPane.XAxis.Scale.TextLabels = labels;        //X轴文本取值
            myPane.XAxis.Type             = AxisType.Text; //X轴类型

            //画到zedGraphControl1控件中,此句必加
            zgc.AxisChange();
            //重绘控件
            Refresh();
        }
Example #29
0
        private void DrawLineJueJin(RequestMonkeyWithUserDetailDto monkey, ZedGraphControl zgc, DrawType type)
        {
            zgc.GraphPane.CurveList.Clear();
            zgc.GraphPane.GraphObjList.Clear();

            GraphPane myPane = zgc.GraphPane;

            //设置图标标题和x、y轴标题
            if (type == DrawType.JueJin)
            {
                myPane.Title.Text = "每日掘金分数走势";
            }
            else
            {
                myPane.Title.Text = "每日掘金收益走势";
            }
            myPane.XAxis.Title.IsVisible = false;
            myPane.YAxis.Title.IsVisible = false;

            //更改标题的字体
            FontSpec myFont = new FontSpec("宋体", 20, Color.Gray, false, false, false);

            myPane.Title.FontSpec       = myFont;
            myPane.XAxis.Title.FontSpec = myFont;
            myPane.YAxis.Title.FontSpec = myFont;
            myPane.Legend.FontSpec      = myFont;

            var list = monkey.makeMoneyPage.records;

            list = list.OrderBy(o => o.day).ToList();
            var count = list.Count;

            string[] labels = new string[count];

            PointPairList list1 = new PointPairList();

            for (int i = 0; i < count; i++)
            {
                var dto = list[i];
                try
                {
                    var showx = dto.day.Substring(0, 4) + "-" + dto.day.Substring(4, 2) + "-" + dto.day.Substring(6, 2);
                    labels[i] = showx;
                }
                catch
                {
                    labels[i] = dto.day;
                }

                double x  = i;
                double y1 = dto.makeMoneyScore;
                if (type == DrawType.Coin)
                {
                    y1 = dto.coin;
                }
                list1.Add(x, y1);
            }

            // 用list1生产一条曲线
            LineItem myCurve = myPane.AddCurve(type == DrawType.JueJin?"掘金分数":"掘金收益", list1, Color.Red, SymbolType.Circle);

            //填充图表颜色
            myPane.Fill = new Fill(Color.White, Color.FromArgb(200, 200, 255), 45.0f);

            myPane.XAxis.Scale.TextLabels = labels;        //X轴文本取值
            myPane.XAxis.Type             = AxisType.Text; //X轴类型

            //画到zedGraphControl1控件中,此句必加
            zgc.AxisChange();
            //重绘控件
            Refresh();
        }
Example #30
0
 private void SetFontSpec(FontSpec fontSpec, string familyName, float emSize, bool isBold)
 {
     fontSpec.Family = familyName;
     fontSpec.Size   = emSize;
     fontSpec.IsBold = isBold;
 }
Example #31
0
        /// <summary>
        /// Basic constructor -- requires that the <see cref="Scale" /> object be intialized with
        /// a pre-existing owner <see cref="Axis" />.
        /// </summary>
        /// <param name="ownerAxis">The <see cref="Axis" /> object that is the owner of this
        /// <see cref="Scale" /> instance.</param>
        public Scale( Axis ownerAxis )
        {
            _ownerAxis = ownerAxis;

            _min = 0.0;
            _max = 1.0;
            _majorStep = 0.1;
            _minorStep = 0.1;
            _exponent = 1.0;
            _mag = 0;
            _baseTic = PointPair.Missing;

            _minGrace = Default.MinGrace;
            _maxGrace = Default.MaxGrace;

            _minAuto = true;
            _maxAuto = true;
            _majorStepAuto = true;
            _minorStepAuto = true;
            _magAuto = true;
            _formatAuto = true;

            _isReverse = Default.IsReverse;
            _isUseTenPower = true;
            _isPreventLabelOverlap = true;
            _isVisible = true;
            _isSkipFirstLabel = false;
            _isSkipLastLabel = false;
            _isSkipCrossLabel = false;

            _majorUnit = DateUnit.Day;
            _minorUnit = DateUnit.Day;

            _format = null;
            _textLabels = null;

            _isLabelsInside = Default.IsLabelsInside;
            _align = Default.Align;
            _alignH = Default.AlignH;

            _fontSpec = new FontSpec(
                Default.FontFamily, Default.FontSize,
                Default.FontColor, Default.FontBold,
                Default.FontUnderline, Default.FontItalic,
                Default.FillColor, Default.FillBrush,
                Default.FillType );

            _fontSpec.Border.IsVisible = false;
            _labelGap = Default.LabelGap;
        }
Example #32
0
        public void CreatePane(ZedGraphControl zgc, List <OverViewDataDto> list)
        {
            zgc.GraphPane.CurveList.Clear();
            zgc.GraphPane.GraphObjList.Clear();

            GraphPane myPane = zgc.GraphPane;

            //设置图标标题和x、y轴标题
            myPane.Title.Text            = "掘金池总额变化";
            myPane.XAxis.Title.IsVisible = false;
            myPane.YAxis.Title.IsVisible = false;

            //更改标题的字体
            FontSpec myFont = new FontSpec("宋体", 20, Color.Gray, false, false, false);

            myPane.Title.FontSpec       = myFont;
            myPane.XAxis.Title.FontSpec = myFont;
            myPane.YAxis.Title.FontSpec = myFont;
            myPane.Legend.FontSpec      = myFont;

            list = list.OrderBy(o => o.Date).ToList();

            string[] labels = new string[list.Count];

            PointPairList list1 = new PointPairList();
            PointPairList list2 = new PointPairList();

            for (int i = 0; i < list.Count; i++)
            {
                var dto = list[i];
                try
                {
                    var showx = dto.Date.Substring(0, 4) + "-" + dto.Date.Substring(4, 2) + "-" + dto.Date.Substring(6, 2);
                    labels[i] = showx;
                }
                catch {
                    labels[i] = dto.Date;
                }

                double x  = i;
                double y1 = dto.AllMakeMoney;
                double y2 = dto.AllMakeMoneyScore;
                list1.Add(x, y1);
                list2.Add(x, y2);
            }

            // 用list1生产一条曲线
            LineItem myCurve = myPane.AddCurve("掘金池总额", list1, Color.Red, SymbolType.Circle);

            LineItem myCurve2 = myPane.AddCurve("掘金分", list2, Color.Blue, SymbolType.Circle);

            //填充图表颜色
            myPane.Fill = new Fill(Color.White, Color.FromArgb(200, 200, 255), 45.0f);

            myPane.XAxis.Scale.TextLabels = labels;        //X轴文本取值
            myPane.XAxis.Type             = AxisType.Text; //X轴类型

            //画到zedGraphControl1控件中,此句必加
            zgc.AxisChange();

            //重绘控件
            Refresh();
        }
Example #33
0
 public virtual void SetWatchWindowFont(FontSpec font)
 {
     if (_txtWatch != null) // In case a derived class overrides InitializeWatchWindow() but not this
     {
         _txtWatch.Font = font.Font;
         _txtWatch.ForeColor = font.Color;
     }
 }
        public void CreateChart(ZedGraphControl zgc)
        {
            zgc.GraphPane.CurveList.Clear();
            zgc.GraphPane.GraphObjList.Clear();

            GraphPane myPane = zgc.GraphPane;

            // Set the titles and axis labels
            myPane.Title.Text       = "代系数增长图";
            myPane.XAxis.Title.Text = "代数";
            myPane.YAxis.Title.Text = "代系数";

            FontSpec myFont = new FontSpec("宋体", 20, Color.Gray, false, false, false);

            myPane.Title.FontSpec       = myFont;
            myPane.XAxis.Title.FontSpec = myFont;
            myPane.YAxis.Title.FontSpec = myFont;
            myPane.Legend.FontSpec      = myFont;

            var MaxGeneration = (int)numericUpDown_max_generation.Value;

            string[] labels = new string[MaxGeneration];

            PointPairList list1 = new PointPairList();

            for (int i = 0; i < MaxGeneration; i++)
            {
                labels[i] = i.ToString();

                double x  = i;
                double y1 = ComputeGenerationCoefficient(i);
                list1.Add(x, y1);
            }

            // Generate a red curve with diamond symbols, and "Velocity" in the legend
            LineItem myCurve = myPane.AddCurve("代系数",
                                               list1, Color.Red, SymbolType.Diamond);

            // Fill the symbols with white
            myCurve.Symbol.Fill = new Fill(Color.White);

            // Show the x axis grid
            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.XAxis.Scale.TextLabels    = labels; //X轴文本取值
            myPane.XAxis.Type = AxisType.Text;         //X轴类型

            // Make the Y axis scale red
            myPane.YAxis.Scale.FontSpec.FontColor = Color.Red;
            myPane.YAxis.Title.FontSpec.FontColor = Color.Red;
            // turn off the opposite tics so the Y tics don't show up on the Y2 axis

            // Align the Y axis labels so they are flush to the axis
            myPane.YAxis.Scale.Align = AlignP.Inside;


            // Fill the axis background with a gradient
            myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45.0f);
            zgc.AxisChange();
            zgc.Refresh();
            zgc.AxisChange();
        }
Example #35
0
 private void font(ExecutionEnvironment env, FontSpec prevFont, Color defaultColor, Action<FontSpec> setFont)
 {
     using (var fontDlg = new FontDialog())
     {
         if (prevFont != null)
             fontDlg.Font = prevFont.Font;
         if (fontDlg.ShowDialog() == DialogResult.OK)
         {
             setFont(new FontSpec(fontDlg.Font, defaultColor));
             env.IfType((HexagonyEnv e) => { e.UpdateWatch(); });
         }
     }
 }
Example #36
0
 public PointAnnotation(string label)
 {
     Label           = label;
     ExtraAnnotation = null;
     FontSpec        = new FontSpec();
 }
Example #37
0
        /// <summary>
        /// Constructor that builds a <see cref="Label" /> from a text <see cref="string" />
        /// and a <see cref="FontSpec" /> instance.
        /// </summary>
        /// <param name="text"></param>
        /// <param name="fontSpec"></param>
        public Label( string text, FontSpec fontSpec )
        {
            _text = (text == null) ? string.Empty : text;

            _fontSpec = fontSpec;
            _isVisible = true;
        }
Example #38
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="TextObj"/> object from which to copy</param>
 public TextObj( TextObj rhs )
     : base(rhs)
 {
     _text = rhs.Text;
     _fontSpec = new FontSpec( rhs.FontSpec );
 }
Example #39
0
        private void Init( string text )
        {
            if ( text != null )
                _text = text;
            else
                text = "Text";

            _fontSpec = new FontSpec(
                Default.FontFamily, Default.FontSize,
                Default.FontColor, Default.FontBold,
                Default.FontItalic, Default.FontUnderline );

            //this.isWrapped = Default.IsWrapped ;
            _layoutArea = new SizeF( 0, 0 );
        }
Example #40
0
        /// <summary>
        /// Render the <see c_ref="Legend"/> to the specified <see c_ref="Graphics"/> device.
        /// </summary>
        /// <remarks>
        /// This method is normally only called by the Draw method
        /// of the parent <see c_ref="GraphPane"/> object.
        /// </remarks>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see c_ref="PaneBase"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see c_ref="GraphPane"/> object using the
        /// <see c_ref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public void Draw(Graphics g, PaneBase pane, float scaleFactor)
        {
            // if the legend is not visible, do nothing
            if (!_isVisible)
            {
                return;
            }

            // Fill the background with the specified color if required
            _fill.Draw(g, _rect);

            PaneList paneList = GetPaneList(pane);

            float halfGap = _tmpSize / 2.0F;

            // Check for bad data values
            if (_hStack <= 0)
            {
                _hStack = 1;
            }
            if (_legendItemWidth <= 0)
            {
                _legendItemWidth = 100;
            }
            if (_legendItemHeight <= 0)
            {
                _legendItemHeight = _tmpSize;
            }

            //float gap = pane.ScaledGap( scaleFactor );

            int   iEntry = 0;
            float x, y;

            // Get a brush for the legend label text
            using (SolidBrush brushB = new SolidBrush(Color.Black))
            {
                foreach (GraphPane tmpPane in paneList)
                {
                    // Loop for each curve in the CurveList collection
                    //foreach ( CurveItem curve in tmpPane.CurveList )
                    int count = tmpPane.CurveList.Count;
                    for (int i = 0; i < count; i++)
                    {
                        CurveItem curve = tmpPane.CurveList[_isReverse ? count - i - 1 : i];

                        if (curve._label._text != "" && curve._label._isVisible)
                        {
                            // Calculate the x,y (TopLeft) location of the current
                            // curve legend label
                            // assuming:
                            //  charHeight/2 for the left margin, plus legendWidth for each
                            //    horizontal column
                            //  legendHeight is the line spacing, with no extra margin above

                            x = _rect.Left + halfGap / 2.0F +
                                (iEntry % _hStack) * _legendItemWidth;
                            y = _rect.Top + iEntry / _hStack * _legendItemHeight;

                            // Draw the legend label for the current curve
                            FontSpec tmpFont = (curve._label._fontSpec != null) ?
                                               curve._label._fontSpec : FontSpec;

                            // This is required because, for long labels, the centering can affect the
                            // position in GDI+.
                            tmpFont.StringAlignment = StringAlignment.Near;

                            if (_isShowLegendSymbols)
                            {
                                tmpFont.Draw(g, pane, curve._label._text,
                                             x + 2.5F * _tmpSize, y + _legendItemHeight / 2.0F + 1,
                                             AlignH.Left, AlignV.Center, scaleFactor);

                                RectangleF rect = new RectangleF(x, y + _legendItemHeight / 4.0F,
                                                                 2 * _tmpSize, _legendItemHeight / 2.0F);
                                curve.DrawLegendKey(g, tmpPane, rect, scaleFactor);
                            }
                            else
                            {
                                if (curve._label._fontSpec == null)
                                {
                                    tmpFont.FontColor = curve.Color;
                                }

                                tmpFont.Draw(g, pane, curve._label._text,
                                             x + 0.0F * _tmpSize, y + _legendItemHeight / 2.0F,
                                             AlignH.Left, AlignV.Center, scaleFactor);
                            }

                            // maintain a curve count for positioning
                            iEntry++;
                        }
                    }
                    if (pane is MasterPane && ((MasterPane)pane).IsUniformLegendEntries)
                    {
                        break;
                    }
                }

                // Draw a border around the legend if required
                if (iEntry > 0)
                {
                    Border.Draw(g, pane, scaleFactor, _rect);
                }
            }
        }
Example #41
0
 /// <summary>
 /// Copy the properties of this <see cref="ZedGraphWebFontSpec"/> to the specified
 /// <see cref="ZedGraph.FontSpec"/> object.
 /// </summary>
 /// <param name="item">The destination <see cref="ZedGraph.FontSpec"/> object</param>
 internal void CopyTo( FontSpec item )
 {
     this.Border.CopyTo( item.Border );
     this.Fill.CopyTo( item.Fill );
     item.Angle = this.Angle;
     item.Size = this.Size;
     item.Family = this.Family;
     item.FontColor = this.FontColor;
     item.StringAlignment = this.StringAlignment;
     item.IsBold = this.IsBold;
     item.IsItalic = this.IsItalic;
     item.IsUnderline = this.IsUnderline;
 }
Example #42
0
        public override void AddPreCurveAnnotations(MSGraphPane graphPane, Graphics g,
                                                    MSPointList pointList, GraphObjList annotations)
        {
            if (Chromatogram == null)
            {
                return;
            }

            // Give priority to showing the best peak text object above all other annotations
            if (DragInfo != null || (!HideBest && TransitionChromInfo != null) || CurveAnnotation != null)
            {
                // Show text and arrow for the best peak
                double intensityBest = 0;
                if (_bestPeakTimeIndex != -1)
                {
                    ScaledRetentionTime timeBest = new ScaledRetentionTime(_measuredTimes[_bestPeakTimeIndex], _displayTimes[_bestPeakTimeIndex]);
                    float xBest = graphPane.XAxis.Scale.Transform(timeBest.DisplayTime);
                    intensityBest = _intensities[_bestPeakTimeIndex];
                    float yBest = graphPane.YAxis.Scale.Transform(intensityBest);

                    if (GraphChromatogram.ShowRT != ShowRTChrom.none || DragInfo != null)
                    {
                        // Best peak gets its own label to avoid curve overlap detection
                        double intensityLabel = graphPane.YAxis.Scale.ReverseTransform(yBest - 5);
                        float? massError      = Settings.Default.ShowMassError && TransitionChromInfo != null
                                               ? TransitionChromInfo.MassError
                                               : null;
                        double dotProduct = _dotProducts != null ? _bestProduct : 0;

                        TextObj text;
                        if (CurveAnnotation != null)
                        {
                            // Darken peptide name a little so light colors stand out against the white background.
                            var color = FontSpec.FontColor;
                            if (!GraphInfo.IsSelected)
                            {
                                color = Color.FromArgb(color.R * 7 / 10, color.G * 7 / 10, color.B * 7 / 10);
                            }
                            var fontSpec = new FontSpec(FontSpec)
                            {
                                FontColor = color, Angle = 90
                            };
                            if (GraphInfo.IsSelected)
                            {
                                fontSpec = new FontSpec(fontSpec)
                                {
                                    IsBold = true, Size = fontSpec.Size + 2, IsAntiAlias = true
                                }
                            }
                            ;

                            // Display peptide name label using vertical text.
                            text = new TextObj(CurveAnnotation, timeBest.DisplayTime, intensityLabel,
                                               CoordType.AxisXYScale, AlignH.Left, AlignV.Center)
                            {
                                ZOrder = ZOrder.A_InFront,
                                IsClippedToChartRect = true,
                                FontSpec             = fontSpec,
                                Tag = new GraphObjTag(this, GraphObjType.best_peak, timeBest),
                            };
                        }
                        else
                        {
                            string label = FormatTimeLabel(timeBest.DisplayTime, massError, dotProduct);

                            text = new TextObj(label, timeBest.DisplayTime, intensityLabel,
                                               CoordType.AxisXYScale, AlignH.Center, AlignV.Bottom)
                            {
                                ZOrder = ZOrder.A_InFront,
                                IsClippedToChartRect = true,
                                FontSpec             = FontSpec,
                                Tag = new GraphObjTag(this, GraphObjType.best_peak, timeBest),
                            };
                        }

                        annotations.Add(text);
                    }

                    // If showing multiple peptides, skip the best peak arrow indicator.
                    if (CurveAnnotation == null)
                    {
                        // Show the best peak arrow indicator
                        double timeArrow      = graphPane.XAxis.Scale.ReverseTransform(xBest - 4);
                        double intensityArrow = graphPane.YAxis.Scale.ReverseTransform(yBest - 2);

                        ArrowObj arrow = new ArrowObj(COLOR_BEST_PEAK, 12f,
                                                      timeArrow, intensityArrow, timeArrow, intensityArrow)
                        {
                            Location             = { CoordinateFrame = CoordType.AxisXYScale },
                            IsArrowHead          = true,
                            IsClippedToChartRect = true,
                            ZOrder = ZOrder.A_InFront
                        };
                        annotations.Add(arrow);
                    }
                }

                // Show the best peak boundary lines
                if (CurveAnnotation == null)
                {
                    double startTime = 0, endTime = 0;
                    if (DragInfo != null)
                    {
                        startTime = DragInfo.StartTime.MeasuredTime;
                        endTime   = DragInfo.EndTime.MeasuredTime;
                    }
                    else if (TransitionChromInfo != null)
                    {
                        var tranPeakInfo = TransitionChromInfo;
                        startTime = tranPeakInfo.StartRetentionTime;
                        endTime   = tranPeakInfo.EndRetentionTime;
                    }
                    AddPeakBoundaries(graphPane, annotations, true,
                                      ScaleRetentionTime(startTime), ScaleRetentionTime(endTime), intensityBest);
                }
                if (Chromatogram.BestPeakIndex >= 0)
                {
                    // Only shade peak when user modified. Otherwise, shading can be added when an entire
                    // precursor was force integrated because of another precursor (e.g. heavy) since that
                    // leads to an empty peak, which will not match the best peak.
                    if (Settings.Default.ShowOriginalPeak && TransitionChromInfo != null && TransitionChromInfo.IsUserModified)
                    {
                        var bestPeak = Chromatogram.GetPeak(Chromatogram.BestPeakIndex);
                        if (bestPeak.StartTime != TransitionChromInfo.StartRetentionTime ||
                            bestPeak.EndTime != TransitionChromInfo.EndRetentionTime)
                        {
                            AddOriginalPeakAnnotation(bestPeak, annotations, graphPane);
                        }
                    }
                }
            }
            if (_displayRawTimes.HasValue)
            {
                AddPeakRawTimes(graphPane, annotations,
                                ScaleRetentionTime(_displayRawTimes.Value.StartBound),
                                ScaleRetentionTime(_displayRawTimes.Value.EndBound),
                                Chromatogram);
            }
        }
Example #43
0
        /// <summary>
        /// Constructor for deserializing objects
        /// </summary>
        /// <param name="info">A <see cref="SerializationInfo"/> instance that defines the serialized data
        /// </param>
        /// <param name="context">A <see cref="StreamingContext"/> instance that contains the serialized data
        /// </param>
        protected TextObj( SerializationInfo info, StreamingContext context )
            : base(info, context)
        {
            // The schema value is just a file version parameter.  You can use it to make future versions
            // backwards compatible as new member variables are added to classes
            int sch = info.GetInt32( "schema2" );

            _text = info.GetString( "text" );
            _fontSpec = (FontSpec) info.GetValue( "fontSpec", typeof(FontSpec) );
            //isWrapped = info.GetBoolean ("isWrapped") ;
            _layoutArea = (SizeF) info.GetValue( "layoutArea", typeof(SizeF) );
        }
Example #44
0
        /// <summary>
        /// Copy constructor
        /// </summary>
        /// <param name="rhs">the <see cref="Label" /> instance to be copied.</param>
        public Label( Label rhs )
        {
            if (rhs._text != null)
                _text = (string)rhs._text.Clone();
            else
                _text = string.Empty;

            _isVisible = rhs._isVisible;
            if ( rhs._fontSpec != null )
                _fontSpec = rhs._fontSpec.Clone();
            else
                _fontSpec = null;
        }
Example #45
0
 private void SetDefaultFontSpec(FontSpec fontSpec)
 {
     fontSpec.Family = "Verdana";
     fontSpec.Size   = 11f * _dpiFactor;
     fontSpec.IsBold = false;
 }
Example #46
0
        /// <summary>
        /// Constructor to build an <see cref="AxisLabel" /> from the text and the
        /// associated font properties.
        /// </summary>
        /// <param name="text">The <see cref="string" /> representing the text to be
        /// displayed</param>
        /// <param name="fontFamily">The <see cref="String" /> font family name</param>
        /// <param name="fontSize">The size of the font in points and scaled according
        /// to the <see cref="PaneBase.CalcScaleFactor" /> logic.</param>
        /// <param name="color">The <see cref="Color" /> instance representing the color
        /// of the font</param>
        /// <param name="isBold">true for a bold font face</param>
        /// <param name="isItalic">true for an italic font face</param>
        /// <param name="isUnderline">true for an underline font face</param>
        public Label( string text, string fontFamily, float fontSize, Color color, bool isBold,
			bool isItalic, bool isUnderline )
        {
            _text = ( text == null ) ? string.Empty : text;

            _fontSpec = new FontSpec( fontFamily, fontSize, color, isBold, isItalic, isUnderline );
            _isVisible = true;
        }
Example #47
0
        /// <summary>
        /// Constructor for deserializing objects
        /// </summary>
        /// <param name="info">A <see cref="SerializationInfo"/> instance that defines the serialized data
        /// </param>
        /// <param name="context">A <see cref="StreamingContext"/> instance that contains the serialized data
        /// </param>
        protected Scale( SerializationInfo info, StreamingContext context )
        {
            // The schema value is just a file version parameter.  You can use it to make future versions
            // backwards compatible as new member variables are added to classes
            int sch = info.GetInt32( "schema" );

            _min = info.GetDouble( "min" );
            _max = info.GetDouble( "max" );
            _majorStep = info.GetDouble( "majorStep" );
            _minorStep = info.GetDouble( "minorStep" );
            _exponent = info.GetDouble( "exponent" );
            _baseTic = info.GetDouble( "baseTic" );

            _minAuto = info.GetBoolean( "minAuto" );
            _maxAuto = info.GetBoolean( "maxAuto" );
            _majorStepAuto = info.GetBoolean( "majorStepAuto" );
            _minorStepAuto = info.GetBoolean( "minorStepAuto" );
            _magAuto = info.GetBoolean( "magAuto" );
            _formatAuto = info.GetBoolean( "formatAuto" );

            _minGrace = info.GetDouble( "minGrace" );
            _maxGrace = info.GetDouble( "maxGrace" );

            _mag = info.GetInt32( "mag" );

            _isReverse = info.GetBoolean( "isReverse" );
            _isPreventLabelOverlap = info.GetBoolean( "isPreventLabelOverlap" );
            _isUseTenPower = info.GetBoolean( "isUseTenPower" );

            _isVisible = true;
            _isVisible = info.GetBoolean( "isVisible" );

            _isSkipFirstLabel = info.GetBoolean( "isSkipFirstLabel" );
            _isSkipLastLabel = info.GetBoolean( "isSkipLastLabel" );
            _isSkipCrossLabel = info.GetBoolean( "isSkipCrossLabel" );

            _textLabels = (string[]) info.GetValue( "textLabels", typeof(string[]) );
            _format = info.GetString( "format" );

            _majorUnit = (DateUnit) info.GetValue( "majorUnit", typeof(DateUnit) );
            _minorUnit = (DateUnit) info.GetValue( "minorUnit", typeof(DateUnit) );

            _isLabelsInside = info.GetBoolean( "isLabelsInside" );
            _align = (AlignP)info.GetValue( "align", typeof( AlignP ) );
            if ( schema >= 11 )
                _alignH = (AlignH)info.GetValue( "alignH", typeof( AlignH ) );

            _fontSpec = (FontSpec)info.GetValue( "fontSpec", typeof( FontSpec ) );
            _labelGap = info.GetSingle( "labelGap" );
        }
Example #48
0
        public void createPane(ZedGraphControl zgc)
        {
            myPane = zgc.GraphPane;
            //设置图标标题和x、y轴标题
            if (server.form1.comboBox1.Text == "BPM")
            {
                myPane.YAxis.Title.Text = "脉搏/BPM";
                myPane.Title.Text       = "BPM变化曲线";
            }
            else if (server.form1.comboBox1.Text == "体温")
            {
                myPane.YAxis.Title.Text = "体温/℃";
                myPane.Title.Text       = "体温变化曲线";
            }
            else
            {
                return;
            }

            myPane.XAxis.Title.Text = "时间/t";


            //更改标题的字体
            FontSpec myFont = new FontSpec("Arial", 20, Color.Red, false, false, false);

            myPane.Title.FontSpec       = myFont;
            myPane.XAxis.Title.FontSpec = myFont;
            myPane.YAxis.Title.FontSpec = myFont;

            // 造一些数据,PointPairList里有数据对x,y的数组
            // Y轴数据
            DataTable table = frm.frmBrowseGraph();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                int     x     = i;
                DataRow row   = table.Rows[i];                                       //传递给每个Row
                Double  value = Convert.ToDouble(row[server.form1.comboBox1.Text]);; //取值
                list.Add(x, value);                                                  //添加一组数据
            }

            // 用list生产一条曲线,标注是 filedPosition/filedUserAccount
            myLine = myPane.AddCurve(server.form1.cbPatient.Text, list, Color.Red, SymbolType.Star);

            //填充图表颜色
            myPane.Fill = new Fill(Color.White, Color.FromArgb(200, 200, 255), 45.0f);

            //以上生成的图标X轴为数字,下面将转换为日期的文本
            string[] labels = new string[table.Rows.Count];
            for (int i = 0; i < table.Rows.Count; i++)
            {
                DataRow row = table.Rows[i];                     //传递给每个Row
                labels[i] = Convert.ToString(row["时间"]);
            }
            oldRowsCount = table.Rows.Count;
            myPane.XAxis.Scale.TextLabels = labels;        //X轴文本取值
            myPane.XAxis.Type             = AxisType.Text; //X轴类型

            //画到zedGraphControl1控件中,此句必加
            zgc.AxisChange();
            zgc.Refresh();

            timer1.Enabled = true;
        }
Example #49
0
 private void font(ref FontSpec fontSpec, Action<FontSpec> set)
 {
     using (var fontDlg = new FontDialog { ShowColor = true })
     {
         if (fontSpec != null)
             fontDlg.Font = fontSpec.Font;
         if (fontDlg.ShowDialog() == DialogResult.OK)
         {
             fontSpec = fontSpec == null ? new FontSpec(fontDlg.Font, Color.Black) : fontSpec.SetFont(fontDlg.Font);
             set(fontSpec);
         }
     }
 }