Beispiel #1
0
 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);
         }
     }
 }
        private void ChangeIcon_Button_Click(object sender, RoutedEventArgs e)
        {
            if (element == null)
            {
                return;
            }

            OpenFileDialog op = new OpenFileDialog();

            if (op.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Bitmap bmp = ImgConverter.GetIcon(op.FileName, MainWindow.thumbnailSize);
                element.Icon     = bmp;
                Thumbnail.Source = ImgConverter.BitmapToImageSource(bmp);
                bmp?.Dispose();
            }
            op.Dispose();
        }
Beispiel #3
0
 private Bitmap GetIcon(string FileName)
 {
     return(ImgConverter.GetIcon(FileName, thumbnailSize));
 }