public void GetFiles(string path)
        {
            if (!Directory.Exists(path))
            {
                return;
            }

            if (workingDirectory_files != null)
            {
                workingDirectory_files.Clear();
            }

            workingDirectory_files = new List <WorkingDirectory_File>();

            workingDirectoryPath = path;

            List <string> directoryFiles = new List <string>(Directory.GetFiles(workingDirectoryPath));

            foreach (string file in directoryFiles)
            {
                string fileName = Path.GetFileNameWithoutExtension(file);
                string fileExt  = Path.GetExtension(file);

                WorkingDirectory_File workingDirectory_file = new WorkingDirectory_File();

                workingDirectory_file.FileName = fileName;
                workingDirectory_file.FileType = fileExt;
                workingDirectory_file.FilePath = file;

                workingDirectory_files.Add(workingDirectory_file);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Previews a DDS image and displays it along with it's properties
        /// </summary>
        public void PreviewImage()
        {
            //if there is no valid item selected, don't continue
            if (ui_textureDirectory_files_listview.SelectedItem == null)
            {
                return;
            }

            //get our selected file object from the working directory
            WorkingDirectory_File workingDirectory_file = (WorkingDirectory_File)ui_textureDirectory_files_listview.SelectedItem;

            //if the selected file is not a .dds file then don't continue (we can only display .dds files)
            if (System.IO.Path.GetExtension(workingDirectory_file.FilePath).Equals(".dds") == false)
            {
                return;
            }

            //create our bitmap object
            BitmapImage bitmap;

            //we are going to try to display the bitmap (if our converter fails and the image can't be decoded as a DDS properly, then we will just catch the exception and ignore)
            try
            {
                //initalize our bitmap object
                bitmap = new BitmapImage();

                //initalize the bitmap image initalizatiom method
                bitmap.BeginInit();

                //get the file path of the dds image on the disk
                bitmap.UriSource = new Uri(workingDirectory_file.FilePath, UriKind.Absolute);

                //end the initalization
                bitmap.EndInit();

                //assign the source to our bitmap object
                ui_imagepreview_image.Source = bitmap;

                //display the name of the image
                ui_imagepreview_imageName_label.Content = workingDirectory_file.FileName;

                //display the image properties
                //ui_imageproperties_infobox_textblock.Text = GetImageProperties_Text(bitmap, workingDirectory_file.FileName, workingDirectory_file.FilePath);
            }
            catch (Exception e)
            {
                //if it fails to decode the dds image and display it, notify the user and write a message.
                //ui_imageproperties_infobox_textblock.Text = "Can't Decode DDS Image.";

                //don't continue
                return;
            }
        }