Inheritance: IInkStrokeBuilder
コード例 #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);
            }
        }
コード例 #3
0
        private async void ShareStorageItemsHandler(DataTransferManager sender, DataRequestedEventArgs e)
        {
            DataRequest request = e.Request;
            request.Data.Properties.Title = "Exemplo de compartilhamento";
            request.Data.Properties.Description = "Demonstração de como compartilhar imagem no windows 10";
            DataRequestDeferral deferral = request.GetDeferral();


            StorageFile arquivo = await KnownFolders.PicturesLibrary.CreateFileAsync("comp.png", CreationCollisionOption.ReplaceExisting);
            InkStrokeBuilder isb = new InkStrokeBuilder();
            

            if (null != arquivo)
            {
                using (var stream = await arquivo.OpenAsync(FileAccessMode.ReadWrite))
                {
                    try
                    {
                        await areaDesenho.InkPresenter.StrokeContainer.SaveAsync(stream);

                        
                    }
                    catch (Exception ex)
                    {
                        MessageDialog md = new MessageDialog(ex.ToString());
                        await md.ShowAsync();
                    }
                    
                }

                try
                {
                    request.Data.SetBitmap(RandomAccessStreamReference.CreateFromFile(arquivo));
                }
                catch(Exception ex)
                {
                    MessageDialog md = new MessageDialog(ex.ToString());
                    await md.ShowAsync();
                }
                finally
                {
                    deferral.Complete();
                }

            }
        }
コード例 #4
0
ファイル: Stroq.cs プロジェクト: philllies/finalproject
 public static InkStroke ToInkStroke(this Stroq source, double stepX = 1, double stepY = 1, double offsetX = 0,
     double offsetY = 0)
 {
     if (source.Points.Count == 0)
         return null;
     var builder = new InkStrokeBuilder();
     return builder.CreateStroke(source.Points);
 }
コード例 #5
0
        public static InkStroke ToInkStroke(this TimeSeries source, double stepX = 1, double stepY = 1, double offsetX = 0, double offsetY = 0)
        {
            var points = new List<Point>();
            for (var i = 0; i < source.Values.Count; i++)
            {
                points.Add(new Point(offsetX + stepX * i, offsetY + (1 - source.Values[i]) * stepY));
            }
            var builder = new InkStrokeBuilder();

            return builder.CreateStroke(points);
        }