Exemplo n.º 1
0
        public void RenderSelectedStrokes(IEnumerable <Identifier> selectedStrokeIds)
        {
            if (!StrokeHandler.IsSelecting)
            {
                throw new InvalidOperationException("Unexpected call to RenderSelectedStrokes");
            }

            RenderingContext.SetTarget(TranslationLayer);
            RenderingContext.ClearColor(MediaColor.FromArgb(27, 0, 0, 0)); // Black transparent background

            RenderingContext.TransformMatrix = StrokeHandler.TransformationMatrix;

            // Draw the selected strokes
            Rect rect = StrokeHandler.DoRenderSelectedStrokes(RenderingContext, selectedStrokeIds);

            if (selectedStrokeIds.Count() == 0)
            {
                TranslationLayerPainted = false;
            }
            else
            {
                TranslationLayerPainted = true;
            }
            RenderingContext.TransformMatrix = Matrix3x2.Identity;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Completes capture of an ink stroke
        /// </summary>
        private void OnPointerReleased(object sender, PointerRoutedEventArgs args)
        {
            // Ignore events from other pointers
            if (!mPointerManager.OnReleased(args))
            {
                return;
            }

            mSwapChainPanel.ReleasePointerCapture(args.Pointer);

            StrokeHandler.OnReleased(mSwapChainPanel, args);

            if (!StrokeHandler.IsSelecting)
            {
                RenderNewStrokeSegment();

                BlendCurrentStrokesLayerToAllStrokesLayer();

                RenderBackbuffer();
                PresentGraphics();

                var ptrDevice = args.GetCurrentPoint(mSwapChainPanel).PointerDevice;
                StrokeHandler.StoreCurrentStroke(ptrDevice.PointerDeviceType);
            }
        }
Exemplo n.º 3
0
        public void Dispose()
        {
            StopProcessingInput();

            DisposeLayers();

            StrokeHandler.Dispose();

            Utils.SafeDispose(Graphics);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Updates current ink stroke with new pointer input
        /// </summary>
        private void OnPointerMoved(object sender, PointerRoutedEventArgs args)
        {
            // Ignore events from other pointers
            if (!mPointerManager.OnMoved(args))
            {
                return;
            }

            StrokeHandler.OnMoved(mSwapChainPanel, args);
        }
Exemplo n.º 5
0
        public void RenderBackbuffer()
        {
            // Copy the scene to the backbuffer
            RenderingContext.SetTarget(BackBufferLayer);

            RenderingContext.DrawLayer(SceneLayer, null, Wacom.Ink.Rendering.BlendMode.Copy);

            if (StrokeHandler.IsSelecting && TranslationLayerPainted)
            {
                StrokeHandler.DrawTranslation(RenderingContext, TranslationLayer);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initiates capture of an ink stroke
        /// </summary>
        private void OnPointerPressed(object sender, PointerRoutedEventArgs args)
        {
            // If currently there is an unfinished stroke - do not interrupt it
            if (!mPointerManager.OnPressed(args))
            {
                return;
            }

            mSwapChainPanel.CapturePointer(args.Pointer);

            StrokeHandler.OnPressed(mSwapChainPanel, args);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Event handler for Graphics object completing initialization
        /// </summary>
        public virtual void OnGraphicsReady(Graphics sender, object o)
        {
            StrokeHandler.DoGraphicsReady();

            RenderingContext = Graphics.GetRenderingContext();

            CreateLayers();
            ClearLayers();

            StartProcessingInput();
            PresentGraphics();
        }
Exemplo n.º 8
0
 public void SetHandler(RasterBrushStyle brushStyle, MediaColor brushColor)
 {
     if (StrokeHandler is RasterStrokeHandler)
     {
         StrokeHandler.SetBrushStyle(brushStyle);
         StrokeHandler.BrushColor = brushColor;
     }
     else
     {
         StrokeHandler = new RasterStrokeHandler(this, brushStyle, brushColor, Graphics);
         StrokeHandler.DoGraphicsReady();
         ClearLayers();
         PresentGraphics();
     }
 }
Exemplo n.º 9
0
 public void SetHandler(VectorBrushStyle brushStyle, MediaColor brushColor)
 {
     if (StrokeHandler is VectorStrokeHandler)
     {
         StrokeHandler.SetBrushStyle(brushStyle);
         StrokeHandler.BrushColor = brushColor;
     }
     else
     {
         StrokeHandler = new VectorStrokeHandler(this, brushStyle, brushColor);
         // Clear screen
         ClearLayers();
         PresentGraphics();
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Redraw all saved strokes
        /// </summary>
        /// <param name="clipRect">Optional clipping rectangle</param>
        public void RedrawAllStrokes(IEnumerable <Identifier> excluded, Rect?clipRect)
        {
            RenderingContext.SetTarget(AllStrokesLayer, clipRect);
            RenderingContext.ClearColor(StrokeHandler.BackgroundColor);

            StrokeHandler.RenderAllStrokes(RenderingContext, excluded, clipRect);

            // Clear CurrentStroke to prepare for next draw
            RenderingContext.SetTarget(CurrentStrokeLayer);
            RenderingContext.ClearColor(Colors.Transparent);

            RenderBackbuffer();

            // Present backbuffer to the screen
            PresentGraphics();
        }
Exemplo n.º 11
0
        /// <summary>
        /// Discard all captured ink
        /// </summary>
        public void ClearStrokes()
        {
            bool redrawAll = StrokeHandler.IsSelecting;

            // Delete saved strokes
            StrokeHandler.ClearStrokes();

            // Clear screen
            ClearLayers();
            if (redrawAll)
            {
                RedrawAllStrokes(null, null);
                RenderBackbuffer();
            }
            PresentGraphics();
        }
Exemplo n.º 12
0
 public void StopSelectionMode()
 {
     StrokeHandler.StopSelectionMode();
 }
Exemplo n.º 13
0
 public void StartSelectionMode(StrokeHandler.SelectionMode mode)
 {
     StrokeHandler.StartSelectionMode(mode);
 }
Exemplo n.º 14
0
 /// <summary>
 /// Loads serialized ink
 /// </summary>
 /// <param name="inkDocument"></param>
 public virtual void LoadInk(InkModel inkDocument)
 {
     StrokeHandler.LoadInk(inkDocument);
 }