/** * When start button clicked, stores rectangle coordinates * x1 and x2 are the upper left and right corner * x1 and x2 are the lower left and right corner * checkClickInterval runs to see the time between clicks * Checks mouse speed function needed and stores the method to a variable * runManualOrAutomatic runs to see how the program will end * */ private void startButton_Click(object sender, EventArgs e) { x1 = SnippingTool.getDrawnRectangle().X; x2 = SnippingTool.getDrawnRectangle().X + SnippingTool.getRectangleWidth(); y1 = SnippingTool.getDrawnRectangle().Y; y2 = SnippingTool.getDrawnRectangle().Y + SnippingTool.getRectangleHeight(); checkClickInterval(comboBoxClickEvery, numericClickEveryMin.Value, numericClickEveryMax.Value); moveAtMouseSpeed = checkMouseSpeed(); runManualOrAutomatic(); }
/** * Listener method that runs when a tab is clicked * If basic tab selected, resizes form back to its original size * If advanced tab selected, sets the label and other components accordingly * If the displayed width or height does not match the rectangle, updates the display * If preview tab selected, shows the user's selection * Resizes the preview tab to display the entire image, accounting for the form's borders cutting off part of the image * If splitting the region into sub-areas, the preview tab will show the image with red lines drawn as dividers * */ private void tabControl1_SelectedIndexChanged(Object sender, EventArgs e) { bool basicTabSelected = tabControl1.SelectedIndex == 0; bool advancedTabSelected = tabControl1.SelectedIndex == 1; bool previewTabSelected = tabControl1.SelectedIndex == 2; widthNotZero = SnippingTool.getRectangleWidth() != 0; heightNotZero = SnippingTool.getRectangleHeight() != 0; if (basicTabSelected) { resizeFormToDefault(); } else if (advancedTabSelected && widthNotZero && heightNotZero) { resizeFormToDefault(); labelWidthHeight.Text = "The area has a width of " + SnippingTool.getRectangleWidth() + " pixels\r\n" + " and a height of " + SnippingTool.getRectangleHeight() + " pixels. Starting from: (" + SnippingTool.getDrawnRectangle().X + "," + SnippingTool.getDrawnRectangle().Y + ")"; checkBoxDivideInto.Enabled = true; if (displayedWidth != SnippingTool.getRectangleWidth() || displayedHeight != SnippingTool.getRectangleHeight()) { divideIntoEqualAreasDisplay(); } } else if (previewTabSelected && widthNotZero && heightNotZero) { previewPictureBox.Visible = true; labelPreviewInstructions.Visible = false; if (SnippingTool.Image.Width > tabControl1.Width) { this.Width = SnippingTool.Image.Width + (this.Width - tabControl1.Width) + 8; } if (SnippingTool.Image.Height > tabControl1.Height) { this.Height = SnippingTool.Image.Height + (this.Height - tabControl1.Height) + 25; } if (checkBoxDivideInto.Checked) { ImageSplitter.drawSplitImage(comboBoxDividedAreas.SelectedIndex, numericDivideIntoEqualAreas.Value); previewPictureBox.Image = ImageSplitter.drawnImage; } else { previewPictureBox.Image = SnippingTool.Image; } } }