Esempio n. 1
0
        private void MyDrawToggle_Toggled(object sender, RoutedEventArgs e)
        {
            if (!IsLoaded)
            {
                return;
            }

            bool isOn = MyDrawToggle.IsOn;

            MyInkCanvas.InkPresenter.IsInputEnabled = isOn;

            // null check needed since this method is called before clear and undo buttons exist
            if (MyClearButton != null)
            {
                MyClearButton.IsEnabled = isOn;
            }
            if (MyUndoButton != null)
            {
                MyUndoButton.IsEnabled = isOn;
            }

            //
            MyResampleToggle.IsEnabled       = !isOn;
            MyResampleSlider.IsEnabled       = !isOn;
            MyScaleToggle.IsEnabled          = !isOn;
            MyScaleSlider.IsEnabled          = !isOn;
            MyTranslateToggle.IsEnabled      = !isOn;
            MyTranslateCenterRadio.IsEnabled = !isOn;
            MyTranslateMedianRadio.IsEnabled = !isOn;
            if (MyTransformButton != null)
            {
                MyTransformButton.IsEnabled = !isOn;
            }

            //
            if (!isOn)
            {
                mySketch = new Sketch(MyInkCanvas.InkPresenter.StrokeContainer.GetStrokes().ToList(), myTimeCollection);
            }
            else
            {
                Sketch clone = SketchTransformation.Clone(mySketch);
                foreach (InkStroke stroke in clone.Strokes)
                {
                    stroke.DrawingAttributes = StrokeVisuals;
                }

                MyInkCanvas.InkPresenter.StrokeContainer.Clear();
                MyInkCanvas.InkPresenter.StrokeContainer.AddStrokes(clone.Strokes);
                myTimeCollection = clone.Times;
            }
        }
Esempio n. 2
0
        private void MyTransformButton_Click(object sender, RoutedEventArgs e)
        {
            if (!IsLoaded)
            {
                return;
            }

            Sketch sketch = SketchTransformation.Clone(mySketch);

            // resample
            if (MyResampleToggle.IsOn)
            {
                int count = (int)MyResampleSlider.Value * 16;
                sketch = SketchTransformation.Resample(sketch, count);
            }

            // scale
            if (MyScaleToggle.IsOn)
            {
                double size = MyScaleSlider.Value * 100;
                sketch = MyScaleSquareRadio.IsChecked.Value ? SketchTransformation.ScaleSquare(sketch, size) : SketchTransformation.ScaleProportional(sketch, size);
            }

            // translate
            if (MyTranslateToggle.IsOn)
            {
                double size = MyScaleSlider.Value * 100;
                Point  k    = new Point(MyInkCanvas.ActualWidth / 2, MyInkCanvas.ActualHeight / 2);
                sketch = MyTranslateMedianRadio.IsChecked.Value ? SketchTransformation.TranslateCentroid(sketch, k) : SketchTransformation.TranslateMedian(sketch, k);
            }

            //
            foreach (InkStroke stroke in sketch.Strokes)
            {
                stroke.DrawingAttributes = StrokeVisuals;
            }
            MyInkCanvas.InkPresenter.StrokeContainer.Clear();
            MyInkCanvas.InkPresenter.StrokeContainer.AddStrokes(sketch.Strokes);
            myTimeCollection = sketch.Times;
        }