사용자가 이미지를 이동하고 확대 / 축소하는 C # WF에 앱이 있습니다. 타원이 제자리에 남아 있고 이미지를 수정할 때 움직이지 않기 때문에 이미지 컨트롤에 타원을 그리고 싶습니다.
전망:
<Grid>
<Canvas Name="cavRoot" Opacity="1">
<Image Name="highresmap4" Source="highresmap4.png" Canvas.Left="0" Canvas.Top="0" Width="1473" Height="770">
</Image>
</Canvas>
</Grid>
모델:
class draw
{
public static void circle(double x, double y, int width, int height, Canvas cv)
{
Ellipse circle = new Ellipse()
{
Width = width,
Height = height,
Stroke = Brushes.Red,
StrokeThickness = 6
};
cv.Children.Add(circle);
circle.SetValue(Canvas.LeftProperty, (double)x);
circle.SetValue(Canvas.TopProperty, (double)y);
}
}
ViewModel :
draw.circle(x, y, 10, 10, cavRoot);
당신은 넣을 수 Image
A의 Grid
와 사용 Margin
의 특성을 Ellipse
내에서 자신의 위치를 지정합니다 Image
:
public static void circle(double x, double y, int width, int height, Panel cv)
{
Ellipse circle = new Ellipse()
{
Width = width,
Height = height,
Stroke = Brushes.Red,
StrokeThickness = 6,
Margin = new Thickness(x, y, 0, 0)
};
cv.Children.Add(circle);
}
XAML :
<Grid x:Name="theGrid">
<Image Name="highresmap4" Source="highresmap4.png" Width="1473" Height="770" />
</Grid>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다