Exemple #1
0
        ///<summary>
        /// constructor for a StylusShape.
        ///</summary>
        internal StylusShape(StylusTip tip, double width, double height, double rotation)
        {
            if (Double.IsNaN(width) || Double.IsInfinity(width) || width < DrawingAttributes.MinWidth || width > DrawingAttributes.MaxWidth)
            {
                throw new ArgumentOutOfRangeException("width");
            }

            if (Double.IsNaN(height) || Double.IsInfinity(height) || height < DrawingAttributes.MinHeight || height > DrawingAttributes.MaxHeight)
            {
                throw new ArgumentOutOfRangeException("height");
            }

            if (Double.IsNaN(rotation) || Double.IsInfinity(rotation))
            {
                throw new ArgumentOutOfRangeException("rotation");
            }

            if (!StylusTipHelper.IsDefined(tip))
            {
                throw new ArgumentOutOfRangeException("tip");
            }


            //
            //  mod rotation to 360 (720 to 0, 361 to 1, -270 to 90)
            //
            m_width    = width;
            m_height   = height;
            m_rotation = rotation == 0 ? 0 : rotation % 360;
            m_tip      = tip;
            if (tip == StylusTip.Rectangle)
            {
                ComputeRectangleVertices();
            }
        }
Exemple #2
0
        ///<summary>
        /// constructor for a StylusShape.
        ///</summary>
        internal StylusShape(StylusTip tip, double width, double height, double rotation)
        {
            if (Double.IsNaN(width) || Double.IsInfinity(width) || width < DrawingAttributes.MinWidth || width > DrawingAttributes.MaxWidth)
            {
                throw new ArgumentOutOfRangeException("width");
            }

            if (Double.IsNaN(height) || Double.IsInfinity(height) || height < DrawingAttributes.MinHeight || height > DrawingAttributes.MaxHeight)
            {
                throw new ArgumentOutOfRangeException("height");
            }

            if (Double.IsNaN(rotation) || Double.IsInfinity(rotation))
            {
                throw new ArgumentOutOfRangeException("rotation");
            }

            if (!StylusTipHelper.IsDefined(tip))
            {
                throw new ArgumentOutOfRangeException("tip");
            }


            //
            //  mod rotation to 360 (720 to 0, 361 to 1, -270 to 90)
            //
            m_width = width;
            m_height = height;
            m_rotation = rotation == 0 ? 0 : rotation % 360;
            m_tip = tip;
            if (tip == StylusTip.Rectangle)
            {
                ComputeRectangleVertices();
            }
        }
Exemple #3
0
 internal StylusShape(StylusTip tip, double width, double height, double rotation)
 {
     if (double.IsNaN(width) || double.IsInfinity(width) || width < DrawingAttributes.MinWidth || width > DrawingAttributes.MaxWidth)
     {
         throw new ArgumentOutOfRangeException("width");
     }
     if (double.IsNaN(height) || double.IsInfinity(height) || height < DrawingAttributes.MinHeight || height > DrawingAttributes.MaxHeight)
     {
         throw new ArgumentOutOfRangeException("height");
     }
     if (double.IsNaN(rotation) || double.IsInfinity(rotation))
     {
         throw new ArgumentOutOfRangeException("rotation");
     }
     if (!StylusTipHelper.IsDefined(tip))
     {
         throw new ArgumentOutOfRangeException("tip");
     }
     m_width    = width;
     m_height   = height;
     m_rotation = ((rotation == 0.0) ? 0.0 : (rotation % 360.0));
     m_tip      = tip;
     if (tip == StylusTip.Rectangle)
     {
         ComputeRectangleVertices();
     }
 }
Exemple #4
0
 internal static bool IsDefined(StylusTip stylusTip)
 {
     if (stylusTip < StylusTip.Rectangle || stylusTip > StylusTip.Ellipse)
     {
         return false;
     }
     return true;
 }
 internal static bool IsDefined(StylusTip stylusTip)
 {
     if (stylusTip < StylusTip.Rectangle || stylusTip > StylusTip.Ellipse)
     {
         return(false);
     }
     return(true);
 }
        private void surfaceDessin_MouseMove(object sender, MouseEventArgs e)
        {
            Point p = e.GetPosition(surfaceDessin);

            textBlockPosition.Text = Math.Round(p.X) + ", " + Math.Round(p.Y) + "px";

            if (clicked)
            {
                DrawingAttributes attributes = new DrawingAttributes();

                // get attributes
                StylusPoint stylusPoint = new StylusPoint(p.X, p.Y, (float)0.5);
                StylusTip   stylusTip   = this.surfaceDessin.DefaultDrawingAttributes.StylusTip;
                Color       color       = this.surfaceDessin.DefaultDrawingAttributes.Color;
                double      width       = this.surfaceDessin.DefaultDrawingAttributes.Width;
                double      height      = this.surfaceDessin.DefaultDrawingAttributes.Height;



                // send to server
                ImagePoint pCoord = new ImagePoint(p.X, p.Y);

                string           action  = "";
                DrawPoint_Server segment = null;
                if (GlobalUser.OutilSelectionnee == "crayon" || GlobalUser.OutilSelectionnee == "efface_segment")
                {
                    action = "ADD";
                    this.trait.Add(p);
                    segment = new DrawPoint_Server("DRAW", action, this.traits.Count, new PointParams(stylusTip.ToString(), color.ToString(), width, height), pCoord);
                }

                else
                {
                    action = "DEL";
                    int index = 0;
                    foreach (var elem in traits)
                    {
                        foreach (var po in elem)
                        {
                            if (p.X >= po.X - 6 && p.X <= po.X + 6 && p.Y >= po.Y - 6 && p.Y <= po.Y + 6)
                            {
                                segment = new DrawPoint_Server("DRAW", action, index, new PointParams(stylusTip.ToString(), color.ToString(), width, height), pCoord);
                                this.surfaceDessin.Strokes[index].DrawingAttributes.Color = System.Windows.Media.Color.FromArgb(255, 255, 255, 255);

                                break;
                            }
                        }
                        index++;
                    }
                }
                if (segment != null && !activateTuto)
                {
                    var image = JsonConvert.SerializeObject(segment);
                    SocketService.MySocket.Emit("draw", image);
                }
            }
        }