Beispiel #1
0
        private async void WriteSampleXml()
        {
            StorageFolder saveFolder    = Windows.Storage.ApplicationData.Current.LocalFolder;
            StorageFolder fluencyFolder = await saveFolder.CreateFolderAsync(this.userFluency, CreationCollisionOption.OpenIfExists);

            // Debug.WriteLine(fluencyFolder.Path);

            string      fileName = this.userName + "_" + this.userGender + "_" + this.currentQuestion.Answer + "_" + DateTime.Now.Ticks + (this.IsSkritter ? "_skritter" : string.Empty) + ".xml";
            StorageFile userFile = await fluencyFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);

            XMLHelpers.SketchToXml(userFile, this.currentQuestion.Answer, this.userName, this.userMotherLanguage, this.userFluency, 0, 0, this.WritingInkCanvas.ActualWidth, this.WritingInkCanvas.ActualHeight, this.sketchStrokes);
        }
Beispiel #2
0
        private void MyPage_Loaded(object sender, RoutedEventArgs e)
        {
            // Adjust canvas size
            double writingBorderHeight = WritingBorder.ActualHeight;
            double writingBorderWidth  = WritingBorder.ActualWidth;

            this.writingFrameLength   = writingBorderHeight < writingBorderWidth ? writingBorderHeight : writingBorderWidth;
            this.WritingBorder.Height = WritingBorder.Width = writingFrameLength;

            // Load templates
            this.strokeTemplates    = new Dictionary <string, Sketch>();
            this.templateImageFiles = new Dictionary <string, StorageFile>();
            Task taskLoad = Task.Run(async() => await this.LoadTemplates());

            taskLoad.Wait();

            Debug.WriteLine(this.strokeTemplates.Count);

            // Load questions
            this.LoadQuestions(out questionFiles);
            this.questions = new List <Question>();
            foreach (StorageFile questionFile in questionFiles)
            {
                Question question = null;
                Task     task     = Task.Run(async() => question = await XMLHelpers.XMLToQuestion(questionFile));
                task.Wait();

                this.questions.Add(question);
            }

            this.currentQuestionIndex = 0;
            this.LoadQuestion(0);

            // Initialize user input
            this.timeCollection = new List <List <long> >();
            this.sketchStrokes  = new List <SketchStroke>();

            this.HidePlayButtons();
        }
Beispiel #3
0
        /// <summary>
        /// Load both sketch and image templates
        /// </summary>
        private async Task LoadTemplates()
        {
            StorageFolder localFolder     = Package.Current.InstalledLocation;
            StorageFolder templatesFolder = await localFolder.GetFolderAsync("Templates");

            // StorageFolder strokeTemplateFolder = await templatesFolder.GetFolderAsync("StrokeData");
            StorageFolder strokeTemplateFolder = await templatesFolder.GetFolderAsync("ExpertStrokes");

            StorageFolder imageTemplateFolder = await templatesFolder.GetFolderAsync("Images");

            var strokeTemplateFileList = await strokeTemplateFolder.GetFilesAsync();

            foreach (var strokeTemplateFile in strokeTemplateFileList)
            {
                ReadInTemplateXML(strokeTemplateFile);
            }

            var templateImageFileList = await imageTemplateFolder.GetFilesAsync();

            foreach (var templateImageFile in templateImageFileList)
            {
                templateImageFiles.Add(XMLHelpers.RemoveExtension(templateImageFile.Name), templateImageFile);
            }
        }
Beispiel #4
0
        private async void ReadInTemplateXML(StorageFile file)
        {
            Sketch sketch = await XMLHelpers.XMLToSketch(file);

            strokeTemplates.Add(sketch.Label, sketch);
        }