private void Rename_Click(object sender, RoutedEventArgs e) //провіряти чи MainWindow editable == true { if ((Owner as MainWindow).IsReadOnly) { return; } RenameWindow renamer = new RenameWindow(elements[currentIndex].Name, elements[currentIndex].Type) { Owner = this }; if (renamer.ShowDialog() == true) { try { elements[currentIndex].Name = renamer.textBox.Text; } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message); return; } Title = elements[currentIndex].Name; } }
private void MenuItem_CreateNewTextFile(object sender, RoutedEventArgs e) { if ((listView.Tag as Element) != null) { RenameWindow newDoc = new RenameWindow(); // ".txt", ElementType.File); newDoc.Owner = this; newDoc.Title = "Новый текстовый документ"; newDoc.label.Content = "Имя файла"; if ((newDoc.ShowDialog() == true) && (newDoc.textBox.Text != "")) { Stream ms = Stream.Null; Bitmap bmp = ImgConverter.GetIcon(".txt", thumbnailSize); FileElement newTextFile = null; try { newTextFile = (listView.Tag as DirElement).AddFile(ms, newDoc.textBox.Text + ".txt", false, bmp); } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message); } bmp?.Dispose(); ShowFiles(listView.Tag as Element, newTextFile); } } }
public void Rename() { if (IsReadOnly) { return; } if (listView.SelectedItem == null) { return; } Element element = listView.SelectedItem as Element; RenameWindow renamer = new RenameWindow(element.Name, element.Type) { Owner = this }; if (renamer.ShowDialog() == true) { try { element.Name = renamer.textBox.Text; } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message); return; } } }
private void CreateNewDir() { RenameWindow newdir = new RenameWindow(); newdir.Owner = this; newdir.Title = "Новая папка"; newdir.label.Content = "Имя папки"; if ((newdir.ShowDialog() == true) && (newdir.textBox.Text != "")) { DirElement newDir; try { newDir = (listView.Tag as DirElement).CreateDir(newdir.textBox.Text); } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message); return; } ShowFiles(listView.Tag as Element, newDir); } }