Inheritance: UITableViewController
Ejemplo n.º 1
0
        void HandleRenameRequested(DocumentReference docRef, object arg2)
        {
            var name = docRef.Name;
            var dir  = Path.GetDirectoryName(docRef.File.Path);
            var c    = new TextInputController {
                Title        = "Rename " + (docRef.File.IsDirectory ? "Folder" : DocumentAppDelegate.Shared.App.DocumentBaseName),
                InputText    = name,
                ValidateFunc = n => DocumentAppDelegate.ValidateNewName(dir, n, docRef.Name),
            };

            var nc = new UINavigationController(c);

            nc.NavigationBar.BarStyle = DocumentAppDelegate.Shared.Theme.NavigationBarStyle;
            nc.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;

            var presenter = this;

            c.Cancelled += (ss, ee) => presenter.DismissViewController(true, null);
            c.Done      += async(ss, ee) => {
                presenter.DismissViewController(true, null);

                if (!string.IsNullOrWhiteSpace(c.InputText) && c.InputText != name)
                {
                    await Rename(docRef, c.InputText);
                }
            };

            presenter.PresentViewController(nc, true, null);
        }
Ejemplo n.º 2
0
        void HandleTitleTap(object sender, EventArgs e)
        {
            if (IsRoot)
            {
                return;
            }

            var name = DirectoryName;
            var dir  = Path.GetDirectoryName(this.Directory);

            var c = new TextInputController {
                Title        = "Rename",
                InputText    = name,
                ValidateFunc = n => DocumentAppDelegate.ValidateNewName(dir, n, name),
            };

            var nc = new UINavigationController(c);

            nc.NavigationBar.BarStyle = DocumentAppDelegate.Shared.Theme.NavigationBarStyle;
            nc.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;

            c.Cancelled += (ss, ee) => nc.DismissViewController(true, null);
            c.Done      += async(ss, ee) => {
                nc.DismissViewController(true, null);

                if (c.InputText != name)
                {
                    try {
                        var FileSystem = FileSystemManager.Shared.ActiveFileSystem;

                        var newDir = Path.Combine(Path.GetDirectoryName(Directory), c.InputText);

                        if (await FileSystem.Move(Directory, newDir))
                        {
                            Directory = newDir;
                            SetTitle();
                            DocumentAppDelegate.Shared.Settings.SetWorkingDirectory(FileSystem, Directory);
                        }
                        else
                        {
                            var alert = new UIAlertView("Rename Error", FileSystem.Id + " did not allow the folder to be renamed.", null, "OK");
                            alert.Show();
                        }
                    } catch (Exception ex) {
                        Debug.WriteLine(ex);
                    }
                }
            };

            PresentViewController(nc, true, null);
        }
Ejemplo n.º 3
0
		void AddFolder ()
		{
			var dir = CurrentDirectory;

			var c = new TextInputController {
				Title = "Create Folder",
				InputText = "",
				Hint = "Enter the name of the new folder.",
				ValidateFunc = n => ValidateNewName (dir, n, null),
			};

			var presenter = docListNav.TopViewController;

			var nc = new UINavigationController (c);
			nc.NavigationBar.BarStyle = Theme.NavigationBarStyle;
			nc.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;

			c.Cancelled += (sender, e) => nc.DismissViewController (true, null);
			c.Done += async (sender, e) => {
				nc.DismissViewController (true, null);

				try {
					var newDirName = c.InputText;
					var dl = CurrentDocumentListController;
					var path = Path.Combine (dl.Directory, newDirName);

					if (await FileSystem.CreateDirectory (path)) {
						docListNav.PushViewController (CreateDirectoryViewController (path), false);
					}
					else {
						new UIAlertView (
							"Error",
							FileSystem.Id + " did not allow the directory to be created.",
							null,
							"OK").Show ();
					}

				} catch (Exception ex) {
					Debug.WriteLine (ex);
				}
			};

			presenter.PresentViewController (nc, true, null);
		}
		void HandleTitleTap (object sender, EventArgs e)
		{
			if (IsRoot)
				return;

			var name = DirectoryName;
			var dir = Path.GetDirectoryName (this.Directory);

			var c = new TextInputController {
				Title = "Rename",
				InputText = name,
				ValidateFunc = n => DocumentAppDelegate.ValidateNewName (dir, n, name),
			};

			var nc = new UINavigationController (c);
			nc.NavigationBar.BarStyle = DocumentAppDelegate.Shared.Theme.NavigationBarStyle;
			nc.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;

			c.Cancelled += (ss, ee) => nc.DismissViewController (true, null);
			c.Done += async (ss, ee) => {
				nc.DismissViewController (true, null);

				if (c.InputText != name) {

					try {
						var FileSystem = FileSystemManager.Shared.ActiveFileSystem;

						var newDir = Path.Combine (Path.GetDirectoryName (Directory), c.InputText);

						if (await FileSystem.Move (Directory, newDir)) {
							Directory = newDir;
							SetTitle ();
							DocumentAppDelegate.Shared.Settings.SetWorkingDirectory (FileSystem, Directory);
						}
						else {
							var alert = new UIAlertView ("Rename Error", FileSystem.Id + " did not allow the folder to be renamed.", null, "OK");
							alert.Show ();
						}

					} catch (Exception ex) {
						Debug.WriteLine (ex);

					}
				}
			};

			PresentViewController (nc, true, null);
		}
		void HandleRenameRequested (DocumentReference docRef, object arg2)
		{
			var name = docRef.Name;
			var dir = Path.GetDirectoryName (docRef.File.Path);
			var c = new TextInputController {
				Title = "Rename " + (docRef.File.IsDirectory ? "Folder" : DocumentAppDelegate.Shared.App.DocumentBaseName),
				InputText = name,
				ValidateFunc = n => DocumentAppDelegate.ValidateNewName (dir, n, docRef.Name),
			};

			var nc = new UINavigationController (c);
			nc.NavigationBar.BarStyle = DocumentAppDelegate.Shared.Theme.NavigationBarStyle;
			nc.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;

			var presenter = this;

			c.Cancelled += (ss, ee) => presenter.DismissViewController (true, null);
			c.Done += async (ss, ee) => {
				presenter.DismissViewController (true, null);

				if (!string.IsNullOrWhiteSpace (c.InputText) && c.InputText != name) {
					await Rename (docRef, c.InputText);
				}
			};

			presenter.PresentViewController (nc, true, null);
		}
Ejemplo n.º 6
0
			public TextInputDataSource (TextInputController controller)
			{
				this.controller = controller;
			}
Ejemplo n.º 7
0
 public TextInputDataSource(TextInputController controller)
 {
     this.controller = controller;
 }