Example #1
0
            public ViewGeo(EvalGraphControl con)
            {
                plyMax = Math.Max((Math.Max(con.evaldata.maxIndex, con.evaldata.selectedIndex) + 9) / 10 * 10, 50);
                var plyMaxLen = $"{plyMax}".Length;

                hScrollValue  = con.HorizontalScroll.Value;
                scoreFontSize = Math.Max(Math.Min(con.Width, con.Height) / 16f, 1f);
                parFontSize   = Math.Max(Math.Min(con.Width, con.Height) / 20f, 1f);
                // 評価値の文字縦長度
                scoreFontSizeXmul = con.Font.Size / 16f;
                lineWidthMul      = Math.Max(Math.Min(con.Width, con.Height) / 512f, 1f);
                scaleLineLen      = 4 * lineWidthMul;
                scaleTextPad      = 5 * lineWidthMul;
                RectangleF bounds;

                using (var path = new GraphicsPath())
                {
                    path.AddString(
                        "+9999",
                        con.Font.FontFamily,
                        (int)con.Font.Style,
                        scoreFontSize,
                        new PointF(0f, 0f),
                        new StringFormat()
                    {
                        Alignment = StringAlignment.Far, LineAlignment = StringAlignment.Near
                    }
                        );
                    using (var matrix = new Matrix(scoreFontSizeXmul, 0f, 0f, 1f, 0f, 0f))
                        path.Transform(matrix);
                    bounds = path.GetBounds();
                    lPad   = 4 + (-1.0f * bounds.Left + scaleTextPad);
                    rPad   = 4 + (con.evaldata.type == EvaluationGraphType.TrigonometricSigmoid ?
                                  (-0.8f * bounds.Left * parFontSize / scoreFontSize + scaleTextPad) :
                                  (-0.1f * bounds.Left * plyMaxLen));
                    graphBodyWidth = con.Width - lPad - rPad;
                    plyWidth       = Math.Max(graphBodyWidth / plyMax, 4f);
                    plyFontSize    = Math.Max(Math.Min(plyWidth * -80f / (plyMaxLen * bounds.Left), 1f) * scoreFontSize, 1f);
                    uPad           = 4 + (int)(+0.5f * bounds.Bottom);
                    bPad           = 4 + (int)(+1.0f * bounds.Bottom * plyFontSize / scoreFontSize + scaleTextPad);
                }
                xlen           = con.evalGraphPictureBox.Width - lPad - rPad;
                ymul           = (con.evalGraphPictureBox.Height - uPad - bPad) * 0.5f;
                yadd           = uPad + ymul;
                scoreRound     = Math.Max(Math.Min(con.Height * 0.01f, plyWidth * 0.5f), 3f);
                scoreLineWidth = Math.Max(scoreRound * 0.5f, 1f);
                boxWidth       = Math.Max((int)(lPad + rPad + plyMax * plyWidth), con.Width);
            }
Example #2
0
            public ViewGeo(EvalGraphControl con)
            {
                plyMax = Math.Max((Math.Max(con.evaldata.maxIndex, con.evaldata.selectedIndex) + 9) / 10 * 10, 50);
                var plyMaxLen = $"{plyMax}".Length;

                hScrollValue  = con.HorizontalScroll.Value;
                scoreFontSize = Math.Max(Math.Min(con.Width / 16f, con.Height / 16f), 1f);
                lineWidthMul  = Math.Max(Math.Min(con.Width, con.Height) / 512f, 1f);
                scaleLineLen  = 6 * lineWidthMul;
                scaleTextPad  = 8 * lineWidthMul;
                RectangleF bounds;

                using (var path = new System.Drawing.Drawing2D.GraphicsPath())
                {
                    using (var font = new FontFamily(con.fontFamilyName))
                        path.AddString(
                            "+9999",
                            font,
                            (int)FontStyle.Regular,
                            scoreFontSize,
                            new PointF(0f, 0f),
                            new StringFormat()
                        {
                            Alignment = StringAlignment.Far, LineAlignment = StringAlignment.Near
                        }
                            );
                    bounds = path.GetBounds();
                    lPad   = 4 + (int)(-1.0f * bounds.Left + scaleTextPad);
                    rPad   = 4 + (int)(-0.1f * plyMaxLen * bounds.Left);
                    uPad   = 4 + (int)(+0.5f * bounds.Bottom);
                    bPad   = 4 + (int)(+1.0f * bounds.Bottom + scaleTextPad);
                }
                xlen           = con.evalGraphPictureBox.Width - lPad - rPad;
                ymul           = (con.evalGraphPictureBox.Height - uPad - bPad) * 0.5f;
                yadd           = uPad + ymul;
                graphBodyWidth = con.Width - lPad - rPad;
                plyWidth       = Math.Max(graphBodyWidth / plyMax, 4f);
                plyFontSize    = Math.Max(Math.Min(scoreFontSize * plyWidth * -80f / (plyMaxLen * bounds.Left), scoreFontSize), 1f);
                scoreRound     = Math.Max(Math.Min(con.Height * 0.01f, plyWidth * 0.5f), 3f);
                scoreLineWidth = Math.Max(scoreRound * 0.5f, 1f);
                boxWidth       = Math.Max((int)(lPad + rPad + plyMax * plyWidth), con.Width);
            }