Exemplo n.º 1
0
        private Sketch Normalize(Sketch original)
        {
            Sketch sketch = SketchTools.Clone(original);

            sketch = SketchTransformation.Resample(sketch, N);
            sketch = SketchTransformation.ScaleSquare(sketch, Size);
            sketch = SketchTransformation.TranslateCentroid(sketch, K);

            return(sketch);
        }
Exemplo n.º 2
0
        private void MyCalculateButton_Click(object sender, RoutedEventArgs e)
        {
            SketchPair input    = myInputPairs[MyInputsComboBox.SelectedIndex];
            SketchPair template = myInputPairs[MyTemplatesComboBox.SelectedIndex];

            double distance1   = SketchTools.Distance(input.Transformed, template.Transformed);
            double distance2   = SketchTools.Distance(template.Transformed, input.Transformed);
            double minDistance = Math.Min(distance1, distance2);

            MyLrDistanceText.Text  = "" + distance1;
            MyRlDistanceText.Text  = "" + distance2;
            MyMinDistanceText.Text = "" + minDistance;
        }
Exemplo n.º 3
0
        private void MyTemplatesComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!IsLoaded)
            {
                return;
            }

            MyTemplateInkCanvas.InkPresenter.StrokeContainer.Clear();

            int    index  = MyTemplatesComboBox.SelectedIndex;
            Sketch sketch = SketchTools.Clone(myTemplatePairs[index].Transformed);

            MyTemplateInkCanvas.InkPresenter.StrokeContainer.AddStrokes(sketch.Strokes);
        }
Exemplo n.º 4
0
        private async Task ReadData()
        {
            // get directory of model templates
            string root          = Package.Current.InstalledLocation.Path;
            string inputsPath    = root + @"\Assets\Inputs\";
            string templatesPath = root + @"\Assets\Models\";

            //
            StorageFolder inputsFolder = await StorageFolder.GetFolderFromPathAsync(inputsPath);

            StorageFolder templatesFolder = await StorageFolder.GetFolderFromPathAsync(templatesPath);

            //
            List <StorageFile> inputFiles    = new List <StorageFile>();
            List <StorageFile> templateFiles = new List <StorageFile>();

            foreach (StorageFile file in await inputsFolder.GetFilesAsync())
            {
                if (file.Name.EndsWith(".xml"))
                {
                    inputFiles.Add(file);
                }
            }
            foreach (StorageFile file in await templatesFolder.GetFilesAsync())
            {
                if (file.Name.EndsWith(".xml"))
                {
                    templateFiles.Add(file);
                }
            }

            //
            myInputs         = new List <Sketch>();
            myTemplates      = new List <Sketch>();
            myInputLabels    = new List <string>();
            myTemplateLabels = new List <string>();
            foreach (StorageFile file in inputFiles)
            {
                Sketch sketch = await SketchTools.ReadXml(file, PEN_DRAWING_ATTRIBUTES); myInputs.Add(sketch); myInputLabels.Add(sketch.Label);
            }
            foreach (StorageFile file in templateFiles)
            {
                Sketch sketch = await SketchTools.ReadXml(file, PEN_DRAWING_ATTRIBUTES); myTemplates.Add(sketch); myTemplateLabels.Add(sketch.Label);
            }
        }