public ProgressSpinnerView(CGRect frame, NSProgress progress) : base(frame) { // Initialize Progress = progress; Progress.AddObserver(this, "fractionCompleted", NSKeyValueObservingOptions.New, IntPtr.Zero); ArcLayer.Path = UIBezierPath.FromArc(new CGPoint(Bounds.GetMidX(), Bounds.GetMidY()), (float)(0.2f * Math.Min(Bounds.Width, Bounds.Height)), (float)(-(Math.PI / 2f)), (float)(2f * Math.PI - (Math.PI / 2f)), true).CGPath; ArcLayer.StrokeColor = TintColor.CGColor; ArcLayer.FillColor = UIColor.Clear.CGColor; ArcLayer.LineWidth = 5; ArcLayer.StrokeStart = 0; ArcLayer.StrokeEnd = 0; ArcLayer.Position = CGPoint.Empty; Layer.AddSublayer(ArcLayer); BackgroundColor = UIColor.Clear; Layer.BorderColor = UIColor.LightGray.CGColor; Layer.BorderWidth = 2; Layer.CornerRadius = 10; ProgressLabel.Text = "0%"; ProgressLabel.TextAlignment = UITextAlignment.Center; ProgressLabel.Frame = Bounds; AddSubview(ProgressLabel); }
public static UIImage FilteredImage(UIImage image) { var progress = NSProgress.FromTotalUnitCount(-1); progress.Cancellable = false; progress.Pausable = false; UIImage outputImage; var filter = new CIPhotoEffectTransfer(); var cgImage = image.CGImage; var ciImage = CIImage.FromCGImage(cgImage); filter.SetValueForKey(ciImage, new NSString("inputImage")); var outputCIImage = filter.OutputImage; var ciContext = CIContext.Create(); var outputCGImage = ciContext.CreateCGImage(outputCIImage, outputCIImage.Extent); outputImage = UIImage.FromImage(outputCGImage); outputCGImage.Dispose(); ciContext.Dispose(); outputCIImage.Dispose(); ciImage.Dispose(); cgImage.Dispose(); filter.Dispose(); progress.CompletedUnitCount = 1; progress.TotalUnitCount = 1; return(outputImage); }
public void CommonApplicationDidFinishLaunching(Action completionHandler) { Scene.ShowsStatistics = true; Scene.BackgroundColor = AppKit.NSColor.Black; NSProgress progress = NSProgress.FromTotalUnitCount(10); DispatchQueue queue = DispatchQueue.GetGlobalQueue(DispatchQueuePriority.Default); queue.DispatchSync(() => { progress.BecomeCurrent(2); var ui = new InGameScene(Scene.Bounds.Size); DispatchQueue.MainQueue.DispatchAsync(() => Scene.OverlayScene = ui ); progress.ResignCurrent(); progress.BecomeCurrent(3); GameSimulation gameSim = GameSimulation.Sim; gameSim.GameUIScene = ui; progress.ResignCurrent(); progress.BecomeCurrent(3); SCNTransaction.Flush(); // Preload Scene.Prepare(gameSim, new Func <bool> (() => true )); progress.ResignCurrent(); progress.BecomeCurrent(1); // Game Play Specific Code gameSim.GameUIScene.GameStateDelegate = gameSim.GameLevel; gameSim.GameLevel.ResetLevel(); gameSim.SetGameState(GameState.PreGame); progress.ResignCurrent(); progress.BecomeCurrent(1); DispatchQueue.MainQueue.DispatchAsync(() => { Scene.Scene = gameSim; Scene.WeakSceneRendererDelegate = gameSim; if (completionHandler != null) { completionHandler(); } }); progress.ResignCurrent(); }); }
private NSProgress SlowImageTransfer(ItemProviderDataCompletionHandler completionHandler) { var progress = NSProgress.FromTotalUnitCount(100); var loadStartDate = new NSDate(); DispatchQueue.MainQueue.DispatchAsync(() => { progress.BecomeCurrent(100); NSTimer.CreateScheduledTimer(0.033f, true, (timer) => { progress.CompletedUnitCount = CompletedUnitCount(loadStartDate); if (progress.CompletedUnitCount >= 100) { completionHandler(Image.AsPNG(), null); timer.Invalidate(); } }); }); return(progress); }
public void DidStartReceivingResource(MCSession session, string resourceName, MCPeerID fromPeer, NSProgress progress) { throw new Exception("This service does not send/receive resources."); }
public void Configure(NSProgress progress) { Progress = progress; }
public override void DidStartReceivingResource(MCSession session, string resourceName, MCPeerID fromPeer, NSProgress progress) { Console.WriteLine("DidStartReceivingResource"); }
public override void DidStartReceivingResource(MCSession session, string resourceName, MCPeerID fromPeer, NSProgress progress) { }
public override void DidStartReceivingResource(MCSession session, string resourceName, MCPeerID fromPeer, NSProgress progress) { //Debug.WriteLine("### DATA START RECEIVING"); }
public static List <NSItemProvider> AsNSItemProviders(this Forms9Patch.IMimeItemCollection entry) { var itemProviders = new List <NSItemProvider>(); foreach (var mimeItem in entry.Items) { if (mimeItem.MimeType?.ToNsUti() is NSString nsUti) { NSItemProvider itemProvider = null; /* * if (mimeItem.Value is Uri uri) * { * // from: https://stackoverflow.com/questions/36685160/unicode-url-could-not-initialize-an-instance-of-the-type-foundation-nsurl-t?rq=1 * var idn = new System.Globalization.IdnMapping(); * Console.WriteLine(uri.AbsoluteUri); * NSUrl nsURL = new NSUrl (uri.Scheme, idn.GetAscii (uri.DnsSafeHost), uri.PathAndQuery); * Console.WriteLine(nsURL.AbsoluteString); * itemProvider = new NSItemProvider(nsUri); * } * else if (mimeItem.Value is FileInfo fileInfo && !mimeItem.MimeType.StartsWith("image/", StringComparison.InvariantCultureIgnoreCase)) * { * // Apple apps don't seem to support this approach * // tried with .jpg and .pdf with Notes and Email app without success * Console.WriteLine(fileInfo.FullName); * NSUrl nsURL = NSUrl.CreateFileUrl(new string[] { fileInfo.FullName }); * Console.WriteLine(nsURL.AbsoluteString); * itemProvider = new NSItemProvider(nsURL); * } * else */ if (mimeItem.Value is FileInfo fileInfo) // && mimeItem.MimeType.StartsWith("image/", StringComparison.InvariantCultureIgnoreCase)) { // this works with Email and Notes apps for PDFs and images!! Console.WriteLine(fileInfo.FullName); itemProvider = new NSItemProvider(); itemProvider.RegisterFileRepresentation(nsUti, NSItemProviderFileOptions.OpenInPlace, NSItemProviderRepresentationVisibility.All, (completionHandler) => { Console.WriteLine(fileInfo.FullName); NSUrl nsURL = NSUrl.CreateFileUrl(new string[] { fileInfo.FullName }); Console.WriteLine(nsURL.AbsoluteString); NSError nsError = null; completionHandler.Invoke(nsURL, false, nsError); var progress = new NSProgress { FileTotalCount = 1, FileCompletedCount = 1, TotalUnitCount = 1, CompletedUnitCount = 1 }; return(progress); }); } else if (mimeItem.Value is string text) { // from: https://josephduffy.co.uk/ios-share-sheets-the-proper-way-locations var nsString = (NSString)text; var utf8 = NSData.FromString(text, NSStringEncoding.UTF8); itemProvider = new NSItemProvider(utf8, nsUti); } else if (mimeItem.Value.ToNSObject() is NSObject nsObject) { itemProvider = new NSItemProvider(nsObject, nsUti); } if (itemProvider != null) { itemProviders.Add(itemProvider); } } } return(itemProviders); }
public void DidStartReceivingResource(MCSession session, string resourceName, MCPeerID fromPeer, NSProgress progress) { // this app doesn't use named resources. }
public void StartShowingProgress(NSProgress progress) { StopShowingProgress(); ProgressView = new ProgressSpinnerView(Bounds, progress); AddSubview(ProgressView); }