示例#1
0
        /// <summary>
        /// Changes ink to solid color
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void InkButton_Tapped(object sender, TappedRoutedEventArgs e)
        {
            _highlight = false;
            var desiredDrawingAttributes = new InkDrawingAttributes()
            {
                Color             = Colors.Pink,
                DrawAsHighlighter = _highlight,
            };

            _inkPresenter.UpdateDefaultDrawingAttributes(desiredDrawingAttributes);
        }
示例#2
0
        private void InitialInk()
        {
            InkPresenter myInkPresenter = this.inkCanvas.InkPresenter;

            myInkPresenter.InputDeviceTypes =
                Windows.UI.Core.CoreInputDeviceTypes.Pen |
                Windows.UI.Core.CoreInputDeviceTypes.Mouse;
            InkDrawingAttributes myAttributes = myInkPresenter.CopyDefaultDrawingAttributes();

            myAttributes.DrawAsHighlighter = false;
            myAttributes.IgnorePressure    = false;
            myAttributes.FitToCurve        = true;
            myInkPresenter.UpdateDefaultDrawingAttributes(myAttributes);

            //
            inkCanvas.InkPresenter.InputProcessingConfiguration.RightDragAction =
                InkInputRightDragAction.LeaveUnprocessed;
            // Listen for unprocessed pointer events from modified input.
            // The input is used to provide selection functionality.
            inkCanvas.InkPresenter.UnprocessedInput.PointerPressed +=
                UnprocessedInput_PointerPressed;
            inkCanvas.InkPresenter.UnprocessedInput.PointerMoved +=
                UnprocessedInput_PointerMoved;
            inkCanvas.InkPresenter.UnprocessedInput.PointerReleased +=
                UnprocessedInput_PointerReleased;

            // Listen for new ink or erase strokes to clean up selection UI.
            inkCanvas.InkPresenter.StrokeInput.StrokeStarted +=
                StrokeInput_StrokeStarted;
            inkCanvas.InkPresenter.StrokesErased +=
                InkPresenter_StrokesErased;
        }
示例#3
0
        private void UpdatePen()
        {
            if (_inkPresenter != null)
            {
                var defaultAttributes = _inkPresenter.CopyDefaultDrawingAttributes();

                switch (penColor.SelectedValue.ToString())
                {
                case "Black":
                    defaultAttributes.Color = Colors.Black;
                    break;

                case "Red":
                    defaultAttributes.Color = Colors.Red;
                    break;

                case "Blue":
                    defaultAttributes.Color = Colors.Blue;
                    break;

                case "Green":
                    defaultAttributes.Color = Colors.Green;
                    break;
                }

                defaultAttributes.Size = new Size(strokeSize.Value, strokeSize.Value);
                defaultAttributes.DrawAsHighlighter = drawAsHighlighter.IsChecked.Value;
                defaultAttributes.PenTip            = penTipShape.IsOn ? PenTipShape.Circle : PenTipShape.Rectangle;

                _inkPresenter.UpdateDefaultDrawingAttributes(defaultAttributes);
            }
        }
        public void SetInkColor(Color inkColor)
        {
            var attributes = new InkDrawingAttributes();

            attributes.Color = inkColor;
            InkPresenter.UpdateDefaultDrawingAttributes(attributes);
        }
        protected override void OnAttached()
        {
            base.OnAttached();

            try
            {
                RegisterPropertyChangedAndSaveUnregToken(
                    IsInputEnabledProperty,
                    (o, a) => this.InkPresenter.IsInputEnabled = IsInputEnabled);

                RegisterPropertyChangedAndSaveUnregToken(
                    InputDeviceTypesProperty,
                    (o, a) => this.InkPresenter.InputDeviceTypes = InputDeviceTypes);

                DependencyPropertyChangedCallback detailChanged = (o, a) =>
                {
                    InkPresenter.InputProcessingConfiguration.Mode = CurrentProfile == InkCanvasProfileType.Erasing ? InkInputProcessingMode.Erasing : InkInputProcessingMode.Inking;
                    var att = InkPresenter.CopyDefaultDrawingAttributes();
                    att.Color             = Color;
                    att.PenTip            = PenShape;
                    att.IgnorePressure    = false;
                    att.DrawAsHighlighter = CurrentProfile == InkCanvasProfileType.Highlighting;
                    att.Size = StrokeSize;
                    InkPresenter.UpdateDefaultDrawingAttributes(att);
                };

                RegisterPropertyChangedAndSaveUnregToken(ColorProperty, detailChanged);
                RegisterPropertyChangedAndSaveUnregToken(StrokeSizeProperty, detailChanged);
                RegisterPropertyChangedAndSaveUnregToken(CurrentProfileProperty, (o, a) =>
                {
                    switch (CurrentProfile)
                    {
                    case InkCanvasProfileType.Drawing:
                        ProfileOfDrawing?.ApplyToInkCanvasController(this);
                        break;

                    case InkCanvasProfileType.Highlighting:
                        ProfileOfHighlighting?.ApplyToInkCanvasController(this);
                        break;

                    case InkCanvasProfileType.Erasing:
                        ProfileOfErasing?.ApplyToInkCanvasController(this);
                        break;

                    default:
                        break;
                    }
                    detailChanged(o, a);
                });
                RegisterPropertyChangedAndSaveUnregToken(PenShapeProperty, detailChanged);


                regs.ForEach(i => i.Item3(null, null));
            }
            catch (Exception ex)
            {
                EventRouter.Instance.RaiseEvent(this, ex);
            }
        }
示例#6
0
        private void UpdateDefaultDrawingAttributes()
        {
            if (_inkPresenter != null)
            {
                InkDrawingAttributes drawingAttributes = _inkPresenter.CopyDefaultDrawingAttributes();
                drawingAttributes.IgnorePressure = true;

                switch (drawingColor.SelectedValue.ToString())
                {
                case "Red":
                    drawingAttributes.Color = Colors.Red;
                    break;

                case "Green":
                    drawingAttributes.Color = Colors.Green;
                    break;

                case "Blue":
                    drawingAttributes.Color = Colors.Blue;
                    break;
                }

                drawingAttributes.Size = new Size(drawingSize.Value, drawingSize.Value);
                drawingAttributes.DrawAsHighlighter = drawingDrawAsHighlighter.IsChecked.Value;
                drawingAttributes.FitToCurve        = drawingFitToCurve.IsChecked.Value;
                drawingAttributes.PenTip            = drawingPenTip.IsOn ? PenTipShape.Circle : PenTipShape.Rectangle;



                if (drawingPenTipTransform.IsChecked == true)
                {
                    drawingAttributes.PenTipTransform = Matrix3x2.CreateSkew(4, 4);
                }
                else
                {
                    drawingAttributes.PenTipTransform = Matrix3x2.Identity;
                }

                _inkPresenter.UpdateDefaultDrawingAttributes(drawingAttributes);



                if (chkErasing.IsChecked == true)
                {
                    _inkPresenter.InputProcessingConfiguration.Mode = InkInputProcessingMode.Erasing;
                }
                else
                {
                    _inkPresenter.InputProcessingConfiguration.Mode = InkInputProcessingMode.Inking;
                }



                _inkPresenter.IsInputEnabled = chkIsInputEnabled.IsChecked.Value;
            }
        }
示例#7
0
        private void UpdatePen()
        {
            if (_inkPresenter != null)
            {
                var defaultAttributes = _inkPresenter.CopyDefaultDrawingAttributes();

                defaultAttributes.PenTip = (bool)penTipShape.IsChecked ? PenTipShape.Circle : PenTipShape.Rectangle;

                _inkPresenter.UpdateDefaultDrawingAttributes(defaultAttributes);
            }
        }
        public MainPage()
        {
            this.InitializeComponent();

            _inkPresenter = canvas.InkPresenter;
            _inkPresenter.InputDeviceTypes =
                CoreInputDeviceTypes.Mouse | CoreInputDeviceTypes.Pen | CoreInputDeviceTypes.Touch;
            var defaultAttributes = _inkPresenter.CopyDefaultDrawingAttributes();

            defaultAttributes.Size = new Size(20, 20);
            _inkPresenter.UpdateDefaultDrawingAttributes(defaultAttributes);
        }
示例#9
0
        private void UpdatePen()
        {
            if (_inkPresenter != null)
            {
                var defaultAttributes = _inkPresenter.CopyDefaultDrawingAttributes();

                // If we are using a pencil, changing pentip is not allowed!
                if (defaultAttributes.Kind == InkDrawingAttributesKind.Default)
                {
                    _inkPresenter.UpdateDefaultDrawingAttributes(defaultAttributes);
                }
            }
        }
        private void myCanvas_PointerMoved(object sender, PointerRoutedEventArgs e)
        {
            InkPresenter inkPresenter = myCanvas.InkPresenter;

            inkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Pen | Windows.UI.Core.CoreInputDeviceTypes.Mouse | Windows.UI.Core.CoreInputDeviceTypes.Touch;
            InkDrawingAttributes myAttributes = inkPresenter.CopyDefaultDrawingAttributes();

            myAttributes.Color           = Windows.UI.Colors.Crimson;
            myAttributes.PenTip          = PenTipShape.Circle;
            myAttributes.PenTipTransform = System.Numerics.Matrix3x2.CreateRotation((float)Math.PI / 4);
            myAttributes.Size            = new Size(2, 5);
            inkPresenter.UpdateDefaultDrawingAttributes(myAttributes);
        }
        private void UpdatePen()
        {
            if (_inkPresenter != null)
            {
                var defaultAttributes = _inkPresenter.CopyDefaultDrawingAttributes();

                // If we are using a pencil, changing pentip is not allowed!
                if (defaultAttributes.Kind == InkDrawingAttributesKind.Default)
                {
                    defaultAttributes.PenTip = (bool)penTipShape.IsChecked ? PenTipShape.Circle : PenTipShape.Rectangle;
                    _inkPresenter.UpdateDefaultDrawingAttributes(defaultAttributes);
                }
            }
        }
示例#12
0
        public async void Init(InkCanvas inkCanvas)
        {
            _presenter = inkCanvas.InkPresenter;
            _presenter.InputDeviceTypes =
                CoreInputDeviceTypes.Pen |
                CoreInputDeviceTypes.Mouse |
                CoreInputDeviceTypes.Touch;
            _presenter.UpdateDefaultDrawingAttributes(new InkDrawingAttributes()
            {
                Color          = Colors.White,
                Size           = new Size(22, 22),
                IgnorePressure = true,
                IgnoreTilt     = true,
            });
            StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(
                new Uri($"ms-appx:///Assets/mnist.onnx"));

            _model = await MNISTModel.CreateMNISTModel(file);
        }
示例#13
0
        public MainPage()
        {
            this.InitializeComponent();


            _inkBitmapRenderer = App.BitmapRenderer = new InkBitmapRenderer();

            _inkPresenter = AnnotationInkCanvas.InkPresenter;
            _inkPresenter.InputDeviceTypes =
                CoreInputDeviceTypes.Mouse | CoreInputDeviceTypes.Pen;

            var desiredDrawingAttributes = new InkDrawingAttributes()
            {
                Color             = Colors.Pink,
                DrawAsHighlighter = _highlight,
            };

            _inkPresenter.UpdateDefaultDrawingAttributes(desiredDrawingAttributes);
            _inkPresenter.StrokesCollected += InkPresenter_StrokesCollected;
        }
示例#14
0
        public FunctionGraph()
        {
            InitializeComponent();
            _backgroundColor  = Background.SolidColor();
            _foregroundColor  = Foreground.SolidColor();
            Canvas.ClearColor = _backgroundColor;

            ManipulationMode =
                ManipulationModes.Scale
                | ManipulationModes.TranslateX
                | ManipulationModes.TranslateY
                | ManipulationModes.TranslateInertia
                | ManipulationModes.ScaleInertia;

            _dispatcher     = Window.Current.Dispatcher;
            _currentStrokes = _rootStrokes;

            InkPresenter inkPresenter = InkInput.InkPresenter;

            inkPresenter.UpdateDefaultDrawingAttributes(new InkDrawingAttributes()
            {
                Size  = new Size(4, 4),
                Color = _foregroundColor
            });

            CoreInkIndependentInputSource coreInputSource = CoreInkIndependentInputSource.Create(inkPresenter);

            coreInputSource.PointerMoving   += CoreInputSource_PointerMoving;
            coreInputSource.PointerPressing += CoreInputSource_PointerPressing;

            _inkInputProcessing            = inkPresenter.InputProcessingConfiguration;
            inkPresenter.StrokesCollected += InkPresenter_StrokesCollected;
            _inkSynchronizer = inkPresenter.ActivateCustomDrying();

            SizeChanged += (s, e) => ReduceFunctionDetail();
            RegisterPropertyChangedCallback(BackgroundProperty, OnBackgroundChanged);
            RegisterPropertyChangedCallback(ForegroundProperty, OnForegroundChanged);
        }