Example #1
0
        public mainForm()
        {
            InitializeComponent();

            // Set up the key listener.
            this.KeyPress += new KeyPressEventHandler(Form1_KeyPress);

            // Link our draw surface to the picture box on the windows form.
            DRAW_SURFACE = pictureBox;

            // Link our preview box to the local version.
            PREIVEW_BOX = currentImageDisplay;

            // Add the key listeners to the buttons on the form. This is to filter out arrow key presses when a button is selected.
            loadImageButton.PreviewKeyDown  += new PreviewKeyDownEventHandler(loadImageButton_PreviewKeyDown);
            eraseButton.PreviewKeyDown      += new PreviewKeyDownEventHandler(eraseButton_PreviewKeyDown);
            floorRadioButton.PreviewKeyDown += new PreviewKeyDownEventHandler(floorRadioButton_PreviewKeyDown);
            wallRadioButton.PreviewKeyDown  += new PreviewKeyDownEventHandler(wallRadioButton_PreviewKeyDown);
            decorRadioButton.PreviewKeyDown += new PreviewKeyDownEventHandler(decorRadioButton_PreviewKeyDown);

            // Link our buttons to the form buttons
            LOAD_IMAGE_BUTTON = loadImageButton;
            ERASE_BUTTON      = eraseButton;

            // Link the group box to a local copy.
            LAYER_GROUP_BOX = layerGroupBox;

            // Link radio buttons to local copies.
            FLOOR_LAYER_RADIO = floorRadioButton;
            WALL_LAYER_RADIO  = wallRadioButton;
            DECOR_LAYER_RADIO = decorRadioButton;

            // Attached the event listeners for the radio buttons.
            FLOOR_LAYER_RADIO.CheckedChanged += new EventHandler(radioButtons_CheckedChanged);
            WALL_LAYER_RADIO.CheckedChanged  += new EventHandler(radioButtons_CheckedChanged);
            DECOR_LAYER_RADIO.CheckedChanged += new EventHandler(radioButtons_CheckedChanged);

            // Adjust the size of the main window based on the scale we've set above.
            this.Width  = (int)(screenWidth * SCREEN_SCALE);
            this.Height = (int)(screenHeight * SCREEN_SCALE);

            // Set the size of the drawing surface based on the main window's properties.
            DRAW_SURFACE.Size = new Size((int)(Width * DRAWING_SURFACE_SCALE), (int)(Height * DRAWING_SURFACE_SCALE));

            // Set the size of the preview box.
            PREIVEW_BOX.Size = new Size(PREVIEW_SIZE, PREVIEW_SIZE);

            // Open image dialog box properties
            selectImageDialog.Filter      = "Image Files (*.bmp, *.gif, *.jpg, *.png)|*.bmp; *.gif; *.jpg; *.png";
            selectImageDialog.Multiselect = false;

            // Open file dialog box properties.
            selectMapDialog.Filter      = "Text Files (*.txt)|*.txt";
            selectMapDialog.Multiselect = false;

            // Save file dialog box properties.
            saveFileDialog.Filter           = "Text Files (*.txt)|*.txt";
            saveFileDialog.RestoreDirectory = true;

            // Export file dialog box properties.
            exportFileDialog.Filter = "Image Files (*.png)|*.png";

            // Initiialize the new map dialog box.
            createMapDialog = new newMapDialog(this);

            // Set the description text for the zoom in/out shortcut keys.
            this.zoomInToolStripMenuItem.ShortcutKeyDisplayString  = "Ctrl +";
            this.zoomOutToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl -";

            // Link all of the preview picture boxes to the elements in the picture box array.
            recentPictures[0] = recent0;
            recentPictures[1] = recent1;
            recentPictures[2] = recent2;
            recentPictures[3] = recent3;
            recentPictures[4] = recent4;
            recentPictures[5] = recent5;
            recentPictures[6] = recent6;
            recentPictures[7] = recent7;
            recentPictures[8] = recent8;
            recentPictures[9] = recent9;

            // Set all of the image tags in the recent pictures array to emtpy and set their size.
            for (int i = 0; i < recentPictures.Length; i++)
            {
                recentPictures[i].Tag    = NO_RECENT_IMAGE;
                recentPictures[i].Width  = RECENT_PICTURE_SIZE;
                recentPictures[i].Height = RECENT_PICTURE_SIZE;
            }
        }
Example #2
0
        public mainForm()
        {
            InitializeComponent();

            // Set up the key listener.
            this.KeyPress += new KeyPressEventHandler(Form1_KeyPress);

            // Link our draw surface to the picture box on the windows form.
            DRAW_SURFACE = pictureBox;

            // Link our preview box to the local version.
            PREIVEW_BOX = currentImageDisplay;

            // Add the key listeners to the buttons on the form. This is to filter out arrow key presses when a button is selected.
            loadImageButton.PreviewKeyDown  += new PreviewKeyDownEventHandler(loadImageButton_PreviewKeyDown);
            eraseButton.PreviewKeyDown      += new PreviewKeyDownEventHandler(eraseButton_PreviewKeyDown);
            floorRadioButton.PreviewKeyDown += new PreviewKeyDownEventHandler(floorRadioButton_PreviewKeyDown);
            wallRadioButton.PreviewKeyDown  += new PreviewKeyDownEventHandler(wallRadioButton_PreviewKeyDown);
            decorRadioButton.PreviewKeyDown += new PreviewKeyDownEventHandler(decorRadioButton_PreviewKeyDown);

            // Link our buttons to the form buttons
            LOAD_IMAGE_BUTTON = loadImageButton;
            ERASE_BUTTON = eraseButton;

            // Link the group box to a local copy.
            LAYER_GROUP_BOX = layerGroupBox;

            // Link radio buttons to local copies.
            FLOOR_LAYER_RADIO = floorRadioButton;
            WALL_LAYER_RADIO = wallRadioButton;
            DECOR_LAYER_RADIO = decorRadioButton;

            // Attached the event listeners for the radio buttons.
            FLOOR_LAYER_RADIO.CheckedChanged += new EventHandler(radioButtons_CheckedChanged);
            WALL_LAYER_RADIO.CheckedChanged += new EventHandler(radioButtons_CheckedChanged);
            DECOR_LAYER_RADIO.CheckedChanged += new EventHandler(radioButtons_CheckedChanged);

            // Adjust the size of the main window based on the scale we've set above.
            this.Width = (int)(screenWidth * SCREEN_SCALE);
            this.Height = (int)(screenHeight * SCREEN_SCALE);

            // Set the size of the drawing surface based on the main window's properties.
            DRAW_SURFACE.Size = new Size((int)(Width * DRAWING_SURFACE_SCALE), (int)(Height * DRAWING_SURFACE_SCALE));

            // Set the size of the preview box.
            PREIVEW_BOX.Size = new Size(PREVIEW_SIZE, PREVIEW_SIZE);

            // Open image dialog box properties
            selectImageDialog.Filter = "Image Files (*.bmp, *.gif, *.jpg, *.png)|*.bmp; *.gif; *.jpg; *.png";
            selectImageDialog.Multiselect = false;

            // Open file dialog box properties.
            selectMapDialog.Filter = "Text Files (*.txt)|*.txt";
            selectMapDialog.Multiselect = false;

            // Save file dialog box properties.
            saveFileDialog.Filter = "Text Files (*.txt)|*.txt";
            saveFileDialog.RestoreDirectory = true;

            // Export file dialog box properties.
            exportFileDialog.Filter = "Image Files (*.png)|*.png";

            // Initiialize the new map dialog box.
            createMapDialog = new newMapDialog(this);

            // Set the description text for the zoom in/out shortcut keys.
            this.zoomInToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl +";
            this.zoomOutToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl -";

            // Link all of the preview picture boxes to the elements in the picture box array.
            recentPictures[0] = recent0;
            recentPictures[1] = recent1;
            recentPictures[2] = recent2;
            recentPictures[3] = recent3;
            recentPictures[4] = recent4;
            recentPictures[5] = recent5;
            recentPictures[6] = recent6;
            recentPictures[7] = recent7;
            recentPictures[8] = recent8;
            recentPictures[9] = recent9;

            // Set all of the image tags in the recent pictures array to emtpy and set their size.
            for (int i = 0; i < recentPictures.Length; i++)
            {
                recentPictures[i].Tag = NO_RECENT_IMAGE;
                recentPictures[i].Width = RECENT_PICTURE_SIZE;
                recentPictures[i].Height = RECENT_PICTURE_SIZE;
            }
        }