Provider GetProvider() { using (SelectProvider sp = new SelectProvider(Program.AllProviders)) { sp.ShowDialog(); return(sp.SelectedProvider); } }
void LoadImage(string path) { pngOriginal = new PNG(path); using (MemoryStream stream = new MemoryStream()) { if (imgOriginal.Image != null) { imgOriginal.Image.Dispose(); } pngOriginal.WriteToStream(stream, true, true); stream.Seek(0, SeekOrigin.Begin); Image img = Image.FromStream(stream); imgOriginal.Image = img; imghandler(imgOriginal, null); } lblNoFile.Visible = false; List <Provider> providers = new List <Provider>(Program.Providers); bool hasEOF = false; bool hasTXT = false; int IDATs = 0; foreach (PNGChunk chunk in pngOriginal.Chunks) { if (chunk.Name == "_EOF") { hasEOF = true; } if (chunk.Name == "tEXt") { hasTXT = true; } if (chunk.Name == "IDAT") { IDATs++; } } if (hasEOF) { providers.Add(Program.XOREOF); } if (hasTXT) { providers.Add(Program.XORTXT); } if (IDATs > 1) { providers.Add(Program.XORIDAT); } Provider pr = null; if (providers.Count > 0) { using (SelectProvider prov = new SelectProvider(providers.ToArray())) { prov.ShowDialog(); pr = prov.SelectedProvider; } } providers = null; if (pr == null) { provider = null; SetHidden(DataType.None, null); tabs.SelectedIndex = 0; } else { try { provider = (SteganographyProvider)Activator.CreateInstance(pr.ProviderType, pngOriginal, true); DisposeHidden(); object data; DataType t = provider.Extract(out data); hidden = data; SetHidden(t, data); hiddent = t; if (t != DataType.None) { menuActionDumpHidden.Enabled = true; } } catch (InvalidPasswordException) { provider = null; SetHidden(DataType.None, null); tabs.SelectedIndex = 0; MessageBox.Show(this, "The password you entered was incorrect.", "Incorrect Password", MessageBoxButtons.OK, MessageBoxIcon.Error); } } tabs.Enabled = true; menuActionInject.Enabled = true; menuActionDumpOriginal.Enabled = true; pngOriginal.RemoveNonCritical(); }