Скопируйте часть рисунка в том же рисункеC#

Место общения программистов C#
Ответить
Anonymous
 Скопируйте часть рисунка в том же рисунке

Сообщение Anonymous »

Я хочу спроектировать продолжающуюся «Водопад», чтобы представлять радиоспект. /> Является ли, что даже правильный подход в Win2d? За пределами экрана: < /p>

Код: Выделить всё

private CanvasRenderTarget offscreen;
private CanvasDevice device = CanvasDevice.GetSharedDevice();
private DispatcherTimer Timer;
< /code>
В конструкторе: < /p>
offscreen = new CanvasRenderTarget(device, 300, 255, 96);
Timer = new DispatcherTimer();
Timer.Interval = TimeSpan.FromMilliseconds(refreshRate);
Timer.Tick += Timer_Tick;
Timer.Start();
< /code>
Работать в событии Timer_tick: < /p>

private void Timer_Tick(object? sender, object e)
{
using (CanvasDrawingSession ds = offscreen.CreateDrawingSession())
{
// Draw rectangle
ds.FillRectangle(10, 10, 100, 100, Colors.Red);
// Source rect to be copied
Rect sourceRegion = new Rect(10, 10, 50, 50);
// Define the destination point on the current canvas
Vector2 destinationPoint = new Vector2(150, 150);
// Copy the specified region from the source to the destination
**ds.DrawImage(offscreen, destinationPoint, sourceRegion); // Unhandled error**
}
if (this.waterfallCanvas != null) this.waterfallCanvas.Invalidate();
}

private void waterfallCanvas_Draw(CanvasControl sender, CanvasDrawEventArgs args)
{
if (offscreen != null) args.DrawingSession.DrawImage(offscreen, 0, 0);
}
он бросает нездоровые Interopservices.comexeption

Подробнее здесь: https://stackoverflow.com/questions/797 ... ingsession
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»