protected override void OnLoad(EventArgs e) { Visible = false; // Hide form window. ShowInTaskbar = false; // Remove from taskbar. base.OnLoad(e); StamperLiveData.Log("Application Started."); // load previous project or start new project InitialiseData(); // show the drives form OnDrives(null, null); }
public void StampDrive(DriveInfo drive) { try { if (OnActivityChanged != null) { OnActivityChanged(eActivity.Stamping); } IEnumerable <string> failiures = null; bool success = false; string msg = "Stamping drive: " + drive.Name; StamperLiveData.Log(msg); DriveStamperUI.ShowMessage(msg, ToolTipIcon.Info); success = Stamper.Stamp(drive, StamperLiveData.Project, out failiures); if (success) { string msgOk = "Drive stamped: " + drive.Name; StamperLiveData.Log(msgOk); DriveStamperUI.ShowMessage(msgOk, ToolTipIcon.Info); } else { string msgFail = "Drive not succesfully stamped:\n" + string.Join("\n", (failiures ?? new List <string>()).ToArray()); StamperLiveData.Log(msgFail); DriveStamperUI.ShowMessage(msgFail, ToolTipIcon.Warning); } } catch (Exception e) { string msgFail = "Unexpected exception:\n" + e.Message; StamperLiveData.Log(msgFail); DriveStamperUI.ShowMessage(msgFail, ToolTipIcon.Warning); } finally { UpdateDrives(); if (OnActivityChanged != null) { OnActivityChanged(eActivity.None); } } }
private void OnDriveArrived(object sender, DriveDetectorEventArgs e) { e.HookQueryRemove = false; UpdateDrives(); // match the drive to a key already in the observed state var drive = StamperLiveData.ObservedDriveState.Keys.Where(k => k.Name == new DriveInfo(e.Drive).Name).FirstOrDefault(); if (drive != null) { StamperLiveData.Log("Drive detected: " + e.Drive + " - in state: " + StamperLiveData.ObservedDriveState[drive].ToString()); } else { StamperLiveData.Log("Drive detected: " + e.Drive + " - state not detected."); } if (drive != null && StamperLiveData.ObservedDriveState[drive] == eDriveState.Ready) { if (StamperLiveData.Mode == eStampMode.Automatic) { StampDrive(drive); } if (StamperLiveData.Mode == eStampMode.SemiAutomatic) { var answer = MessageBox.Show("Stamp drive: " + drive.Name + "?", "Drive detected", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (answer == System.Windows.Forms.DialogResult.Yes) { StampDrive(drive); } } UpdateDrives(); } }
/// <summary> /// Called by DriveDetector after removable device has been unplugged /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnDriveRemoved(object sender, DriveDetectorEventArgs e) { StamperLiveData.Log("Drive removed: " + e.Drive); UpdateDrives(); }