0
This is my current status告诉我x轴和y轴在OxyPlot
在图片中,你看到两个黄色为主色调和两个reds.The鲜艳的颜色则与代码创建的行。颜色较深的颜色已涂上油漆。我很想展示中间的Achs。我已经这样做了,但并不像我想的那样多。在图片中,您可以看到斧头不会完全靠近边缘。所以我扩展了Paint。所以它应该看起来也是事后。我想问最后的价值范围有多大。 (End是在矩形创建之后)。我认为这不是创建中间轴的最佳方式。我认为它更好,但不知道如何。 如何使笔画一直到边缘或有可能与 例如plotModel.PlotType = showMiddleAxis
?如果我不将它保存为Oxyplot的图像,但作为交互OxyPlot,轴也应该“去”。
编辑:
如果我通过代码添加的中轴线,该OxyPlot(即一个人看到整个中轴线)。这不应该如此。它应该只放大矩形和点。
我希望你能帮助我,谢谢。
与往常一样,现在的代码在等待着你:
Rootobject.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Rechteck
{
internal class Rootobject
{
public Point[] Points { get; set; }
public Rectangle[] Rectangles { get; set; }
}
internal class Point
{
public double X { get; set; }
public double Y { get; set; }
}
internal class Rectangle
{
public double XMin { get; set; }
public double XMax { get; set; }
public double YMin { get; set; }
public double YMax { get; set; }
}
}
MainWindow.xaml.cs
using System;
using System.Collections.Generic;
using System.Windows;
using OxyPlot;
namespace Rechteck
{
/// <summary>
/// Interaktionslogik für MainWindow.xaml
/// </summary>
public partial class MainWindow : Window, IPreviewCreator
{
public MainWindow()
{
InitializeComponent();
m_bWithAxis = true;
m_bWithFrame = true;
m_bWithGrid = true;
m_bWithCenterAxis = true;
try
{
PlotModel plotModel;
if (withFrame)
{
plotModel = new PlotModel { };
}
else
{
plotModel = new PlotModel { PlotAreaBorderColor = OxyColors.Transparent };
}
plotModel.PlotType = PlotType.Cartesian;
if (withAxis)
{
if (withGrid)
{
plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis { Position = OxyPlot.Axes.AxisPosition.Bottom, MinimumPadding = 0.1, MaximumPadding = 0.1, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot });
plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis { Position = OxyPlot.Axes.AxisPosition.Left, MinimumPadding = 0.1, MaximumPadding = 0.1, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot });
}
else
{
plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis { Position = OxyPlot.Axes.AxisPosition.Bottom, MinimumPadding = 0.1, MaximumPadding = 0.1 });
plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis { Position = OxyPlot.Axes.AxisPosition.Left, MinimumPadding = 0.1, MaximumPadding = 0.1 });
}
}
else
{
if (withGrid)
{
plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis { Position = OxyPlot.Axes.AxisPosition.Bottom, MinorTickSize = 0, TickStyle = OxyPlot.Axes.TickStyle.None, TextColor = OxyColors.Transparent, MinimumPadding = 0.1, MaximumPadding = 0.1, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot });
plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis { Position = OxyPlot.Axes.AxisPosition.Left, MinorTickSize = 0, TickStyle = OxyPlot.Axes.TickStyle.None, TextColor = OxyColors.Transparent, MinimumPadding = 0.1, MaximumPadding = 0.1, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot });
}
else
{
plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis { Position = OxyPlot.Axes.AxisPosition.Bottom, MinorTickSize = 0, TickStyle = OxyPlot.Axes.TickStyle.None, TextColor = OxyColors.Transparent, MinimumPadding = 0.1, MaximumPadding = 0.1 });
plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis { Position = OxyPlot.Axes.AxisPosition.Left, MinorTickSize = 0, TickStyle = OxyPlot.Axes.TickStyle.None, TextColor = OxyColors.Transparent, MinimumPadding = 0.1, MaximumPadding = 0.1 });
}
}
var series2 = new OxyPlot.Series.LineSeries
{
LineStyle = LineStyle.None,
MarkerType = MarkerType.Circle,
MarkerSize = 5,
MarkerFill = OxyColors.Transparent,
MarkerStroke = OxyColors.Black,
MarkerStrokeThickness = 1,
};
series2.Points.Add(new DataPoint(8.0, 1.0));
series2.Points.Add(new DataPoint(4.0, 8.0));
series2.Points.Add(new DataPoint(8.0, 4.0));
series2.Points.Add(new DataPoint(1.0, 8.0));
series2.Points.Add(new DataPoint(10.0, 1.0));
series2.Smooth = true;
plotModel.Series.Add(series2);
for (int i = 0; i < 3; i++)
{
var series1 = new OxyPlot.Series.LineSeries
{
LineStyle = LineStyle.Solid,
MarkerType = MarkerType.Circle,
MarkerSize = 1,
MarkerFill = OxyColors.Transparent,
MarkerStroke = OxyColors.Black,
MarkerStrokeThickness = 1,
};
switch (i)
{
case 0:
series1.Points.Add(new DataPoint(1.0, 1.0));
series1.Points.Add(new DataPoint(4.0, 1.0));
series1.Points.Add(new DataPoint(4.0, 4.0));
series1.Points.Add(new DataPoint(1.0, 4.0));
series1.Points.Add(new DataPoint(1.0, 1.0));
break;
case 2:
series1.Points.Add(new DataPoint(3.0, 3.0));
series1.Points.Add(new DataPoint(12.0, 3.0));
series1.Points.Add(new DataPoint(12.0, 12.0));
series1.Points.Add(new DataPoint(3.0, 12.0));
series1.Points.Add(new DataPoint(3.0, 3.0));
break;
}
series1.Smooth = false;
plotModel.Series.Add(series1);
for (int s = 0; s < 2; s++)
{
if (s == 0)
{
var series3 = new OxyPlot.Series.LineSeries
{
LineStyle = LineStyle.Solid,
MarkerType = MarkerType.Circle,
MarkerSize = 1,
Color = OxyColors.Yellow,
MarkerFill = OxyColors.Transparent,
MarkerStroke = OxyColors.Black,
MarkerStrokeThickness = 1,
};
series3.Points.Add(new DataPoint(0, -10));
series3.Points.Add(new DataPoint(0, +10));
series3.Smooth = false;
plotModel.Series.Add(series3);
}
else
{
var series4 = new OxyPlot.Series.LineSeries
{
LineStyle = LineStyle.Solid,
MarkerType = MarkerType.Circle,
MarkerSize = 1,
Color = OxyColors.Red,
MarkerFill = OxyColors.Transparent,
MarkerStroke = OxyColors.Black,
MarkerStrokeThickness = 1,
};
series4.Points.Add(new DataPoint(-10, 0));
series4.Points.Add(new DataPoint(+10, 0));
series4.Smooth = false;
plotModel.Series.Add(series4);
}
}
}
try
{
this.Content = new OxyPlot.Wpf.PlotView { Model = plotModel, Width = 800, Height = 800 };
}
catch (Exception)
{
}
}
catch (Exception)
{
}
}
private List<double> pointX = new List<double>();
private List<double> pointY = new List<double>();
private bool m_bWithAxis;
private bool m_bWithFrame;
private bool m_bWithGrid;
private bool m_bWithCenterAxis;
public int m_iMargin;
public bool withAxis
{
get { return m_bWithAxis; }
set { m_bWithAxis = value; }
}
public bool withFrame
{
get { return m_bWithFrame; }
set { m_bWithFrame = value; }
}
public bool withGrid
{
get { return m_bWithGrid; }
set { m_bWithGrid = value; }
}
public bool withCenterAxis
{
get { return m_bWithCenterAxis; }
set { m_bWithCenterAxis = value; }
}
public int margin
{
get { return m_iMargin; }
set { m_iMargin = value; }
}
public bool actualizePreview(out string errorMessage)
{
throw new NotImplementedException();
}
public void addPoint(double pX, double pY)
{
throw new NotImplementedException();
}
public void addRectangle(double pXmin, double pXMax, double pYMin, double pYMax)
{
throw new NotImplementedException();
}
public void clear()
{
throw new NotImplementedException();
}
public bool readJSONFile(out string errorMessage, string filename)
{
throw new NotImplementedException();
}
public bool savePicture(out string errorMessage, out System.Drawing.Image preview, int pWidth, int pHeight)
{
throw new NotImplementedException();
}
}
}
MainWindow.xaml
<Window x:Class="Rechteck.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Rechteck"
mc:Ignorable="d"
Title="MainWindow" Height="900" Width="900">
<Grid>
</Grid>
</Window>
若发现有丢失或模糊之处,发表评论那里。
难道你是[gabelundmesser](http://stackoverflow.com/users/7597016/gabelundmesser)? – lokusking
不,我不是这个用户。 –