{ static void colorText(string text, myColor color) { switch (color) { case myColor.yellow: { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(text); break; } case myColor.red: { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(text); break; } case myColor.blue: { Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine(text); break; } case myColor.green: { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(text); break; } } }
static void Main(string[] args) { myColor c = myColor.Red; if (c == myColor.Red) { Console.WriteLine($"myColor is {c}"); } Console.ReadKey(); }
void GetButtonColor(Color color) { for (int i = 0; i < boxManager.boxColorList.Count; i++) { if (color == boxManager.boxColorList[i]) { OrderColorName = (myColor)i; break; } } }
static void Main(string[] args) { Console.WriteLine("Введите строку: "); string str = Console.ReadLine(); Console.WriteLine("Введите цвет: 0 - yellow, 1 - red, 2 - blue, 3 - green"); int c = int.Parse(Console.ReadLine()); myColor cc = (myColor)c; colorText(str, cc); }
private void jsonSerialize() { // Create serialization object myColor colour1 = new myColor(); colour1.colourCodes = myColours; // Convert colour1 to json data and save as txt file in the root of the C: drive string jsonData = JsonConvert.SerializeObject(colour1); File.WriteAllText(@"c:\mycolours.txt", jsonData); }
public static int GetFlyerIndex(String[] recognized, string[] palabras) { bool full = true; foreach (String element in recognized) { if (element == null) { full = false; break; } } if (full) { Tipo bTipo = Tipo.nulo; myColor bColor = myColor.nulo; if (recognized[0] == palabras[0]) //Avion/Plane { bTipo = Tipo.Avion; } if (recognized[0] == palabras[1]) //Helicoptero/Chopper { bTipo = Tipo.Helicoptero; } if (recognized[0] == palabras[2]) //Militar/Militar { bTipo = Tipo.Militar; } if (recognized[0] == palabras[3]) //OVNI/UFO { bTipo = Tipo.OVNI; } if (recognized[1] == palabras[4]) //Amarillo/Yellow { bColor = myColor.Amarillo; } if (recognized[1] == palabras[5]) //Azul/Blue { bColor = myColor.Azul; } if (recognized[1] == palabras[6]) //Blanco/White { bColor = myColor.Blanco; } if (recognized[1] == palabras[7]) //Naranja/Orange { bColor = myColor.Naranja; } if (recognized[1] == palabras[8]) //Negro/Black { bColor = myColor.Negro; } if (recognized[1] == palabras[9]) //Rojo/Red { bColor = myColor.Rojo; } if (recognized[1] == palabras[10]) //Verde/Green { bColor = myColor.Verde; } if (recognized[1] == palabras[11]) //Violeta/Purple { bColor = myColor.Violeta; } try { return(Global.flyers.FindIndex(x => x.tipo == bTipo && x.mycolor == bColor)); } catch (ArgumentNullException anex) { return(-1); } } return(-1); }
//Comandos public static int GetFlyerIndex(KeyboardState ks) { Tipo bTipo = Tipo.nulo; myColor bColor = myColor.nulo; if (ks.GetPressedKeys().Length == 3) { if (ks.IsKeyDown(Keys.A)) { bTipo = Tipo.Avion; } if (ks.IsKeyDown(Keys.H)) { bTipo = Tipo.Helicoptero; } if (ks.IsKeyDown(Keys.M)) { bTipo = Tipo.Militar; } if (ks.IsKeyDown(Keys.O)) { bTipo = Tipo.OVNI; } if (ks.IsKeyDown(Keys.D0)) { bColor = myColor.Amarillo; } if (ks.IsKeyDown(Keys.K)) { bColor = myColor.Azul; } if (ks.IsKeyDown(Keys.D2)) { bColor = myColor.Blanco; } if (ks.IsKeyDown(Keys.D3)) { bColor = myColor.Naranja; } if (ks.IsKeyDown(Keys.D4)) { bColor = myColor.Negro; } if (ks.IsKeyDown(Keys.D5)) { bColor = myColor.Rojo; } if (ks.IsKeyDown(Keys.D6)) { bColor = myColor.Verde; } if (ks.IsKeyDown(Keys.D7)) { bColor = myColor.Violeta; } try { return(Global.flyers.FindIndex(x => x.tipo == bTipo && x.mycolor == bColor)); } catch (ArgumentNullException anex) { return(-1); } } return(-1); }
public Flyer(int heightVP, int widthVP, Game1 game) { this.exists = true; //La aeronave esta activa this.moving = true; //La aeronave esta en movimiento this.tipo = GetNewFlyerTipo(OVNI(Global.landCount)); //Se le asigna un TIPO a la aeronave if (this.tipo == Tipo.OVNI) { this.mycolor = myColor.Amarillo; } else { try { this.mycolor = GetNewFlyerColor(this.tipo); //Se le asigna un COLOR a la aeronave } catch (Exception e) { this.mycolor = myColor.nulo; while (this.mycolor == myColor.nulo) //Si todos los colores de ese tipo estan "tomado" se le asigna un nuevo tipo { this.tipo = GetNewFlyerTipo(OVNI(Global.landCount)); try { this.mycolor = GetNewFlyerColor(this.tipo); //Se le asigna un COLOR a la aeronave } catch (Exception ex) { this.mycolor = myColor.nulo; } } } } switch (this.tipo) //Dependiendo del tipo: { case Tipo.Avion: this.flyrColor = Global.colorsFly[Global.ColorTypeToSubindex(this.mycolor)]; //Se le da un Color de Filtro this.tipo = Tipo.Avion; //Se guarda el tipo this.velocidad = vAvion; //Se le asigna una velocidad this.vInicial = vAvion; //Y una velocidad inicial (para resetear la aeronave) this.punt = 125; //Se le asigna un puntaje this.tFlyer = game.Content.Load <Texture2D>("Imagenes/AvionGeneral0"); //Una textura para la posicion 1 this.tFlyerT = game.Content.Load <Texture2D>("Imagenes/AvionGeneral1"); //Una textura para la posicion 2 this.partesFlyer.Add(new Part(game.Content.Load <Texture2D>("Imagenes/pedazoCabAvion"), this.flyrColor, this.Position)); this.partesFlyer.Add(new Part(game.Content.Load <Texture2D>("Imagenes/pedazoColaAvion"), this.flyrColor, this.Position)); this.partesFlyer.Add(new Part(game.Content.Load <Texture2D>("Imagenes/pedazoAlaAvion"), this.flyrColor, this.Position)); break; case Tipo.Helicoptero: this.flyrColor = Global.colorsFly[Global.ColorTypeToSubindex(this.mycolor)]; this.tipo = Tipo.Helicoptero; this.velocidad = vCopter; this.vInicial = vCopter; this.punt = 75; this.tFlyer = game.Content.Load <Texture2D>("Imagenes/CopterGeneral0"); this.tFlyerT = game.Content.Load <Texture2D>("Imagenes/CopterGeneral1"); this.partesFlyer.Add(new Part(game.Content.Load <Texture2D>("Imagenes/pedazoCabCopter"), this.flyrColor, this.Position)); this.partesFlyer.Add(new Part(game.Content.Load <Texture2D>("Imagenes/pedazoColaCopter"), this.flyrColor, this.Position)); this.partesFlyer.Add(new Part(game.Content.Load <Texture2D>("Imagenes/pedazoHelice"), this.flyrColor, this.Position)); break; case Tipo.Militar: this.flyrColor = Global.colorsFly[Global.ColorTypeToSubindex(this.mycolor)]; this.tipo = Tipo.Militar; this.velocidad = vMilitar; this.vInicial = vMilitar; this.punt = 150; this.tFlyer = game.Content.Load <Texture2D>("Imagenes/MilitarGeneral0"); this.tFlyerT = game.Content.Load <Texture2D>("Imagenes/MilitarGeneral1"); this.partesFlyer.Add(new Part(game.Content.Load <Texture2D>("Imagenes/pedazoCabMilitar"), this.flyrColor, this.Position)); this.partesFlyer.Add(new Part(game.Content.Load <Texture2D>("Imagenes/pedazoAlaMilitar"), this.flyrColor, this.Position)); this.partesFlyer.Add(new Part(game.Content.Load <Texture2D>("Imagenes/pedazoAlaMilitar"), this.flyrColor, this.Position)); break; case Tipo.OVNI: this.flyrColor = Color.White; this.tipo = Tipo.OVNI; this.velocidad = vOVNI; this.vInicial = vOVNI; this.punt = 250; if (Global.landCountOVNI != 4) { this.tFlyer = game.Content.Load <Texture2D>("Imagenes/OVNIGeneral0"); this.tFlyerT = game.Content.Load <Texture2D>("Imagenes/OVNIGeneral1"); this.partesFlyer.Add(new Part(game.Content.Load <Texture2D>("Imagenes/pedazoOVNI"), this.flyrColor, this.Position)); this.partesFlyer.Add(new Part(game.Content.Load <Texture2D>("Imagenes/pedazoOVNI"), this.flyrColor, this.Position)); } else { this.tFlyer = game.Content.Load <Texture2D>("Imagenes/TARDISEasterEgg"); this.tFlyerT = game.Content.Load <Texture2D>("Imagenes/TARDISEasterEgg"); this.partesFlyer.Add(new Part(game.Content.Load <Texture2D>("Imagenes/TARDISEasterEgg"), this.flyrColor, this.Position)); } break; } float x, y; this.direccion = SetPositionDireccion(this, heightVP, widthVP, out x, out y); //Se asigna una Posicion y una Direccion int tries = 0; while (AlarmaChoque(this) && tries < 50) //Si la aeronave va a aparecer cerca de otra, se asigna una nueva posicion y direccion { tries++; this.direccion = SetPositionDireccion(this, heightVP, widthVP, out x, out y); } this.Position.X = x; //Se guarda la posicion X this.Position.Y = y; //Se guarda la posicion Y this.turningDir = this.direccion; switch (this.tipo) { case Tipo.Avion: if (!Global.soundmute) { Global.SEInstances[1].Play(); } else { Global.SEInstances[1].Stop(); } break; case Tipo.Helicoptero: if (!Global.soundmute) { Global.SEInstances[2].Play(); } else { Global.SEInstances[2].Stop(); } break; case Tipo.Militar: if (!Global.soundmute) { Global.SEInstances[3].Play(); } else { Global.SEInstances[3].Stop(); } break; case Tipo.OVNI: if (Global.landCountOVNI != 4) { if (!Global.soundmute) { Global.SEInstances[4].Play(); } else { Global.SEInstances[4].Stop(); } } else { if (!Global.soundmute) { Global.SEInstances[7].Play(); } else { Global.SEInstances[7].Stop(); } } break; } Global.flyers.Add(this); //Se agrega a la lista con todas las aeronaves }
public Flyer(int heightVP, int widthVP, Game1 game, string position, Tipo typeIN, myColor colorIN) //Used in Tutorial { this.exists = true; //La aeronave esta activa this.moving = false; //La aeronave esta en movimiento this.tipo = typeIN; //Se le asigna un TIPO a la aeronave this.mycolor = colorIN; switch (this.tipo) //Dependiendo del tipo: { case Tipo.Avion: this.flyrColor = Global.colorsFly[Global.ColorTypeToSubindex(this.mycolor)]; //Se le da un Color de Filtro this.tipo = Tipo.Avion; //Se guarda el tipo this.velocidad = 0.0f; //Se le asigna una velocidad this.vInicial = 0.0f; //Y una velocidad inicial (para resetear la aeronave) this.punt = 0; //Se le asigna un puntaje this.tFlyer = game.Content.Load <Texture2D>("Imagenes/AvionGeneral0"); //Una textura para la posicion 1 this.tFlyerT = game.Content.Load <Texture2D>("Imagenes/AvionGeneral1"); //Una textura para la posicion 2 break; case Tipo.Helicoptero: this.flyrColor = Global.colorsFly[Global.ColorTypeToSubindex(this.mycolor)]; this.tipo = Tipo.Helicoptero; this.velocidad = 0.0f; this.vInicial = 0.0f; this.punt = 0; this.tFlyer = game.Content.Load <Texture2D>("Imagenes/CopterGeneral0"); this.tFlyerT = game.Content.Load <Texture2D>("Imagenes/CopterGeneral1"); break; case Tipo.Militar: this.flyrColor = Global.colorsFly[Global.ColorTypeToSubindex(this.mycolor)]; this.tipo = Tipo.Militar; this.velocidad = 0.0f; this.vInicial = 0.0f; this.punt = 0; this.tFlyer = game.Content.Load <Texture2D>("Imagenes/MilitarGeneral0"); this.tFlyerT = game.Content.Load <Texture2D>("Imagenes/MilitarGeneral1"); break; case Tipo.OVNI: this.flyrColor = Color.White; this.tipo = Tipo.OVNI; this.velocidad = 0.0f; this.vInicial = 0.0f; this.punt = 0; this.tFlyer = game.Content.Load <Texture2D>("Imagenes/OVNIGeneral0"); this.tFlyerT = game.Content.Load <Texture2D>("Imagenes/OVNIGeneral1"); break; } this.direccion = 0.0f; //Se asigna una Posicion y una Direccion this.Position.X = heightVP / 2; //Se guarda la posicion X this.Position.Y = widthVP / 2; //Se guarda la posicion Y this.turningDir = this.direccion; switch (this.tipo) { case Tipo.Avion: if (!Global.soundmute) { Global.SEInstances[1].Play(); } else { Global.SEInstances[1].Stop(); } break; case Tipo.Helicoptero: if (!Global.soundmute) { Global.SEInstances[2].Play(); } else { Global.SEInstances[2].Stop(); } break; case Tipo.Militar: if (!Global.soundmute) { Global.SEInstances[3].Play(); } else { Global.SEInstances[3].Stop(); } break; case Tipo.OVNI: if (Global.landCountOVNI != 4) { if (!Global.soundmute) { Global.SEInstances[4].Play(); } else { Global.SEInstances[4].Stop(); } } else { if (!Global.soundmute) { Global.SEInstances[7].Play(); } else { Global.SEInstances[7].Stop(); } } break; } Global.flyers.Add(this); //Se agrega a la lista con todas las aeronaves }
private Color toColor(myColor c) { myColor tmp = c; if (tmp.R < 0) tmp.R = 0; if (tmp.R > 255) tmp.R = 255; if (tmp.G < 0) tmp.G = 0; if (tmp.G > 255) tmp.G = 255; if (tmp.B < 0) tmp.B = 0; if (tmp.B > 255) tmp.B = 255; return Color.FromArgb(tmp.R,tmp.G,tmp.B); }
private Bitmap bicubic() { int newx = x; int newy = y; int newWidth = (int)zoomk * width; int newHeight = (int)zoomk * height; Color[,] newData = new Color[newWidth,newHeight]; Color[,] data = new Color[width,height]; if (radioButton3.Checked) data = toAreaColorMatr(btp); else data = toColorMatr(btp); double tx = (double) 1.0/zoomk; // How many zoom per X and Y double ty = (double) 1.0/zoomk; double dx, dy; myColor d0,d2,d3,a0,a1,a2,a3; myColor[] C = new myColor[4]; myColor resColor; for(int i=2; i<newWidth-2/tx; i++) for(int j=2; j<newHeight-2/tx; j++) { x = (int)(tx*i); // Getting pixels from original image y = (int)(ty * j); dx = tx * i - x; // Get the difference from int points of original dy = ty * j - y ; for(int l=0;l<=3;l++) { d0 = deColors(toMyColor(data[x - 1, y - 1 + l]), toMyColor(data[x, y - 1 + l])); //Finding derivatives X d2 = deColors(toMyColor(data[x + 1, y - 1 + l]), toMyColor(data[x, y - 1 + l])); d3 = deColors(toMyColor(data[x + 2, y - 1 + l]), toMyColor(data[x, y - 1 + l])); a0 = toMyColor(data[x, y - 1 + l]); // Finding coeefs a1 = sColors(sColors(d2,prodColors(d0,(-1.0/3.0))),prodColors(d3,(-1.0/6.0))); a2 = sColors(prodColors(d0,(1.0/2.0)),prodColors(d2,(1.0/2.0))); a3 = sColors(sColors(prodColors(d2,(1.0/2.0)),prodColors(d0,(-1.0/6.0))),prodColors(d3,(1.0/6.0))); C[l] = getCubi(a0,a1,a2,a3,dx); // Finding cub equation } d0 = deColors(C[0],C[1]); // Finding derivatives Y d2 = deColors(C[2],C[1]); d3 = deColors(C[3],C[1]); a0 = C[1]; a1 = sColors(sColors(d2,prodColors(d0,(-1.0/3.0))),prodColors(d3,(-1.0/6.0))); // Finding coeefs a2 = sColors(prodColors(d0,(1.0/2.0)),prodColors(d2,(1.0/2.0))); a3 = sColors(sColors(prodColors(d2,(1.0/2.0)),prodColors(d0,(-1.0/6.0))),prodColors(d3,(1.0/6.0))); resColor = getCubi(a0,a1,a2,a3,dy); // Getting produced color from cub equation newData[i,j] = toColor(resColor); } Bitmap newImage = toBitmap(newData, newWidth, newHeight); return newImage; }
private myColor sColors(myColor c, myColor c1) { myColor res; res.R = c.R + c1.R; res.G = c.G + c1.G; res.B = c.B + c1.B; return res; }
private myColor prodColors(myColor c, double d) { myColor res; res.R = (int)(c.R*d); res.G = (int)(c.G*d); res.B = (int)(c.B*d); return res; }
private myColor getCubi(myColor a0, myColor a1, myColor a2, myColor a3, double dx) { myColor res; res = sColors(a0, prodColors(a1, dx)); res = sColors(res, prodColors(a2, dx * dx)); res = sColors(res, prodColors(a3, dx * dx * dx)); return res; }
private myColor deductColors(myColor c1, myColor c2) { int sumr = 0, sumg = 0, sumb = 0; sumr = Math.Abs(c1.R - c2.R); sumg = Math.Abs(c1.G - c2.G); sumb = Math.Abs(c1.B - c2.B); myColor res; res.R = sumr; res.G = sumb; res.B = sumb; return res; }
private myColor deColors(myColor c, myColor c1) { myColor res; res.R = c.R - c1.R; res.G = c.G - c1.G; res.B = c.B - c1.B; return res; // return Color.FromArgb(c.R - c1.R, c.G - c1.G, c.B - c1.B); // return res; }