//protected virtual SolidColorBrush UpdateInkColor(InkBoardSettings inkBoardSettings) //{ // SolidColorBrush solidColorBrush = new SolidColorBrush(inkBoardSettings.InkColor); // solidColorBrush.Freeze(); // return solidColorBrush; //} //protected virtual DrawingAttributes UpdateDrawingAttributes(InkBoardSettings inkBoardSettings) //{ // return new DrawingAttributes // { // FitToCurve = false, // IgnorePressure = false, // StylusTip = StylusTip.Ellipse, // Color = inkBoardSettings.InkColor, // Width = inkBoardSettings.InkThickness, // Height = inkBoardSettings.InkThickness // }; //} private void CreateRealTimeVisuals() { if (_mainContainerVisual != null && _rawInkHostVisual1 == null) { _rawInkHostVisual1 = new DynamicRendererHostVisual(); _rawInkHostVisual2 = new DynamicRendererHostVisual(); _currentHostVisual = null; _mainContainerVisual.Children.Add(_rawInkHostVisual1); _mainContainerVisual.Children.Add(_rawInkHostVisual2); //_renderingThread = DynamicRendererThreadManager.GetCurrentThreadInstance(); } }
DynamicRendererHostVisual _strokeHV; // App thread rendering HostVisual public StrokeInfo(DrawingAttributes drawingAttributes, int stylusDeviceId, int startTimestamp, DynamicRendererHostVisual hostVisual) { _stylusId = stylusDeviceId; _startTime = startTimestamp; _lastTime = _startTime; _drawingAttributes = drawingAttributes.Clone(); // stroke copy for duration of stroke. _strokeNodeIterator = new StrokeNodeIterator(_drawingAttributes); Color color = _drawingAttributes.Color; _opacity = _drawingAttributes.IsHighlighter ? 0 : (double)color.A / (double)StrokeRenderer.SolidStrokeAlpha; color.A = StrokeRenderer.SolidStrokeAlpha; // Set the brush to be used with this new stroke too (since frozen can be shared by threads) SolidColorBrush brush = new SolidColorBrush(color); brush.Freeze(); _fillBrush = brush; _strokeHV = hostVisual; hostVisual.AddStrokeInfoRef(this); // Add ourselves as reference. }
/// <summary> /// Create the visual target /// This method is called from the application context /// </summary> private void CreateRealTimeVisuals() { // Only create if we have a root visual and have not already created them. if (_mainContainerVisual != null && _rawInkHostVisual1 == null) { // Create new VisualTarget and hook up in apps visuals under element. _rawInkHostVisual1 = new DynamicRendererHostVisual(); _rawInkHostVisual2 = new DynamicRendererHostVisual(); _currentHostVisual = null; // Pick a new current HostVisual on first stylus input. _mainContainerVisual.Children.Add(_rawInkHostVisual1); _mainContainerVisual.Children.Add(_rawInkHostVisual2); // NOTE: Do the work later if perf is bad hooking up VisualTargets on StylusDown... // Guarentee that objects are valid when on the DR thread below. //DynamicRendererHostVisual[] myArgs = new DynamicRendererHostVisual[2] { _rawInkHostVisual1, _rawInkHostVisual2 }; // Do this last since we can be reentrant on this call and we want to set // things up so we are all set except for the real time thread visuals which // we set up on first usage. _renderingThread = DynamicRendererThreadManager.GetCurrentThreadInstance(); /* // We are being called by the main UI thread, so invoke a call over to // the inking thread to create the visual targets. // NOTE: Since input rendering uses the same priority we are guanenteed // that this will be processed before any input will try to be rendererd. _renderingThread.ThreadDispatcher.BeginInvoke(DispatcherPriority.Send, (DispatcherOperationCallback)delegate(object args) { DynamicRendererHostVisual[] hostVisuals = (DynamicRendererHostVisual[])args; VisualTarget vt; // Query the VisualTarget properties to initialize them. vt = hostVisuals[0].VisualTarget; vt = hostVisuals[1].VisualTarget; return null; }, myArgs); */ } }