public override object ConvertTo(ITypeDescriptorContext context,
                                         CultureInfo culture,
                                         object value,
                                         Type destinationType)
        {
            if (culture == null)
            {
                culture = CultureInfo.CurrentCulture;
            }
            // LAMESPEC: "The default implementation calls the object's
            // ToString method if the object is valid and if the destination
            // type is string." MS does not behave as per the specs.
            // Oh well, we have to be compatible with MS.
            if (value is Point_)
            {
                Point_ point = (Point_)value;
                if (destinationType == typeof(string))
                {
                    return(point.X.ToString(culture) + culture.TextInfo.ListSeparator
                           + " " + point.Y.ToString(culture));
                }
                else if (destinationType == typeof(InstanceDescriptor))
                {
                    ConstructorInfo ctor = typeof(Point_).GetConstructor(new Type[] { typeof(int), typeof(int) });
                    return(new InstanceDescriptor(ctor, new object[] { point.X, point.Y }));
                }
            }

            return(base.ConvertTo(context, culture, value, destinationType));
        }
Example #2
0
        // -----------------------
        // Public Constructors
        // -----------------------

        /// <summary>
        ///	Rectangle Constructor
        /// </summary>
        ///
        /// <remarks>
        ///	Creates a Rectangle_ from Point and Size values.
        /// </remarks>

        public Rectangle_(Point_ location, Size_ size)
        {
            x      = location.X;
            y      = location.Y;
            width  = size.Width;
            height = size.Height;
        }
Example #3
0
        public bool IsVisible(Point_ point)
        {
            bool result;

            Status status = GDIPlus.GdipIsVisibleRegionPointI(nativeRegion, point.X, point.Y,
                                                              IntPtr.Zero, out result);

            GDIPlus.CheckStatus(status);

            return(result);
        }
Example #4
0
        public bool IsVisible(Point_ point, Graphics g)
        {
            IntPtr ptr = (g == null) ? IntPtr.Zero : g.NativeObject;
            bool   result;

            Status status = GDIPlus.GdipIsVisibleRegionPointI(nativeRegion, point.X, point.Y,
                                                              ptr, out result);

            GDIPlus.CheckStatus(status);

            return(result);
        }
Example #5
0
        // -----------------------
        // Public Constructors
        // -----------------------

        /// <summary>
        ///	Size Constructor
        /// </summary>
        ///
        /// <remarks>
        ///	Creates a Size from a Point value.
        /// </remarks>

        public Size_(Point_ pt)
        {
            width  = pt.X;
            height = pt.Y;
        }
Example #6
0
        /// <summary>
        ///	Offset Method
        /// </summary>
        ///
        /// <remarks>
        ///	Moves the Rectangle_ a specified distance.
        /// </remarks>

        public void Offset(Point_ pos)
        {
            x += pos.X;
            y += pos.Y;
        }
Example #7
0
        /// <summary>
        ///	Contains Method
        /// </summary>
        ///
        /// <remarks>
        ///	Checks if a Point lies within this Rectangle.
        /// </remarks>

        public bool Contains(Point_ pt)
        {
            return(Contains(pt.X, pt.Y));
        }
Example #8
0
 public static Point_ Subtract(Point_ pt, Size sz)
 {
     return(new Point_(pt.X - sz.Width, pt.Y - sz.Height));
 }
Example #9
0
 public void Offset(Point_ p)
 {
     Offset(p.X, p.Y);
 }
Example #10
0
 public static Point_ Add(Point_ pt, Size sz)
 {
     return(new Point_(pt.X + sz.Width, pt.Y + sz.Height));
 }