public void ButtonSwitcher ()
		{
			if (DBAccountManager.SharedManager.LinkedAccount == null) {
				Root = new RootElement ("DropBox Sync") {
					new Section (){
						new StringElement ("Link Account", () => DBAccountManager.SharedManager.LinkFromController (NavigationController)) { 
							Alignment = UITextAlignment.Center 
						}
					}
				};
			} else {
				Root = new RootElement ("DropBox Sync") {
					new Section () {
						new StringElement ("Unlink Account", () => {
							DBAccountManager.SharedManager.LinkedAccount.Unlink ();
							ButtonSwitcher ();
						}) { Alignment = UITextAlignment.Center },
						new StringElement ("Show DropBox Files", () => {
							filesController = new DVCFiles (DBPath.Root);
							NavigationController.PushViewController (filesController, true);
						}) { Alignment = UITextAlignment.Center } 
					}
				};
			}
		}
        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);
                }
            }
        }
        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);
                }
            }
        }
        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));
            }
        }
Example #5
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.Status == System.Threading.Tasks.TaskStatus.Faulted || 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);
                 }
             });
         });
     }
 }
Example #6
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 ButtonSwitcher()
 {
     if (DBAccountManager.SharedManager.LinkedAccount == null)
     {
         Root = new RootElement("DropBox Sync")
         {
             new Section()
             {
                 new StringElement("Link Account", () => DBAccountManager.SharedManager.LinkFromController(NavigationController))
                 {
                     Alignment = UITextAlignment.Center
                 }
             }
         };
     }
     else
     {
         Root = new RootElement("DropBox Sync")
         {
             new Section()
             {
                 new StringElement("Unlink Account", () => {
                     DBAccountManager.SharedManager.LinkedAccount.Unlink();
                     ButtonSwitcher();
                 })
                 {
                     Alignment = UITextAlignment.Center
                 },
                 new StringElement("Show DropBox Files", () => {
                     filesController = new DVCFiles(DBPath.Root);
                     NavigationController.PushViewController(filesController, true);
                 })
                 {
                     Alignment = UITextAlignment.Center
                 }
             }
         };
     }
 }
Example #8
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);
                 }
             });
         });
     }
 }
		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));
            }
        }