public static Color parseStringToColor(string s) { if (Const.isItalian == 0) { int indx = Array.IndexOf((Const.getRow(Const.ColorBackGroundPossibile, 0)), s); if (indx == -1) { return(Const.BackgroundColor); } return(Color.FromName(Const.ColorBackGroundPossibile[1, indx])); } else { return(Color.FromName(s)); } }
public void defineCBox() { //vado a impostare adesso i vari colori selzionabili nelle varie barre cBoxLeanguage.Items.AddRange(Const.getRow(Const.LanguagePossible, Const.isItalian)); cBoxLeanguage.SelectedItem = Const.getRow(Const.LanguagePossible, Const.isItalian)[Const.isItalian]; cBoxLevel.Items.AddRange(Const.LevelPossible); cBoxLevel.SelectedItem = Const.currentLevel.difficulty.ToString(); cBoxBackground.Items.AddRange(Const.getRow(Const.ColorBackGroundPossibile, Const.isItalian)); cBoxBackground.SelectedItem = Const.convertTextIngToIT(Const.BackgroundColor.Name); cBoxBBeckground.Items.AddRange(Const.getRow(Const.ColorButtonBackground, Const.isItalian)); cBoxBBeckground.SelectedItem = Const.convertTextIngToIT(Const.ButtonColor.Name); cBoxBText.Items.AddRange(Const.getRow(Const.ColorButtonText, Const.isItalian)); cBoxBText.SelectedItem = Const.convertTextIngToIT(Const.TextColor.Name); }
public static void init() { BackgroundColor = Color.Beige; ButtonColor = Color.DarkSlateGray; TextColor = Color.White; isItalian = 1; Const.loadSettingFile(); //TextColor = Color.bla; proj = new Form1(); setting = new SettingForm(); help = new Help(); Const.score = 0; }
public void init() { //adesso andiamo a impostare i colori dei pulsanti e dello schemro //Colore schermo: this.BackColor = Const.BackgroundColor; //colore dei pulsanti Const.settingColorButton(ref ButtonMenu); Const.settingColorButton(ref buttonSave); Const.checkButtonLangh(ref buttonSave, typeButton.save); Const.checkLabelLangh(ref labelLanguage, typeLabel.Language); Const.checkLabelLangh(ref labelLivel, typeLabel.Liv); Const.checkLabelLangh(ref labelColor1, typeLabel.colorBack); Const.checkLabelLangh(ref labelColor2, typeLabel.colorBBackGr); Const.checkLabelLangh(ref labelColor3, typeLabel.colorText); }
private void buttonSave_Click(object sender, EventArgs e) { Const.BackgroundColor = Const.parseStringToColor(cBoxBackground.SelectedItem.ToString()); Const.ButtonColor = Const.parseStringToColor(cBoxBBeckground.SelectedItem.ToString()); Const.TextColor = Const.parseStringToColor(cBoxBText.SelectedItem.ToString()); Const.currentLevel = new Level(Int32.Parse(cBoxLevel.SelectedItem.ToString())); if ((cBoxLeanguage.SelectedItem.ToString() == "Italiano" || cBoxLeanguage.SelectedItem.ToString() == "Italian")) { cBoxBackground.Items.Clear(); cBoxBBeckground.Items.Clear(); cBoxBText.Items.Clear(); cBoxLeanguage.Items.Clear(); Const.isItalian = 0; defineCBox(); } else if (Const.isItalian != 1) { cBoxBackground.Items.Clear(); cBoxBBeckground.Items.Clear(); cBoxBText.Items.Clear(); cBoxLeanguage.Items.Clear(); Const.isItalian = 1; defineCBox(); } init(); Const.proj.init(); Const.proj.loadCanvas(); Const.proj.drawShape(); Const.menu.init(); Const.help.init(); Const.saveSettingOnFile(); }
public void init() { //vado a posizionare i vari pulsanti sullp schemo startGame.Location = new Point(Const.widthScreen / 2 - startGame.Width / 2, Const.heightScreen / 4 - startGame.Height); help.Location = new Point(Const.widthScreen / 2 - startGame.Width / 2, startGame.Location.Y + 100); setting.Location = new Point(Const.widthScreen / 2 - startGame.Width / 2, help.Location.Y + 100); ButtonExit.Location = new Point(Const.widthScreen / 2 - ButtonExit.Width / 2, setting.Location.Y + 100); //adesso andiamo a impostare i colori dei pulsanti e dello schemro //Colore schermo: this.BackColor = Const.BackgroundColor; //colore dei pulsanti Const.settingColorButton(ref startGame); Const.settingColorButton(ref setting); Const.settingColorButton(ref ButtonExit); Const.settingColorButton(ref help); Const.checkButtonLangh(ref startGame, typeButton.start); Const.checkButtonLangh(ref setting, typeButton.setting); Const.checkButtonLangh(ref ButtonExit, typeButton.exit); }
public static void loadSettingFile() { try { //Pass the file path and file name to the StreamReader constructor StreamReader sr = new StreamReader("Settings.txt"); //Read the first line of text Const.isItalian = Int32.Parse(sr.ReadLine()); Const.currentLevel = new Level(Int32.Parse(sr.ReadLine())); if (Const.isItalian == 0) { Const.ButtonColor = Const.parseStringToColor(Const.convertTextItToIng(sr.ReadLine())); Const.BackgroundColor = Const.parseStringToColor(Const.convertTextItToIng(sr.ReadLine())); Const.TextColor = Const.parseStringToColor(Const.convertTextItToIng(sr.ReadLine())); } else { Const.ButtonColor = Const.parseStringToColor(sr.ReadLine()); Const.BackgroundColor = Const.parseStringToColor(sr.ReadLine()); Const.TextColor = Const.parseStringToColor(sr.ReadLine()); } //Close the file sr.Close(); } catch (Exception e) { Console.WriteLine("Exception: " + e.Message); Const.currentLevel = new Level(3); } }
private void button2_Click(object sender, EventArgs e) { Const.score++; Const.checkLabelLangh(ref label2, typeLabel.score); currentShape = getNextShape(); }