예제 #1
0
        private Screensaver(Actions action, bool readOnly, IntPtr[] hwnds) {
            #if (DEBUG)
                this.debugLog = new List<string>();
            #endif
            
            this.version = new Version(Application.ProductVersion);
            this.readOnly = readOnly;
            this.action = action;
            this.hwnds = hwnds;
            this.config = new Config(this);
            this.config.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.PreviewKeyDown);
            this.config.browser.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.PreviewKeyDown);

            this.config.browser.Navigate(new Uri(Constants.getDataFolder(Constants.ConfigHtmlFile)));
            this.config.browser.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.config.ConfigDocumentCompleted);
            if (this.action == Actions.Config) this.config.Show();
            else {
                if (this.action != Actions.Wallpaper) {
                    this.mouseMoveTimer = new System.Windows.Forms.Timer();
                    this.mouseMoveTimer.Interval = 1500;
                    this.mouseMoveTimer.Tick += mouseMoveTimer_Tick;
                }
            }
            // Wait for config document to load to complete initialisation: Config.ConfigDocumentCompleted()
        }
        public FileNodes(Config config, Screensaver screensaver)
        {
            this.config = config;
            this.screensaver = screensaver;
            this.fileDatabase = new FileDatabase(this.screensaver.readOnly);
            //this.fileDatabase.MetadataReadEvent += new MetadataReadEventHandler(metadataShow);

            if (screensaver.action != Screensaver.Actions.Wallpaper) {

                this.resetFoldersQueue();

                this.backgroundWorker = new System.ComponentModel.BackgroundWorker();
                this.backgroundWorker.WorkerReportsProgress = true;
                this.backgroundWorker.WorkerSupportsCancellation = true;
                this.backgroundWorker.DoWork += new DoWorkEventHandler(DoWorkImageFolder);
                this.backgroundWorker.ProgressChanged += new ProgressChangedEventHandler(progressChanged);
                this.backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(runWorkerCompleted);

                // Use local folders as this.folders is used in backgroundWorker
                //var folders = Utils.stringToConcurrentQueue(Convert.ToString(this.config.getPersistant("folders")));
                // Purge database in main thread rather, to avoid having to run database filter twice
                this.purgeNotMatchingParentFolders(this.folders);

                this.backgroundWorker.RunWorkerAsync();
            }
        }