Ejemplo n.º 1
0
        public StretchImage GetFlippedImage()
        {
            NSAffineTransform t          = new NSAffineTransform();
            StretchImage      image      = (StretchImage)this.Copy();
            CGSize            dimensions = image.Size;

            nint   scaleX     = 1;
            nint   scaleY     = 1;
            nfloat drawPointX = 0;
            nfloat drawPointY = 0;

            if (EndPoint.X < StartPoint.X)
            {
                scaleX     = -1;
                drawPointX = scaleX * dimensions.Width;
            }
            if (EndPoint.Y > StartPoint.Y)
            {
                scaleY     = -1;
                drawPointY = scaleY * dimensions.Height;
            }

            image.LockFocus();
            t.Scale(scaleX, scaleY);
            t.Concat();

            image.Draw(new CGPoint(drawPointX, drawPointY), new CGRect(0, 0, dimensions.Width, dimensions.Height), NSCompositingOperation.SourceOver, 1);
            image.UnlockFocus();
            return(image);
        }
Ejemplo n.º 2
0
        public override NSObject Copy(NSZone zone)
        {
            StretchImage image = (StretchImage)base.Copy(zone);

            image.StartPoint = this.StartPoint;
            image.EndPoint   = this.EndPoint;
            image.Opacity    = this.Opacity;
            image.PerformSelector(new Selector("retain"));
            return(image);
        }
Ejemplo n.º 3
0
partial         void ShowOpenPanel(Foundation.NSObject sender)
        {
            NSOpenPanel panel = NSOpenPanel.OpenPanel;
            panel.AllowedFileTypes = NSImage.ImageFileTypes;
            panel.BeginSheet(stretchView.Window, (result) => {
                if (result == 1) {
                    StretchImage image = new StretchImage(panel.Url);
                    stretchView.Image = image;
                }
                panel = null;
            });
        }
Ejemplo n.º 4
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();
            this.SetValueForKey(new NSNumber(1.0f), new NSString("Opacity"));

            mPath           = new NSBezierPath();
            mPath.LineWidth = 3.0f;
//			CreateRandomPath();
//			CreateRandomOvals();
            CreateRandomCurves();
            Image = new StretchImage("LittleBeach.jpg");
        }
Ejemplo n.º 5
0
        partial void ShowOpenPanel(Foundation.NSObject sender)
        {
            NSOpenPanel panel = NSOpenPanel.OpenPanel;

            panel.AllowedFileTypes = NSImage.ImageFileTypes;
            panel.BeginSheet(stretchView.Window, (result) => {
                if (result == 1)
                {
                    StretchImage image = new StretchImage(panel.Url);
                    stretchView.Image  = image;
                }
                panel = null;
            });
        }
Ejemplo n.º 6
0
        public override void DrawRect(CoreGraphics.CGRect dirtyRect)
        {
            CGRect bounds = this.Bounds;

            // Fill view with green
            NSColor.Green.Set();
            NSBezierPath.FillRect(bounds);
            // Draw the path in white
            NSColor.Red.Set();
            mPath.Stroke();
            if (mImages.Count > 0)
            {
                foreach (StretchImage image in mImages)
                {
                    StretchImage drawImage = image.GetFlippedImage();
                    CGRect       imageRect = new CGRect(0, 0, drawImage.Size.Width, drawImage.Size.Height);
                    drawImage.DrawInRect(image.DrawingRect(), imageRect, NSCompositingOperation.SourceOver, image.Opacity);
                }
            }
        }
Ejemplo n.º 7
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();
            this.SetValueForKey(new NSNumber(1.0f), new NSString("Opacity"));

            mPath = new NSBezierPath();
            mPath.LineWidth = 3.0f;
            //			CreateRandomPath();
            //			CreateRandomOvals();
            CreateRandomCurves();
            Image = new StretchImage("LittleBeach.jpg");
        }