// Is called by other apps from "open in" dialogs public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation) { var sourceFile = url.Path; var destFile = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), System.IO.Path.GetFileName(sourceFile)); if (!File.Exists(sourceFile)) { return(false); } var fileExists = false; if (File.Exists(destFile)) { fileExists = true; File.Delete(destFile); } File.Copy(sourceFile, destFile); Cartridge cart = new Cartridge(destFile); CartridgeLoaders.LoadMetadata(new FileStream(destFile, FileMode.Open), cart); // TODO // If there was a cartridge with the same filename, than replace if (fileExists) { } if (window.RootViewController.PresentedViewController is UINavigationController && window.RootViewController.PresentedViewController == navCartSelect) { // Now create a new list for cartridges viewCartSelect = new CartridgeList(this); // Add the cartridge view to the navigation controller // (it'll be the top most screen) navCartSelect.PopToRootViewController(true); navCartSelect.SetViewControllers(new UIViewController[] { (UIViewController)viewCartSelect }, false); // CartridgeDetail cartDetail = new CartridgeDetail(this); // ((UINavigationController)window.RootViewController.PresentedViewController).PushViewController (cartDetail,true); // cartDetail.Cartridge = cart; } return(true); }
/// <summary> /// Fill cartridge list by a list of filenames. All filenames in the list contains a valid path and filename. /// </summary> /// <param name="dir">Path to directory to get cartridges from.</param> public void GetByFileList(List <string> files) { if (files == null) { statusMessage = "No files found"; throw new ArgumentNullException("files"); } // Delete old ones Clear(); foreach (string fileName in files) { if (File.Exists(fileName)) { Cartridge cart = new Cartridge(fileName); CartridgeLoaders.LoadMetadata(new FileStream(fileName, FileMode.Open), cart); Add(cart); } } }