private void PreviewPAL(DataRow dataRow) { HidePreviewControls(); Byte[] buffer = Utilities.InflateFile(dataRow); if ((buffer != null) && (buffer.Length > 0)) { String Name = (String)dataRow["Name"]; this.m_PALFilePreview = new PALFile(new MemoryStream(buffer)); this.m_PALFilePreview.Filename = Name.Substring(Name.LastIndexOf("/") + 1); this.flowLayoutPanelPalPreview.Visible = true; this.flowLayoutPanelPalPreview.BringToFront(); this.flowLayoutPanelPalPreview.SuspendLayout(); foreach (Color color in this.m_PALFilePreview.Colors) { Button button = new Button(); button.Size = new Size(32, 32); button.BackColor = color; button.FlatStyle = FlatStyle.Flat; button.FlatAppearance.BorderColor = Color.Black; button.FlatAppearance.BorderSize = 0; button.FlatAppearance.MouseDownBackColor = color; button.FlatAppearance.MouseOverBackColor = color; button.Font = new Font("Microsoft Sans Serif", 6, FontStyle.Regular, GraphicsUnit.Point); button.Text = this.m_PALFilePreview.HexadecimalIndex(color); this.flowLayoutPanelPalPreview.Controls.Add(button); } this.flowLayoutPanelPalPreview.ResumeLayout(true); } }
protected override void OnVisibleChanged(EventArgs e) { base.OnVisibleChanged(e); if (!this.Visible) { this.Text = "TRE Explorer " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; this.toolStripStatusLabel.Text = "0 colors"; this.m_PALFile = null; this.toolStripButtonPalSave.Enabled = false; this.toolStripButtonPalSaveAs.Enabled = false; this.flowLayoutPanelPalEditor.SuspendLayout(); if (this.flowLayoutPanelPalEditor.Controls.Count > 0) { foreach (Button button in this.flowLayoutPanelPalEditor.Controls) { button.Dispose(); } this.flowLayoutPanelPalEditor.Controls.Clear(); } this.flowLayoutPanelPalEditor.ResumeLayout(true); } }
private void listView_SelectedIndexChanged(object sender, EventArgs e) { if (this.m_DataViewListView != null) { if ((this.listView.SelectedIndices.Count > 0) && (this.listView.SelectedIndices[0] < this.m_DataViewListView.Count)) { DataRow dataRow = this.m_DataViewListView[this.listView.SelectedIndices[0]].Row; String name = (String)dataRow["Name"]; this.toolStripButtonExport.Enabled = true; if (this.listView.SelectedIndices.Count == 1) { if ((this.m_LastPreviewed != this.listView.SelectedIndices[0]) && ((String)dataRow["File_Type"] != "File Folder")) { this.m_IFFFilePreview = null; this.m_PALFilePreview = null; this.m_STFFilePreview = null; this.m_LastPreviewed = this.listView.SelectedIndices[0]; if ((name.ToLower().EndsWith(".dds")) || (name.ToLower().EndsWith(".tga"))) { this.PreviewDDS(dataRow); } else if (name.ToLower().EndsWith(".iff")) { this.PreviewIFF(dataRow); } else if (name.ToLower().EndsWith(".stf")) { this.PreviewSTF(dataRow); } else if ((name.ToLower().EndsWith(".wav")) || (name.ToLower().EndsWith(".mp3"))) { this.PreviewMP3WAV(); } else if (name.ToLower().EndsWith(".pal")) { this.PreviewPAL(dataRow); } else if ((name.ToLower().EndsWith(".inc")) || (name.ToLower().EndsWith(".qst"))) { this.PreviewINCQST(dataRow); } else { this.PreviewOther(dataRow); } } Int32 imageIndex = this.ImageIndex(dataRow["File_Type"].ToString()); if (imageIndex != -1) { this.pictureBoxDetails.Image = new Bitmap(this.imageListLarge.Images[imageIndex], this.pictureBoxDetails.Width, this.pictureBoxDetails.Height); name = name.Trim(new Char[] { '/' }); if (name.Contains("/")) { name = name.Substring(name.LastIndexOf("/") + 1); } if (dataRow["File_Type"].ToString() == "File Folder") { this.webBrowserDetails.DocumentText = "<BODY BGCOLOR=\"#" + String.Format("{0:X}", SystemColors.Control.R) + String.Format("{0:X}", SystemColors.Control.G) + String.Format("{0:X}", SystemColors.Control.B) + "\"><FONT FACE=\"Microsoft Sans Serif\" SIZE=\"2\">" + ((TRE_Explorer.Properties.Settings.Default.DetailsDisplaysFullPath) ? ((String)dataRow["Name"]).Trim() : name).TrimStart(new Char[] { '/' }) + "<BR>" + dataRow["File_Type"].ToString() + "</FONT></BODY>"; } else { this.webBrowserDetails.DocumentText = "<BODY BGCOLOR=\"#" + String.Format("{0:X}", SystemColors.Control.R) + String.Format("{0:X}", SystemColors.Control.G) + String.Format("{0:X}", SystemColors.Control.B) + "\"><TABLE HEIGHT=\"*\" WIDTH=\"*\" BORDER=\"0\" CELPADDING=\"1\" CELLSPACING=\"1\"><TR VALIGN=\"TOP\"><TD ALIGN=\"LEFT\" NOWRAP><FONT FACE=\"Microsoft Sans Serif\" SIZE=\"2\">" + ((TRE_Explorer.Properties.Settings.Default.DetailsDisplaysFullPath) ? ((String)dataRow["Name"]).Trim() : name) + "<BR>" + dataRow["File_Type"].ToString() + "</FONT></TD><TD ALIGN=\"RIGHT\" NOWRAP><FONT COLOR=\"#888888\" FACE=\"Microsoft Sans Serif\" SIZE=\"2\">Size: <BR>Container: <BR>Compressed Size: </FONT></TD><TD ALIGN=\"LEFT\" NOWRAP><FONT FACE=\"Microsoft Sans Serif\" SIZE=\"2\">" + Utilities.SizeToString((Int32)dataRow["Final_Size"]) + "<BR>" + ((String)dataRow["Filename"]).Substring(((String)dataRow["Filename"]).LastIndexOf("\\") + 1) + "<BR>" + Utilities.SizeToString((Int32)dataRow["Size"]) + "</FONT></TD></TR></TABLE></BODY>"; } } } else if (this.listView.SelectedIndices.Count > 1) { HidePreviewControls(); try { /* this.pictureBoxDetails.Image = new Bitmap(this.pictureBoxDetails.Width, this.pictureBoxDetails.Height); Graphics graphics = Graphics.FromImage(this.pictureBoxDetails.Image); foreach (Int32 index in this.listView.SelectedIndices) { Int32 imageIndex = this.ImageIndex(this.dataViewListView[index]["file_type"].ToString()); if (imageIndex != -1) { graphics.DrawImage(this.imageListLarge.Images[imageIndex], 0, 0, this.pictureBoxDetails.Width, this.pictureBoxDetails.Height); } } */ this.pictureBoxDetails.Image = this.imageListLarge.Images[this.ImageIndex((String)dataRow["File_Type"])]; } catch { } this.webBrowserDetails.DocumentText = "<BODY BGCOLOR=\"#" + String.Format("{0:X}", SystemColors.Control.R) + String.Format("{0:X}", SystemColors.Control.G) + String.Format("{0:X}", SystemColors.Control.B) + "\"><FONT FACE=\"Microsoft Sans Serif\" SIZE=\"2\">" + String.Format("{0:n0}", this.listView.SelectedIndices.Count) + " item" + ((this.listView.SelectedIndices.Count == 1) ? "" : "s") + " selected</FONT></BODY>"; } } else { HidePreviewControls(); this.pictureBoxDetails.Image = new Bitmap(this.imageListLarge.Images[0], this.pictureBoxDetails.Width, this.pictureBoxDetails.Height); this.webBrowserDetails.DocumentText = "<BODY BGCOLOR=\"#" + String.Format("{0:X}", SystemColors.Control.R) + String.Format("{0:X}", SystemColors.Control.G) + String.Format("{0:X}", SystemColors.Control.B) + "\"><FONT FACE=\"Microsoft Sans Serif\" SIZE=\"2\">" + String.Format("{0:n0}", this.m_DataViewListView.Count) + " item" + ((this.m_DataViewListView.Count == 1) ? "" : "s") + "</FONT></BODY>"; } } else { HidePreviewControls(); this.pictureBoxDetails.Image = new Bitmap(this.pictureBoxDetails.Width, this.pictureBoxDetails.Height); this.webBrowserDetails.DocumentText = "<BODY BGCOLOR=\"#" + String.Format("{0:X}", SystemColors.Control.R) + String.Format("{0:X}", SystemColors.Control.G) + String.Format("{0:X}", SystemColors.Control.B) + "\"></BODY>"; } this.toolStripButtonExport.Enabled = (this.listView.SelectedIndices.Count > 0); this.toolStripButtonExportFileChain.Enabled = ((this.listView.SelectedIndices.Count == 1) && (this.m_IFFFilePreview != null) && (!this.m_IFFFilePreview.IsDataTable)); }
internal void PALLoadFile(String filename) { this.m_PALFile = new PALFile(filename); PALDisplay(); }