//在当前文件夹下创建一个文件夹 private async void MenuFlyoutItem_Click_CreateDir(object sender, RoutedEventArgs e) { nr = 2; InPutName.Text = ""; TitleName.Text = "输入文件夹名"; TitleName.Text = "文件夹名"; await InPutDialog.ShowAsync(); }
//重命名 private async void MenuFlyoutItem_Click_ReName(object sender, RoutedEventArgs e) { nr = 1; if (nowfile.filetype == 0) { TitleName.Text = "重命名文件夹"; TitleName.Text = "文件夹名"; } else { TitleName.Text = "重命名文件"; TitleName.Text = "文件名"; } await InPutDialog.ShowAsync(); }
private void Cancle_Click(object sender, RoutedEventArgs e) { InPutDialog.Hide(); }
//名命比较重要的函数 private void Name_ReName(object sender, RoutedEventArgs e) { string name; if (nr == 1) { string newname = InPutName.Text; string oldname = nowfile.filename; int flags = 0; while (true) { if (files.Count() == 0) { break; } foreach (Model.File file in files) { if (file.filename == newname && file.filetype == nowfile.filetype) { ShowMessageDialog("文件(夹)名重复, 请重新输入"); } } dirNodeManager.ReName(oldname, newname); flags = 1; if (flags == 1) { break; } } } else if (nr == 2) { Random ra = new Random(); int n = ra.Next(100); name = InPutName.Text; if (name == "" || name == null) { ShowMessageDialog("请输入文件名"); return; } int flags = 0; int size = ra.Next(100); while (true) { if (files.Count() == 0) { dirNodeManager.MakeDir(name); break; } foreach (Model.File file in files) { if (file.filename == name && file.filetype == 0) { ShowMessageDialog("文件(夹)名重复"); flags = 1; return; } } dirNodeManager.MakeDir(name); flags = 1; if (flags == 1) { break; } } } else if (nr == 3) { Random ra = new Random(); int n = ra.Next(100); name = InPutName.Text; if (name == "" || name == null) { ShowMessageDialog("请输入文件名"); return; } int flags = 0; int size = ra.Next(100); int type = ra.Next(4); while (true) { if (files.Count() == 0) { dirNodeManager.CreateFile(name, size, type + 1); break; } foreach (Model.File file in files) { if (file.filename == name && file.filetype == type + 1) { ShowMessageDialog("文件名重复"); flags = 1; return; } } dirNodeManager.CreateFile(name, size, type + 1); flags = 1; if (flags == 1) { break; } } } DirNode d = dirNodeManager.GetWorkDir(); string name1 = dirNodeManager.GetWorkDir().name; files.Clear(); dirNodeManager.LSNOW(d, name1); files = dirNodeManager.GetNowFiles(); InPutDialog.Hide(); }