Exemplo n.º 1
0
        //
        // Helper function to generate shadow
        //
        private void GenerateShapeShadow(CGContext context, UIBezierPath shapeObject, nfloat xOffset, nfloat yOffset, nfloat blurValue, CGBlendMode blendingMode, UIColor shadowColor, nfloat borderWidth, int borderPosition, nfloat iWidth, nfloat iHeight)
        {
            CGPoint basePoint;
            CGPoint offsetPoint;
            CGSize  calculatedShadowOffset;
            nfloat  calculatedShadowBlur;
            CGPoint constPointZero;

            constPointZero = new CGPoint(0, 0);

            basePoint              = baseTransform.TransformPoint(context.PointToDeviceSpace(constPointZero));
            offsetPoint            = baseTransform.TransformPoint(context.PointToDeviceSpace(new CGPoint(xOffset, yOffset)));
            calculatedShadowOffset = new CGSize(offsetPoint.X - basePoint.X, offsetPoint.Y - basePoint.Y);
            if (blurValue == 0)
            {
                calculatedShadowBlur = 0;
            }
            else
            {
                calculatedShadowBlur = Hypot(calculatedShadowOffset.Width, calculatedShadowOffset.Height) / blurValue;
            }
            context.SetShadow(calculatedShadowOffset, calculatedShadowBlur, shadowColor.CGColor);
            context.SetBlendMode(blendingMode);

            context.BeginTransparencyLayer(null);

            UIColor.Black.SetFill();
            shapeObject.Fill();

            if (borderWidth > 0)
            {
                if (borderPosition == 0)
                {
                    context.SaveState();
                    shapeObject.LineWidth = borderWidth;
                    UIColor.Black.SetStroke();
                    shapeObject.Stroke();
                    context.RestoreState();
                }

                if (borderPosition == 1)
                {
                    context.BeginPath();
                    context.AddPath(shapeObject.CGPath);
                    context.EOClip();
                }

                if (borderPosition == 2)
                {
                    context.BeginPath();
                    context.AddPath(shapeObject.CGPath);
                    context.AddRect(RectangleFExtensions.Inset(shapeObject.Bounds, iWidth, iHeight));
                    context.EOClip();
                }
            }

            context.EndTransparencyLayer();
        }
Exemplo n.º 2
0
        private void updateMinimumMaximumZoom()
        {
            RectangleF targetRect = RectangleFExtensions.Inset(Bounds, ContentViewPadding, ContentViewPadding);
            float      zoomScale  = getZoomScaleThatFits(targetRect.Size, _pageContentView.Bounds.Size);

            MinimumZoomScale = zoomScale;
            MaximumZoomScale = zoomScale * MgrAccessor.SettingsMgr.Settings.ZoomScaleLevels;
            _zoomScaleStep   = (MaximumZoomScale - MinimumZoomScale) / MgrAccessor.SettingsMgr.Settings.ZoomScaleLevels;
        }
            private UIImage GetIconForText(string text, nuint bucketIndex)
            {
                var nsText = new NSString(text);
                var icon   = _iconCache.ObjectForKey(nsText);

                if (icon != null)
                {
                    return((UIImage)icon);
                }

                var font           = UIFont.BoldSystemFontOfSize(14);
                var paragraphStyle = NSParagraphStyle.Default;
                var dict           = NSDictionary.FromObjectsAndKeys(
                    objects: new NSObject[] { font, paragraphStyle, this._options.RendererTextColor.ToUIColor() },
                    keys: new NSObject[] { UIStringAttributeKey.Font, UIStringAttributeKey.ParagraphStyle, UIStringAttributeKey.ForegroundColor }
                    );
                var attributes = new UIStringAttributes(dict);


                var textSize      = nsText.GetSizeUsingAttributes(attributes);
                var rectDimension = Math.Max(20, Math.Max(textSize.Width, textSize.Height)) + 3 * bucketIndex + 6;
                var rect          = new CGRect(0.0f, 0.0f, rectDimension, rectDimension);

                UIGraphics.BeginImageContext(rect.Size);
                UIGraphics.BeginImageContextWithOptions(rect.Size, false, 0);

                // Background circle
                var ctx = UIGraphics.GetCurrentContext();

                ctx.SaveState();

                bucketIndex = (nuint)Math.Min((int)bucketIndex, this._options.BucketColors.Length - 1);
                var backColor = this._options.BucketColors[bucketIndex];

                ctx.SetFillColor(backColor.ToCGColor());
                ctx.FillEllipseInRect(rect);
                ctx.RestoreState();

                // Draw the text
                UIColor.White.SetColor();
                var textRect = RectangleFExtensions.Inset(rect, (rect.Size.Width - textSize.Width) / 2,
                                                          (rect.Size.Height - textSize.Height) / 2);

                nsText.DrawString(RectangleFExtensions.Integral(textRect), attributes);

                var newImage = UIGraphics.GetImageFromCurrentImageContext();

                UIGraphics.EndImageContext();

                this._iconCache.SetObjectforKey(newImage, nsText);

                return(newImage);
            }
Exemplo n.º 4
0
        /// Create a copy view of target view
        /// It helps us not to affect the original target view
        public static void AddTarget(this ShowCase materialShowcase, CGPoint atCenter)
        {
            materialShowcase.targetCopyView = materialShowcase.targetView.SnapshotView(true);
            var width  = materialShowcase.targetCopyView.Frame.Width;
            var height = materialShowcase.targetCopyView.Frame.Height;

            materialShowcase.targetCopyView.Frame  = new CGRect(0, 0, width, height);
            materialShowcase.targetCopyView.Center = atCenter;
            materialShowcase.targetCopyView.TranslatesAutoresizingMaskIntoConstraints = true;
            materialShowcase.targetCopyView.Frame             = RectangleFExtensions.Inset(materialShowcase.targetCopyView.Frame, -5f, -5f);
            materialShowcase.targetCopyView.Layer.BorderColor = UIColor.White.CGColor;
            materialShowcase.targetCopyView.Layer.BorderWidth = 5f;
            materialShowcase.AddSubview(materialShowcase.targetCopyView);
        }
Exemplo n.º 5
0
        public override void PrepareLayout()
        {
            base.PrepareLayout();
            calculatedAttributes.Clear();

            contentWidth = CollectionView.Frame.Width;
            nfloat columnWidth = contentWidth / NumberOfColumns;
            nfloat height      = columnWidth * 1.25f; // Our cells height is a 25% greater than their width

            for (int i = 0; i < columnsXOffset.Length; i++)
            {
                columnsXOffset[i] = i * columnWidth;
            }

            for (int i = 0; i < columnsYOffset.Length; i++)
            {
                columnsYOffset[i] = 0;
            }

            UICollectionViewLayoutAttributes attribute1 = UICollectionViewLayoutAttributes.CreateForCell(NSIndexPath.FromItemSection(0, 0));

            attribute1.Frame = new CGRect(columnsXOffset[1], 0, columnWidth, buttonHeight);
            calculatedAttributes.Add(attribute1);

            columnsYOffset[1] = buttonHeight; // Second column has a vertical offset (due to sell button height)

            int column = 0;

            for (int i = 0; i < CollectionView.NumberOfItemsInSection(1); i++)
            {
                var indexPath  = NSIndexPath.FromItemSection(i, 1);
                var frame      = new CGRect(columnsXOffset[column], columnsYOffset[column], columnWidth, height);
                var insetFrame = RectangleFExtensions.Inset(frame, 0f, 0f);

                UICollectionViewLayoutAttributes attribute = UICollectionViewLayoutAttributes.CreateForCell(indexPath);
                attribute.Frame = insetFrame;

                calculatedAttributes.Add(attribute);

                contentHeight          = System.NMath.Max(contentHeight, RectangleFExtensions.GetMaxY(frame));
                columnsYOffset[column] = columnsYOffset[column] + height;

                column = column >= (NumberOfColumns - 1) ? 0 : ++column;
            }
        }
Exemplo n.º 6
0
        CGRect autoCompleteTableViewFrameForTextField(MLPAutoCompleteTextField textField)
        {
            CGRect frame = CGRect.Empty;

            if ((this.AutoCompleteTableFrame).Width > 0)
            {
                frame = this.AutoCompleteTableFrame;
            }
            else
            {
                frame    = textField.Frame;
                frame.Y += textField.Frame.Size.Height;
            }

            frame.X      += textField.AutoCompleteTableOriginOffset.Width;
            frame.Y      += textField.AutoCompleteTableOriginOffset.Height;
            frame.Height += textField.AutoCompleteTableSizeOffset.Height;
            frame.Width  += textField.AutoCompleteTableSizeOffset.Width;
            frame         = RectangleFExtensions.Inset(frame, 1, 0);

            return(frame);
        }
        private UIImage GetIconForText(string text, UIImage baseImage)
        {
            var nsText = new NSString(text);
            var icon   = iconCache.ObjectForKey(nsText);

            if (icon != null)
            {
                return((UIImage)icon);
            }

            var font = UIFont.BoldSystemFontOfSize(12);
            var size = baseImage.Size;

            UIGraphics.BeginImageContextWithOptions(size, false, 0.0f);
            baseImage.Draw(new CGRect(0, 0, size.Width, size.Height));
            var rect = new CGRect(0, 0, baseImage.Size.Width, baseImage.Size.Height);

            var paragraphStyle = NSParagraphStyle.Default;
            var attributes     = new UIStringAttributes(NSDictionary.FromObjectsAndKeys(
                                                            objects: new NSObject[] { font, paragraphStyle, options.RendererTextColor.ToUIColor() },
                                                            keys: new NSObject[] { UIStringAttributeKey.Font, UIStringAttributeKey.ParagraphStyle, UIStringAttributeKey.ForegroundColor }
                                                            ));

            var textSize = nsText.GetSizeUsingAttributes(attributes);
            var textRect = RectangleFExtensions.Inset(rect, (rect.Size.Width - textSize.Width) / 3,
                                                      (rect.Size.Height - textSize.Height) / 1);

            nsText.DrawString(RectangleFExtensions.Integral(textRect), attributes);

            var newImage = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            iconCache.SetObjectforKey(newImage, nsText);
            return(newImage);
        }
Exemplo n.º 8
0
        //
        // ShapeObjectLogo
        //
        private void DrawShapeObjectLogo(CGContext context)
        {
            UIBezierPath ShapeObjectLogo;

            // Shape Path
            ShapeObjectLogo = new UIBezierPath();
            ShapeObjectLogo.MoveTo(new CGPoint(21.640106, 0.000000));
            ShapeObjectLogo.AddCurveToPoint(new CGPoint(16.612139, 2.920175), new CGPoint(19.615119, 0.005031), new CGPoint(17.632132, 1.159215));
            ShapeObjectLogo.AddLineTo(new CGPoint(0.752245, 30.580328));
            ShapeObjectLogo.AddCurveToPoint(new CGPoint(0.752245, 36.419672), new CGPoint(-0.250748, 32.346320), new CGPoint(-0.250748, 34.654687));
            ShapeObjectLogo.AddLineTo(new CGPoint(16.612139, 64.080831));
            ShapeObjectLogo.AddCurveToPoint(new CGPoint(21.641106, 67.000000), new CGPoint(17.632132, 65.841791), new CGPoint(19.615119, 66.995975));
            ShapeObjectLogo.AddLineTo(new CGPoint(53.359894, 67.000000));
            ShapeObjectLogo.AddCurveToPoint(new CGPoint(58.387861, 64.080831), new CGPoint(55.384881, 66.995975), new CGPoint(57.367868, 65.841791));
            ShapeObjectLogo.AddLineTo(new CGPoint(74.247755, 36.419672));
            ShapeObjectLogo.AddCurveToPoint(new CGPoint(74.247755, 30.580328), new CGPoint(75.250748, 34.654687), new CGPoint(75.250748, 32.346320));
            ShapeObjectLogo.AddLineTo(new CGPoint(58.386861, 2.920175));
            ShapeObjectLogo.AddCurveToPoint(new CGPoint(53.359894, 0.000000), new CGPoint(57.367868, 1.159215), new CGPoint(55.384881, 0.004025));
            ShapeObjectLogo.AddLineTo(new CGPoint(21.640106, 0.000000));
            ShapeObjectLogo.ClosePath();
            ShapeObjectLogo.MoveTo(new CGPoint(21.640106, 0.000000));
            ShapeObjectLogo.MoveTo(new CGPoint(21.928104, 16.181713));
            ShapeObjectLogo.AddCurveToPoint(new CGPoint(22.061103, 16.181713), new CGPoint(21.972313, 16.176991), new CGPoint(22.016894, 16.176991));
            ShapeObjectLogo.AddLineTo(new CGPoint(27.532066, 16.181713));
            ShapeObjectLogo.AddCurveToPoint(new CGPoint(28.130062, 16.537930), new CGPoint(27.778919, 16.189389), new CGPoint(28.004637, 16.323845));
            ShapeObjectLogo.AddLineTo(new CGPoint(37.411001, 33.143280));
            ShapeObjectLogo.AddCurveToPoint(new CGPoint(37.500000, 33.410946), new CGPoint(37.458060, 33.225659), new CGPoint(37.488317, 33.316656));
            ShapeObjectLogo.AddCurveToPoint(new CGPoint(37.587999, 33.143280), new CGPoint(37.511374, 33.316728), new CGPoint(37.541289, 33.225734));
            ShapeObjectLogo.AddLineTo(new CGPoint(46.846938, 16.537930));
            ShapeObjectLogo.AddCurveToPoint(new CGPoint(47.466934, 16.181713), new CGPoint(46.977011, 16.317781), new CGPoint(47.212411, 16.182533));
            ShapeObjectLogo.AddLineTo(new CGPoint(52.936897, 16.181713));
            ShapeObjectLogo.AddCurveToPoint(new CGPoint(53.557893, 17.229233), new CGPoint(53.421894, 16.186744), new CGPoint(53.784891, 16.798552));
            ShapeObjectLogo.AddLineTo(new CGPoint(44.497953, 33.500503));
            ShapeObjectLogo.AddLineTo(new CGPoint(53.557893, 49.748630));
            ShapeObjectLogo.AddCurveToPoint(new CGPoint(52.937897, 50.818287), new CGPoint(53.806891, 50.181323), new CGPoint(53.434894, 50.823318));
            ShapeObjectLogo.AddLineTo(new CGPoint(47.466934, 50.818287));
            ShapeObjectLogo.AddCurveToPoint(new CGPoint(46.846938, 50.439932), new CGPoint(47.207875, 50.812898), new CGPoint(46.971429, 50.668606));
            ShapeObjectLogo.AddLineTo(new CGPoint(37.586999, 33.834582));
            ShapeObjectLogo.AddCurveToPoint(new CGPoint(37.500000, 33.566916), new CGPoint(37.540639, 33.752052), new CGPoint(37.511064, 33.661063));
            ShapeObjectLogo.AddCurveToPoint(new CGPoint(37.411001, 33.834582), new CGPoint(37.488317, 33.661206), new CGPoint(37.458060, 33.752204));
            ShapeObjectLogo.AddLineTo(new CGPoint(28.131062, 50.439932));
            ShapeObjectLogo.AddCurveToPoint(new CGPoint(27.532066, 50.818287), new CGPoint(28.010506, 50.662417), new CGPoint(27.783589, 50.805749));
            ShapeObjectLogo.AddLineTo(new CGPoint(22.062103, 50.818287));
            ShapeObjectLogo.AddCurveToPoint(new CGPoint(21.442107, 49.748630), new CGPoint(21.564106, 50.823318), new CGPoint(21.192109, 50.182329));
            ShapeObjectLogo.AddLineTo(new CGPoint(30.500047, 33.500503));
            ShapeObjectLogo.AddLineTo(new CGPoint(21.440107, 17.229233));
            ShapeObjectLogo.AddCurveToPoint(new CGPoint(21.927104, 16.181713), new CGPoint(21.223109, 16.836790), new CGPoint(21.488107, 16.265233));
            ShapeObjectLogo.AddLineTo(new CGPoint(21.928104, 16.181713));
            ShapeObjectLogo.ClosePath();
            ShapeObjectLogo.MoveTo(new CGPoint(21.928104, 16.181713));

            context.SaveState();
            context.TranslateCTM(3.000000f, 7.000000f);

            // Shape Outer Shadow
            context.SaveState();
            context.BeginPath();
            context.AddPath(ShapeObjectLogo.CGPath);
            context.AddRect(RectangleFExtensions.Inset(ShapeObjectLogo.Bounds, -1f, -2f));
            context.EOClip();
            context.TranslateCTM(-77f, 0f);
            GenerateShapeShadow(context, ShapeObjectLogo, 77f, 1f, 77f, 0, UIColor.FromHSBA(0.000000f, 0.000000f, 0.000000f, 0.500000f), 0f, 0, 0f, 0f);
            context.RestoreState();

            // Shape Fill
            context.SaveState();
            if (Active)
            {
                UIColor.FromHSBA(0.530476f, 0.849515f, 0.807843f, 1.000000f).SetFill();
            }
            else
            {
                UIColor.FromRGB(137, 137, 137).SetFill();
            }

            ShapeObjectLogo.Fill();
            context.RestoreState();

            context.RestoreState();
        }
Exemplo n.º 9
0
        /// <summary>
        /// Creates the bottom bar.
        /// </summary>
        /// <returns>The bottom bar view.</returns>
        protected virtual UIView _CreateBottomBar()
        {
            // Create bottom bar
            var bottomBarFrame = View.Bounds;

            bottomBarFrame.X     += BarPaddingH;
            bottomBarFrame.Y      = bottomBarFrame.Size.Height - BarPaddingV - BottombarHeight;
            bottomBarFrame.Width -= BarPaddingH * 2;
            bottomBarFrame.Height = BottombarHeight;
            var bottomBar = new UIXToolbarView(bottomBarFrame, 0.92f, 0.32f, 0.8f);

            bottomBar.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleWidth;

            // Create slider
            float sliderWidth = bottomBarFrame.Width - 15;

            if (MgrAccessor.OptionsMgr.Options.PageNumberVisible)
            {
                sliderWidth -= PageNumberLabelSize.Width;
            }
            var pageSliderFrame = new RectangleF(5, 10, sliderWidth, 20);

            _Slider                  = new UISlider(pageSliderFrame);
            _Slider.MinValue         = 1;
            _Slider.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            _Slider.ValueChanged    += delegate {
                if (_PageNumberLabel != null)
                {
                    _PageNumberLabel.Text = string.Format(@"{0}/{1}", (int)_Slider.Value, PDFDocument.PageCount);
                }
            };
            _Slider.TouchUpInside += delegate(object sender, EventArgs e) {
                OpenDocumentPage((int)_Slider.Value);
            };
            bottomBar.AddSubview(_Slider);

            // Create page number view
            if (MgrAccessor.OptionsMgr.Options.PageNumberVisible)
            {
                var pageNumberViewFrame = new RectangleF(pageSliderFrame.Width + 10, 5, PageNumberLabelSize.Width, PageNumberLabelSize.Height);
                var pageNumberView      = new UIView(pageNumberViewFrame);
                pageNumberView.AutosizesSubviews      = false;
                pageNumberView.UserInteractionEnabled = false;
                pageNumberView.AutoresizingMask       = UIViewAutoresizing.FlexibleLeftMargin;
                pageNumberView.BackgroundColor        = UIColor.FromWhiteAlpha(0.4f, 0.5f);
                pageNumberView.Layer.CornerRadius     = 5.0f;
                pageNumberView.Layer.ShadowOffset     = new SizeF(0.0f, 0.0f);
                pageNumberView.Layer.ShadowPath       = UIBezierPath.FromRect(pageNumberView.Bounds).CGPath;
                pageNumberView.Layer.ShadowRadius     = 2.0f;
                pageNumberView.Layer.ShadowOpacity    = 1.0f;
                // Create page number label
                var pageNumberLabelFrame = RectangleFExtensions.Inset(pageNumberView.Bounds, 4.0f, 2.0f);
                _PageNumberLabel = new UILabel(pageNumberLabelFrame);
                _PageNumberLabel.AutosizesSubviews = false;
                _PageNumberLabel.AutoresizingMask  = UIViewAutoresizing.None;
                _PageNumberLabel.TextAlignment     = UITextAlignment.Center;
                _PageNumberLabel.BackgroundColor   = UIColor.Clear;
                _PageNumberLabel.TextColor         = UIColor.White;
                _PageNumberLabel.Font         = UIFont.SystemFontOfSize(16.0f);
                _PageNumberLabel.ShadowOffset = new SizeF(0.0f, 1.0f);
                _PageNumberLabel.ShadowColor  = UIColor.Black;
                _PageNumberLabel.AdjustsFontSizeToFitWidth = true;
                _PageNumberLabel.MinimumFontSize           = 12.0f;
                pageNumberView.AddSubview(_PageNumberLabel);
                bottomBar.AddSubview(pageNumberView);
            }
            return(bottomBar);
        }