public void add_new_textures_from_path(string Path) { try { string[] FileNames = Directory.GetFiles(Path); foreach (string f_name in FileNames) { try { var path = f_name.Split('\\', '/'); var image = new ImageContent(path[path.Length - 1], new Bitmap(f_name)); image.name = "tex_" + image.name.Substring(0, image.name.IndexOf(".")) + "\0"; packs.packs[0].Attach(image); } catch { ResourceCollectorXNA.ConsoleWindow.TraceMessage(string.Format("File «{0}» contains no image data!", f_name)); } } } catch (Exception ee) { Eggs.Message(ee.Message); } FormMainPackExplorer.Instance.UpdateData(); }
public void button2_Click(object sender, EventArgs e) { var fileDialog = new OpenFileDialog(); fileDialog.Multiselect = true; if (fileDialog.ShowDialog() != DialogResult.Cancel) { foreach (string f_name in fileDialog.FileNames) { try { var path = f_name.Split('\\', '/'); var image = new ImageContent(path[path.Length - 1], new Bitmap(f_name)); image.name = "tex_" + image.name.Substring(0,image.name.IndexOf("."))+"\0"; packs.packs[0].Attach(image); FormMainPackExplorer.Instance.UpdateData(); } catch { MessageBox.Show(string.Format("File «{0}» contains no image data!", f_name)); } } } if (sender == null) this.Close(); }
private void button4_Click(object sender, EventArgs e) { listBox1.Enabled = false; int[] denumenators = { 2, 4}; string name = listBox1.SelectedItem.ToString(); ImageContent baseimage = null; for (int i = 0; i < List.Pack.Objects.Count; i++) { if (List.Pack.Objects[i].name == name) { baseimage = List.Pack.Objects[i] as ImageContent; break; } } if (baseimage != null) { Image bbb = Image.FromStream(new System.IO.MemoryStream(baseimage.data)); generatedimages = new ImageContent[denumenators.Length]; List.Names.Clear(); List.Names.Add(name); listBox2.Items.Clear(); listBox2.Items.Add(name); for (int i = 0; i < denumenators.Length; i++) { generatedimages[i] = new ImageContent(name.TrimEnd('\0') + "_lod" + i.ToString() + "\0", new Bitmap(bbb, new Size(bbb.Width / denumenators[i], bbb.Height / denumenators[i]))); List.Names.Add(generatedimages[i].name); listBox2.Items.Add(generatedimages[i].name); listBox1.Items.Add(generatedimages[i].name); } } }