コード例 #1
0
ファイル: MainPage.xaml.cs プロジェクト: DHBrett/Graffiti
        /// <summary>
        /// Click handler that allows adding a new test annotation
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddTestAnnotationButtonClick(object sender, RoutedEventArgs e)
        {
            if (TestsList.SelectedItem != null && IsTextSelected())
            {
                var testannotation = new TestAnnotation(
                    new TestBody(((Test)TestsList.SelectedItem).NameForDisplay),
                    new Target("oa:SpecificResource", "",
                    new Selector(SpecHighlitText.Substring(0, Math.Min(50, SpecHighlitText.Length)), SpecHighlitXpath)));

                AnnotationData.AddAnnotation(testannotation, GetSpecID());

                TestsList.SelectedItem = null;
            }

            FindAnnotationsFor(SpecHighlitText);

            _UnsavedChanges = true;
        }
コード例 #2
0
ファイル: AnnotationData.cs プロジェクト: DHBrett/Graffiti
        /// <summary>
        /// Add a new test annotation to the store. Instead of toggling, this just returns if the annotation already exists.
        /// </summary>
        /// <param name="annotation">The annotation to add</param>
        /// <returns>Just a task</returns>
        public static async Task AddAnnotation(TestAnnotation annotation, string ID)
        {
            if (!Exists(annotation))
            {
                data.Add(annotation);

                if (!SampleData.DEMO)
                {
                    var localFolder = ApplicationData.Current.LocalFolder;
                    StorageFile sampleFile = await localFolder.GetFileAsync(ID + TESTSFILENAME);
                    var serialized = await JsonConvert.SerializeObjectAsync(new AnnotationPackage(data).testannotations);
                    await FileIO.WriteTextAsync(sampleFile, serialized);
                }
            }
        }