Exemple #1
0
 public InkObjectStroke(InkObject ink, StylusPointCollection stylusPoints)
     : base(stylusPoints)
 {
     this.ink = ink;
     inkTool  = ink.CreateFromInkData(ink.inkTool);
     this.DrawingAttributes       = ink.inkDA.Clone();
     this.DrawingAttributes.Color = ink.myInkCanvas.fillColor;
 }
Exemple #2
0
 protected override void OnStylusDown(RawStylusInput rawStylusInput)
 {
     myInkCanvas.isFromFileInk = false;
     inkTool = CreateFromInkData(myInkCanvas.myData);
     inkDA   = myInkCanvas.inkDA.Clone();
     this.DrawingAttributes = inkDA;
     previousPoint          = new Point(double.NegativeInfinity, double.NegativeInfinity);
     base.OnStylusDown(rawStylusInput);
 }
Exemple #3
0
 public InkObject(MyInkCanvas myInkCanvas, bool isInkColorAtEnd)
 {
     this.myInkCanvas     = myInkCanvas;
     this.isInkColorAtEnd = isInkColorAtEnd;
     brush.Opacity        = 0.09;
     inkTool = CreateFromInkData(myInkCanvas.myData);
     inkDA   = myInkCanvas.inkDA.Clone();
     this.DrawingAttributes = inkDA;
 }
Exemple #4
0
        public InkStylusType inkStylusType; //笔尖类型

        public MyInkData Clone()
        {
            MyInkData data = new MyInkData()
            {
                inkRadius = this.inkRadius,
                inkColor  = this.inkColor,
            };

            return(data);
        }
Exemple #5
0
        protected double GetStylusInkDistance(MyInkData data, out Size size)
        {
            double width  = data.inkRadius;;
            double height = data.inkRadius;

            size = new Size(width, height);
            double distance = Math.Max(size.Width, size.Height) * 1.5 + 10;

            return(distance);
        }
Exemple #6
0
 /// <summary>
 /// 初始化墨迹类型和笔尖信息,其初值必须与RibbonTab中的默认选项相同
 /// </summary>
 public MyInkCanvas()
 {
     fillColor   = Colors.Transparent;
     this.myData = new MyInkData()
     {
         inkRadius = 6.0,
         inkColor  = Colors.Red,
     };
     UpdateInkParams();
     SetInkAttributes(InkType.曲线.ToString());
 }
Exemple #7
0
        /// <summary>当收集墨迹时,会自动调用此方法</summary>
        protected override void OnStrokeCollected(InkCanvasStrokeCollectedEventArgs e)
        {
            this.Strokes.Remove(e.Stroke);
            ink.CreateNewStroke(e);
            MyInkData     data = ink.InkStroke.inkTool;
            StringBuilder sb   = new StringBuilder();

            sb.AppendFormat("inkName:{0}#", ink.inkType);
            sb.AppendFormat("inkRadius:{0}#", data.inkRadius);
            Color c = data.inkColor;

            sb.AppendFormat("inkColor:{0},{1},{2},{3}#", c.A, c.R, c.G, c.B);
            sb.AppendFormat("inkStylusType:{0}#", data.inkStylusType);
            ink.InkStroke.AddPropertyData(Guid.NewGuid(), sb.ToString());
            this.Strokes.Add(ink.InkStroke);
            InkCanvasStrokeCollectedEventArgs args = new InkCanvasStrokeCollectedEventArgs(ink.InkStroke);

            base.OnStrokeCollected(args);
        }
Exemple #8
0
        /// <summary>当从文件中加载墨迹时,会自动调用此方法</summary>
        protected override void OnStrokesReplaced(InkCanvasStrokesReplacedEventArgs e)
        {
            isFromFileInk = true;
            StrokeCollection strokes = e.NewStrokes.Clone();

            this.Strokes.Remove(e.NewStrokes);
            base.OnStrokesReplaced(e);

            foreach (var v in strokes)
            {
                this.Strokes.Remove(v);
                Guid      id   = v.GetPropertyDataIds()[0];
                string[]  s    = ((string)v.GetPropertyData(id)).Split('#');
                MyInkData data = new MyInkData();
                for (int i = 0; i < s.Length; i++)
                {
                    string[] property = s[i].Split(':');
                    data.inkStylusType = (InkStylusType)Enum.Parse(typeof(InkStylusType), property[1]);
                    switch (property[0])
                    {
                    case "inkName":
                        this.SetInkAttributes(property[1]);
                        break;

                    case "inkRadius":
                        data.inkRadius = double.Parse(property[1]);
                        break;

                    case "inkColor":
                        string[] c = property[1].Split(',');
                        data.inkColor = Color.FromArgb(byte.Parse(c[0]), byte.Parse(c[1]), byte.Parse(c[2]), byte.Parse(c[3]));
                        break;
                    }
                }
                ink.inkTool = ink.CreateFromInkData(data);
                InkCanvasStrokeCollectedEventArgs args = new InkCanvasStrokeCollectedEventArgs(v);
                this.OnStrokeCollected(args);
            }
        }
Exemple #9
0
        public MyInkData CreateFromInkData(MyInkData data)
        {
            MyInkData tool = data.Clone();

            tool.inkBrush = null;
            if (isInkColorAtEnd)
            {
                GradientStopCollection c = new GradientStopCollection()
                {
                    new GradientStop(Colors.White, 0.05),
                    new GradientStop(Colors.Gold, 0.15),
                    new GradientStop(data.inkColor, 1.0),
                };
                tool.inkBrush = new SolidColorBrush(data.inkColor);
                Brush b = tool.inkBrush;
                tool.inkPen = new Pen(b, tool.inkRadius * 0.5);
            }
            else
            {
                tool.inkBrush = new SolidColorBrush(data.inkColor);
                tool.inkPen   = new Pen(tool.inkBrush, tool.inkRadius * 0.5);
            }
            return(tool);
        }
Exemple #10
0
 public override Point Draw(Point first, MyInkData tool, DrawingContext dc, StylusPointCollection points)
 {
     return(first);
 }
Exemple #11
0
 public abstract Point Draw(Point first, MyInkData tool, DrawingContext dc, StylusPointCollection points);