示例#1
0
 public PhotoSlideshow(Photo[] photos, int slideshowInterval)
 {
     if (photos == null)
     {
         throw new ArgumentException("photos cannot be null");
     }
     if (photos.Length == 0)
     {
         throw new ArgumentException("must supply at least 1 photo");
     }
     Photos = photos;
     _slideshowInterval = slideshowInterval;
 }
示例#2
0
        static void StartPhotoSlideshow()
        {
            SIP slideshowProcess = new SIP(delegate()
            {
                // TODO: Fetch photo database from an XML/JSON file using REST
                Photo[] photos = new Photo[]{
                    new Photo("Photos/michaelten-pow.jpg", "My two sisters, Kaya and Alicia, and me"),
                    new Photo("Photos/lounging_at_pool.jpg", "Lounging by the pool at the Planet Hollywood Hotel, Las Vegas"),
                    new Photo("Photos/coaster.jpg", "Autumn and me on the roller coaster at New York, New York, Las Vegas"),
                    new Photo("Photos/just_michael.jpg", "Just me"),
                    new Photo("Photos/paris_vegas.jpg", "Autumn and me at Paris, Las Vegas"),
                    new Photo("Photos/checking_in.jpg", "Checking into the Planet Hollywood Hotel, Las Vegas"),
                    new Photo("Photos/autumn_and_michael.jpg", "Autumn and me"),
                    new Photo("Photos/wii_at_earls.jpg", "Playing Wii Sports Golf at Earl's house"),
                    new Photo("Photos/packed_jeep.jpg", "My Jeep packed full of my cousin Michelle's belongings.  I was helping her move.")
                };

                _slideshow = new PhotoSlideshow(photos, 10 * 1000);
                SignalDaemon.Start();
                ExportDelegate("ShowNextPhoto", ExportedShowNextPhoto);
                ExportDelegate("ShowPreviousPhoto", ExportedShowPreviousPhoto);
                _slideshow.ShowPhoto(0);
                _slideshow.StartSlideshow();
            }, ThreadPriority.Normal, "Tenpow.PhotoSlideshow");

            // install a custom signal handler to call the appropriate method based upon the PhotoSlideshowSignal that we receive
            slideshowProcess.CustomSignal += delegate(int data)
            {
                PhotoSlideshowSignal signal = (PhotoSlideshowSignal)data;
                if (signal == PhotoSlideshowSignal.ShowNextPhoto)
                {
                    _slideshow.ShowNextPhoto();
                }
                else if (signal == PhotoSlideshowSignal.ShowPreviousPhoto)
                {
                    _slideshow.ShowPreviousPhoto();
                }
                else
                {
                    // TODO: Write to standard error
                    Console.WriteLine("Received unknown signal " + data);
                }
            };
            slideshowProcess.Start();
            _slideshowPid = slideshowProcess.PID;
        }