Example #1
0
        /// <summary>
        ///  ファイルから読み込む.
        /// </summary>
        /// <returns></returns>
        public async Task <bool> LoadAsync()
        {
            this.InputRecorder.Clear();
            if (String.IsNullOrEmpty(this.InternalName))
            {
                return(true);
            }

            try
            {
                var folder = await ApplicationData.Current.LocalFolder.GetFolderAsync(this.InternalName);

                var serializer = new InputTraceSerializer()
                {
                    TargetFolder = folder,
                };
                var traces = await serializer.DeserializeAsync();

                if (traces == null)
                {
                    return(false);
                }
                this.InputRecorder.SetTraces(traces);
                return(true);
            }
            catch (System.IO.FileNotFoundException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                return(false);
            }
        }
Example #2
0
        /// <summary>
        ///  ファイルとして保存する.
        /// </summary>
        /// <returns></returns>
        public async Task <bool> SaveAsync()
        {
            StorageFolder folder;

            if (!String.IsNullOrEmpty(this.InternalName))
            {
                folder = await ApplicationData.Current.LocalFolder.GetFolderAsync(this.InternalName);
            }
            else
            {
                folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(DateTime.UtcNow.Ticks.ToString(), CreationCollisionOption.GenerateUniqueName);

                if (folder != null)
                {
                    this.InternalName = folder.Name;
                    this.DisplayName  = DateTime.Now.ToString();
                }
            }
            if (folder == null)
            {
                return(false);
            }

            var serializer = new InputTraceSerializer()
            {
                TargetFolder = folder,
            };

            await serializer.SerializeAsync(this.InputRecorder);

            return(true);
        }