public void CreateNewDocument() { // Create path to new file // var docsFolder = Environment.GetFolderPath (Environment.SpecialFolder.Personal); var docsFolder = Path.Combine(iCloudUrl.Path, "Documents"); var docPath = Path.Combine(docsFolder, TestFilename); var ubiq = new NSUrl(docPath, false); // Create new document at path Console.WriteLine("Creating Document at:" + ubiq.AbsoluteString); Document = new GenericTextDocument(ubiq); // Set the default value Document.Contents = "(default value)"; // Save document to path Document.Save(Document.FileUrl, UIDocumentSaveOperation.ForCreating, (saveSuccess) => { Console.WriteLine("Save completion:" + saveSuccess); if (saveSuccess) { Console.WriteLine("Document Saved"); } else { Console.WriteLine("Unable to Save Document"); } }); // Inform caller RaiseDocumentLoaded(Document); }
public void OpenDocument(NSUrl url) { try { Console.WriteLine("Attempting to open: {0}", url); Document = new GenericTextDocument(url); // Open the document Document.Open((success) => { if (success) { Console.WriteLine("Document Opened"); } else { Console.WriteLine("Failed to Open Document"); } }); // Inform caller RaiseDocumentLoaded(Document); } catch (Exception e) { Console.WriteLine(e.Message); } }
internal void RaiseDocumentLoaded(GenericTextDocument document) { // Inform caller DocumentLoaded?.Invoke(document); }