Beispiel #1
0
        public void Run()
        {
            Cursor.Hide();
            Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
            Config myconfig = config;

            Log.Instance.IsEnabled = config.IsLoggingEnabled;
            Log.Instance.Write("Starting screen saver");
            Log.Instance.Write(Application.CommonAppDataPath);
            Random rnd = new Random();


            myconfig.BackGroundStyle = config.BackGroundStyle == BackGroundStyle.Random ?
                                       (rnd.Next(1, 10) % 2 == 0 ? BackGroundStyle.Black : BackGroundStyle.White)
                : config.BackGroundStyle;
            myconfig.ImageStyle = config.ImageStyle == ImageStyle.Random ?
                                  (rnd.Next(1, 10) % 2 == 0 ? ImageStyle.CenterFill : ImageStyle.Whole)
                : config.ImageStyle;


            List <IImageSource> imageSources = new List <IImageSource>();

            if (config.IsEnabledFileImageSource)
            {
                imageSources.Add(new FileImageSource(config.FileImageSourcePath, config.FileNameSearchParms, config.Comicstyle));
            }

            if (config.IsEnabledFlickrImageSource)
            {
                imageSources.Add(new FlickrImageSource(config.FlickrImageSourceTags, config.IsFlickrImageSourceTagAndLogic, config.FlickrImageSourceUserName, config.FlickrImageSourceText, myconfig.ImageStyle == ImageStyle.CenterFill));
            }
            IImageSource imageSource = new RoundRobinImageSource(imageSources, new ColorSquareImageSource());

            // base x size on width of primary screen
            int xSize = Screen.PrimaryScreen.Bounds.Width / config.XCount;

            // build window for each screen
            // order screens by x coordinates

            //int screenlimit=1;

            SortedList <int, Screen> orderedscreens = new SortedList <int, Screen>();

            foreach (Screen pscreen in Screen.AllScreens)
            {
                //Screen pscreen = Screen.PrimaryScreen;
                orderedscreens.Add(pscreen.Bounds.X, pscreen);
                //if (orderedscreens.Count >= screenlimit){break;};
            }

            foreach (Screen screen in orderedscreens.Values)
            {
                //Log.Instance.Write(screen.DeviceName + "@ X:" + screen.Bounds.X + "Y:" + screen.Bounds.Y);
                //Screen screen = Screen.PrimaryScreen;

                Window wnd = new Window(screen.Bounds, xSize, myconfig, imageSource);
                windows.Add(wnd);
                wnd.End += DisplayWindowEndEventHandler;

                wnd.Show();
            }
            Window wnd1 = windows[0];

            wnd1.Focus();
            wnd1.LostFocus += DisplayWindowLostFocusEvenHandler;

            // start the background drawing thread
            thread = new Thread(ThreadProc);
            thread.IsBackground = true;
            thread.Start();
        }
        public void Run()
        {
            Cursor.Hide();
            Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
            Config myconfig = config;

            Log.Instance.IsEnabled = config.IsLoggingEnabled;
            Log.Instance.Write("Starting screen saver");
            Log.Instance.Write(Application.CommonAppDataPath);
            Random rnd = new Random();

            myconfig.BackGroundStyle = config.BackGroundStyle == BackGroundStyle.Random ?
                (rnd.Next(1,10) % 2 == 0 ? BackGroundStyle.Black : BackGroundStyle.White)
                : config.BackGroundStyle;
            myconfig.ImageStyle = config.ImageStyle == ImageStyle.Random ?
                (rnd.Next(1,10) % 2 == 0 ? ImageStyle.CenterFill : ImageStyle.Whole)
                : config.ImageStyle;

            List<IImageSource> imageSources = new List<IImageSource>();
            if (config.IsEnabledFileImageSource)
                imageSources.Add(new FileImageSource(config.FileImageSourcePath, config.FileNameSearchParms, config.Comicstyle));

            if (config.IsEnabledFlickrImageSource)
                imageSources.Add(new FlickrImageSource(config.FlickrImageSourceTags, config.IsFlickrImageSourceTagAndLogic, config.FlickrImageSourceUserName, config.FlickrImageSourceText,  myconfig.ImageStyle == ImageStyle.CenterFill));
            IImageSource imageSource = new RoundRobinImageSource(imageSources, new ColorSquareImageSource());

            // base x size on width of primary screen
            int xSize = Screen.PrimaryScreen.Bounds.Width / config.XCount;

            // build window for each screen
            // order screens by x coordinates

            //int screenlimit=1;

            SortedList<int,Screen> orderedscreens = new SortedList<int,Screen>();
            foreach (Screen pscreen in Screen.AllScreens){
            //Screen pscreen = Screen.PrimaryScreen;
                orderedscreens.Add(pscreen.Bounds.X, pscreen);
                //if (orderedscreens.Count >= screenlimit){break;};

            }

            foreach (Screen screen in orderedscreens.Values) {
                //Log.Instance.Write(screen.DeviceName + "@ X:" + screen.Bounds.X + "Y:" + screen.Bounds.Y);
                //Screen screen = Screen.PrimaryScreen;

                Window wnd = new Window(screen.Bounds, xSize, myconfig, imageSource);
                windows.Add(wnd);
                wnd.End += DisplayWindowEndEventHandler;

                wnd.Show();
            }
            Window wnd1 = windows[0];
            wnd1.Focus();
            wnd1.LostFocus+=DisplayWindowLostFocusEvenHandler;

            // start the background drawing thread
            thread = new Thread(ThreadProc);
            thread.IsBackground = true;
            thread.Start();
        }