Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.0 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORPORATION, 1998, 1999, 2000
  4. *
  5. * TITLE: FINDIMGS.H
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: ShaunIv
  10. *
  11. * DATE: 1/13/1999
  12. *
  13. * DESCRIPTION: Specialization of CFindFiles class that looks for image files and
  14. * stores them in a dynamic array which is shuffled on initialization
  15. *
  16. *******************************************************************************/
  17. #include "precomp.h"
  18. #pragma hdrstop
  19. #include "findimgs.h"
  20. #include "ssutil.h"
  21. #include "isdbg.h"
  22. CFindImageFiles::CFindImageFiles(void)
  23. : m_nCurrentFile(0)
  24. {
  25. }
  26. CFindImageFiles::~CFindImageFiles(void)
  27. {
  28. }
  29. bool CFindImageFiles::NextFile( CSimpleString &strFilename )
  30. {
  31. bool bResult = false;
  32. strFilename = TEXT("");
  33. if (m_ImageFiles.Size())
  34. {
  35. if (m_nCurrentFile >= m_ImageFiles.Size())
  36. {
  37. m_nCurrentFile = 0;
  38. }
  39. strFilename = m_ImageFiles[m_nCurrentFile];
  40. m_nCurrentFile++;
  41. bResult = (strFilename.Length() != 0);
  42. }
  43. return(bResult);
  44. }
  45. bool CFindImageFiles::PreviousFile( CSimpleString &strFilename )
  46. {
  47. bool bResult = false;
  48. strFilename = TEXT("");
  49. if (m_ImageFiles.Size()==1)
  50. {
  51. m_nCurrentFile = 0;
  52. strFilename = m_ImageFiles[0];
  53. bResult = (strFilename.Length() != 0);
  54. }
  55. else if (m_ImageFiles.Size()>=2)
  56. {
  57. m_nCurrentFile--;
  58. if (m_nCurrentFile < 0)
  59. m_nCurrentFile = m_ImageFiles.Size()-1;
  60. int nPrevFile = m_nCurrentFile-1;
  61. if (nPrevFile < 0)
  62. nPrevFile = m_ImageFiles.Size()-1;
  63. strFilename = m_ImageFiles[nPrevFile];
  64. bResult = (strFilename.Length() != 0);
  65. }
  66. return(bResult);
  67. }
  68. void CFindImageFiles::Shuffle(void)
  69. {
  70. for (int i=0;i<m_ImageFiles.Size();i++)
  71. {
  72. ScreenSaverUtil::Swap( m_ImageFiles[i], m_ImageFiles[m_RandomNumberGen.Generate(i,m_ImageFiles.Size())]);
  73. }
  74. }