Beispiel #1
0
 private async Task SetImageAsync(SetImageTrace trace)
 {
     using (var strm = await trace.File.OpenReadAsync())
     {
         await SetImageAsync(strm);
     }
 }
Beispiel #2
0
        /// <summary>
        ///  文字列にシリアライズされた手描き入力を復元する.
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        private static InputTraceBase ParseTrace(string text)
        {
            JsonArray jsonArray;

            if (!JsonArray.TryParse(text, out jsonArray))
            {
                return(null);
            }

            InputTraceKind kind;

            if (!Enum.TryParse(jsonArray.GetStringAt(0), out kind))
            {
                return(null);
            }

            InputTraceBase trace;

            switch (kind)
            {
            case InputTraceKind.BeginStroke:
                trace = new BeginStrokeTrace();
                break;

            case InputTraceKind.MoveStroke:
                trace = new MoveStrokeTrace();
                break;

            case InputTraceKind.EndStroke:
                trace = new EndStrokeTrace();
                break;

            case InputTraceKind.RemoveStroke:
                trace = new RemoveStrokeTrace();
                break;

            case InputTraceKind.SetStrokeColor:
                trace = new SetStrokeColorTrace();
                break;

            case InputTraceKind.SetStrokeThickness:
                trace = new SetStrokeThicknessTrace();
                break;

            case InputTraceKind.SetBackgroundColor:
                trace = new SetBackgroundColorTrace();
                break;

            case InputTraceKind.SetImage:
                trace = new SetImageTrace();
                break;

            default:
                return(null);
            }

            trace.LoadFromJson(jsonArray);
            return(trace);
        }
Beispiel #3
0
        public async Task SetImageAsync(Windows.Storage.StorageFile imageFile, bool deferred = false)
        {
            var trace = new SetImageTrace()
            {
                Timestamp = DateTime.UtcNow.Ticks,
                FileName  = imageFile.Name,
                File      = imageFile,
                Source    = InputTraceFileSource.CreateNew,
            };

            await SetImageAsync(trace);

            if (deferred)
            {
                this.inputRecorderForNewTrace.AddDeferredTrace(trace);
            }
            else
            {
                this.inputRecorderForNewTrace.Add(trace);
            }
        }