private void PopulateFileBrowser()
 {
     try
     {
         foreach (var directory in Directory.GetDirectories(DirPath))
         {
             var files = Directory.GetFiles(directory);
             foreach (var file in files)
             {
                 var fileName = System.IO.Path.Combine(System.IO.Path.GetFileName(directory), System.IO.Path.GetFileName(file));
                 var button   = new Button()
                 {
                     Content = AssetDBEntry.GetDBNameFromFileName(fileName),
                     Margin  = new Thickness(10),
                     Height  = 25,
                     Tag     = fileName
                 };
                 button.Click += FileSelected_Click;
                 FileBrowser.Children.Add(button);
                 DirFiles.Add(fileName);
                 FileBrowserSource.Add(fileName, button);
             }
         }
     }
     catch (Exception e)
     {
         MessageBox.Show("An error occured viewing this directory... " + e);
     }
 }
        public void PopulateFileInfo(AssetDBEntry dbe, bool newlyCreated)
        {
            if (dbe == null)
            {
                return;
            }
            OpenEntry        = dbe;
            FileNameBox.Text = dbe.FileName;
            var name = dbe.DBName ?? "UNKNOWN";

            DBNameBox.Text    = name;
            AssetGuidBox.Text = dbe.GUID;
            if (!newlyCreated)
            {
                AssetTypeSwitcher.SelectedItem = Enum.GetName(typeof(AssetType), dbe.Type);
            }
            else
            {
                AssetTypeSwitcher.SelectedItem = "Texture";
                if (dbe.FileName.EndsWith(".wav"))
                {
                    AssetTypeSwitcher.SelectedItem = "Sound";
                }
                if (dbe.FileName.EndsWith(".obj"))
                {
                    AssetTypeSwitcher.SelectedItem = "Model";
                }
            }
            RefreshReferences(dbe);
            Title = "ADE - Viewing " + name;
        }
        private void PopulateFileInfo(string filePath)
        {
            if (unsavedChanges)
            {
                var result = MessageBox.Show("Opening a new file will delete all unsaved changes. Would you like to save?",
                                             "Changes Unsaved", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
                if (result == MessageBoxResult.Cancel)
                {
                    return;
                }
                if (result == MessageBoxResult.Yes)
                {
                    Save();
                }
                unsavedChanges = false;
            }
            var file = new FileInfo(System.IO.Path.Combine(DirPath, filePath));

            try
            {
                FilePreview.Source          = new BitmapImage(new Uri(System.IO.Path.Combine(DirPath, filePath)));
                FileCorruptBlock.Visibility = Visibility.Collapsed;
            }
            catch
            {
                FilePreview.Source          = null;
                FileCorruptBlock.Visibility = Visibility.Visible;
            }
            var dbe = AssetDBEntry.LoadFromFileName(filePath, out bool created);

            PopulateFileInfo(dbe, created);
        }
 public TextureToolPage(string FilePath, string AssetGuid) : this(FilePath)
 {
     var dbe = AssetDBEntry.Load(AssetGuid, true);
     if (dbe == null)
     {
         MessageBox.Show($"The AssetDBEntry using GUID: {AssetGuid} could not be found. Verify that the path: {FilePath} is " +
                         $"the correct Workspace Directory. If not, you can change it on the opening screen of the editor.");
         return;
     }
     PopulateFileInfo(dbe, false);
 }
 public TextureToolPage(string FilePath) : this()
 {
     DirPath = FilePath;
     PopulateFileBrowser();
     AssetTypeSwitcher.ItemsSource = Enum.GetNames(typeof(AssetType));
     GalleryView.OnDataSelected   += (object sender, LevelDataBlock d) =>
     {
         if (OpenEntry.ReferencedDataBlocks.Where(x => x.GUID == d.GUID).Any())
         {
             return;
         }
         OpenEntry.ReferencedDataBlocks.Add(d);
         RefreshReferences(OpenEntry);
         unsavedChanges = true;
     };
     AssetDBEntry.PushWorkspaceDir(FilePath);
 }
 private void RefreshReferences(AssetDBEntry dbe)
 {
     GUIDBox.Children.Clear();
     foreach (var guid in dbe.ReferencedDataBlocks)
     {
         var button = new Button()
         {
             Content    = guid.GUID + " " + guid.Name,
             Padding    = new Thickness(10, 5, 10, 5),
             Margin     = new Thickness(0, 0, 5, 0),
             Background = new SolidColorBrush(AppResources.S_ColorConvert(guid.Color)),
             Tag        = guid
         };
         button.Click += delegate
         {
             dbe.ReferencedDataBlocks.Remove((LevelDataBlock)button.Tag);
             unsavedChanges = true;
             RefreshReferences(dbe);
         };
         GUIDBox.Children.Add(button);
     }
 }