0
새로운 범용 앱 프로젝트 (VS 2015)를 만들었으며 별도의 스레드를 통해 페이지에 원을 무작위로 그려야합니다. 아래의 간단한 코드를 참조하십시오. 실제로 원을 그리려면 무엇을 추가해야합니까?Windows 10 Universal App에서 별도의 스레드에 사용자 지정 원을 그리는 방법은 무엇입니까?
감사합니다. 방금 화면에 원을 그리하려는 경우
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml.Shapes;
using System.Threading.Tasks;
namespace CircleDraw {
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
this.Loaded += MainPage_Loaded;
}
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
Task.Factory.StartNew(() => DrawNewCircleEverySecondAsync(), TaskCreationOptions.LongRunning);
}
private static Random r = new Random(DateTime.UtcNow.Millisecond);
private const int minRadius = 25;
private const int maxRadius = 100;
private async Task DrawNewCircleEverySecondAsync()
{
double height = grid1.ActualHeight;
double width = grid1.ActualWidth;
while (true)
{
int x = r.Next((int)width);
int y = r.Next((int)height);
int radius = r.Next(minRadius, maxRadius);
// How do I draw this new circle here?
await Task.Delay(1000);
}
}
}
}
당신은 사용자 정의 원을 그리 무엇을 의미합니까? 자세한 내용을 제공해 주시겠습니까? – Scavenger
내가 말하는 것은 주어진 x, y 좌표와 반지름으로 화면에 원을 그리는 것입니다. –