/* ILLUSTRATING TEXT BY TAG CLOUDS - Creating the Tag Cloud ---------------------------------------------------------------------------------------------------------------- Author: Emma E. Alberts Instructor: Bonita McVey & Dave Pankratz Date: 5/6/2019 Purpose: create a program that reads a data file and constructs a tag cloud ----------------------------------------------------------------------------------------------------------------*/ using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; namespace Capstone { public partial class Form1 : Form { /* GLOBALS ----------------------------------------------------------------------------------------------------------------*/ public int WINDOWSFORM_HEIGHT = 575; public int WINDOWSFORM_WIDTH = 775; public int PANEL1_HEIGHT = 470; public int PANEL1_WIDTH = 750; // FREQUENCY CUTOFFS public int SMALLEST_FONTSIZE_FREQCUTOFF = 1; public int SMALL_FONTSIZE_FREQCUTOFF = 3; public int MEDIUM_FONTSIZE_FREQCUTOFF = 5; public int LARGE_FONTSIZE_FREQCUTOFF = 10; // FONTSIZE GLOBALS public int SMALLEST_FONTSIZE = 8; public int SMALL_FONTSIZE = 14; public int MEDIUM_FONTSIZE = 20; public int LARGE_FONTSIZE = 26; public Random r = new Random(); public int LOCATION_SIZE = 5; /* TAGLABEL STRUCT Date: 2/19/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: define a custom data type to represent a tag's text and its frequency Variables: tagText: Type: String Purpose: stores tag's text field tagFrequency: Type: int Purpose: how often the tag occurs - will be used to determine the color and font size ----------------------------------------------------------------------------------------------------------------*/ public struct tagLabel { public String tagText; public int tagFrequency; public SizeF tagSize; } /* FORM ----------------------------------------------------------------------------------------------------------------*/ public Form1() { InitializeComponent(); SetWindowsFormSize(); Console.ReadLine(); } /* FUNCTIONS ----------------------------------------------------------------------------------------------------------------*/ /* SetWindowsFormSize Date: 2/19/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: set the size of the Windows Form - sets maximum and minimum size so that form size cannot be changed by user Parameters: none Output: none ----------------------------------------------------------------------------------------------------------------*/ void SetWindowsFormSize() { this.MinimumSize = new Size(WINDOWSFORM_WIDTH, WINDOWSFORM_HEIGHT); this.MaximumSize = new Size(WINDOWSFORM_WIDTH, WINDOWSFORM_HEIGHT); } /* GetFontSize Date: 2/19/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: returns the font size based upon its frequency Parameters: tagFrequency - needs tag frequency to determine how large it should appear in cloud Output: returns the corresponding font size ----------------------------------------------------------------------------------------------------------------*/ int GetFontSize(int tagFrequency) { if (tagFrequency <= SMALL_FONTSIZE_FREQCUTOFF) { return SMALLEST_FONTSIZE; } else if (tagFrequency <= MEDIUM_FONTSIZE_FREQCUTOFF) { return SMALL_FONTSIZE; } else if (tagFrequency <= LARGE_FONTSIZE_FREQCUTOFF) { return MEDIUM_FONTSIZE; } else { return LARGE_FONTSIZE; } } /* readFile Date: 3/26/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: reads the data file Parameters: tags - a list of tags that will be added to the tag cloud Output: tags is a reference parameter, so it automatically returns ----------------------------------------------------------------------------------------------------------------*/ void readFile(List tags) { tagLabel addMe = new Capstone.Form1.tagLabel(); string[] fileContents = System.IO.File.ReadAllLines(@"C:\Users\emmaalberts\Desktop\CSCI 460\Capstone\Capstone\tags.txt"); foreach (string line in fileContents) { string[] words = line.Split(' '); addMe.tagText = words[0]; addMe.tagFrequency = Convert.ToInt32(words[1]); tags.Add(addMe); } } /* panel1_Paint_1 Date: 3/13/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: paints the tags on panel1 ----------------------------------------------------------------------------------------------------------------*/ public void panel1_Paint_1(object sender, PaintEventArgs e) { drawCloud(); } /* drawCloud Date: 4/25/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: draws the tag cloud ----------------------------------------------------------------------------------------------------------------*/ public void drawCloud() { List words = new List(); readFile(words); // need to set the background color before drawing panel1.BackColor = GetBackgroundColor(); panel1.Height = PANEL1_HEIGHT; panel1.Width = PANEL1_WIDTH; int panelHeight = panel1.Height; int panelWidth = panel1.Width; int tagLocations_width = panelWidth / LOCATION_SIZE; int tagLocations_height = panelHeight / LOCATION_SIZE; int[,] tagLocations = new int[tagLocations_width, tagLocations_height]; // no tags exist yet - initialize all to 0 for (int x = 0; x < tagLocations.GetLength(0); x++) { for (int y = 0; y < tagLocations.GetLength(1); y++) tagLocations[x, y] = 0; } int curXCoord = (panelWidth / 2); int curYCoord = (panelHeight / 2); Random rnd = new Random(); Graphics g = panel1.CreateGraphics(); Pen p = new Pen(Color.Black); SolidBrush sb = new SolidBrush(Color.Blue); SizeF stringSize; setShape(tagLocations); int direction = 0; // used to help determine what direction the spiral placing pattern goes - up, down, left, right foreach (tagLabel tag in words) { stringSize = g.MeasureString(tag.tagText, new Font("Arial", GetFontSize(tag.tagFrequency))); int height = (int)stringSize.Height / LOCATION_SIZE; int width = (int)stringSize.Width / LOCATION_SIZE; //System.Windows.Forms.MessageBox.Show("before call to placeTags"); placeTag(tagLocations, ref direction, ref curXCoord, ref curYCoord, height, width); //System.Windows.Forms.MessageBox.Show("after call to placeTags"); if (changeLocations(tagLocations, curXCoord, curYCoord, width, height)) { //System.Windows.Forms.MessageBox.Show("change Locations = true"); g.DrawString(tag.tagText, new Font("Arial", GetFontSize(tag.tagFrequency)), new SolidBrush(GetTextColor(tag.tagFrequency)), curXCoord, curYCoord); } //System.Windows.Forms.MessageBox.Show("direction in main:" + ((direction + 1) % 8)); direction = (direction+1) % 8; } List linesToWrite = new List(); for (int rowIndex = 0; rowIndex < tagLocations_width; rowIndex++) { StringBuilder line = new StringBuilder(); for (int colIndex = 0; colIndex < tagLocations_height; colIndex++) line.Append(tagLocations[rowIndex, colIndex]).Append(" "); linesToWrite.Add(line.ToString()); } System.IO.File.WriteAllLines("C:\\Users\\emmaalberts\\Desktop\\CSCI 460\\Capstone\\Capstone\\test.txt", linesToWrite.ToArray()); } /* panelFull Date: 4/14/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: can the panel fit anymore tags? Parameters: tagLocations - a two dimensional array of the available/taken spots on the panel Output: boolean - true if it is ful - false if there is still room ----------------------------------------------------------------------------------------------------------------*/ bool panelFull(int [,] tagLocations) { for (int i = 0; i < tagLocations.GetLength(0); i++) { for (int j = 0; j < tagLocations.GetLength(1); j++) { if (tagLocations[i, j] == 0) return false; } } return true; } /* outOfBounds Date: 4/7/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: to determine if the next placement if outside of the boundaries of the panel Parameters: x - the x coordinate of the word that should be placed y - the y coordinate of the word that should be placed height - the height of the word that should be placed width - the width of the word that should be placed Output: boolean - true if you are off the grid - false if you are on the grid ----------------------------------------------------------------------------------------------------------------*/ bool outOfBounds(int x, int y, int height, int width) { float bottomRightX = (int)Math.Ceiling(GetBottomRightX(x, y, width, height)); float bottomRightY = (int)Math.Ceiling(GetBottomRightY(x, y, width, height)); if ( x < 0 || x > panel1.Width || y < 0 || y > panel1.Height || bottomRightX < 0 || bottomRightX > panel1.Width || bottomRightY < 0 || bottomRightY > panel1.Height ) return true; else return false; } /* placeTag Date: 4/12/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: find where a tag should be placed - recursive algorithm Parameters: tagLocations - two dimensional array of what locations are available/taken on the panel direction - the direction in which you should continue to attempt to place the word curX - the x coordinate of the word that should be placed curY - the y coordinate of the word that should be placed height - the height of the word that should be placed width - the width of the word that should be placed Output: ----------------------------------------------------------------------------------------------------------------*/ void placeTag(int[,] tagLocations, ref int direction, ref int curX, ref int curY, int height, int width) { if (panelFull(tagLocations)) return; else if (outOfBounds(curX, curY, height, width)) { // call placeTag - switch direction and reset middle curX = PANEL1_WIDTH / 2; curY = PANEL1_HEIGHT / 2; direction = (direction+1) % 8; placeTag(tagLocations, ref direction, ref curX, ref curY, height, width); } else if (LocationGood(tagLocations, curX, curY, height, width)) return; else { switch (direction) { case 0: // down curY += LOCATION_SIZE; // down placeTag(tagLocations, ref direction, ref curX, ref curY, height, width); break; case 1: // down/left curX -= LOCATION_SIZE; // left curY += LOCATION_SIZE; // down placeTag(tagLocations, ref direction, ref curX, ref curY, height, width); break; case 2: // left curX -= LOCATION_SIZE; // left placeTag(tagLocations, ref direction, ref curX, ref curY, height, width); break; case 3: // left/up curX -= LOCATION_SIZE; // left curY -= LOCATION_SIZE; // up placeTag(tagLocations, ref direction, ref curX, ref curY, height, width); break; case 4: // up curY -= LOCATION_SIZE; // up placeTag(tagLocations, ref direction, ref curX, ref curY, height, width); break; case 5: // up/right curY -= LOCATION_SIZE; // up curX += LOCATION_SIZE; // right placeTag(tagLocations, ref direction, ref curX, ref curY, height, width); break; case 6: // right curX += LOCATION_SIZE; // right placeTag(tagLocations, ref direction, ref curX, ref curY, height, width); break; case 7: // right/down curY += LOCATION_SIZE; // down curX += LOCATION_SIZE; // right placeTag(tagLocations, ref direction, ref curX, ref curY, height, width); break; } } return; } /* LocationGood Date: 4/16/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: determine if a location is available to place a word on Parameters: tagLocations - two dimensional array that shows what locations are available/taken in the panel startX - the x coordinate of the placement location startY - the y coordinate of the placement location i_max - the width of the word / how far horizontally over to check j_max - the height of the word / how far vertically over to check Output: boolean - true if you should place the tag there - false if you should find a different spot ----------------------------------------------------------------------------------------------------------------*/ bool LocationGood(int[,] tagLocations, int x, int y, int height, int width) { //System.Windows.Forms.MessageBox.Show("LocationGood"); if (x < 0 || x > panel1.Width || y < 0 || y > panel1.Height) return false; //int k = (int)Math.Floor((double)x / LOCATION_SIZE); //int l = (int)Math.Floor((double)y / LOCATION_SIZE); int k = x / LOCATION_SIZE; int l = y / LOCATION_SIZE; if (k < 0 || k > tagLocations.GetLength(0) || l < 0 || l > tagLocations.GetLength(1)) return false; int i_max = k + width; int j_max = l + height; if (i_max < 0 || i_max > tagLocations.GetLength(0) || j_max < 0 || j_max > tagLocations.GetLength(1)) return false; for (int i = k; i < i_max; i++) { for (int j = l; j < j_max; j++) { //System.Windows.Forms.MessageBox.Show("i: " + i + " j: " + j); if (tagLocations[i, j] == 1) return false; } } return true; } /* changeLocations Date: 4/10/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: change the 2d grid behind the panel to adjust for a placed word Parameters: tagLocations - two dimensional array that shows what locations are available/taken in the panel startX - the x coordinate of the placement location startY - the y coordinate of the placement location i_max - the width of the word / how far horizontally over to check j_max - the height of the word / how far vertically over to check Output: boolean - true if you should place the tag there - false if you should find a different spot ----------------------------------------------------------------------------------------------------------------*/ bool changeLocations(int[,] tagLocations, int startX, int startY, int i_max, int j_max) { // traverse through the squares it will cover //int x = (int)Math.Floor((double)startX / LOCATION_SIZE); //int y = (int)Math.Floor((double)startY / LOCATION_SIZE); int x = startX / LOCATION_SIZE; int y = startY / LOCATION_SIZE; for (int i = x; i < (x + i_max); i++) { for (int j = y; j < (y + j_max); j++) { if (i > tagLocations.GetLength(0) || j > tagLocations.GetLength(1) || i < 0 || j < 0) { //System.Windows.Forms.MessageBox.Show("change Locations = false : adding to " + i + "," + j); return false; } tagLocations[i, j] = 1; } } return true; } /* IntersectsWith Date: 3/13/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: determines if two tags are overlapping Parameters: x1 - x coordinate of tag 1 y1 - y coordinate of tag 1 width1 - width of tag 1 height1 - height of tag 1 x2 - x coordinate of tag2 y2 - x coordinate of tag2 width2 - width of tag 2 height2 - height of tag 2 Output: returns the boolean - false means they do not intersect, true means they do ----------------------------------------------------------------------------------------------------------------*/ bool IntersectsWith(int x1, int y1, float width1, float height1, int x2, int y2, float width2, float height2) { // get all of the corners for string1 float topLeftX1 = GetTopLeftX(x1, y1, width1, height1); float topLeftY1 = GetTopLeftY(x1, y1, width1, height1); float topRightX1 = GetTopRightX(x1, y1, width1, height1); float topRightY1 = GetTopRightY(x1, y1, width1, height1); float bottomLeftX1 = GetBottomLeftX(x1, y1, width1, height1); float bottomLeftY1 = GetBottomLeftY(x1, y1, width1, height1); float bottomRightX1 = GetBottomRightX(x1, y1, width1, height1); float bottomRightY1 = GetBottomRightY(x1, y1, width1, height1); // get all of the corners for string2 float topLeftX2 = GetTopLeftX(x2, y2, width2, height2); float topLeftY2 = GetTopLeftY(x2, y2, width2, height2); float topRightX2 = GetTopRightX(x2, y2, width2, height2); float topRightY2 = GetTopRightY(x2, y2, width2, height2); float bottomLeftX2 = GetBottomLeftX(x2, y2, width2, height2); float bottomLeftY2 = GetBottomLeftY(x2, y2, width2, height2); float bottomRightX2 = GetBottomRightX(x2, y2, width2, height2); float bottomRightY2 = GetBottomRightY(x2, y2, width2, height2); //System.Windows.Forms.MessageBox.Show("topleftx/" + topLeftX1 + "/" + topLeftX2 + "/toplefty/" + topLeftY1 + "/" + topLeftY2 + "/toprightx/" + topRightX1 + "/" + topRightX2 + "/toprighty/" + topRightY1 + "/" + topRightY2 + "/bottomleftx/" + bottomLeftX1 + "/" + bottomLeftX2 + "/bottomlefty/" + bottomLeftY1 + "/" + bottomLeftY2 + "/bottomrightx/" + bottomRightX1 + "/" + bottomRightX2 + "/bottomrightY/" + bottomRightY1 + "/" + bottomRightY2); // check top left corner if (topLeftX2 <= bottomRightX1 && topLeftY2 <= bottomRightY1 && topLeftX2 >= topLeftX1 && topLeftY2 >= topLeftY1) return true; // check top right corner else if (topRightX2 <= bottomLeftX1 && topRightY2 >= bottomLeftY1 && topRightX2 >= topRightX1 && topRightY2 <= topRightY1) return true; // check bottom left corner else if (bottomLeftX2 >= topRightX1 && bottomLeftY2 <= topRightY1 && bottomLeftX2 <= bottomLeftX1 && bottomLeftY2 >= bottomLeftY1) return true; // check bottom right corner else if (bottomRightX2 >= topLeftX1 && bottomRightY2 >= topLeftY1 && bottomRightX2 <= bottomRightX1 && bottomRightY2 <= bottomRightY1) return true; else return false; } /* GetTopLeftX Date: 3/13/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: returns the x coordinate of the top left corner of the tag Parameters: x - the x coordinate of the tag y - the y coordinate of the tag width - the width of the tag height - the height of the tag Output: returns float designating the x coordinate of the top left corner of the tag ----------------------------------------------------------------------------------------------------------------*/ float GetTopLeftX(int x, int y, float width, float height) { return x; } /* GetTopLeftY Date: 3/13/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: returns the y coordinate of the top left corner of the tag Parameters: x - the x coordinate of the tag y - the y coordinate of the tag width - the width of the tag height - the height of the tag Output: returns float designating the y coordinate of the top left corner of the tag ----------------------------------------------------------------------------------------------------------------*/ float GetTopLeftY(int x, int y, float width, float height) { return y; } /* GetTopRightX Date: 3/13/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: returns the x coordinate of the top right corner of the tag Parameters: x - the x coordinate of the tag y - the y coordinate of the tag width - the width of the tag height - the height of the tag Output: returns float designating the x coordinate of the top right corner of the tag ----------------------------------------------------------------------------------------------------------------*/ float GetTopRightX(int x, int y, float width, float height) { return x + width; } /* GetTopRightY Date: 3/13/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: returns the y coordinate of the top right corner of the tag Parameters: x - the x coordinate of the tag y - the y coordinate of the tag width - the width of the tag height - the height of the tag Output: returns float designating the y coordinate of the top right corner of the tag ----------------------------------------------------------------------------------------------------------------*/ float GetTopRightY(int x, int y, float width, float height) { while(true) { } return y; } /* GetBottomLeftX Date: 3/13/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: returns the x coordinate of the bottom left corner of the tag Parameters: x - the x coordinate of the tag y - the y coordinate of the tag width - the width of the tag height - the height of the tag Output: returns float designating the x coordinate of the bottom left corner of the tag ----------------------------------------------------------------------------------------------------------------*/ float GetBottomLeftX(int x, int y, float width, float height) { return x; } /* GetBottomLeftY Date: 3/13/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: returns the y coordinate of the bottom left corner of the tag Parameters: x - the x coordinate of the tag y - the y coordinate of the tag width - the width of the tag height - the height of the tag Output: returns float designating the y coordinate of the bottom left corner of the tag ----------------------------------------------------------------------------------------------------------------*/ float GetBottomLeftY(int x, int y, float width, float height) { return y + height; } /* GetBottomRightX Date: 3/13/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: returns the x coordinate of the bottom right corner of the tag Parameters: x - the x coordinate of the tag y - the y coordinate of the tag width - the width of the tag height - the height of the tag Output: returns float designating the x coordinate of the bottom right corner of the tag ----------------------------------------------------------------------------------------------------------------*/ float GetBottomRightX(int x, int y, float width, float height) { return x + width; } /* GetBottomRightY Date: 3/13/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: returns the y coordinate of the bottom right corner of the tag Parameters: x - the x coordinate of the tag y - the y coordinate of the tag width - the width of the tag height - the height of the tag Output: returns float designating the y coordinate of the bottom right corner of the tag ----------------------------------------------------------------------------------------------------------------*/ float GetBottomRightY(int x, int y, float width, float height) { return y + height; } /* colorSchemeComboBox_SelectedIndexChanged Date: 4/6/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: to redraw the panel if a new color scheme is selected Parameters: sender - the item that sent it e - event arguments from the form ----------------------------------------------------------------------------------------------------------------*/ private void colorSchemeComboBox_SelectedIndexChanged(object sender, EventArgs e) { panel1.Invalidate(); } /* shapeComboBox_SelectedIndexChanged Date: 4/6/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: to redraw the panel if a new shape is selected Parameters: sender - the item that sent it e - event arguments from the form ----------------------------------------------------------------------------------------------------------------*/ private void shapeComboBox_SelectedIndexChanged(object sender, EventArgs a) { panel1.Invalidate(); } /* GetTextColor Date: 3/15/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: set the text color of a specific tag Parameters: frequency - the number of times the word appears in the cloud - each tag frequency corresponds with a different color Output: Color - the text color of the current tag ----------------------------------------------------------------------------------------------------------------*/ public Color GetTextColor(int frequency) { String colorScheme = colorSchemeComboBox.SelectedItem.ToString(); //System.Windows.Forms.MessageBox.Show("GetTextColor " + colorScheme); if (colorScheme == "Feelin' Blue") { if (frequency <= SMALL_FONTSIZE_FREQCUTOFF) return Color.MediumBlue; else if (frequency <= MEDIUM_FONTSIZE_FREQCUTOFF) return Color.DodgerBlue; else if (frequency <= LARGE_FONTSIZE_FREQCUTOFF) return Color.DeepSkyBlue; else return Color.DarkBlue; } else if (colorScheme == "You Are My Sunshine") { if (frequency <= SMALL_FONTSIZE_FREQCUTOFF) return Color.Gold; else if (frequency <= MEDIUM_FONTSIZE_FREQCUTOFF) return Color.OrangeRed; else if (frequency <= LARGE_FONTSIZE_FREQCUTOFF) return Color.Orange; else return Color.Yellow; } else if (colorScheme == "It's Not Easy Being Green") { if (frequency <= SMALL_FONTSIZE_FREQCUTOFF) return Color.Green; else if (frequency <= MEDIUM_FONTSIZE_FREQCUTOFF) return Color.DarkSeaGreen; else if (frequency <= LARGE_FONTSIZE_FREQCUTOFF) return Color.ForestGreen; else return Color.DarkGreen; } else if (colorScheme == "Norby's Favorite") { if (frequency <= SMALL_FONTSIZE_FREQCUTOFF) return Color.Goldenrod; else if (frequency <= MEDIUM_FONTSIZE_FREQCUTOFF) return Color.Green; else if (frequency <= LARGE_FONTSIZE_FREQCUTOFF) return Color.Yellow; else return Color.ForestGreen; } else if (colorScheme == "Random") return Color.FromArgb(r.Next(0, 256), r.Next(0, 256), r.Next(0, 256)); else { if (frequency <= SMALL_FONTSIZE_FREQCUTOFF) return Color.DeepPink; else if (frequency <= MEDIUM_FONTSIZE_FREQCUTOFF) return Color.HotPink; else if (frequency <= LARGE_FONTSIZE_FREQCUTOFF) return Color.Red; else return Color.DarkRed; } } /* setShape Date: 4/22/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: set the cutout shape of the tag cloud Parameters: tagLocations - two dimensional array that tells whether a spot on the panel is taken/available Output: tagLocations (by nature of an array) is a reference parameter, so changes are reflected in main program ----------------------------------------------------------------------------------------------------------------*/ public void setShape(int[,] tagLocations) { String shape = shapeComboBox.SelectedItem.ToString(); //System.Windows.Forms.MessageBox.Show("setShape " + shape); if (shape == "Square") { for (int i = 40; i < 80; i++) { for (int j = 20; j < 60; j++) { tagLocations[i,j] = 1; } } } else if (shape == "Triangle") { for (int i = 20; i < 70; i++) { for (int j = 20; j < i; j++) { tagLocations[i, j] = 1; } } } return; } /* GetBackgroundColor Date: 3/15/2019 ---------------------------------------------------------------------------------------------------------------- Purpose: sets the background color of the panel Output: color of the background based upon the colorSchemeComboBox selection ----------------------------------------------------------------------------------------------------------------*/ public Color GetBackgroundColor() { String colorScheme = colorSchemeComboBox.SelectedItem.ToString(); if (colorScheme == "Feelin' Blue") return Color.LightSteelBlue; else if (colorScheme == "You Are My Sunshine") return Color.LightYellow; else if (colorScheme == "It's Not Easy Being Green") return Color.LightGreen; else if (colorScheme == "Norby's Favorite") return Color.LightGoldenrodYellow; else if (colorScheme == "Random") return Color.FromArgb(r.Next(0, 256), r.Next(0, 256), r.Next(0, 256)); else return Color.LightPink; } } }