/// <summary>
 /// Constructor
 /// </summary>
 /// <param name="aMonitor">A DeviceVolumeMonitor instance that ownes the object</param>
 /// <param name="aHandle">The Windows handle to be used</param>
 public _DeviceVolumeMonitor(DeviceVolumeMonitor aMonitor)
 {
     fMonitor = aMonitor;
 }
Example #2
0
    private void UpdateIcons()
    {
      ulong optionBitmask = 0L;
      ulong num2;
      bool flag = false;
      var icon = new DiskIcon();
      Log.Debug("iMONLCDg.UpdateIcons(): Starting Icon Update Thread");
      var mask = new BuiltinIconMask();
      var drive = new CDDrive();
      if (DisplaySettings.BlankDisplayWithVideo & DisplaySettings.EnableDisplayAction)
      {
        GUIWindowManager.OnNewAction += OnExternalAction;
      }
      for (int i = 0; i < 0x1b; i++)
      {
        Inserted_Media[i] = 0;
      }
      if (DisplayOptions.DiskIcon & DisplayOptions.DiskMonitor)
      {
        char[] cDDriveLetters = CDDrive.GetCDDriveLetters();
        var arg = cDDriveLetters.Length;
        Log.Debug("iMONLCDg.UpdateIcons(): Found {0} CD/DVD Drives.", arg);
        for (int j = 0; j < cDDriveLetters.Length; j++)
        {
          if (drive.Open(cDDriveLetters[j]))
          {
            Log.Debug("iMONLCDg.UpdateIcons(): Checking media in Drive {0}.", cDDriveLetters[j]);
            bool flag2 = false;
            for (int k = 0; k < 10; k++)
            {
              if (drive.IsCDReady())
              {
                flag2 = true;
              }
              else
              {
                Thread.Sleep(50);
              }
            }
            if (flag2)
            {
              Log.Debug("iMONLCDg.UpdateIcons(): Waiting for Drive {0} to refresh.", cDDriveLetters[j]);
              drive.Refresh();
              if (drive.GetNumAudioTracks() > 0)
              {
                Inserted_Media[cDDriveLetters[j] - 'A'] = 1;
                Log.Debug("iMONLCDg.UpdateIcons(): Found Audio CD in Drive {0}.", cDDriveLetters[j]);
              }
              else if (File.Exists(cDDriveLetters[j] + @"\VIDEO_TS"))
              {
                Inserted_Media[cDDriveLetters[j] - 'A'] = 2;
                Log.Debug("iMONLCDg.UpdateIcons(): Found DVD in Drive {0}.", cDDriveLetters[j]);
              }
              else
              {
                Inserted_Media[cDDriveLetters[j] - 'A'] = 4;
                Log.Debug("iMONLCDg.UpdateIcons(): Unknown media found in Drive {0}.", cDDriveLetters[j]);
              }
            }
            else
            {
              Inserted_Media[cDDriveLetters[j] - 'A'] = 0;
              Log.Debug("iMONLCDg.UpdateIcons(): No media found in Drive {0}.", cDDriveLetters[j]);
            }
          }
          drive.Close();
        }
      }
      if (DisplayOptions.DiskIcon & DisplayOptions.DiskMonitor)
      {
        ActivateDVM();
      }
      icon.Reset();
      while (true)
      {
        do
        {
          lock (ThreadMutex)
          {
            if (DoDebug)
            {
              Log.Info("iMONLCDg.UpdateIcons(): Checking for Thread termination request");
            }
            if (_stopUpdateIconThread)
            {
              Log.Info("iMONLCDg.UpdateIcons(): Icon Update Thread terminating");
              _stopUpdateIconThread = false;
              if (DisplaySettings.BlankDisplayWithVideo & DisplaySettings.EnableDisplayAction)
              {
                GUIWindowManager.OnNewAction -= OnExternalAction;
              }
              if (DVM != null)
              {
                DVM.Dispose();
                DVM = null;
              }
              return;
            }
            if ((!DVMactive & DisplayOptions.DiskIcon) & DisplayOptions.DiskMonitor)
            {
              ActivateDVM();
            }
            num2 = optionBitmask;
            flag = !flag;
            int num7 = _CurrentLargeIcon;
            LastVolLevel = volLevel;
            LastProgLevel = progLevel;
            int num8 = 0;
            icon.Off();
            icon.Animate();
            if (DoDebug)
            {
              Log.Info("iMONLCDg.UpdateIcons(): Checking TV Card status: IsAnyCardRecording = {0}, IsViewing = {1}",
                       MiniDisplayHelper.IsCaptureCardRecording().ToString(),
                       MiniDisplayHelper.IsCaptureCardViewing().ToString());
            }
            MiniDisplayHelper.GetSystemStatus(ref MPStatus);
            Check_Idle_State();
            if (DoDebug)
            {
              Log.Info("iMONLCDg.UpdateIcons(): System Status: Plugin Status = {0}, IsIdle = {1}",
                       MPStatus.CurrentPluginStatus.ToString(), MPStatus.MP_Is_Idle);
            }
            optionBitmask = ConvertPluginIconsToDriverIcons(MPStatus.CurrentIconMask);
            if ((optionBitmask & (0x400000000L)) > 0L)
            {
              num8 = 5;
            }
            else if ((optionBitmask & (8L)) > 0L)
            {
              num8 = 1;
            }
            if (MiniDisplayHelper.IsCaptureCardViewing() && !MPStatus.Media_IsTimeshifting)
            {
              icon.On();
              icon.InvertOn();
              icon.RotateCW();
            }
            if (_mpIsIdle)
            {
              num8 = 0;
            }
            if (MPStatus.MediaPlayer_Playing)
            {
              icon.On();
              if ((MPStatus.CurrentIconMask & (0x10L)) > 0L)
              {
                icon.InvertOff();
              }
              else
              {
                icon.InvertOn();
              }
              if ((MPStatus.CurrentIconMask & (0x10000000000L)) > 0L)
              {
                icon.RotateCCW();
              }
              else
              {
                icon.RotateCW();
              }
              icon.FlashOff();
              if (((((((MPStatus.CurrentIconMask & (0x40L)) > 0L) |
                      ((MPStatus.CurrentIconMask & (8L)) > 0L)) |
                     (MPStatus.CurrentPluginStatus == Status.PlayingDVD)) |
                    (MPStatus.CurrentPluginStatus == Status.PlayingTV)) |
                   (MPStatus.CurrentPluginStatus == Status.PlayingVideo)) |
                  (MPStatus.CurrentPluginStatus == Status.Timeshifting))
              {
                if ((MPStatus.CurrentPluginStatus == Status.PlayingTV) |
                    ((MPStatus.CurrentIconMask & (8L)) > 0L))
                {
                  num8 = 1;
                }
                else
                {
                  num8 = 2;
                }
                if (DisplaySettings.BlankDisplayWithVideo)
                {
                  DisplayOff();
                }
              }
              else
              {
                num8 = 3;
              }
              GetEQ();
            }
            else if (MPStatus.MediaPlayer_Paused)
            {
              icon.On();
              lock (DWriteMutex)
              {
                EQSettings._EqDataAvailable = false;
                _iconThread.Priority = ThreadPriority.BelowNormal;
              }
              RestoreDisplayFromVideoOrIdle();
              icon.FlashOn();
              num8 = 6;
            }
            else
            {
              icon.Off();
              RestoreDisplayFromVideoOrIdle();
              lock (DWriteMutex)
              {
                EQSettings._EqDataAvailable = false;
                _iconThread.Priority = ThreadPriority.BelowNormal;
              }
            }
            if ((!MiniDisplayHelper.Player_Playing() & !MiniDisplayHelper.IsCaptureCardViewing()) ||
                (DisplayOptions.DiskIcon & !DisplayOptions.DiskMediaStatus))
            {
              int num9 = 0;
              if (DisplayOptions.DiskIcon)
              {
                for (int m = 0; m < 0x1b; m++)
                {
                  num9 |= Inserted_Media[m];
                }
                switch (num9)
                {
                  case 1:
                    optionBitmask |= mask.ICON_CDIn;
                    goto Label_06B0;

                  case 2:
                    optionBitmask |= mask.ICON_DVDIn;
                    goto Label_06B0;
                }
                if (num9 > 0)
                {
                  optionBitmask |= mask.ICON_DiskOn;
                }
              }
            }
            Label_06B0:
            if (DisplayOptions.DiskIcon & DisplayOptions.DiskMediaStatus)
            {
              optionBitmask |= icon.Mask;
            }
            if (DoDebug)
            {
              Log.Info("iMONLCDg.UpdateIcons(): last = {0}, new = {1}, disk mask = {2}",
                       num2.ToString("X0000000000000000"), optionBitmask.ToString("X0000000000000000"),
                       icon.Mask.ToString("X0000000000000000"));
            }
            if (optionBitmask != num2)
            {
              lock (DWriteMutex)
              {
                SendData(iMonCommand.General.SetIcons, optionBitmask);
              }
            }
            DisplayEQ();
            if (DisplayOptions.VolumeDisplay || DisplayOptions.ProgressDisplay)
            {
              lock (DWriteMutex)
              {
                ShowProgressBars();
              }
            }
            if (num8 != num7)
            {
              _CurrentLargeIcon = num8;
            }
          }
        } while (EQSettings._EqDataAvailable && !MPStatus.MediaPlayer_Paused);
        Thread.Sleep(200);
      }
    }
Example #3
0
 private void ActivateDVM()
 {
   try
   {
     if (!DVMactive)
     {
       DVM = new DeviceVolumeMonitor(GUIGraphicsContext.form.Handle);
       if (DVM != null)
       {
         DVM.OnVolumeInserted += VolumeInserted;
         DVM.OnVolumeRemoved += VolumeRemoved;
         DVM.AsynchronousEvents = true;
         DVM.Enabled = true;
         Log.Debug("iMONLCDg.ActivateDVM(): DVM Activated");
         DVMactive = true;
       }
     }
   }
   catch (Exception exception)
   {
     DVMactive = true;
     Log.Debug("iMONLCDg.ActivateDVM(): caught exception: {0}", exception);
   }
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="aMonitor">A DeviceVolumeMonitor instance that ownes the object</param>
 /// <param name="aHandle">The Windows handle to be used</param>
 public _DeviceVolumeMonitor(DeviceVolumeMonitor aMonitor)
 {
   fMonitor = aMonitor;
 }