コード例 #1
0
            public override void LoadingFinished(UIWebView webView)
            {
                double height, width;
                int    header, sidespace;

                width     = 595.2;
                height    = 841.8;
                header    = 10;
                sidespace = 10;

                UIEdgeInsets pageMargins = new UIEdgeInsets(header, sidespace, header, sidespace);

                webView.ViewPrintFormatter.ContentInsets = pageMargins;

                UIPrintPageRenderer renderer = new UIPrintPageRenderer();

                renderer.AddPrintFormatter(webView.ViewPrintFormatter, 0);

                CGSize pageSize      = new CGSize(width, height);
                CGRect printableRect = new CGRect(sidespace,
                                                  header,
                                                  pageSize.Width - (sidespace * 2),
                                                  pageSize.Height - (header * 2));
                CGRect paperRect = new CGRect(0, 0, width, height);

                renderer.SetValueForKey(NSValue.FromObject(paperRect), (NSString)"paperRect");
                renderer.SetValueForKey(NSValue.FromObject(printableRect), (NSString)"printableRect");
                NSData file = PrintToPDFWithRenderer(renderer, paperRect);

                File.WriteAllBytes(filename, file.ToArray());

                OnPageLoadFinished?.Invoke(this, new EventArgs());
            }
コード例 #2
0
        public override void DidFinishNavigation(WKWebView webView, WKNavigation navigation)
        {
            try
            {
                int          padding     = 10;
                UIEdgeInsets pageMargins = new UIEdgeInsets(padding, padding, padding, padding);
                webView.ViewPrintFormatter.ContentInsets = pageMargins;
                UIPrintPageRenderer renderer = new UIPrintPageRenderer();
                renderer.AddPrintFormatter(webView.ViewPrintFormatter, 0);
                CGSize pageSize      = new CGSize(PDFToHtml.PageWidth, PDFToHtml.PageHeight);
                CGRect printableRect = new CGRect(padding, padding, pageSize.Width - (padding * 2), pageSize.Height - (padding * 2));
                CGRect paperRect     = new CGRect(0, 0, PDFToHtml.PageWidth, PDFToHtml.PageHeight);

                var nSString            = new NSString("PaperRect");
                var printableRectstring = new NSString("PrintableRect");

                renderer.SetValueForKey(NSValue.FromObject(paperRect), nSString);
                renderer.SetValueForKey(NSValue.FromObject(printableRect), printableRectstring);

                NSData file = PrintToPDFWithRenderer(renderer, paperRect);
                File.WriteAllBytes(PDFToHtml.FilePath + ".pdf", file.ToArray());
                PDFToHtml.Status = PDFEnum.Completed;
            }
            catch
            {
                PDFToHtml.Status = PDFEnum.Failed;
            }
        }
コード例 #3
0
        void HideMenuLayerAnimation(NSString timingFunctionName = null)
        {
            CGRect f               = _shadowLayer.Frame;
            var    group           = new CAAnimationGroup();
            var    animationOffset = new CABasicAnimation();

            animationOffset.KeyPath = new NSString("position");
            animationOffset.From    = NSValue.FromCGPoint(new CGPoint(f.GetMidX(), f.GetMidY()));
            animationOffset.To      = NSValue.FromCGPoint(new CGPoint(f.GetMidX() - UIScreen.MainScreen.Bounds.Width * _targetViewControllerOffset, f.GetMidY()));

            var animationScaleX = new CABasicAnimation();

            animationScaleX.KeyPath = new NSString("transform.scale.x");
            animationScaleX.From    = NSValue.FromObject(0.8f);
            animationScaleX.To      = NSValue.FromObject(1.0f);

            var animationScaleY = new CABasicAnimation();

            animationScaleY.KeyPath = new NSString("transform.scale.y");
            animationScaleY.From    = NSValue.FromObject(0.8f);
            animationScaleY.To      = NSValue.FromObject(1.0f);

            //during pan gesture animation curve should be linear
            //In other cases EaseInOut
            group.TimingFunction = CAMediaTimingFunction.FromName(timingFunctionName ?? CAMediaTimingFunction.EaseInEaseOut);
            group.Duration       = TransitionDurationTime;
            group.Animations     = new[] { animationOffset, animationScaleX, animationScaleY };

            _shadowLayer.AddAnimation(group, "HideShadowLayerAnimation");
        }
コード例 #4
0
        public override bool BeginTracking(UITouch touch, UIEvent uievent)
        {
            if (TrackTouchLocation)
            {
                _touchCenterLocation = touch.LocationInView(this);
            }
            else
            {
                _touchCenterLocation = null;
            }

            UIView.Animate(0.1, 0, UIViewAnimationOptions.AllowUserInteraction, () =>
            {
                _rippleBackgroundView.Alpha = 1;
            }, null);
            _rippleView.Transform = CGAffineTransform.MakeScale(0.5f, 0.5f);

            UIView.Animate(0.7, 0, UIViewAnimationOptions.CurveEaseOut | UIViewAnimationOptions.AllowUserInteraction, () =>
            {
                _rippleView.Transform = CGAffineTransform.MakeIdentity();
            }, null);

            if (ShadowRippleEnable)
            {
                _tempShadowRadius  = Layer.ShadowRadius;
                _tempShadowOpacity = Layer.ShadowOpacity;

                var shadowAnim = new CABasicAnimation {
                    KeyPath = "shadowRadius"
                };
                shadowAnim.To = NSValue.FromObject(ShadowRippleRadius);

                var opacityAnim = new CABasicAnimation {
                    KeyPath = "shadowOpacity"
                };
                opacityAnim.To = NSValue.FromObject(1);

                var groupAnim = new CAAnimationGroup();
                groupAnim.Duration            = 0.7;
                groupAnim.FillMode            = CAFillMode.Forwards;
                groupAnim.RemovedOnCompletion = false;
                groupAnim.Animations          = new[] { shadowAnim, opacityAnim };
                Layer.AddAnimation(groupAnim, "shadow");
            }
            return(base.BeginTracking(touch, uievent));
        }
コード例 #5
0
        void AddLayer(MGLStyle style)
        {
            var source = new MGLVectorSource(identifier: "contours", configurationURL: new NSUrl("mapbox://mapbox.mapbox-terrain-v2"));
            var layer  = new MGLLineStyleLayer(identifier: "contours", source: source);

            layer.SourceLayerIdentifier = "contour";
            layer.LineJoin = MGLStyleValue.ValueWithRawValue(NSValue.FromObject(MGLLineJoin.Round));
            layer.LineCap  = MGLStyleValue.ValueWithRawValue(NSValue.FromObject(MGLLineCap.Round));

            layer.LineColor = MGLStyleValue.ValueWithRawValue(UIColor.Brown);

            layer.LineWidth = MGLStyleValue.ValueWithRawValue(NSValue.FromObject(1.0));
            style.AddSource(source);

            style.AddLayer(layer);
            contoursLayer = layer;
        }
コード例 #6
0
        void ShowMenuCancelLayerAnimation(double offset)
        {
            var group = new CAAnimationGroup();

            var animationOffset = new CABasicAnimation();

            animationOffset.KeyPath = new NSString("position");
            //Calculate position of shadow layer's X when animation was cancelled
            var offsetX   = UIScreen.MainScreen.Bounds.Width * _targetViewControllerOffset;
            var originalX = _shadowLayer.Frame.GetMidX() - ((offset / TransitionDurationTime) * offsetX);

            //Start animatiom from cancelled X position
            animationOffset.From = NSValue.FromCGPoint(new CGPoint(originalX, _shadowLayer.Frame.GetMidY()));
            //to position when animation began
            animationOffset.To = NSValue.FromCGPoint(new CGPoint(_shadowLayer.Frame.GetMidX(), _shadowLayer.Frame.GetMidY()));

            var scaleDiff = _targetViewControllerInitialScale - _targetViewControllerEndScale;
            //scaling of view when animation was cancelled
            var cancelledScalePosition = _targetViewControllerInitialScale - (scaleDiff - (offset / TransitionDurationTime) * scaleDiff);

            //Animate x/y positions from size when was cancelled
            //To size before interaction begin
            var animationScaleX = new CABasicAnimation();

            animationScaleX.KeyPath = new NSString("transform.scale.x");
            animationScaleX.From    = NSValue.FromObject(cancelledScalePosition);
            animationScaleX.To      = NSValue.FromObject(_targetViewControllerEndScale);

            var animationScaleY = new CABasicAnimation();

            animationScaleY.KeyPath = new NSString("transform.scale.y");
            animationScaleY.From    = NSValue.FromObject(cancelledScalePosition);
            animationScaleY.To      = NSValue.FromObject(_targetViewControllerEndScale);

            group.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.Linear);

            //It's pretty much random
            //with small animation time, it's looks good
            //With long animation time it's not really fit, but still not so bad
            group.Duration            = offset / 6;
            group.FillMode            = CAFillMode.Forwards;
            group.RemovedOnCompletion = false;
            group.Animations          = new[] { animationScaleX, animationScaleY, animationOffset };

            _shadowLayer.AddAnimation(group, "ShowScaleLayerAnimation");
        }
コード例 #7
0
        private void StyleContainer(UIView container, bool animate, float duration)
        {
            if (this.ShowShadow)
            {
                UIBezierPath shadowPath = UIBezierPath.FromRoundedRect(container.Bounds, 0);
                if (animate)
                {
                    CABasicAnimation animation = CABasicAnimation.FromKeyPath("shadowPath");
                    animation.From     = NSValue.FromObject(container.Layer.ShadowPath);
                    animation.To       = NSValue.FromObject(shadowPath.CGPath);
                    animation.Duration = duration;

                    container.Layer.AddAnimation(animation, "shadowPath");
                }
                container.Layer.ShadowPath    = shadowPath.CGPath;
                container.Layer.ShadowColor   = UIColor.Black.CGColor;
                container.Layer.ShadowRadius  = this.ShadowRadius;
                container.Layer.ShadowOpacity = this.ShadowOpacity;
                container.ClipsToBounds       = false;
            }
        }
コード例 #8
0
        void ShowMenuScaleShadowLayerAnimation()
        {
            //Need two separate animations for scaling x & y
            //Array crashes when trying to set ZPosition
            var group           = new CAAnimationGroup();
            var animationScaleX = new CABasicAnimation();

            animationScaleX.KeyPath = new NSString("transform.scale.x");
            animationScaleX.From    = NSValue.FromObject(1.0f);
            animationScaleX.To      = NSValue.FromObject(0.8f);

            var animationScaleY = new CABasicAnimation();

            animationScaleY.KeyPath   = new NSString("transform.scale.y");
            animationScaleY.From      = NSValue.FromObject(1.0f);
            animationScaleY.To        = NSValue.FromObject(0.8f);
            group.Duration            = TransitionDurationTime;
            group.FillMode            = CAFillMode.Forwards;
            group.RemovedOnCompletion = false;
            group.TimingFunction      = new CAMediaTimingFunction(0.25f, 0.1f, 0.25f, 1);
            group.Animations          = new[] { animationScaleX, animationScaleY };

            _shadowLayer.AddAnimation(group, "ShowScaleLayerAnimation");
        }
コード例 #9
0
        internal void LoadApps()
        {
            applicationsTable.Enabled = false;
            progressIndicator.StartAnimation(this);

            List <FinderFile> currentApps = new List <FinderFile> ();

            appTableContent.Remove(NSArray.FromArray <NSObject> ((NSArray)appTableContent.Content));
            //((NSMutableArray)appTableContent.Content).RemoveAll();

            SBElementArray folders = (SBElementArray)finder.ValueForKeyPath((NSString)"startupDisk.folders");
            SBObject       apps    = (SBObject)folders.Object("Applications");
            bool           exists  = apps.ValueForKey((NSString)"exists").ToString() == "1" ? true : false;

            // if the applicatoins folder exists...
            if (exists)
            {
                // get the applications in the folder
                SBElementArray topLevelApps = (SBElementArray)apps.ValueForKey((NSString)"applicationFiles");

                for (int x = 0; x <= topLevelApps.Count; x++)
                {
                    if (((SBObject)topLevelApps.ObjectAt(NSValue.FromObject(x))).ValueForKey((NSString)"name") != null)
                    {
                        // add each of the applications to our list of applications
                        currentApps.Add(new FinderFile((SBObject)topLevelApps.ObjectAt(NSValue.FromObject(x))));
                    }
                }


                SBObject       apps2      = (SBObject)folders.Object("Applications");
                SBElementArray appFolders = (SBElementArray)apps2.ValueForKey((NSString)"folders");

                for (int x = 0; x <= appFolders.Count; x++)
                {
                    // get the nth Folder
                    SBObject nthFolder = (SBObject)appFolders.ObjectAt(NSValue.FromObject(x));
                    // get the applications contained in the nth Folder
                    SBElementArray secondLevelApps = (SBElementArray)nthFolder.ValueForKey((NSString)"applicationFiles");

                    for (int s = 0; s <= secondLevelApps.Count; s++)
                    {
                        if (((SBObject)secondLevelApps.ObjectAt(NSValue.FromObject(s))).ValueForKey((NSString)"name") != null)
                        {
                            // add each of the applications to our list of applications
                            currentApps.Add(new FinderFile((SBObject)secondLevelApps.ObjectAt(NSValue.FromObject(s))));
                        }
                    }
                }
            }

            // now add each FinderFile to the table content array
            foreach (FinderFile ff in currentApps)
            {
                appTableContent.AddObject(ff);
            }

            progressIndicator.StopAnimation(this);

            applicationsTable.Enabled = true;
        }