private async void SetRenameDirectoryUi(bool show, string oldItemName = "") { ModalBackGroundShown = show; RenameWindowShown = show; if (show) { LabelAddModalFolder.Text = oldItemName; await Task.Run(() => { Task.Delay(200).ContinueWith((args) => { EntryNewDirectoryField.Focus(); }); }); } else { EntryNewDirectoryField.Unfocus(); EntryNewDirectoryField.Text = ""; LabelAddModalFolder.Text = "Enter name of new folder"; await Task.Run(() => { Task.Delay(100).ContinueWith((args) => { AddDirModalWinShown = false; }); }); } }
private async void SetAddDirectoryUi(bool show) { ModalBackGroundShown = show; if (show) { await Task.Run(() => { Task.Delay(200).ContinueWith((args) => { EntryNewDirectoryField.Focus(); }); }); } else { EntryNewDirectoryField.Unfocus(); EntryNewDirectoryField.Text = ""; await Task.Run(() => { Task.Delay(100).ContinueWith((args) => { AddDirModalWinShown = false; }); }); } }
private async void BtnAcceptNewDirAdding_Clicked(object sender, EventArgs e) { var newDirName = ""; if (string.IsNullOrEmpty(EntryNewDirectoryField.Text) || string.IsNullOrWhiteSpace(EntryNewDirectoryField.Text)) { return; } try { newDirName = Path.Combine(currentDirectory.FullName, EntryNewDirectoryField.Text.Trim()); if (Directory.Exists(newDirName)) { ShowErrorMessage($"Folder: [{newDirName}] already exist!"); return; } if (RenameWindowShown) { await Task.Run(() => Utilites.RenameDirItem(DirList.FirstOrDefault(x => x.ItemChecked)?.FullPath, newDirName)).ContinueWith((arg) => { if (!arg.Result) { ShowErrorMessage($"Something goes wrong"); } }); } else { // Try to create the directory. DirectoryInfo di = Directory.CreateDirectory(newDirName); } GetDir(currentDirectory.GetFileSystemInfoFullName()); EntryNewDirectoryField.Unfocus(); EntryNewDirectoryField.Text = ""; ModalBackGroundShown = false; AddDirModalWinShown = false; } catch (Exception ex) { } }