Beispiel #1
0
        /// <summary>
        ///  背景の色を設定する.
        /// </summary>
        public void SaveSetBackgroundColorTrace()
        {
            var bgColor    = this.BackgroundColor;
            var colorbrush = this.layoutRoot.Background as SolidColorBrush;

            System.Diagnostics.Debug.WriteLine("SaveSetBackgroundColorTrace: {0}", bgColor);

            // 今透明
            //   --> 透明にするなら記録の必要なし
            // 今透明でない
            //   --> 同じ色にするなら記録の必要なし
            if ((colorbrush == null) || (colorbrush.Color.A == 0))
            {
                if (bgColor.A == 0)
                {
                    return;
                }
            }
            else
            {
                if (bgColor == colorbrush.Color)
                {
                    return;
                }
            }

            var trace = new SetBackgroundColorTrace()
            {
                Timestamp = DateTimeOffset.UtcNow.Ticks,
                Color     = this.BackgroundColor,
            };

            this.inputRecorderForNewTrace.Add(trace);
            SetBackgroundColor(trace);
        }
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
        /// <summary>
        ///  背景の色を設定する.
        /// </summary>
        /// <param name="trace"></param>
        private void SetBackgroundColor(SetBackgroundColorTrace trace)
        {
            System.Diagnostics.Debug.WriteLine("SetBackgroundColorTrace: {0}", trace.Color);
            //var colorbrush = this.layoutRoot.Background as SolidColorBrush;
            //if ((colorbrush != null) && (colorbrush.Color == trace.Color))
            //{
            //    return;
            //}
            //else if ((colorbrush == null) && (this.BackgroundColor.A == 0))
            //{
            //    return;
            //}

            this.layoutRoot.Background = new SolidColorBrush(trace.Color);
        }