Leaked source code of windows server 2003
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.

82 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. CFindImageFiles::CFindImageFiles(void)
  22. : m_nCurrentFile(0)
  23. {
  24. }
  25. CFindImageFiles::~CFindImageFiles(void)
  26. {
  27. }
  28. bool CFindImageFiles::NextFile( CSimpleString &strFilename )
  29. {
  30. bool bResult = false;
  31. strFilename = TEXT("");
  32. if (m_ImageFiles.Size())
  33. {
  34. if (m_nCurrentFile >= m_ImageFiles.Size())
  35. {
  36. m_nCurrentFile = 0;
  37. }
  38. strFilename = m_ImageFiles[m_nCurrentFile];
  39. m_nCurrentFile++;
  40. bResult = (strFilename.Length() != 0);
  41. }
  42. return(bResult);
  43. }
  44. bool CFindImageFiles::PreviousFile( CSimpleString &strFilename )
  45. {
  46. bool bResult = false;
  47. strFilename = TEXT("");
  48. if (m_ImageFiles.Size()==1)
  49. {
  50. m_nCurrentFile = 0;
  51. strFilename = m_ImageFiles[0];
  52. bResult = (strFilename.Length() != 0);
  53. }
  54. else if (m_ImageFiles.Size()>=2)
  55. {
  56. m_nCurrentFile--;
  57. if (m_nCurrentFile < 0)
  58. m_nCurrentFile = m_ImageFiles.Size()-1;
  59. int nPrevFile = m_nCurrentFile-1;
  60. if (nPrevFile < 0)
  61. nPrevFile = m_ImageFiles.Size()-1;
  62. strFilename = m_ImageFiles[nPrevFile];
  63. bResult = (strFilename.Length() != 0);
  64. }
  65. return(bResult);
  66. }
  67. void CFindImageFiles::Shuffle(void)
  68. {
  69. for (int i=0;i<m_ImageFiles.Size();i++)
  70. {
  71. ScreenSaverUtil::Swap( m_ImageFiles[i], m_ImageFiles[m_RandomNumberGen.Generate(i,m_ImageFiles.Size())]);
  72. }
  73. }