Esempio n. 1
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);
      }
    }
Esempio n. 2
0
 private void DisplayUpdate()
 {
   uint segments = 0;
   bool flag = false;
   DiskIcon icon = new DiskIcon();
   if (this.DoDebug)
   {
     Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Starting Display Update Thread");
   }
   CDDrive drive = new CDDrive();
   bool flag2 = false;
   int num2 = 0;
   if (this.DisplaySettings.BlankDisplayWithVideo & this.DisplaySettings.EnableDisplayAction)
   {
     GUIWindowManager.OnNewAction += new OnActionHandler(this.OnExternalAction);
   }
   char[] cDDriveLetters = CDDrive.GetCDDriveLetters();
   if (this.DoDebug)
   {
     object[] arg = new object[] {cDDriveLetters.Length.ToString()};
     Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Found {0} CD/DVD Drives.", arg);
   }
   //if (cDDriveLetters.Length > 0)
   //{
   //  drive.Open(cDDriveLetters[0]);
   //}
   icon.Reset();
   while (true)
   {
     lock (this.StopMutex)
     {
       if (this.stopDisplayUpdateThread)
       {
         if (this.DoDebug)
         {
           Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Display Update Thread terminating");
         }
         if (this.DisplaySettings.BlankDisplayWithVideo & this.DisplaySettings.EnableDisplayAction)
         {
           GUIWindowManager.OnNewAction -= new OnActionHandler(this.OnExternalAction);
         }
         return;
       }
     }
     MiniDisplayHelper.GetSystemStatus(ref this.MPStatus);
     flag = !flag;
     int num3 = num2;
     int num4 = 0;
     uint num5 = 0;
     icon.Off();
     icon.Animate();
     if (this.DoDebug)
     {
       Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Collecting status...");
     }
     if (MiniDisplayHelper.MPStatus.Media_IsRecording)
     {
       num5 |= 0x2000;
       num4 = 5;
       if (this.DoDebug)
       {
         Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Setting REC icon");
       }
     }
     if (this.MPStatus.MediaPlayer_Playing)
     {
       string property;
       string[] strArray;
       if ((this.MPStatus.Media_IsTV || this.MPStatus.Media_IsTVRecording) &
           (!this.MPStatus.Media_IsDVD && !this.MPStatus.Media_IsCD))
       {
         if (this.MPStatus.MediaPlayer_Playing)
         {
           if (this.DisplaySettings.BlankDisplayWithVideo)
           {
             this.DisplayOff();
           }
         }
         else
         {
           this.RestoreDisplayFromVideoOrIdle();
         }
         num5 |= 1;
         num4 = 1;
         if (this.DoDebug)
         {
           Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Setting ICON_TV");
         }
       }
       if (this.MPStatus.Media_IsDVD || this.MPStatus.Media_IsCD)
       {
         if (this.MPStatus.Media_IsDVD & this.MPStatus.Media_IsVideo)
         {
           if (this.DisplaySettings.BlankDisplayWithVideo)
           {
             this.DisplayOff();
           }
           num5 |= 8;
           num5 |= 2;
           num4 = 2;
           if (this.DoDebug)
           {
             Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Setting ICON_DVD & ICON_MOVIE");
           }
         }
         else if (this.MPStatus.Media_IsCD & !this.MPStatus.Media_IsVideo)
         {
           num5 |= 0x10;
           num5 |= 4;
           num4 = 3;
           if (this.DoDebug)
           {
             Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Setting ICON_MUSIC & ICON_CD");
           }
         }
         icon.On();
         icon.InvertOff();
         if (this.MPStatus.MediaPlayer_Playing)
         {
           if (this.MPStatus.Media_Speed > 0)
           {
             icon.RotateCW();
           }
           else if (this.MPStatus.Media_Speed < 0)
           {
             icon.RotateCCW();
           }
           icon.FlashOff();
         }
         else
         {
           this.RestoreDisplayFromVideoOrIdle();
           icon.FlashOn();
           num4 = 6;
           if (this.DoDebug)
           {
             Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Setting PAUSED icon");
           }
         }
       }
       if (this.MPStatus.Media_IsMusic)
       {
         if (this.DoDebug)
         {
           Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Setting ICON_MUSIC");
         }
         num5 |= 0x10;
         num4 = 3;
         icon.On();
         icon.InvertOn();
         if (this.MPStatus.MediaPlayer_Playing)
         {
           if (this.MPStatus.Media_Speed > 0)
           {
             icon.RotateCW();
           }
           else if (this.MPStatus.Media_Speed < 0)
           {
             icon.RotateCCW();
           }
           icon.FlashOff();
         }
         else
         {
           icon.FlashOn();
           num4 = 6;
           if (this.DoDebug)
           {
             Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Setting PAUSED icon");
           }
         }
         if (!_useDiskIconForAllMedia)
         {
           icon.Off();
         }
         property = GUIPropertyManager.GetProperty("#Play.Current.File");
         if (property.Length > 0)
         {
           string str2;
           strArray = property.Split(new char[] {'.'});
           if ((strArray.Length > 1) && ((str2 = strArray[1]) != null))
           {
             if (!(str2 == "mp3"))
             {
               if (str2 == "ogg")
               {
                 num5 |= 0x80;
                 if (this.DoDebug)
                 {
                   Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Setting ICON_OGG");
                 }
               }
               else if (str2 == "wma")
               {
                 num5 |= 0x200;
                 if (this.DoDebug)
                 {
                   Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Setting ICON_WMA");
                 }
               }
               else if (str2 == "wav")
               {
                 num5 |= 0x4000;
                 if (this.DoDebug)
                 {
                   Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Setting ICON_WAV");
                 }
               }
             }
             else
             {
               num5 |= 0x100;
               if (this.DoDebug)
               {
                 Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Setting ICON_MP3");
               }
             }
           }
         }
       }
       if (this.MPStatus.Media_IsVideo & !this.MPStatus.Media_IsDVD)
       {
         num5 |= 8;
         num5 |= 0x10;
         num4 = 4;
         if (this.DoDebug)
         {
           Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Setting ICON_MOVIE");
         }
         icon.On();
         icon.InvertOn();
         if (this.MPStatus.MediaPlayer_Playing)
         {
           if (this.DisplaySettings.BlankDisplayWithVideo)
           {
             this.DisplayOff();
           }
           if (this.MPStatus.Media_Speed > 0)
           {
             icon.RotateCW();
           }
           else if (this.MPStatus.Media_Speed < 0)
           {
             icon.RotateCCW();
           }
           icon.FlashOff();
         }
         else
         {
           this.RestoreDisplayFromVideoOrIdle();
           icon.FlashOn();
           num4 = 6;
           if (this.DoDebug)
           {
             Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Setting PAUSED icon");
           }
         }
         if (!_useDiskIconForAllMedia)
         {
           icon.Off();
         }
         property = GUIPropertyManager.GetProperty("#Play.Current.File");
         Log.Debug("current file: {0}", new object[] {property});
         if (property.Length > 0)
         {
           string str3;
           num5 |= 0x10;
           strArray = property.Split(new char[] {'.'});
           if ((strArray.Length > 1) && ((str3 = strArray[1].ToLowerInvariant()) != null))
           {
             if ((!(str3 == "ifo") && !(str3 == "vob")) && !(str3 == "mpg"))
             {
               if (str3 == "wmv")
               {
                 num5 |= 0x400;
                 if (this.DoDebug)
                 {
                   Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Setting ICON_WMV");
                 }
               }
               else if (str3 == "divx")
               {
                 num5 |= 0x20;
                 if (this.DoDebug)
                 {
                   Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Setting ICON_DIVX");
                 }
               }
               else if (str3 == "xvid")
               {
                 num5 |= 0x800;
                 if (this.DoDebug)
                 {
                   Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Setting ICON_XVID");
                 }
               }
             }
             else
             {
               num5 |= 0x40;
               if (this.DoDebug)
               {
                 Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Setting ICON_MPG");
               }
             }
           }
         }
       }
     }
     if (!this.MPStatus.MediaPlayer_Playing || !_useDiskIconForAllMedia)
     {
       if (!this.MPStatus.MediaPlayer_Playing)
       {
         this.RestoreDisplayFromVideoOrIdle();
       }
       segments = 0;
       if (drive.IsOpened)
       {
         if (drive.IsCDReady())
         {
           if (!flag2)
           {
             flag2 = drive.Refresh();
           }
           if (drive.GetNumAudioTracks() > 0)
           {
             segments = this.ICON_CDIn;
           }
           else
           {
             segments = this.ICON_DVDIn;
           }
         }
         else
         {
           flag2 = false;
         }
       }
     }
     if (!this.MPStatus.MediaPlayer_Active)
     {
       this.RestoreDisplayFromVideoOrIdle();
       if (_mpIsIdle)
       {
         num5 |= 0x1000;
         num4 = 0;
         if (this.DoDebug)
         {
           Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Setting ICON_IDLE");
         }
       }
     }
     if (this.DoDebug)
     {
       Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Status collected...");
     }
     if (num4 != num3)
     {
       num2 = num4;
     }
     this.GetEQ();
     this.DisplayEQ();
     lock (this.DWriteMutex)
     {
       if (this.DoDebug)
       {
         Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Building display image");
       }
       if ((_useProgressDisplay || _useVolumeDisplay) || _useIcons)
       {
         this.ClearIconArea();
       }
       if (_useProgressDisplay || _useVolumeDisplay)
       {
         this.DrawProgressBars();
       }
       if (_useIcons)
       {
         if (!this.MPStatus.MediaPlayer_Playing || !_useDiskIconForAllMedia)
         {
           this.DrawDiskIcon(segments);
         }
         else
         {
           this.DrawDiskIcon(icon.Mask);
         }
         this.DrawIcons(num5);
         this.DrawLargeIcons();
       }
       if (this.DoDebug)
       {
         Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() image built - sending to display");
       }
       this.GX_Session.SendAsyncFrame(this.GX_Surface);
     }
     if (!this.EQSettings._EqDataAvailable)
     {
       if (this.DoDebug)
       {
         Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Sleeping...");
       }
       Thread.Sleep(250);
       if (this.DoDebug)
       {
         Log.Info("MatrixGX.MOGXDisplay.DisplayUpdate() Waking...");
       }
     }
   }
 }
Esempio n. 3
0
 public void DoDisplayTest()
 {
   var mask = new BuiltinIconMask();
   if ((_DisplayType == DisplayType.LCD) || (_DisplayType == DisplayType.LCD2))
   {
     Log.Debug("(IDisplay) iMONLCDg.Setup() configure - do display test");
     _displayTest = true;
     OpenLcd();
     ClearDisplay();
     Thread.Sleep(500);
     SendText("iMONLCDg", "Display Test");
     Thread.Sleep(500);
     SendText("iMONLCDg", "All Icons");
     for (int i = 0; i < 2; i++)
     {
       SendData(iMonCommand.General.SetIcons, mask.ICON_ALL);
       Thread.Sleep(500);
       SendData(iMonCommand.General.SetIcons);
       Thread.Sleep(500);
     }
     var icon = new DiskIcon();
     icon.Reset();
     icon.On();
     SendText("iMONLCDg", "Disk On");
     Thread.Sleep(500);
     SendText("iMONLCDg", "Disk Spin CW");
     icon.RotateCW();
     for (int j = 0; j < 0x10; j++)
     {
       icon.Animate();
       SendData(iMonCommand.General.SetIcons, icon.Mask);
       Thread.Sleep(250);
     }
     SendText("iMONLCDg", "Disk Spin CCW");
     icon.RotateCCW();
     for (int k = 0; k < 0x10; k++)
     {
       icon.Animate();
       SendData(iMonCommand.General.SetIcons, icon.Mask);
       Thread.Sleep(250);
     }
     SendText("iMONLCDg", "Disk Flash");
     icon.RotateOff();
     icon.FlashOn();
     for (int m = 0; m < 0x10; m++)
     {
       icon.Animate();
       SendData(iMonCommand.General.SetIcons, icon.Mask);
       Thread.Sleep(250);
     }
     CloseLcd();
     _displayTest = false;
     Log.Debug("(IDisplay) iMONLCDg.Setup() configure - display test complete");
   }
 }