Ejemplo n.º 1
0
        static ImageTestForm()
        {
            string folderPath = RegisteredOptions.GetStringSetting(RegisteredOptions.OPT_IMAGE_FOLDER);

            availableImages.AddRange(SWA.Utilities.Directory.Find(folderPath, "*.jpg", true));
            availableImages.AddRange(SWA.Utilities.Directory.Find(folderPath, "*.gif", true));
            availableImages.AddRange(SWA.Utilities.Directory.Find(folderPath, "*.png", true));
        }
Ejemplo n.º 2
0
        private void selectImageFolderButton_Click(object sender, EventArgs e)
        {
            // Start at the path found in the registered options.
            this.imageFolderBrowserDialog.SelectedPath = RegisteredOptions.GetStringSetting(RegisteredOptions.OPT_IMAGE_FOLDER);

            if (this.imageFolderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                this.imageFolderTextBox.Text = this.imageFolderBrowserDialog.SelectedPath;
            }
        }
Ejemplo n.º 3
0
        private void LoadSettings()
        {
            // General tab.
            checkBoxDetailsBox.Checked          = RegisteredOptions.GetBoolSetting(RegisteredOptions.OPT_SHOW_DETAILS_BOX);
            checkBoxBlinking.Checked            = RegisteredOptions.GetBoolSetting(RegisteredOptions.OPT_BLINKING);
            checkBoxEfficientSolvers.Checked    = RegisteredOptions.GetBoolSetting(RegisteredOptions.OPT_EFFICIENT_SOLVERS);
            textBoxStepsPerSecond.Text          = RegisteredOptions.GetIntSetting(RegisteredOptions.OPT_STEPS_PER_SECOND).ToString();
            checkBoxLogSolverStatistics.Checked = RegisteredOptions.GetBoolSetting(RegisteredOptions.OPT_LOG_SOLVER_STATISTICS);

#if !DEBUG
            // No logging in Release version
            checkBoxLogSolverStatistics.Visible = false;
#endif

            // Images tab.
            imageNumberNumericUpDown.Value = RegisteredOptions.GetIntSetting(RegisteredOptions.OPT_IMAGE_NUMBER);
            InitImageSizeCtrl(imageMinSizeNumericUpDown, RegisteredOptions.OPT_IMAGE_MIN_SIZE, RegisteredOptions.OPT_IMAGE_MIN_SIZE_PCT);
            InitImageSizeCtrl(imageMaxSizeNumericUpDown, RegisteredOptions.OPT_IMAGE_MAX_SIZE, RegisteredOptions.OPT_IMAGE_MAX_SIZE_PCT);
            imageFolderTextBox.Text = RegisteredOptions.GetStringSetting(RegisteredOptions.OPT_IMAGE_FOLDER);
            subtractImagesBackgroundCheckBox.Checked = RegisteredOptions.GetBoolSetting(RegisteredOptions.OPT_IMAGE_SUBTRACT_BACKGROUND);

            // Background tab.
            checkBoxBackgroundImage.Checked   = RegisteredOptions.GetBoolSetting(RegisteredOptions.OPT_BACKGROUND_IMAGES);
            backgroundImageFolderTextBox.Text = RegisteredOptions.GetStringSetting(RegisteredOptions.OPT_BACKGROUND_IMAGE_FOLDER);

            if (backgroundImageFolderTextBox.Text == "")
            {
                checkBoxDifferentBackgroundImageFolder.Checked = false;
                backgroundImageFolderTextBox.Enabled           = false;
                selectBackgroundImageFolderButton.Enabled      = false;
                backgroundImageFolderTextBox.Text = imageFolderTextBox.Text;
            }
            else
            {
                checkBoxDifferentBackgroundImageFolder.Checked = true;
                backgroundImageFolderTextBox.Enabled           = true;
                selectBackgroundImageFolderButton.Enabled      = true;
            }

            // Extras tab.
            checkBoxPaintAllWalls.Checked  = RegisteredOptions.GetBoolSetting(RegisteredOptions.OPT_PAINT_ALL_WALLS);
            checkBoxOutlineShapes.Checked  = RegisteredOptions.GetBoolSetting(RegisteredOptions.OPT_OUTLINE_SHAPES);
            checkBoxIrregularMazes.Checked = RegisteredOptions.GetBoolSetting(RegisteredOptions.OPT_IRREGULAR_MAZES);
            checkBoxMultipleMazes.Checked  = RegisteredOptions.GetBoolSetting(RegisteredOptions.OPT_MULTIPLE_MAZES);
            imageBackgroundFuzzinessNumericUpDown.Value = RegisteredOptions.GetIntSetting(RegisteredOptions.OPT_IMAGE_BACKGROUND_FUZZINESS);
        }
Ejemplo n.º 4
0
        public void IL_GetNextTest_01()
        {
            string testObject = "GetNext";

            int    minSize     = 300;
            int    maxSize     = 500;
            string imageFolder = RegisteredOptions.GetStringSetting(RegisteredOptions.OPT_IMAGE_FOLDER);

            int queueLength = 4;

            ImageLoader target = new ImageLoader(minSize, maxSize, false, imageFolder, queueLength, "TEST");

            for (int i = 0; i < 20; i++)
            {
                ContourImage img = target.GetNext(null);
                Assert.AreNotEqual(null, img, testObject + "returned null");
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Returns an ImageLoader configured with the screen saver parameters from the registry
        /// or null if the "image number" option is 0.
        /// </summary>
        /// <returns></returns>
        public static ImageLoader GetScreenSaverImageLoader(Rectangle screenBounds)
        {
            int    count            = RegisteredOptions.GetIntSetting(RegisteredOptions.OPT_IMAGE_NUMBER);
            int    minSize          = ImageSize(screenBounds, RegisteredOptions.OPT_IMAGE_MIN_SIZE, RegisteredOptions.OPT_IMAGE_MIN_SIZE_PCT);
            int    maxSize          = ImageSize(screenBounds, RegisteredOptions.OPT_IMAGE_MAX_SIZE, RegisteredOptions.OPT_IMAGE_MAX_SIZE_PCT);
            string imageFolder      = RegisteredOptions.GetStringSetting(RegisteredOptions.OPT_IMAGE_FOLDER);
            bool   backgroundImages = RegisteredOptions.GetBoolSetting(RegisteredOptions.OPT_BACKGROUND_IMAGES);

            if (count > 0)
            {
                ImageLoader result = new ImageLoader(minSize, maxSize, false, imageFolder, count + 2, "FGIL");
                result.YieldNullPercentage = (backgroundImages ? 5 : 0);
                return(result);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 6
0
        private void ScreenSaverForm_Load(object sender, EventArgs e)
        {
            // Switch auto repeat mode on.
            ariadneController.RepeatMode = true;

            if (fullScreenMode)
            {
                SetupFullscreenScreenSaver();

                // Let the MazeUserControl cover the whole form.
                this.mazeUserControl.Location = new Point(0, 0);
                this.mazeUserControl.Size     = this.Size;
            }
            else
            {
                // Let the MazeUserControl cover most of the form.
                this.mazeUserControl.Location = new Point(0, 0);
                this.mazeUserControl.Size     = this.DisplayRectangle.Size;
            }
            this.mazeUserControl.BringToFront();

            // Other optional controls need to be displayed in front of the maze.
            this.outerInfoPanel.BringToFront();

            // Load background images.
            if (RegisteredOptions.GetBoolSetting(RegisteredOptions.OPT_BACKGROUND_IMAGES))
            {
                string imageFolder = RegisteredOptions.GetStringSetting(RegisteredOptions.OPT_BACKGROUND_IMAGE_FOLDER);
                if (imageFolder == "")
                {
                    imageFolder = RegisteredOptions.GetStringSetting(RegisteredOptions.OPT_IMAGE_FOLDER);
                }
                int percentage = ((RegisteredOptions.GetIntSetting(RegisteredOptions.OPT_IMAGE_NUMBER) > 0) ? 20 : 100);
                this.mazeUserControl.MazePainter.CreateBackgroundImageLoader(imageFolder, percentage);
            }

            this.OnNew(null, null);
            this.OnStart(null, null);

            // Now the first maze has been loaded.
            this.loadingFirstMaze = false;
        }
Ejemplo n.º 7
0
        private IEnumerable <string> LoadImagePaths()
        {
            string s = RegisteredOptions.GetStringSetting(thread.Name + " " + RegisteredOptions.SAVE_IMAGE_PATHS);

            if (s.Length == 0)
            {
                return(new List <string>());
            }

            string[] result = s.Split(new char[] { PathSeparator });

            for (int i = 0; i < result.Length; i++)
            {
                result[i] = imageFolder + result[i];
            }

            lock (RecentlyUsedImages)
            {
                RecentlyUsedImages.AddRange(result);
            }

            return(result);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates a ScreenSaverController instance,
        /// draws an initial maze
        /// and starts an AriadneController.
        /// </summary>
        /// <param name="windowHandleArg">The MazePainter will draw on this window.</param>
        /// <remarks>
        /// If this is not the primary screen, no cotroller is started,
        /// the application will terminate and the screen will stay blank.
        /// </remarks>
        public ScreenSaverController(string windowHandleArg)
        {
            #region Evaluate the given window's properties.
            var windowHandle    = (IntPtr)UInt32.Parse(windowHandleArg);
            var targetGraphics  = Graphics.FromHwnd(windowHandle);
            var targetRectangle = Platform.GetClientRectangle(windowHandle);
            //Log.WriteLine("targetRectangle = " + targetRectangle, true); // {X=0,Y=0,Width=1366,Height=768}
            #endregion

#if true
            #region Blank secondary screen(s).
            // ... because more than one of these mazes is just too distracting.  :-)
            if (!IsOnPrimaryScreen(windowHandle))
            {
                // We don't have to do anything, really.
                // xscreensaver has given us a blank (black) window and we may
                // terminate the application
                //Log.WriteLine("Goodbye on " + targetRectangle, true);
                //Application.Run();
                Application.Exit();
            }
            #endregion
#endif

            // Create an ImageLoader, now that it is clear that we will need it.
            Directory.ResultValidForSeconds = -1;
            var imageLoader = ImageLoader.GetScreenSaverImageLoader(Screen.PrimaryScreen.Bounds);

            #region Create a MazePainter.
            this.painter = new MazePainter(targetGraphics, targetRectangle, this as IMazePainterClient);
            #endregion

            #region Create a MazeUserControl.
            this.mazeUserControl             = new MazeUserControl(painter, targetRectangle.Size);
            this.mazeUserControl.ImageLoader = imageLoader;
            this.mazeUserControl.MazeForm    = this;
            #endregion

            #region Apply some registered options.
            if (RegisteredOptions.GetBoolSetting(RegisteredOptions.OPT_PAINT_ALL_WALLS) == false)
            {
                painter.RandomizeWallVisibility = true;
            }
            ContourImage.DisplayProcessedImage = RegisteredOptions.GetBoolSetting(RegisteredOptions.OPT_IMAGE_SUBTRACT_BACKGROUND);

            // Load background images.
            if (RegisteredOptions.GetBoolSetting(RegisteredOptions.OPT_BACKGROUND_IMAGES))
            {
                string imageFolder = RegisteredOptions.GetStringSetting(RegisteredOptions.OPT_BACKGROUND_IMAGE_FOLDER);
                if (imageFolder == "")
                {
                    imageFolder = RegisteredOptions.GetStringSetting(RegisteredOptions.OPT_IMAGE_FOLDER);
                }
                int percentage = ((RegisteredOptions.GetIntSetting(RegisteredOptions.OPT_IMAGE_NUMBER) > 0) ? 20 : 100);
                painter.CreateBackgroundImageLoader(imageFolder, percentage);
            }

            if (RegisteredOptions.GetBoolSetting(RegisteredOptions.OPT_SHOW_DETAILS_BOX))
            {
                this.infoPanelPainter = new InfoPanelPainter(painter);
            }
            #endregion

            // Create and display the first maze.
            this.OnNew(null, null);

            #region Create and start an AriadneController.
            SolverController controller = new SolverController(this, painter, null);
            this.ariadneController       = new AriadneController(this, controller);
            ariadneController.RepeatMode = true;
            ariadneController.Start();
            #endregion
        }