public void SelectCanvas(int canvasIndex) { InkCanvas oldInkCanvas = _currentInkCanvas; _currentInkCanvas = (InkCanvas)_canvasList.Children[canvasIndex]; //copy images & strokes if (oldInkCanvas != null) { foreach (Image uIElement in oldInkCanvas.GetSelectedElements().OfType<Image>()) { oldInkCanvas.Children.Remove(uIElement); _currentInkCanvas.Children.Add(uIElement); } foreach (Stroke stroke in oldInkCanvas.GetSelectedStrokes()) { if (Keyboard.IsKeyDown(Key.LeftShift)) _currentInkCanvas.Strokes.Add(stroke.Clone()); if (Keyboard.IsKeyDown(Key.LeftAlt)) { oldInkCanvas.Strokes.Remove(stroke); _currentInkCanvas.Strokes.Add(stroke); } } } //hide all canvases foreach (InkCanvas inkCanvas in _canvasList.Children) { inkCanvas.Opacity = .2; inkCanvas.IsHitTestVisible = false; } _currentInkCanvas.IsHitTestVisible = true; _currentInkCanvas.Opacity = 1; //SetMode(InkCanvasEditingMode.Select, CustomMode.select); _currentInkCanvas.Select(new StrokeCollection()); if (null != oldInkCanvas) oldInkCanvas.Select(new StrokeCollection()); }
public void SelectCanvas(int i) { InkCanvas _oldInkCanvas = _InkCanvas; _InkCanvas = (InkCanvas)_CanvasList.Children[i]; if (_oldInkCanvas != null) { foreach (Image _UIElement in _oldInkCanvas.GetSelectedElements().OfType<Image>().ToList()) { _oldInkCanvas.Children.Remove(_UIElement); _InkCanvas.Children.Add(_UIElement); } foreach (Stroke _Stroke in _oldInkCanvas.GetSelectedStrokes()) { if (Keyboard.IsKeyDown(Key.LeftShift)) _InkCanvas.Strokes.Add(_Stroke.Clone()); if (Keyboard.IsKeyDown(Key.LeftAlt)) { _oldInkCanvas.Strokes.Remove(_Stroke); _InkCanvas.Strokes.Add(_Stroke); } } } foreach (InkCanvas _InkCanvas1 in _CanvasList.Children) { _InkCanvas1.Opacity = .2; _InkCanvas1.IsHitTestVisible = false; } _InkCanvas.IsHitTestVisible = true; _InkCanvas.Opacity = 1; //SetMode(InkCanvasEditingMode.Select, CustomMode.select); _InkCanvas.Select(new StrokeCollection()); if (null != _oldInkCanvas) _oldInkCanvas.Select(new StrokeCollection()); }