public void CreateAt(string input) { DBError error; if (!CreatingFolder) { string noteFilename = string.Format ("{0}.txt", input); var path = Root.ChildPath (noteFilename); var file = Filesystem.CreateFile (path, out error); if (file == null) new UIAlertView ("Unable to create note", "An error has occurred: " + error.Description, null, "Ok", null).Show (); else { var controller = new NoteController (file); NavigationController.PushViewController (controller, true); } } else { var path = Root.ChildPath (input); bool success = Filesystem.CreateFolder (path, out error); if (!success) new UIAlertView ("Unable to create folder", "An error has occurred: " + error.Description, null, "Ok", null).Show (); else { var controller = new FolderListController (Filesystem, path); NavigationController.PushViewController (controller, true); } } }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { if (ctrl.Contents.Count() <= indexPath.Row) return; DBError error; var info = ctrl.Contents.ElementAt (indexPath.Row); if (!ctrl.Moving) { UIViewController controller; if (info.IsFolder) controller = new FolderListController (ctrl.Filesystem, info.Path); else { var file = ctrl.Filesystem.OpenFile (info.Path, out error); if (file == null) { new UIAlertView ("Error", "There was an error opening your note: " + error.Description, null, "Ok", null).Show (); return; } controller = new NoteController (file); } ctrl.NavigationController.PushViewController (controller, true); } else { ctrl.FromPath = info.Path; var alert = new UIAlertView ("Choose a destination", "", null, "Cancel", new string[] {"Move"}); alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput; alert.Clicked += (sender, e) => { if (e.ButtonIndex != alert.CancelButtonIndex) { string input = alert.GetTextField (0).Text; if (ctrl.Moving) ctrl.MoveTo (input); else ctrl.CreateAt (input); } ctrl.Moving = false; ctrl.FromPath = null; ctrl.LoadFiles(); }; alert.Show (); } }