Exemplo n.º 1
0
        private async void MyLoadFileButton_Click(object sender, RoutedEventArgs e)
        {
            FileOpenPicker picker = new FileOpenPicker();

            picker.SuggestedStartLocation = PickerLocationId.Desktop;
            picker.ViewMode = PickerViewMode.List;
            picker.FileTypeFilter.Add("*");

            StorageFile file = await picker.PickSingleFileAsync();

            if (file == null)
            {
                return;
            }

            mySketch = await SketchTools.XmlToSketch(file, PEN_VISUALS);

            MyInkStrokes.Clear();
            MyInkStrokes.AddStrokes(mySketch.Strokes);
        }
Exemplo n.º 2
0
        private void MyTransformDataButton_Click(object sender, RoutedEventArgs e)
        {
            if (mySketch == null || MyInkStrokes.GetStrokes().Count == 0)
            {
                return;
            }

            Sketch sketch = null;

            MyInkStrokes.Clear();
            sketch = SketchTools.Clone(mySketch);

            if (!MyResampleToggle.IsOn && !MyScaleToggle.IsOn && !MyTranslateToggle.IsOn && !MyFrameToggle.IsOn)
            {
                MyInkStrokes.AddStrokes(sketch.Strokes);
                return;
            }

            if (MyResampleToggle.IsOn)
            {
                int n = int.Parse(MyResampleCountTextBox.Text);

                sketch = SketchTransformation.Resample(sketch, n);
            }

            if (MyScaleToggle.IsOn)
            {
                double size = double.Parse(MyScaleSizeTextBox.Text);

                if (MyScaleSquareRadio.IsChecked.Value)
                {
                    sketch = SketchTransformation.ScaleSquare(sketch, size);
                }
                else if (MyScaleProportionalRadio.IsChecked.Value)
                {
                    sketch = SketchTransformation.ScaleProportional(sketch, size);
                }
                else if (MyScaleFrameRadio.IsChecked.Value)
                {
                    sketch = SketchTransformation.ScaleFrame(sketch, size);
                }
            }

            if (MyTranslateToggle.IsOn)
            {
                Point k = new Point(MyInkCanvas.ActualWidth / 2, MyInkCanvas.ActualHeight / 2);

                if (MyTranslateCentroidRadio.IsChecked.Value)
                {
                    sketch = SketchTransformation.TranslateCentroid(sketch, k);
                }
                else if (MyTranslateMedianRadio.IsChecked.Value)
                {
                    sketch = SketchTransformation.TranslateMedian(sketch, k);
                }
                else if (MyTranslateFrameRadio.IsChecked.Value)
                {
                    sketch = SketchTransformation.TranslateFrame(sketch, k);
                }
            }

            if (MyFrameToggle.IsOn)
            {
                List <InkStroke> frameStrokes = GetFrameStrokes(sketch);
                sketch.Strokes.AddRange(frameStrokes);
            }

            MyInkStrokes.AddStrokes(sketch.Strokes);
        }