Example #1
0
        public override void MouseDown(NSEvent theEvent)
        {
            NSPoint locationInSelf = this.ConvertPointFromView (theEvent.LocationInWindow, null);
            NSRect dragThumbFrame = this.dragThumbView.Frame;

            if (dragThumbFrame.PointInRect (locationInSelf)) {
                this.dragOffsetIntoGrowBox = new NSSize (locationInSelf.x - dragThumbFrame.origin.x, locationInSelf.y - dragThumbFrame.origin.y);
                NSDictionary metrics = NSDictionary.DictionaryWithObjectsAndKeys (
                NSNumber.NumberWithFloat (dragThumbFrame.MinX), (NSString)"initialThumbX",
                NSNumber.NumberWithFloat (dragThumbFrame.MinY), (NSString)"initialThumbY",
                null);
                NSDictionary views = NSDictionary.DictionaryWithObjectForKey (this.dragThumbView, (NSString)"dragThumbView");

                this.horizontalDragConstraint = NSLayoutConstraint.ConstraintsWithVisualFormatOptionsMetricsViews ("H:|-(initialThumbX)-[dragThumbView]", 0, metrics, views).LastObject.Retain<NSLayoutConstraint> ();
                this.verticalDragConstraint = NSLayoutConstraint.ConstraintsWithVisualFormatOptionsMetricsViews ("V:|-(initialThumbY)-[dragThumbView]", 0, metrics, views).LastObject.Retain<NSLayoutConstraint> ();

                // try lowering the priority to NSLayoutPriorityDragThatCannotResizeWindow to see the difference
                this.horizontalDragConstraint.Priority = NSLayoutPriority.NSLayoutPriorityDragThatCanResizeWindow;
                this.verticalDragConstraint.Priority = NSLayoutPriority.NSLayoutPriorityDragThatCanResizeWindow;

                this.AddConstraint (this.horizontalDragConstraint);
                this.AddConstraint (this.verticalDragConstraint);

                // just for fun.  Try it out!
                this.Window.VisualizeConstraints (NSArray.ArrayWithObjects (this.horizontalDragConstraint, this.verticalDragConstraint, null));
            }
        }
Example #2
0
        public void TestStaticCreation()
        {
            NSPoint refPoint = new NSPoint(1, 2);
            NSValue val = NSValue.ValueWithPoint(refPoint);
            Check(val);
            NSPoint point = val.PointValue;
            Assert.AreEqual(refPoint, point, "Points must be equal");

            NSRange refRange = new NSRange(3, 4);
            val = NSValue.ValueWithRange(refRange);
            Check(val);
            NSRange range = val.RangeValue;
            Assert.AreEqual(refRange, range, "Ranges must be equal");

            NSRect refRect = new NSRect(5, 6, 789, 789);
            val = NSValue.ValueWithRect(refRect);
            Check(val);
            NSRect rect = val.RectValue;
            Assert.AreEqual(refRect, rect, "Rectangles must be equal");

            NSSize refSize = new NSSize(456, 789);
            val = NSValue.ValueWithSize(refSize);
            Check(val);
            NSSize size = val.SizeValue;
            Assert.AreEqual(refSize, size, "Sizes must be equal");
        }
Example #3
0
 public void setSelectedRectSize(NSSize size)
 {
     this.selectedRect.size = size;
 }
Example #4
0
 public void moveSelectedRectBy(NSSize delta)
 {
     this.selectedRect.origin.x += delta.width;
     this.selectedRect.origin.y += delta.height;
 }
Example #5
0
 public static extern NSString NSStringFromSize(NSSize aSize);
Example #6
0
 /// <summary>
 /// Tests two size values for equality.
 /// </summary>
 /// <remarks>Original declaration is : BOOL NSEqualSizes(NSSize aSize, NSSize bSize)</remarks>
 public static bool NSEqualSizes(NSSize aSize,
                                 NSSize bSize)
 {
     return Equals(aSize, bSize);
 }
Example #7
0
		/// <summary>
		/// Converts a <see cref="NSSize"/> instance to a <see cref="CGSize"/>
		/// </summary>
		/// <param name="nssize">The <see cref="NSSize"/> to convert.</param>
		/// <returns>A new <see cref="CGSize"/> instance.</returns>
		public static CGSize CGSizeFromNSSize(NSSize nssize)
		{
			return CGSize.CGSizeMake(nssize.width, nssize.height);
		}		
 public override void SetFrameSize(NSSize size)
 {
     this.SendMessageSuper(SimpleLayoutViewClass, "setFrameSize:", size);
     this.Layout();
 }
Example #9
0
        /// <summary>
        /// Returns the result of the division of the size instance by the given factor.
        /// </summary>
        /// <param name="size">The size.</param>
        /// <param name="factor">The factor.</param>
        /// <returns></returns>
		public static NSSize Divide(NSSize size, CGFloat factor)
        {
            return new NSSize(size.width/factor, size.height/factor);
        }
Example #10
0
 /// <summary>
 /// Returns the product of the size instance by the given factor.
 /// </summary>
 /// <param name="size">The size.</param>
 /// <param name="factor">The factor.</param>
 /// <returns></returns>
 public static NSSize Multiply(NSSize size, CGFloat factor)
 {
     return new NSSize(size.width*factor, size.height*factor);
 }
Example #11
0
 /// <summary>
 /// Returns the difference of the two sizes instances.
 /// </summary>
 /// <param name="size1">A size.</param>
 /// <param name="size2">A size.</param>
 /// <returns></returns>
 public static NSSize Substract(NSSize size1, NSSize size2)
 {
     return new NSSize(size1.width - size2.width, size1.height - size2.height);
 }
Example #12
0
 /// <summary>
 /// Returns the sum of the two sizes instances.
 /// </summary>
 /// <param name="size1">A size.</param>
 /// <param name="size2">A size.</param>
 /// <returns></returns>
 public static NSSize Add(NSSize size1, NSSize size2)
 {
     return new NSSize(size1.width + size2.width, size1.height + size2.height);
 }
Example #13
0
 /// <summary>
 /// Translates the point by the specified size.
 /// </summary>
 /// <param name="nsPoint">A point.</param>
 /// <param name="nsSize">A size.</param>
 /// <returns></returns>
 public static NSPoint Substract(NSPoint nsPoint, NSSize nsSize)
 {
     return new NSPoint(nsPoint.x - nsSize.width, nsPoint.y - nsSize.height);
 }
Example #14
0
 /// <summary>
 /// Translates the point by the specified size.
 /// </summary>
 /// <param name="nsPoint">A point.</param>
 /// <param name="nsSize">A size.</param>
 /// <returns></returns>
 public static NSPoint Add(NSPoint nsPoint, NSSize nsSize)
 {
     return new NSPoint(nsPoint.x + nsSize.width, nsPoint.y + nsSize.height);
 }