Open/Close optical drive tray toggle now working.
authorStephaneLenclud
Thu, 03 Sep 2015 18:18:48 +0200
changeset 156f6d93a560a78
parent 155 703daa997f59
child 157 0f3e7b21c663
Open/Close optical drive tray toggle now working.
Server/MainForm.Hid.cs
     1.1 --- a/Server/MainForm.Hid.cs	Wed Sep 02 22:35:47 2015 +0200
     1.2 +++ b/Server/MainForm.Hid.cs	Thu Sep 03 18:18:48 2015 +0200
     1.3 @@ -336,9 +336,16 @@
     1.4  
     1.5                  if (PreventRemovalOfVolume(handle,false))
     1.6                  {
     1.7 -                   StorageCheckVerify(handle);
     1.8 +                    //StorageCheckVerify(handle);
     1.9  
    1.10 -                    if (MediaEject(handle))
    1.11 +                    DateTime before;
    1.12 +                    before = DateTime.Now;
    1.13 +                    bool ejectSuccess = MediaEject(handle);
    1.14 +                    double ms = (DateTime.Now - before).TotalMilliseconds;
    1.15 +
    1.16 +                    //We assume that if it take more than a certain time to for eject to execute it means we actually ejected.
    1.17 +                    //If our eject completes too rapidly we assume the tray is already open and we will try to close it. 
    1.18 +                    if (ejectSuccess && ms > 100)
    1.19                      {
    1.20                          Debug.WriteLine("Media was ejected");
    1.21                      }