/// <summary> /// The ResultDialog constructor /// </summary> /// <param name="result">A <see cref="String"/> containing the hash produced by the /// <see cref="HashEngine"/></param> /// <param name="hash">A <see cref="Hashes"/> enum value indicating which hashing /// algorithm was used</param> /// <param name="outputType">A <see cref="OutputType"/> enum value indicating which /// output encoding type was used</param> public ResultDialog(string result, Hashes hash, OutputType outputType) { // Do the usual initialization: InitializeComponent(); // Put the hash text in the result box: txtResult.Text = result; // Build the hash type label: string labelText = HashEngine.GetHashName(hash) + " / " + HashEngine.GetOutputTypeName(outputType) + ":"; // Hold onto the output type for comparison later: this.outputType = outputType; }
/// <summary> /// Constructor /// </summary> public OptionsDialog() { try { InitializeComponent(); // The state of the Disable Update Checks checkbox should get set by setting the DisableUpdateCheck property. // For the rest, we'll need to do some digging. The Send To shortcuts only make sense on Windows, so just in // case, make sure we're currently running on a Windows box before proceeding here. if (Environment.OSVersion.Platform == PlatformID.Win32NT || Environment.OSVersion.Platform == PlatformID.Win32Windows) { // Convert the path to the Send To folder to a string for our convenience: sendToPath = Environment.GetFolderPath(Environment.SpecialFolder.SendTo); // Set up the output types drop-down. This is pretty simple, and mimics what we did on the main form. // However, we don't know the current state of any existing shortcuts, so we'll default the output type // drop-down to the default value. comboOutputTypes.Items.Clear(); foreach (OutputType otTemp in Enum.GetValues(typeof(OutputType))) { comboOutputTypes.Items.Add(HashEngine.GetOutputTypeName(otTemp)); } comboOutputTypes.SelectedItem = HashEngine.GetOutputTypeName(HashEngine.DefaultOutputType); // Set up the list of shortcuts as a checkbox list box. What we'll do is loop through the available hash // algorithms and, for each one, determine whether or not a shortcut already exists for it. That will decide // whether or not the checkbox will be checked initially. Once we know that, create an item in the list for // that hash and set its initial checked state. listSentToShortcuts.Items.Clear(); foreach (Hashes hashTemp in Enum.GetValues(typeof(Hashes))) { string shortcutFile = sendToPath + Path.DirectorySeparatorChar.ToString() + HashEngine.GetHashName(hashTemp) + ".lnk"; bool isChecked = System.IO.File.Exists(shortcutFile); listSentToShortcuts.Items.Add(HashEngine.GetHashName(hashTemp), isChecked); } } // If we're not running on Windows, disable the Send To shortcut controls so the user can't do anything // with them: else { listSentToShortcuts.Enabled = false; comboOutputTypes.Enabled = false; toolTip1.SetToolTip(listSentToShortcuts, "Send To shortcuts are not supported on your operating system."); toolTip1.SetToolTip(comboOutputTypes, "Send To shortcuts are not supported on your operating system."); } // If enabled, make our tooltips look like nifty balloons: toolTip1.IsBalloon = true; } catch (Exception ex) { MessageBox.Show("There was a problem trying to build the options dialog box.\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }