示例#1
0
        void OnPenColorChanged(object sender, RoutedEventArgs e)
        {
            if (inkCanvas != null)
            {
                InkDrawingAttributes drawingAttributes = inkCanvas.InkPresenter.CopyDefaultDrawingAttributes();

                // Use button's background to set new pen's color
                var btnSender = sender as Button;
                var brush     = btnSender.Background as Windows.UI.Xaml.Media.SolidColorBrush;

                drawingAttributes.Color = brush.Color;
                inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
            }
        }
        public Scenario2()
        {
            this.InitializeComponent();

            // Initialize drawing attributes. These are used in inking mode.
            InkDrawingAttributes drawingAttributes = new InkDrawingAttributes();

            drawingAttributes.Color = Windows.UI.Colors.Red;
            double penSize = 4;

            drawingAttributes.Size           = new Windows.Foundation.Size(penSize, penSize);
            drawingAttributes.IgnorePressure = false;
            drawingAttributes.FitToCurve     = true;

            // Show the available recognizers
            inkRecognizerContainer = new InkRecognizerContainer();
            recoView = inkRecognizerContainer.GetRecognizers();
            if (recoView.Count > 0)
            {
                foreach (InkRecognizer recognizer in recoView)
                {
                    RecoName.Items.Add(recognizer.Name);
                }
            }
            else
            {
                RecoName.IsEnabled = false;
                RecoName.Items.Add("No Recognizer Available");
            }
            RecoName.SelectedIndex = 0;

            // Set the text services so we can query when language changes
            textServiceManager = CoreTextServicesManager.GetForCurrentView();
            textServiceManager.InputLanguageChanged += TextServiceManager_InputLanguageChanged;

            SetDefaultRecognizerByCurrentInputMethodLanguageTag();

            // Initialize reco tooltip
            recoTooltip         = new ToolTip();
            recoTooltip.Content = InstallRecoText;
            ToolTipService.SetToolTip(InstallReco, recoTooltip);

            // Initialize the InkCanvas
            inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
            inkCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Mouse | Windows.UI.Core.CoreInputDeviceTypes.Pen | Windows.UI.Core.CoreInputDeviceTypes.Touch;

            this.Unloaded    += Scenario2_Unloaded;
            this.SizeChanged += Scenario2_SizeChanged;
        }
示例#3
0
        void Canvas_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            if (DrawingTool != "Eraser")
            {
                Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Cross, 1);
            }
            else
            {
                Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.UniversalNo, 1);
            }
            Canvas     canvas     = sender as Canvas;
            InkManager inkManager = MedcialInkManager;

            switch (DrawingTool)
            {
            case "Pencil":
            {
                var MyDrawingAttributes = new InkDrawingAttributes();
                MyDrawingAttributes.Size       = new Size(StrokeThickness, StrokeThickness);
                MyDrawingAttributes.Color      = BorderColor;
                MyDrawingAttributes.FitToCurve = true;
                inkManager.SetDefaultDrawingAttributes(MyDrawingAttributes);

                PreviousContactPoint = e.GetCurrentPoint(canvas).Position;
                if (e.GetCurrentPoint(canvas).Properties.IsLeftButtonPressed)
                {
                    // Pass the pointer information to the InkManager.
                    inkManager.ProcessPointerDown(e.GetCurrentPoint(canvas));
                    PenID     = e.GetCurrentPoint(canvas).PointerId;
                    e.Handled = true;
                }
            }
            break;

            case "Eraser":
            {
                Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.UniversalNo, 1);
                StartPoint             = e.GetCurrentPoint(canvas).Position;
                Pencil                 = new Polyline();
                Pencil.Stroke          = new SolidColorBrush(Colors.White);
                Pencil.StrokeThickness = 10;
                canvas.Children.Add(Pencil);
            }
            break;

            default:
                break;
            }
        }
示例#4
0
        private void StrokeInput_StrokeContinued(InkStrokeInput sender, PointerEventArgs args)
        {
            // Coge el punto por el que ha pasado el cursor pulsado
            Point point = new Point(args.CurrentPoint.Position.X, args.CurrentPoint.Position.Y);

            // Lo añade a la lista de puntos
            points.Add(point);

            // Si la lista tiene más de un punto
            if (points.Count > 1)
            {
                // Creau una lista de InkPoints a partir de la lista de puntos, necesaria para hacer el stroke
                List <InkPoint> inkpoints = new List <InkPoint>();

                foreach (Point p in points)
                {
                    inkpoints.Add(new InkPoint(p, 0.5f));
                }

                // Crea el stroke a partir de los inkpoints
                InkStroke stroke = builder.CreateStrokeFromInkPoints(inkpoints, System.Numerics.Matrix3x2.Identity);

                // Copia los atributos de dibujado (color y eso) del canvas original
                InkDrawingAttributes ida = inkCanvas.InkPresenter.CopyDefaultDrawingAttributes();
                stroke.DrawingAttributes = ida;

                // Le añadae el stroke creado al canvas de copia
                //canvas2.InkPresenter.StrokeContainer.AddStroke(stroke);

                List <clsPunto> punticos = new List <clsPunto>();

                foreach (Point p in points)
                {
                    punticos.Add(new clsPunto(p.X, p.Y, ida.Color));
                }

                if (conn.State == ConnectionState.Connected)
                {
                    proxy.Invoke("strokeDraw", punticos, viewModel.Partida.NombreSala);
                }

                // Guarda el ultimo punto
                Point ultimo = points.Last <Point>();

                // Vacía la lista de puntos y le añade el ultimo del anterior stroke, para que el dibujado no de "saltos"
                points = new List <Point>();
                points.Add(ultimo);
            }
        }
        public Scenario2()
        {
            this.InitializeComponent();
            //read language related resource file .strings/en or zh-cn/resources.resw
            Run run1 = new Run();

            run1.Text = ResourceManagerHelper.ReadValue("Description2_p1");
            this.textDes.Inlines.Add(run1);
            this.textDes.Inlines.Add(new LineBreak());

            // Initialize drawing attributes. These are used in inking mode.
            InkDrawingAttributes drawingAttributes = new InkDrawingAttributes();

            drawingAttributes.Color = Windows.UI.Colors.Red;
            double penSize = 4;

            drawingAttributes.Size           = new Windows.Foundation.Size(penSize, penSize);
            drawingAttributes.IgnorePressure = false;
            drawingAttributes.FitToCurve     = true;

            // Show the available recognizers
            inkRecognizerContainer = new InkRecognizerContainer();
            recoView = inkRecognizerContainer.GetRecognizers();
            if (recoView.Count > 0)
            {
                foreach (InkRecognizer recognizer in recoView)
                {
                    RecoName.Items.Add(recognizer.Name);
                }
            }
            else
            {
                RecoName.IsEnabled = false;
                RecoName.Items.Add("No Recognizer Available");
            }
            RecoName.SelectedIndex = 0;

            // Set the text services so we can query when language changes
            textServiceManager = CoreTextServicesManager.GetForCurrentView();
            textServiceManager.InputLanguageChanged += TextServiceManager_InputLanguageChanged;

            SetDefaultRecognizerByCurrentInputMethodLanguageTag();

            // Initialize the InkCanvas
            inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
            inkCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Mouse | Windows.UI.Core.CoreInputDeviceTypes.Pen | Windows.UI.Core.CoreInputDeviceTypes.Touch;

            this.SizeChanged += Scenario2_SizeChanged;
        }
        /// <summary>
        /// 設定其他的屬性
        /// </summary>
        private void SetDrawingAttributes()
        {
            var attributes = new InkDrawingAttributes
            {
                Color             = Colors.GreenYellow,
                Size              = new Size(18, 18),
                DrawAsHighlighter = true,
                FitToCurve        = true,
                IgnorePressure    = false,
                IgnoreTilt        = false,
                PenTip            = PenTipShape.Rectangle,
            };

            inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(attributes);
        }
 public static void DemoStrokeOrder(Canvas canvas, InkCanvas inkCanvas, int[] correspondence)
 {
     for (int i = 0; i < correspondence.Length; i++)
     {
         if (correspondence[i] != i)
         {
             InkStroke            wrongOrderStroke  = inkCanvas.InkPresenter.StrokeContainer.GetStrokes()[i];
             InkDrawingAttributes drawingAttributes = new InkDrawingAttributes();
             drawingAttributes.Color            = Windows.UI.Colors.Orange;
             drawingAttributes.PenTip           = PenTipShape.Circle;
             drawingAttributes.Size             = new Size(20, 20);
             wrongOrderStroke.DrawingAttributes = drawingAttributes;
         }
     }
 }
示例#8
0
        CreateInkDrawingAttributesCore(Brush brush, double strokeWidth)
        {
            InkDrawingAttributes inkDrawingAttributes = new InkDrawingAttributes();

            inkDrawingAttributes.Size = new Windows.Foundation.Size(strokeWidth, strokeWidth * 20);
            SolidColorBrush solidColorBrush = brush as SolidColorBrush;

            inkDrawingAttributes.Color = solidColorBrush?.Color ?? Colors.DeepPink;

            Matrix3x2 matrix = Matrix3x2.CreateRotation(45);

            inkDrawingAttributes.PenTipTransform = matrix;

            return(inkDrawingAttributes);
        }
示例#9
0
        public MainPage()
        {
            SetFigureName();
            this.InitializeComponent();
            inkCanvas.InkPresenter.InputDeviceTypes |= CoreInputDeviceTypes.Mouse;
            toolbar.ActiveTool = toolButtonLasso;     //toolbar에서 lasso툴 고정?
            initValue();

            InkDrawingAttributes drawingAttributes = new InkDrawingAttributes();

            drawingAttributes.Color          = Windows.UI.Colors.Black;
            drawingAttributes.IgnorePressure = false;
            drawingAttributes.FitToCurve     = true;
            inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
        }
示例#10
0
        public DrawingAttributes(Color brushColor, Size brushSize, bool brushFitsToCurve, [Optional] IEnumerable <Color> activePaletteColors)
        {
            _brushColor       = brushColor;
            _brushSize        = brushSize;
            _brushFitsToCurve = brushFitsToCurve;
            _displayText      = false;


            SheetMusic = new SheetMusic();
            var newAttributes = new InkDrawingAttributes {
                FitToCurve = _brushFitsToCurve, Color = _brushColor, Size = _brushSize
            };

            InkStrokeManager.SetDefaultDrawingAttributes(newAttributes);
        }
        public MainPage()
        {
            this.InitializeComponent();

            inkDataCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Mouse | Windows.UI.Core.CoreInputDeviceTypes.Touch | Windows.UI.Core.CoreInputDeviceTypes.Pen;
            var attr = new InkDrawingAttributes();

            attr.Color          = Colors.White;
            attr.IgnorePressure = true;
            attr.PenTip         = PenTipShape.Rectangle;
            attr.Size           = new Size(10, 10);
            inkDataCanvas.InkPresenter.UpdateDefaultDrawingAttributes(attr);
            inkDataCanvas.InkPresenter.StrokesCollected += InkPresenter_StrokesCollected;
            //inkToolbar.InkDrawingAttributes.Color = Colors.White;
        }
示例#12
0
        private void CurrentPen_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            var inkDA = new InkDrawingAttributes()
            {
                Color             = CurrentPen.Color,
                Size              = new Size(CurrentPen.Size, CurrentPen.Size),
                DrawAsHighlighter = CurrentPen.IsHighlighter,
                IgnorePressure    = true
            };

            _inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(inkDA);

            NavigationModel.Options.LastPen = CurrentPen;
            StorageIO.SaveOptions(NavigationModel.Options);
        }
示例#13
0
        public static InkDrawingAttributes PencilDrawingAttributes(Windows.UI.Color color, Size size)
        {
            InkDrawingAttributes drawingAttributes = new InkDrawingAttributes
            {
                Color             = color,
                Size              = size,
                PenTip            = PenTipShape.Circle,
                DrawAsHighlighter = false,
                PenTipTransform   = System.Numerics.Matrix3x2.Identity,
                IgnorePressure    = false,
                FitToCurve        = true,
            };

            return(drawingAttributes);
        }
示例#14
0
        //private void BackButtonBackRequested(object sender, BackRequestedEventArgs e)
        //{
        //    if (EditorContainer.Visibility == Visibility.Visible)
        //    {
        //        CloseEditor();
        //        e.Handled = true;
        //    }
        //}

        private void InitializeInker()
        {
            Inker.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Pen;

            var drawingAttributes = new InkDrawingAttributes
            {
                DrawAsHighlighter = false,
                Color             = Colors.DarkBlue,
                PenTip            = PenTipShape.Circle,
                IgnorePressure    = false,
                Size = new Size(3, 3)
            };

            Inker.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
            Inker.InkPresenter.StrokesCollected += InkPresenter_StrokesCollected;
        }
        public Scenario1()
        {
            this.InitializeComponent();

            InkDrawingAttributes drawingAttributes = new InkDrawingAttributes();

            drawingAttributes.Color          = Windows.UI.Colors.Red;
            drawingAttributes.Size           = new Size(penSize, penSize);
            drawingAttributes.IgnorePressure = false;
            drawingAttributes.FitToCurve     = true;

            inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
            inkCanvas.InkPresenter.InputDeviceTypes  = Windows.UI.Core.CoreInputDeviceTypes.Mouse | Windows.UI.Core.CoreInputDeviceTypes.Pen;
            inkCanvas.InkPresenter.StrokesCollected += InkPresenter_StrokesCollected;
            inkCanvas.InkPresenter.StrokesErased    += InkPresenter_StrokesErased;
        }
        void Initialize()
        {
            this.InitializeComponent();

            penSize = minPenSize + penSizeIncrement * 1;

            InkDrawingAttributes drawingAttributes = new InkDrawingAttributes();

            drawingAttributes.Color          = Windows.UI.Colors.Black;
            drawingAttributes.Size           = new Size(penSize, penSize);
            drawingAttributes.IgnorePressure = false;
            drawingAttributes.FitToCurve     = true;

            inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
            inkCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Mouse | Windows.UI.Core.CoreInputDeviceTypes.Pen | Windows.UI.Core.CoreInputDeviceTypes.Touch;
        }
        public InkNotesControl()
        {
            this.InitializeComponent();

            penSize = minPenSize + penSizeIncrement * PenThickness.SelectedIndex;

            InkDrawingAttributes drawingAttributes = new InkDrawingAttributes();

            drawingAttributes.Color          = Windows.UI.Colors.Red;
            drawingAttributes.Size           = new Size(penSize, penSize);
            drawingAttributes.IgnorePressure = false;
            drawingAttributes.FitToCurve     = true;

            inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
            inkCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Mouse | Windows.UI.Core.CoreInputDeviceTypes.Pen | Windows.UI.Core.CoreInputDeviceTypes.Touch;
        }
示例#18
0
        /// <summary>
        /// Convert a UWP ink drawing attributes to Xamarin
        /// </summary>
        /// <param name="attributes">a UWP ink drawing attributes</param>
        /// <returns>a Xamarin ink drawing attributes</returns>
        public static XInkDrawingAttributes ToXInkDrawingAttributes(this InkDrawingAttributes attributes)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException(nameof(attributes));
            }

            return(new XInkDrawingAttributes
            {
                Color = attributes.Color.ToFormsColor(),
                IgnorePressure = attributes.IgnorePressure,
                Kind = attributes.Kind == Windows.UI.Input.Inking.InkDrawingAttributesKind.Default ? XInkDrawingAttributesKind.Default : XInkDrawingAttributesKind.Pencil,
                PenTip = attributes.PenTip == Windows.UI.Input.Inking.PenTipShape.Circle ? XPenTipShape.Circle : XPenTipShape.Rectangle,
                Size = Convert.ToSingle(attributes.Size.Height)
            });
        }
    public void Init(ref InkCanvas display, ref ComboBox size, ref ComboBox colour)
    {
        string selectedSize             = ((ComboBoxItem)size.SelectedItem).Tag.ToString();
        string selectedColour           = ((ComboBoxItem)colour.SelectedItem).Tag.ToString();
        InkDrawingAttributes attributes = new InkDrawingAttributes();

        attributes.Color          = stringToColour(selectedColour);
        attributes.Size           = new Size(int.Parse(selectedSize), int.Parse(selectedSize));
        attributes.IgnorePressure = false;
        attributes.FitToCurve     = true;
        display.InkPresenter.UpdateDefaultDrawingAttributes(attributes);
        display.InkPresenter.InputDeviceTypes =
            CoreInputDeviceTypes.Mouse |
            CoreInputDeviceTypes.Pen |
            CoreInputDeviceTypes.Touch;
    }
示例#20
0
        public NotificationView()
        {
            this.InitializeComponent();
            suggestions = new ObservableCollection <string>();
            MyInkCanvas.InkPresenter.InputDeviceTypes =
                Windows.UI.Core.CoreInputDeviceTypes.Mouse |
                Windows.UI.Core.CoreInputDeviceTypes.Pen;

            // Set initial ink stroke attributes.
            InkDrawingAttributes drawingAttributes = new InkDrawingAttributes();

            drawingAttributes.Color          = Windows.UI.Colors.Black;
            drawingAttributes.IgnorePressure = false;
            drawingAttributes.FitToCurve     = true;
            MyInkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
        }
        public void SendStrokeInChunks(Guid strokeId, List <InkPoint> points, InkDrawingAttributes drawingAttributes, Action <byte[]> sendAction)
        {
            var isFirstChunk   = true;
            var chunksOfPoints = ChunksOfPoints(points, ChunkSize).ToList();

            for (short i = 0; i < chunksOfPoints.Count; i++)
            {
                var          chunk = chunksOfPoints[i];
                StrokePoints strokePoints;
                if (isFirstChunk)
                {
                    strokePoints = new StrokeDescription
                    {
                        IsPencil          = drawingAttributes.Kind == InkDrawingAttributesKind.Pencil,
                        DrawAsHighlighter = drawingAttributes.DrawAsHighlighter,
                        ColorValues       = new[] { drawingAttributes.Color.A, drawingAttributes.Color.R, drawingAttributes.Color.G, drawingAttributes.Color.B },
                        FitToCurve        = drawingAttributes.FitToCurve,
                        IgnorePressure    = drawingAttributes.IgnorePressure,
                        SizeValues        = new[] { drawingAttributes.Size.Width, drawingAttributes.Size.Height },
                        Opacity           = drawingAttributes.PencilProperties?.Opacity ?? 1.0
                    };
                    isFirstChunk = false;
                }
                else
                {
                    strokePoints = new StrokePoints();
                }
                strokePoints.Id               = strokeId;
                strokePoints.Order            = i;
                strokePoints.NumberOfPackages = (short)chunksOfPoints.Count;

                strokePoints.PointXValues   = chunk.Select(p => p.Position.X).ToArray();
                strokePoints.PointYValues   = chunk.Select(p => p.Position.Y).ToArray();
                strokePoints.PressureValues = chunk.Select(p => p.Pressure).ToArray();

                byte[] protobuf;
                using (var stream = new MemoryStream())
                {
                    Serializer.Serialize(stream, strokePoints);
                    protobuf = stream.ToArray();
                }

                var compressedProtobuf = protobuf.Compress();

                sendAction(compressedProtobuf);
            }
        }
        internal void OnDeserializedMethod(StreamingContext context)
        {
            var finalPointList = new List <InkPoint>(SerializableFinalPointList.Count);

            foreach (var point in SerializableFinalPointList)
            {
                finalPointList.Add(new InkPoint(point.Position, point.Pressure, point.TiltX, point.TiltY, point.Timestamp));
            }

            FinalPointList = finalPointList;

            InkDrawingAttributes pencilAttributes;

            if (SerializableDrawingAttributesKind.HasValue &&
                SerializableDrawingAttributesKind == (short)InkDrawingAttributesKind.Pencil)
            {
                pencilAttributes = InkDrawingAttributes.CreateForPencil();
            }
            else
            {
                pencilAttributes = new InkDrawingAttributes
                {
                    PenTip            = DrawingAttributes.PenTip,
                    PenTipTransform   = DrawingAttributes.PenTipTransform,
                    DrawAsHighlighter = DrawingAttributes.DrawAsHighlighter
                };
            }

            pencilAttributes.Color          = DrawingAttributes.Color;
            pencilAttributes.FitToCurve     = DrawingAttributes.FitToCurve;
            pencilAttributes.IgnorePressure = DrawingAttributes.IgnorePressure;
            pencilAttributes.IgnoreTilt     = DrawingAttributes.IgnoreTilt;
            pencilAttributes.Size           = DrawingAttributes.Size;

            if (SerializableDrawingAttributesPencilProperties.HasValue)
            {
                pencilAttributes.PencilProperties.Opacity = SerializableDrawingAttributesPencilProperties.Value;
            }

            DrawingAttributesIgnored = pencilAttributes;

            // Empty unused values
            SerializableDrawingAttributesPencilProperties = null;
            SerializableFinalPointList        = null;
            SerializableDrawingAttributesKind = null;
        }
示例#23
0
        private static void PenSize(DependencyObject d,
                                    DependencyPropertyChangedEventArgs e)
        {
            InkCanvas ink = d as InkCanvas;

            if (ink == null)
            {
                return;
            }

            InkDrawingAttributes drawingAttributes = ink.InkPresenter.CopyDefaultDrawingAttributes();
            var size = Convert.ToInt32(e.NewValue);

            drawingAttributes.Size = new Size(size, size);

            ink.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
        }
示例#24
0
        private static void PenColor(DependencyObject d,
                                     DependencyPropertyChangedEventArgs e)
        {
            InkCanvas ink = d as InkCanvas;

            if (ink == null)
            {
                return;
            }

            InkDrawingAttributes drawingAttributes = ink.InkPresenter.CopyDefaultDrawingAttributes();
            var brush = e.NewValue as SolidColorBrush;

            drawingAttributes.Color = brush.Color;

            ink.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
        }
        // <SnippetSetInitialStrokeAttributes>
        public MainPage()
        {
            this.InitializeComponent();

            // Set supported inking device types.
            inkCanvas.InkPresenter.InputDeviceTypes =
                Windows.UI.Core.CoreInputDeviceTypes.Mouse |
                Windows.UI.Core.CoreInputDeviceTypes.Pen;

            // Set initial ink stroke attributes.
            InkDrawingAttributes drawingAttributes = new InkDrawingAttributes();

            drawingAttributes.Color          = Windows.UI.Colors.Black;
            drawingAttributes.IgnorePressure = false;
            drawingAttributes.FitToCurve     = true;
            inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
        }
示例#26
0
        public InkPage()
        {
            InitializeComponent();

            InkCanvas.InkPresenter.InputDeviceTypes =
                Windows.UI.Core.CoreInputDeviceTypes.Mouse |
                Windows.UI.Core.CoreInputDeviceTypes.Pen;

            var drawingAttributes = new InkDrawingAttributes
            {
                Color          = Windows.UI.Colors.Black,
                IgnorePressure = false,
                FitToCurve     = true
            };

            InkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
        }
示例#27
0
        public TestUserControl()
        {
            this.InitializeComponent();

            inkcanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Pen | Windows.UI.Core.CoreInputDeviceTypes.Mouse | Windows.UI.Core.CoreInputDeviceTypes.Touch;
            InkDrawingAttributes attributes = new InkDrawingAttributes();

            attributes.Color = Colors.White;
            inkcanvas.InkPresenter.UpdateDefaultDrawingAttributes(attributes);

            String      mediaFilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MicrosoftLogo.mp4");
            String      mediaFileUri  = "file:///" + mediaFilePath.Replace('\\', '/');
            MediaSource mediaSource   = MediaSource.CreateFromUri(new Uri(mediaFileUri));

            mediaplayerelement.Source = new MediaPlaybackItem(mediaSource);
            mediaplayerelement.MediaPlayer.IsLoopingEnabled = true;
        }
示例#28
0
        private static void PenTypeChanged(DependencyObject d,
                                           DependencyPropertyChangedEventArgs e)
        {
            InkCanvas ink = d as InkCanvas;

            if (ink == null)
            {
                return;
            }

            InkDrawingAttributes drawingAttributes = ink.InkPresenter.CopyDefaultDrawingAttributes();

            var penType = e.NewValue as PenType?;

            if (penType == null)
            {
                return;
            }

            switch (penType)
            {
            case PenType.Ballpoint:
                drawingAttributes.PenTip            = PenTipShape.Circle;
                drawingAttributes.DrawAsHighlighter = false;
                drawingAttributes.PenTipTransform   = System.Numerics.Matrix3x2.Identity;
                break;

            case PenType.Calligraphy:
                drawingAttributes.PenTip            = PenTipShape.Rectangle;
                drawingAttributes.DrawAsHighlighter = true;
                drawingAttributes.PenTipTransform   = System.Numerics.Matrix3x2.Identity;
                break;

            case PenType.Highlighter:
                drawingAttributes.PenTip            = PenTipShape.Rectangle;
                drawingAttributes.DrawAsHighlighter = false;

                // Set a 45 degree rotation on the pen tip
                double radians = 45.0 * Math.PI / 180;
                drawingAttributes.PenTipTransform = System.Numerics.Matrix3x2.CreateRotation((float)radians);
                break;
            }

            ink.InkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);
        }
        public void SetColor(ref bool?item, bool?value)
        {
            SetProperty(ref item, value);

            InkDrawingAttributes defaultAttributes = _inkCanvas.InkPresenter.CopyDefaultDrawingAttributes();

            defaultAttributes.PenTip = PenTipShape.Rectangle;
            defaultAttributes.Size   = new Size(3, 3);

            defaultAttributes.Color = new Windows.UI.Color()
            {
                A = 255,
                R = Red == true ? (byte)0xff : (byte)0,
                G = Green == true ? (byte)0xff : (byte)0,
                B = Blue == true ? (byte)0xff : (byte)0
            };
            _inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(defaultAttributes);
        }
示例#30
0
        protected override InkDrawingAttributes CreateInkDrawingAttributesCore(Brush brush, double strokeWidth)
        {
            InkDrawingAttributes inkDrawingAttributes = new InkDrawingAttributes();

            inkDrawingAttributes.PenTip         = PenTipShape.Circle;
            inkDrawingAttributes.IgnorePressure = false;
            SolidColorBrush solidColorBrush = (SolidColorBrush)brush;

            if (solidColorBrush != null)
            {
                inkDrawingAttributes.Color = solidColorBrush.Color;
            }

            inkDrawingAttributes.Size            = new Size(strokeWidth, 2.0f * strokeWidth);
            inkDrawingAttributes.PenTipTransform = System.Numerics.Matrix3x2.CreateRotation((float)(Math.PI * 45 / 180));

            return(inkDrawingAttributes);
        }