SetDefaultDrawingAttributes() public method

public SetDefaultDrawingAttributes ( [ drawingAttributes ) : void
drawingAttributes [
return void
コード例 #1
0
        private async Task SaveStrokesToBitmap(WriteableBitmap b)
        {
            Rect imgRect = new Rect(0, 0, b.PixelWidth, b.PixelHeight);
            InkStrokeContainer container = TheInkCanvas.InkPresenter.StrokeContainer;
            InkStrokeBuilder builder = new InkStrokeBuilder();

            // Unsichtbare Tinte!
            InkDrawingAttributes da = TheInkCanvas.InkPresenter.CopyDefaultDrawingAttributes();
            da.Size = new Size(0.1, 0.1);
            builder.SetDefaultDrawingAttributes(da);

            // Strich in oberer linker Ecke einfügen
            InkStroke topLeft = builder.CreateStroke(new List<Point>() {
                new Point(1, 1),
                new Point(2, 2) });
            container.AddStroke(topLeft);

            // Strich in unterer Rechter Ecke einfügen
            InkStroke bottomRight = builder.CreateStroke(new List<Point>() {
                new Point(imgRect.Width -2, imgRect.Height -2),
                new Point(imgRect.Width -1, imgRect.Height -1) });   
            container.AddStroke(bottomRight);

            // Striche in WriteableBitmap speichern
            WriteableBitmap bmp;
            using (InMemoryRandomAccessStream ims =
                new InMemoryRandomAccessStream())
            {
                await container.SaveAsync(ims);
                bmp = await new WriteableBitmap(1, 1)
                    .FromStream(ims, BitmapPixelFormat.Bgra8);
            }
            // Bilder zusammenfügen
            b.Blit(imgRect, bmp, imgRect, WriteableBitmapExtensions.BlendMode.Alpha);
        }
コード例 #2
0
ファイル: InkTests.cs プロジェクト: fengweijp/Win2D
        public void DrawInkDoesNotModifyContextState()
        {
            Point[] points =
            {
                new Point(0, 0),
                new Point(100, 100),
            };

            var strokeBuilder = new InkStrokeBuilder();

            var stroke1 = strokeBuilder.CreateStroke(points);

            strokeBuilder.SetDefaultDrawingAttributes(new InkDrawingAttributes
            {
                Color = Colors.Yellow,
                DrawAsHighlighter = true
            });

            var stroke2 = strokeBuilder.CreateStroke(points);

            using (var device = new CanvasDevice())
            using (var target = new CanvasCommandList(device))
            using (var drawingSession = target.CreateDrawingSession())
            {
                var originalProperties = GetPropertyValues(drawingSession);

                drawingSession.DrawInk(new InkStroke[] { stroke1 });

                var propertiesAfterDraw1 = GetPropertyValues(drawingSession);

                drawingSession.DrawInk(new InkStroke[] { stroke2 });

                var propertiesAfterDraw2 = GetPropertyValues(drawingSession);

                CollectionAssert.AreEqual(originalProperties, propertiesAfterDraw1);
                CollectionAssert.AreEqual(originalProperties, propertiesAfterDraw2);
            }
        }