示例#1
0
 public ControlBackEnd(float width, float height)
 {
     Plot     = new ScottPlot.Plot();
     Settings = Plot.GetSettings(false);
     Resize(width, height);
     NewBitmap(600, 400);
 }
示例#2
0
        private static Point[] GetLocations(ScottPlot.Settings settings, int padding, Size frameSize, float legendFontMaxWidth)
        {
            Point frameLocation  = new Point();
            Point textLocation   = new Point();
            Point shadowLocation = new Point();

            // calculate locations even if it's not going to be displayed
            legendLocation loc = settings.legend.location;

            if (loc == legendLocation.none)
            {
                loc = legendLocation.lowerRight;
            }

            int frameWidth  = frameSize.Width;
            int frameHeight = frameSize.Height;

            switch (loc)
            {
            case (legendLocation.lowerRight):
                frameLocation.X = (int)(settings.dataSize.Width - frameWidth - padding);
                frameLocation.Y = (int)(settings.dataSize.Height - frameHeight - padding);
                textLocation.X  = (int)(settings.dataSize.Width - (legendFontMaxWidth + padding));
                textLocation.Y  = settings.dataSize.Height - padding * 2;
                break;

            case (legendLocation.upperLeft):
                frameLocation.X = (int)(padding);
                frameLocation.Y = (int)(padding);
                textLocation.X  = (int)(frameWidth - legendFontMaxWidth + padding);
                textLocation.Y  = (int)(frameHeight);
                break;

            case (legendLocation.lowerLeft):
                frameLocation.X = (int)(padding);
                frameLocation.Y = (int)(settings.dataSize.Height - frameHeight - padding);
                textLocation.X  = (int)(frameWidth - legendFontMaxWidth + padding);
                textLocation.Y  = settings.dataSize.Height - padding * 2;
                break;

            case (legendLocation.upperRight):
                frameLocation.X = (int)(settings.dataSize.Width - frameWidth - padding);
                frameLocation.Y = (int)(padding);
                textLocation.X  = (int)(settings.dataSize.Width - (legendFontMaxWidth + padding));
                textLocation.Y  = (int)(frameHeight);
                break;

            case (legendLocation.upperCenter):
                frameLocation.X = (int)((settings.dataSize.Width) / 2 - frameWidth / 2);
                frameLocation.Y = (int)(padding);
                textLocation.X  = (int)(frameLocation.X + frameWidth - legendFontMaxWidth);
                textLocation.Y  = (int)(frameHeight);
                break;

            case (legendLocation.lowerCenter):
                frameLocation.X = (int)((settings.dataSize.Width) / 2 - frameWidth / 2);
                frameLocation.Y = (int)(settings.dataSize.Height - frameHeight - padding);
                textLocation.X  = (int)(frameLocation.X + frameWidth - legendFontMaxWidth);
                textLocation.Y  = settings.dataSize.Height - padding * 2;
                break;

            case (legendLocation.middleLeft):
                frameLocation.X = (int)(padding);
                frameLocation.Y = (int)(settings.dataSize.Height / 2 - frameHeight / 2);
                textLocation.X  = (int)(frameWidth - legendFontMaxWidth + padding);
                textLocation.Y  = (int)(frameLocation.Y + frameHeight - padding);
                break;

            case (legendLocation.middleRight):
                frameLocation.X = (int)(settings.dataSize.Width - frameWidth - padding);
                frameLocation.Y = (int)(settings.dataSize.Height / 2 - frameHeight / 2);
                textLocation.X  = (int)(settings.dataSize.Width - (legendFontMaxWidth + padding));
                textLocation.Y  = (int)(frameLocation.Y + frameHeight - padding);
                break;

            default:
                throw new NotImplementedException($"legend location {settings.legend.location} is not supported");
            }

            switch (settings.legend.shadow)
            {
            case (shadowDirection.lowerRight):
                shadowLocation.X = frameLocation.X + 2;
                shadowLocation.Y = frameLocation.Y + 2;
                break;

            case (shadowDirection.lowerLeft):
                shadowLocation.X = frameLocation.X - 2;
                shadowLocation.Y = frameLocation.Y + 2;
                break;

            case (shadowDirection.upperRight):
                shadowLocation.X = frameLocation.X + 2;
                shadowLocation.Y = frameLocation.Y - 2;
                break;

            case (shadowDirection.upperLeft):
                shadowLocation.X = frameLocation.X - 2;
                shadowLocation.Y = frameLocation.Y - 2;
                break;

            default:
                settings.legend.shadow = shadowDirection.none;
                break;
            }

            textLocation.Y += padding;
            return(new Point[] { frameLocation, textLocation, shadowLocation });
        }
示例#3
0
文件: Backend.cs 项目: ctxQ/ScottPlot
 public void Reset(float width, float height, Plot newPlot)
 {
     Plot     = newPlot;
     Settings = Plot.GetSettings(false);
     Resize(width, height);
 }