//
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            window = new UIWindow (UIScreen.MainScreen.Bounds);

            var accountManager = new DBAccountManager (key: "t3ow4tvu36zlh5s", secret: "w4nmqlk5ul1uiw8");

            DBAccountManager.SetSharedManager (accountManager);
            settingsController = new SettingsController (accountManager);

            var initialControllers = new List<UIViewController>();
            initialControllers.Add (settingsController);

            var account = accountManager.LinkedAccount;
            if (account != null) {
                var fileSystem = new DBFilesystem (account);
                var folderController = new FolderListController (fileSystem, DBPath.Root);
                initialControllers.Add (folderController);
            }

            navController = new UINavigationController ();
            navController.ViewControllers = initialControllers.ToArray ();
            window.RootViewController = navController;
            window.BackgroundColor = UIColor.White;

            window.MakeKeyAndVisible ();
            return true;
        }
예제 #2
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            window = new UIWindow(UIScreen.MainScreen.Bounds);

            var accountManager = new DBAccountManager(key: "t3ow4tvu36zlh5s", secret: "w4nmqlk5ul1uiw8");

            DBAccountManager.SetSharedManager(accountManager);
            settingsController = new SettingsController(accountManager);



            var initialControllers = new List <UIViewController>();

            initialControllers.Add(settingsController);

            var account = accountManager.LinkedAccount;

            if (account != null)
            {
                var fileSystem       = new DBFilesystem(account);
                var folderController = new FolderListController(fileSystem, DBPath.Root);
                initialControllers.Add(folderController);
            }

            navController = new UINavigationController();
            navController.ViewControllers = initialControllers.ToArray();
            window.RootViewController     = navController;
            window.BackgroundColor        = UIColor.White;

            window.MakeKeyAndVisible();
            return(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();
            }
        }
        public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)
        {
            var account = DBAccountManager.SharedManager.HandleOpenURL (url);

            if (account != null) {
                var fileSystem = new DBFilesystem (account);
                var folderController = new FolderListController (fileSystem, DBPath.Root);
                navController.PushViewController(folderController, true);
            }
            return true;
        }
예제 #5
0
        public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)
        {
            var account = DBAccountManager.SharedManager.HandleOpenURL(url);

            if (account != null)
            {
                var fileSystem       = new DBFilesystem(account);
                var folderController = new FolderListController(fileSystem, DBPath.Root);
                navController.PushViewController(folderController, true);
            }
            return(true);
        }
        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)
        {
            switch (RowTypeForIndexPath(indexPath))
            {
            case RowType.AccountRow:
                var account    = ctlr.Manager.LinkedAccount;
                var fileSystem = new DBFilesystem(account);
                Console.WriteLine("Created filesystem " + fileSystem.Description);
                var controller = new FolderListController(fileSystem, DBPath.Root);
                ctlr.NavigationController.PushViewController(controller, true);
                break;

            case RowType.LinkRow:
                ctlr.Manager.LinkFromController(ctlr.NavigationController);
                break;

            case RowType.UnlinkRow:
                ctlr.Manager.LinkedAccount.Unlink();
                break;

            default:
                break;
            }
        }
 public MyFolderTableViewSource(FolderListController controller)
 {
     ctrl = controller;
 }
 public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
 {
     switch (RowTypeForIndexPath (indexPath)) {
     case RowType.AccountRow:
         var account = ctlr.Manager.LinkedAccount;
         var fileSystem = new DBFilesystem (account);
         Console.WriteLine ("Created filesystem " + fileSystem.Description);
         var controller = new FolderListController (fileSystem, DBPath.Root);
         ctlr.NavigationController.PushViewController (controller, true);
         break;
     case RowType.LinkRow:
         ctlr.Manager.LinkFromController (ctlr.NavigationController);
         break;
     case RowType.UnlinkRow:
         ctlr.Manager.LinkedAccount.Unlink ();
         break;
     default:
         break;
     }
 }
        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 ();
            }
        }
 public MyFolderTableViewSource(FolderListController controller)
 {
     ctrl = controller;
 }