Exemplo n.º 1
0
        public static void SortOrder()
        {
            Dialog     dialog     = new Dialog("Sort By", 25, 10);
            RadioGroup radioGroup = new RadioGroup(3, 1, new string[] { "Ascending", "Descending" }, (int)Utils.Settings.SortOrder);

            dialog.Add(radioGroup);

            Button btnOk = new Button("OK", true);

            btnOk.Clicked = delegate()
            {
                Utils.Settings.SortOrder = (Utils.SortOrder)radioGroup.Selected;
                Utils.Settings.Save();

                MyDrive.SortItems();

                dialog.Running = false;
                Application.Top.SetFocus(MyDrive.Window);
            };
            Button btnCancel = new Button("Cancel");

            btnCancel.Clicked = delegate()
            {
                dialog.Running = false;
                Application.Top.SetFocus(MyDrive.Window);
            };
            dialog.AddButton(btnOk);
            dialog.AddButton(btnCancel);

            Application.Run(dialog);
            Application.Refresh();
        }
Exemplo n.º 2
0
        public static void NewFolder()
        {
            string newFolderName  = "New Folder";
            int    newFolderCount = 0;

            while (MyDrive.Files != null && MyDrive.Files.Find((file) => file.Name.Equals(newFolderName)) != null)
            {
                newFolderName = string.Format("New Folder ({0})", ++newFolderCount);
            }

            Dialog    dialog    = new Dialog("Enter Folder Name", 50, 8);
            TextField textField = new TextField(newFolderName)
            {
                X     = 1,
                Y     = 1,
                Width = Dim.Fill(1)
            };

            dialog.Add(textField);

            Button btnOk = new Button("OK", true);

            btnOk.Clicked = delegate()
            {
                Utils.Drive.NewFolder(MyDrive.CurrentDirectory.Id, textField.Text.ToString()).ContinueWith((task) =>
                {
                    Application.MainLoop.Invoke(() =>
                    {
                        MyDrive.Files.Add(task.Result);

                        MyDrive.SortItems();

                        MyDrive.SelectItem(task.Result);

                        dialog.Running = false;
                        Application.Top.SetFocus(MyDrive.Window);
                    });
                });
            };
            Button btnCancel = new Button("Cancel");

            btnCancel.Clicked = delegate()
            {
                dialog.Running = false;
                Application.Top.SetFocus(MyDrive.Window);
            };
            dialog.AddButton(btnOk);
            dialog.AddButton(btnCancel);

            Application.Run(dialog);
            Application.Refresh();
        }