Esempio n. 1
0
 public PaintControl()
 {
     DA = new System.Windows.Ink.DrawingAttributes
     {
         Color = System.Windows.Media.Colors.Black
     };
     Size = 5;
 }
Esempio n. 2
0
        /// <summary>
        /// Create a stroke from an InkStroke. Used when adding the stroke.
        /// </summary>
        /// <param name="stroke"></param>
        /// <param name="dtGuid"></param>
        /// <param name="SAMPLE_RATE"></param>
        public Stroke(System.Windows.Ink.Stroke stroke, Guid dtGuid, float SAMPLE_RATE)
            : this()
        {
            // Get the timestamp for the function using a const Guid
            ulong theTime;

            if (stroke.ContainsPropertyData(dtGuid))
            {
                // MIT file format
                ulong fileTime = (ulong)stroke.GetPropertyData(dtGuid);
                theTime = (fileTime - 116444736000000000) / 10000;
            }
            else
            {
                theTime = ((ulong)DateTime.Now.ToFileTime() - 116444736000000000) / 10000;
            }

            // Set time data for each point and add it to the list of substroke's points
            List <Point> pointsToAdd = new List <Point>();

            System.Windows.Input.StylusPointCollection stylusPoints = stroke.StylusPoints;
            int numPoints = stylusPoints.Count;

            for (int i = 0; i < numPoints; i++)
            {
                // We believe this to be the standard sample rate.  The multiplication by 1,000 is to convert from
                // seconds to milliseconds.
                //
                // Our time is in the form of milliseconds since Jan 1, 1970
                //
                // NOTE: The timestamp for the stroke is made WHEN THE PEN IS LIFTED
                System.Windows.Input.StylusPoint styPoint = stylusPoints[i];
                ulong adjustedTime = theTime - (ulong)((1 / SAMPLE_RATE * 1000) * (numPoints - i));
                Point toAdd        = new Point((float)styPoint.X, (float)styPoint.Y, (float)styPoint.PressureFactor, Convert.ToUInt64(adjustedTime), "point");
                // HACK: Add back in if debugging: if (!pointsToAdd.Contains(toAdd))
                pointsToAdd.Add(toAdd);
            }

            // Create the new substroke using its drawing attributes
            System.Windows.Ink.DrawingAttributes drawingAttributes = stroke.DrawingAttributes;
            Substroke substroke = new Substroke(pointsToAdd);

            substroke.Name      = "substroke";
            substroke.Color     = drawingAttributes.Color.GetHashCode();
            substroke.PenTip    = drawingAttributes.StylusTip.ToString();
            substroke.PenWidth  = (float)drawingAttributes.Width;
            substroke.PenHeight = (float)drawingAttributes.Height;
            substroke.Source    = "InkSketch.canvasStrokeToSketchStroke";
            substroke.Start     = pointsToAdd[0].Id;
            substroke.End       = pointsToAdd[pointsToAdd.Count - 1].Id;
            this.AddSubstroke(substroke);

            // Update the stroke's attributes
            this._xmlAttributes.Name   = "stroke";
            this._xmlAttributes.Time   = (ulong)theTime;
            this._xmlAttributes.Type   = "stroke";
            this._xmlAttributes.Source = "Converter";
        }
Esempio n. 3
0
        private void Init()
        {
            Span_image    = new Image[2];
            Span_image[0] = this.Chat_Span;
            Span_image[1] = this.Pen_Span;

            selectSpan();
            da = new System.Windows.Ink.DrawingAttributes();
            this.Canvas_p.DefaultDrawingAttributes = da;
        }
Esempio n. 4
0
        private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            System.Windows.Ink.DrawingAttributes inkDA = new System.Windows.Ink.DrawingAttributes();
            inkDA.Color          = Colors.Black;
            inkDA.FitToCurve     = false;
            inkDA.Height         = e.NewValue;
            inkDA.Width          = e.NewValue;
            inkDA.IgnorePressure = false;
            inkDA.IsHighlighter  = false;
            inkDA.StylusTip      = System.Windows.Ink.StylusTip.Ellipse;

            inkCanvas1.DefaultDrawingAttributes = inkDA;
        }
Esempio n. 5
0
        private void Init()
        {
            Span_image    = new Image[2];
            Span_image[0] = this.Chat_Span;
            Span_image[1] = this.Pen_Span;
            da            = new System.Windows.Ink.DrawingAttributes();
            this.Canvas_p.DefaultDrawingAttributes = da;


            this.grid_0.Children.Add(test);
            test.SetValue(Grid.RowProperty, 1);
            test.SetValue(Grid.ColumnSpanProperty, 2);

            selectSpan();
        }
Esempio n. 6
0
        public void Init(ClipWindow clipWin)
        {
            win      = clipWin;
            this.ink = clipWin.ink;

            ink.EditingMode = InkCanvasEditingMode.None;
            inkAttr         = ink.DefaultDrawingAttributes;

            lineSizeCb.ItemsSource  = lineSizes;
            lineAlphaCb.ItemsSource = lineAlphas;
            lineColorCb.ItemsSource = lineColors;

            lineSizeCb.SelectedIndex  = 2;
            lineColorCb.SelectedIndex = 0;
            lineAlphaCb.SelectedIndex = 2;
        }
Esempio n. 7
0
        public MainWindow()
        {
            InitializeComponent();

            var drawingAttributes = new System.Windows.Ink.DrawingAttributes
            {
                Color  = Colors.Black,
                Width  = 10,
                Height = 10
            };

            Canvas.DefaultDrawingAttributes = drawingAttributes;
            Canvas.UsesTouchShape           = false;
            var wrap = new GestureTouchPipeline(Canvas);

            wrap.GestureTouchMove += wrap_GestureTouchMove;
            wrap.GestureTouchDown += wrap_GestureTouchDown;
        }
Esempio n. 8
0
        void wrap_GestureTouchMove(object sender, GestureTouchEventArgs e)
        {
            Title = e.TouchPoint.Size.Width.ToString();
            var drawingAttributes = new System.Windows.Ink.DrawingAttributes();

            if (e.TouchPoint.Size.Width < 6)
            {
                drawingAttributes.Width = drawingAttributes.Height = 5;
                drawingAttributes.Color = Colors.DarkOliveGreen;
            }
            else if (e.TouchPoint.Size.Width > 6 && e.TouchPoint.Size.Width < 14)
            {
                drawingAttributes.Width = drawingAttributes.Height = 15;
                drawingAttributes.Color = Colors.Orange;
            }
            else
            {
                drawingAttributes.Width = drawingAttributes.Height = 30;
                drawingAttributes.Color = Colors.Red;
            }
            Canvas.DefaultDrawingAttributes = drawingAttributes;
            Canvas.ReleaseStylusCapture();
        }
 public void AttachVisuals(System.Windows.Media.Visual visual, System.Windows.Ink.DrawingAttributes drawingAttributes)
 {
 }