Example #1
0
 //</Snippet5>
 //<Snippet7>
 void DrawingAttributesChanged(object sender, PropertyDataChangedEventArgs e)
 {
     // Reattach the visual of the DynamicRenderer to the InkPresenter
     // whenever the DrawingAttributes change.
     presenter.DetachVisuals(renderer.RootVisual);
     presenter.AttachVisuals(renderer.RootVisual, renderer.DrawingAttributes);
 }
Example #2
0
        public override void Perform()
        {
            if (TargetInkCanvas.StylusPlugInCollection.Count > 0)
            {
                InkPresenter inkPresenter = TargetInkCanvas.CustomInkPresenter;

                int             index           = CountIndex % TargetInkCanvas.StylusPlugInCollection.Count;
                DynamicRenderer dynamicRenderer = TargetInkCanvas.StylusPlugInCollection[index] as DynamicRenderer;
                if (dynamicRenderer == null)
                {
                    return;
                }

                if (dynamicRenderer != TargetInkCanvas.CustomDynamicRenderer)
                {
                    inkPresenter.DetachVisuals(dynamicRenderer.RootVisual);
                    TargetInkCanvas.StylusPlugInCollection.Remove(dynamicRenderer);
                }
                else
                {
                    // A sign of gotten a stylus plug-in object
                    bool foundOne = false;
                    foreach (DynamicRenderer plugin in TargetInkCanvas.StylusPlugInCollection)
                    {
                        if (plugin != dynamicRenderer)
                        {
                            TargetInkCanvas.CustomDynamicRenderer = plugin;
                            foundOne = true;
                            break;
                        }
                    }
                    if (!foundOne)
                    {
                        TargetInkCanvas.CustomDynamicRenderer = null;
                    }
                }
            }
        }