コード例 #1
0
        public override void SetBrushStyle(VectorBrushStyle value)
        {
            StopSelectionMode();
            switch (mBrushStyle = value)
            {
            case VectorBrushStyle.Pen:
                mActiveTool = new PenTool();
                break;

            case VectorBrushStyle.Felt:
                mActiveTool = new FeltTool();
                break;

            case VectorBrushStyle.Brush:
                mActiveTool = new BrushTool();
                break;

            case VectorBrushStyle.Selection:
                throw new InvalidOperationException("");

            default:
                throw new Exception("Unknown brush type");
            }
            mActiveTool.PointsAdded += OnPointsAdded;
        }
コード例 #2
0
        public VectorStrokeHandler(Renderer renderer, VectorBrushStyle style, MediaColor color)
            : base(renderer, color)
        {
            BrushColor = color;
            SetBrushStyle(style);

            // Spatial Model
            mSpatialModel                 = new SpatialModel(new VectorInkStrokeFactory());
            mSpatialModel.StrokeAdded    += OnSpatialModelStrokeAdded;
            mSpatialModel.StrokeRemoved  += OnSpatialModelStrokeRemoved;
            mSpatialModel.StrokeSelected += OnSpatialModelStrokeSelected;
            mSpatialModel.EraseFinished  += OnSpatialModelEraseFinished;
            mSpatialModel.SelectStarted  += OnSpatialModelSelectStarted;
            mSpatialModel.SelectFinished += OnSpatialModelSelectFinished;

            WorkItemHandler workItemHandler = new WorkItemHandler((IAsyncAction action) =>
            {
                try
                {
                    mSpatialModel.StartProcessingJobs();
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Trace.WriteLine($"Exception: {ex.Message}");
                }
            });

            mSpatialModelLoopWorker = Windows.System.Threading.ThreadPool.RunAsync(workItemHandler, WorkItemPriority.High, WorkItemOptions.TimeSliced);
        }
コード例 #3
0
        /// <summary>
        /// Constructor. Creates rendering brush; initializes graphics
        /// </summary>
        /// <param name="swapChainPanel">SwapChainPanel on which to render captured ink</param>
        /// <param name="brushType">Type of brush to use</param>
        /// <param name="thickness">Relative thickness of brush</param>
        /// <param name="color">Color of ink</param>
        /// <param name="style">Shape of brush (VectorBrush only)</param>
        public Renderer(SwapChainPanel swapChainPanel, VectorBrushStyle style, MediaColor color)
        {
            StrokeHandler = new VectorStrokeHandler(this, style, color);

            mSwapChainPanel         = swapChainPanel;
            Graphics.GraphicsReady += OnGraphicsReady;
            Graphics.Initialize(mSwapChainPanel, false);
        }
コード例 #4
0
        public VectorInkBuilder(VectorBrushStyle brushStyle)
        {
            BrushPolygon bp4  = new BrushPolygon(0.0f, VectorBrushFactory.CreateEllipseBrush(4, 1.0f, 1.0f));
            BrushPolygon bp8  = new BrushPolygon(2.0f, VectorBrushFactory.CreateEllipseBrush(8, 1.0f, 1.0f));
            BrushPolygon bp16 = new BrushPolygon(6.0f, VectorBrushFactory.CreateEllipseBrush(16, 1.0f, 1.0f));
            BrushPolygon bp32 = new BrushPolygon(18.0f, VectorBrushFactory.CreateEllipseBrush(32, 1.0f, 1.0f));

            mBrush = new VectorBrush(bp4, bp8, bp16, bp32);

            BrushStyle = brushStyle;
        }
コード例 #5
0
        public VectorInkControl(VectorBrushStyle brushStyle, MediaColor brushColor, InkModel inkDocument = null)
        {
            InitializeComponent();

            mBrushStyle = brushStyle;
            mInkBuilder = new VectorInkBuilder(brushStyle);

            BrushColor = brushColor;

            LoadInk(inkDocument);

            StartProcessingInput();
        }
コード例 #6
0
        private void CheckControlType(VectorBrushStyle brushStyle, ToggleButton btn)
        {
            var inkCtrl = NavFrame.Content as VectorInkControl;

            if (inkCtrl == null)
            {
                SetCurrentControl(new VectorInkControl(brushStyle, BrushColor));
            }
            else
            {
                inkCtrl.BrushStyle = brushStyle;
            }
            ToggleBrushButton(btn);
        }
コード例 #7
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();
     }
 }