我正在使用 WFP 构建应用程序 C#,我正在尝试绘制形状,每个形状都属于一个类,并且此类包含一个用于外部形状的 Polygon,以及 1 到 3 条折线以使其看起来像真正的 2D 对象,这个方式我可以动态更改整个形状的某些属性(颜色,可见性等)我必须说一些折线是根据所需的高度和宽度由循环创建的
但是现在我正面临着一些折线渲染的问题我希望最终结果看起来像位图像素,没有阴影、模糊或边缘效果。
这是一个例子(面板是给网格的名称)
public partial class Window1 : Window {
private Polyline zigzag;
public Window1() {
InitializeComponent();
PointCollection points = new PointCollection();
ArrayList axisX = new ArrayList();
ArrayList axisY = new ArrayList();
zigzag = new Polyline();
zigzag.Stroke = Brushes.Black;
int count = 1;
Boolean increase = true;
//the number 60 in this loop is to represent the width of the main shape
for (int p = 3; p < 60 - 3; p++) {
if (count == 1) {
axisX.Add(p);
axisY.Add(5);
increase = true;
}
if (count == 4) {
axisX.Add(p);
axisY.Add(2);
increase = false;
}
if (increase) {
count++;
}
else {
count--;
}
}
for (int i = 0; i < axisX.Count; i++) {
//the number 10 is to represent the position where the Poliline is to be placed
int tmpx = 10 + (int)axisX[i];
int tmpy = 10 + (int)axisY[i];
points.Add(new Point(tmpx, tmpy));
}
this.zigzag.Points = points;
RenderOptions.SetEdgeMode(Panel , EdgeMode.Aliased);
Panel.Children.Add(zigzag);
}
}
The picture shows the drawn zigzag on above, and the way it should look like below