Example #1
0
 static Serializar()
 {
     dicAssembly = new LlistaOrdenada <string, string>();
     for (int i = 0; i < AsseblyQualifiedNameTiposAceptados.Length; i++)
     {
         dicAssembly.Add(AsseblyQualifiedNameTiposAceptados[i], AsseblyQualifiedNameTiposAceptados[i]);
     }
 }
Example #2
0
 static Hex()
 {
     diccionarioCaracteresValidos = new LlistaOrdenada <char, char>();
     for (int i = 0; i < caracteresHex.Length; i++)
     {
         diccionarioCaracteresValidos.Add(caracteresHex[i][0], caracteresHex[i][0]);
     }
 }
Example #3
0
        public Point GetPoint(int colorInt)
        {
            const int ARGB = 4;
            int       posicion;

            byte[] bytesColor;
            Point  location   = default(Point);
            bool   encontrado = false;

            if (pointLocatedByColorList.ContainsKey(colorInt))
            {
                location = pointLocatedByColorList[colorInt].Value;
            }
            else
            {
                bytesColor = Serializar.GetBytes(colorInt);
                for (int y = 0, yFin = Convert.ToInt32(imagen.Height), xFin = Convert.ToInt32(imagen.Width) * ARGB; y < yFin && !encontrado; y++)
                {
                    for (int x = 0; x < xFin && !encontrado; x += ARGB)
                    {
                        posicion   = x + (y * xFin);
                        encontrado = bytesImg[posicion] == bytesColor[0] && bytesImg[posicion + 1] == bytesColor[1] && bytesImg[posicion + 2] == bytesColor[2] && bytesImg[posicion + 3] == bytesColor[3];
                        if (encontrado)
                        {
                            location = new Point(x, y);
                        }
                    }
                }
                if (!encontrado)
                {
                    throw new ArgumentOutOfRangeException("El color no esta dentro de la imagen!");
                }
                else
                {
                    pointLocatedByColorList.Add(colorInt, location);
                    if (!colorLocatedByPointerList.ContainsKey(new PointZ(location, 0)))
                    {
                        colorLocatedByPointerList.Add(new PointZ(location, 0), System.Drawing.Color.FromArgb(colorInt));
                    }
                }
            }
            return(location);
        }
Example #4
0
        static void IIniciaFaena()
        {
            Thread hiloFaena;

            for (int i = hilosFaenas.Count; i < MaxThreadsClase; i++)  //pongo los threads que voy a necesitar
            {
                hiloFaena          = new Thread(() => HazFaena());
                hiloFaena.Priority = ThreadPriority;
                hiloFaena.Name     = generadorId.Siguiente();
                hilosFaenas.Add(hiloFaena.Name, hiloFaena);
                hiloFaena.Start();
            }
        }
Example #5
0
 public void Add(TKey1 key1, TKey2 key2, TValue value)
 {
     if (llista1.ContainsKey(key1))
     {
         throw new Exception("Esta duplicada la clave1 para el valor");
     }
     if (llista2.ContainsKey(key2))
     {
         throw new Exception("Esta duplicada la clave2 para el valor");
     }
     llista1.Add(key1, value);
     llista2.Add(key2, value);
     llistaClau1.Add(key1, key2);
     llistaClau2.Add(key2, key1);
 }
 public void Add(TKey key, TValue value)
 {
     if (key == null)
     {
         throw new ArgumentNullException();
     }
     if (value == null)
     {
         throw new ArgumentNullException();
     }
     if (!diccionari.ContainsKey(key))
     {
         diccionari.Add(key, new LlistaOrdenada <IComparable, TValue>());
     }
     diccionari[key].Add(value, value);
 }
Example #7
0
        static void HazFaena()
        {
            Tiket <TipoTrabajo> tiket = null;

            while (faenasEstaticas.Count > 0)
            {
                tiket = faenasEstaticas.Pop();
                if (tiket != null)
                {
                    feanasHaciendose.Add(tiket.IdUnico, new KeyValuePair <Thread, Tiket <TipoTrabajo> >(Thread.CurrentThread, tiket));
                    tiket.EstadoFaena = Tiket <TipoTrabajo> .EstadoFaenaEnum.Haciendose;
                    try {
                        tiket.HazFaena();
                    } catch (Exception ex) {
                        tiket.Excepcion(ex);
                    }
                    QuitarFaena(tiket);
                    feanasHaciendose.Remove(tiket.IdUnico);
                    tiket.EstadoFaena = Tiket <TipoTrabajo> .EstadoFaenaEnum.Acabado;
                    tiket.FaenaHechaEvent();
                }
            }
            hilosFaenas.Remove(Thread.CurrentThread.Name);
        }
Example #8
0
        public void Add(Chunk chunk, bool reemplazarOExcepcion)
        {
            Chunk chunkABuscar = null;

            switch (chunk.ChunkType)
            {
            case IDATChunk.NAME:
                idats.Add(chunk);
                break;

            case "iCCP":
                if (sRGB != null)
                {
                    if (reemplazarOExcepcion)
                    {
                        sRGB = null;
                    }
                    else
                    {
                        throw new Exception("Ya existe un chunk sRGB por lo que no puede ir un iCCP");
                    }
                }
                if (iCCP != null)
                {
                    if (!reemplazarOExcepcion)
                    {
                        throw new Exception("Chunk " + chunk.ChunkType + " repetido...solo puede haber uno");
                    }
                }
                iCCP = chunk;
                break;

            case "sRGB":
                if (iCCP != null)
                {
                    if (reemplazarOExcepcion)
                    {
                        iCCP = null;
                    }
                    else
                    {
                        throw new Exception("Ya existe un chunk iCCP por lo que no puede ir un sRGB");
                    }
                }
                if (sRGB != null)
                {
                    if (!reemplazarOExcepcion)
                    {
                        throw new Exception("Chunk " + chunk.ChunkType + " repetido...solo puede haber uno");
                    }
                }
                sRGB = chunk;
                break;

            case tIMEChunk.NAME:
                if (tIME != null && !reemplazarOExcepcion)
                {
                    throw new Exception("Solo puede haber un chunk tIME!!");
                }
                tIME = new tIMEChunk(chunk);
                break;

            case "PLTE":
                if (PLTE != null && !reemplazarOExcepcion)
                {
                    throw new Exception("Solo puede haber un chunk PLTE!!");
                }
                PLTE = chunk;
                break;

            case tEXtChunk.NAME:
                tEXtChunk tEXt = new tEXtChunk(chunk);
                metadata.Add(tEXt.Keyword, tEXt);
                break;

            case zTXtChunk.NAME:
                zTXtChunk zTXt = new zTXtChunk(chunk);
                metadata.Add(zTXt.Keyword, zTXt);
                break;

            default:
                if (!chunksCeroOIlimitados.Existe(chunk.ChunkType))
                {
                    //miro si existe
                    extras.WhileEach(chunkToCompare => {
                        if (chunkToCompare.Equals(chunk))
                        {
                            chunkABuscar = chunk;
                        }
                        return(chunkABuscar == null);
                    });
                    //si existe lo trato
                    if (chunkABuscar != null)
                    {
                        if (reemplazarOExcepcion)
                        {
                            extras.Remove(chunkABuscar);
                        }
                        else
                        {
                            throw new Exception("Solo puede haber uno de " + chunkABuscar);
                        }
                    }
                }
                extras.Add(chunk);
                break;
            }
        }