Exemplo n.º 1
0
		public void CreateAt (string input)
		{
			if (!creatingFolder) {
				string noteFilename = string.Format ("{0}.txt", input);
				var newPath = path.ChildPath (noteFilename);
				DBFilesystem.SharedFilesystem.CreateFileAsync (newPath).ContinueWith (t => {
					InvokeOnMainThread (()=> {
						if (t.Result == null)
							new UIAlertView ("Unable to create note", "An error has occurred", null, "Ok", null).Show ();
						else {
							var controller = new NoteController (t.Result);
							NavigationController.PushViewController (controller, true);
						}
					});
				});
			} else {
				var newPath = path.ChildPath (input);
				DBFilesystem.SharedFilesystem.CreateFolderAsync (newPath).ContinueWith (t => {
					InvokeOnMainThread (() => {
						if (!t.Result)
							new UIAlertView ("Unable to create folder", "An error has occurred", null, "Ok", null).Show ();
						else {
							var controller = new DVCFiles (newPath);
							NavigationController.PushViewController (controller, true);
						}
					});
				});
			}
		}
        public void CreateAt(string input)
        {
            DBError error;
            if (!creatingFolder) {
                string noteFilename = string.Format ("{0}.txt", input);
                var newPath = path.ChildPath (noteFilename);
                var file = DBFilesystem.SharedFilesystem.CreateFile (newPath, 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 newPath = path.ChildPath (input);
                bool success = DBFilesystem.SharedFilesystem.CreateFolder (newPath, out error);
                if (!success)
                    new UIAlertView ("Unable to create folder", "An error has occurred: " + error.Description, null, "Ok", null).Show ();
                else {
                    var controller = new DVCFiles (newPath);
                    NavigationController.PushViewController (controller, true);
                }
            }
        }
Exemplo n.º 3
0
		void LoadFiles ()
		{
			DBFilesystem.SharedFilesystem.ListFolderAsync (path).ContinueWith (t => {
				if(t.Result != null)
				{
					InvokeOnMainThread (()=> {	
						Root.Clear ();
						Root.Add (new Section ());
					});
					foreach (DBFileInfo info in t.Result ) {
						var localinfo = info;
						
						var filerow = new StyledStringElement (localinfo.Path.Name, () => {
							if (localinfo.IsFolder) {
								InvokeOnMainThread( ()=> {
									filesController = new DVCFiles (localinfo.Path);
									NavigationController.PushViewController (filesController, true);
								});
							} else {
								DBFilesystem.SharedFilesystem.OpenFileAsync (localinfo.Path).ContinueWith (r => {
									if (r.Result != null) {
										InvokeOnMainThread (() => {
											var noteController = new NoteController (r.Result);
											NavigationController.PushViewController (noteController, true);
										});
									}
								});
							}
						}) {
							Accessory = localinfo.IsFolder ? UITableViewCellAccessory.DisclosureIndicator : UITableViewCellAccessory.None
						};
						InvokeOnMainThread (()=> Root[0].Add (filerow));
					}
				}
			});
		}
        void LoadFiles()
        {
            DBError error;
            var contents = DBFilesystem.SharedFilesystem.ListFolder (path, out error);

            InvokeOnMainThread (()=> {
                Root.Clear ();
                Root.Add (new Section ());
            });
            foreach (DBFileInfo info in contents) {
                var localinfo = info;

                var filerow = new StyledStringElement (localinfo.Path.Name, () => {
                    if (localinfo.IsFolder) {
                        filesController = new DVCFiles (localinfo.Path);
                        NavigationController.PushViewController (filesController, true);
                    } else {
                        DBError err;
                        var file = DBFilesystem.SharedFilesystem.OpenFile (localinfo.Path, out err);
                        var noteController = new NoteController (file);
                        NavigationController.PushViewController (noteController, true);
                    }
                }) {
                    Accessory = localinfo.IsFolder ? UITableViewCellAccessory.DisclosureIndicator : UITableViewCellAccessory.None
                };
                InvokeOnMainThread (()=> Root[0].Add (filerow));
            }
        }