private void lstParts_SelectedIndexChanged(object sender, EventArgs e) { pnlPart.Controls.Clear(); Control next = null; object obj = lstParts.SelectedItems.Count == 0 ? null : lstParts.SelectedItems[0].Tag; if (obj is GifPartHeader) { GifPartHeader head = obj as GifPartHeader; ctrlHeader.Part = head; next = ctrlHeader; } else if (obj is GifPartLwzImage) { GifPartLwzImage img = obj as GifPartLwzImage; ctrlLwzImg.Part = img; next = ctrlLwzImg; } else if (obj is GifPartMetaData.ApplicationData) { GifPartMetaData.ApplicationData meta = obj as GifPartMetaData.ApplicationData; ctrlMetaApp.Part = meta; next = ctrlMetaApp; } else if (obj is GifPartMetaData.Comment) { GifPartMetaData.Comment meta = obj as GifPartMetaData.Comment; ctrlHex.Part = meta; next = ctrlHex; } else if (obj is GifPartMetaData.GraphicsControl) { GifPartMetaData.GraphicsControl meta = obj as GifPartMetaData.GraphicsControl; ctrlMetaCtrl.Part = meta; next = ctrlMetaCtrl; } else if (obj is GifPartMetaData.Loop) { GifPartMetaData.Loop meta = obj as GifPartMetaData.Loop; ctrlMetaLoop.Part = meta; next = ctrlMetaLoop; } else if (obj is GifPartMetaData.TextDraw) { GifPartMetaData.TextDraw meta = obj as GifPartMetaData.TextDraw; ctrlMetaText.Part = meta; next = ctrlMetaText; } else if (obj is GifPartMetaData) { GifPartMetaData meta = obj as GifPartMetaData; ctrlHex.Part = meta; next = ctrlHex; } else if (obj is GifPartGarbageData) { GifPartGarbageData meta = obj as GifPartGarbageData; ctrlHex.Part = meta; next = ctrlHex; } if (ctrlCurr != next) { SuspendLayout(); pnlPart.Controls.Clear(); if (next != null) { pnlPart.Controls.Add(next); next.Dock = DockStyle.Fill; } ResumeLayout(); ctrlCurr = next; } }
private void UpdateListViewItem(ListViewItem item, GifPart part) { if (part is GifPartHeader) { item.Text = "Header"; item.ImageIndex = 0; } else if (part is GifPartLwzImage) { GifPartLwzImage img = part as GifPartLwzImage; item.Text = string.Format("Image [{0}x{1} @{2}x{3}]", img.Width, img.Height, img.Left, img.Top); item.ImageIndex = 1; } else if (part is GifPartMetaData.ApplicationData) { GifPartMetaData.ApplicationData app = part as GifPartMetaData.ApplicationData; item.Text = string.Format("AppData [{0}]", app.AppIdentifier); item.ImageIndex = 2; } else if (part is GifPartMetaData.Loop) { GifPartMetaData.Loop loop = part as GifPartMetaData.Loop; item.Text = string.Format("AppData [Repeat: {0}]", loop.Iterations); item.ImageIndex = 2; } else if (part is GifPartMetaData.Comment) { GifPartMetaData.Comment cmt = part as GifPartMetaData.Comment; item.Text = string.Format("Comment [{0} bytes]", cmt.Content.Length); item.ImageIndex = 3; } else if (part is GifPartMetaData.GraphicsControl) { GifPartMetaData.GraphicsControl ctrl = part as GifPartMetaData.GraphicsControl; item.Text = string.Format("Control [Trans:{0}, Delay:{1}]", ctrl.UseTransparency ? "1" : "0", ctrl.UseUserInput ? "User" : ((ctrl.DelayTime).ToString() + "ms")); item.ImageIndex = 4; } else if (part is GifPartMetaData.TextDraw) { GifPartMetaData.TextDraw txt = part as GifPartMetaData.TextDraw; string txtt = txt.Text; item.Text = string.Format("Text [{2}, @{0}x{1}]", txt.Left, txt.Width, txtt.Length > 10 ? (txtt.Substring(0, 8) + "...") : txtt); item.ImageIndex = 5; } else if (part is GifPartMetaData) { GifPartMetaData mta = part as GifPartMetaData; item.Text = string.Format("Unknown [{0}]", mta.MetaType); item.ImageIndex = 6; } else if (part is GifPartTerminator) { item.Text = "EOF"; item.ImageIndex = 7; } else if (part is GifPartGarbageData) { GifPartGarbageData grb = part as GifPartGarbageData; item.Text = "Garbage data"; item.ImageIndex = 8; } }