コード例 #1
0
 public bool leerArchivo(string path, Documento data)
 {
     throw new NotImplementedException();
 }
コード例 #2
0
 public EditorModelo()
 {
     Documento = new Documento("untiled");
     caretaker = new Caretaker();
 }
コード例 #3
0
        public bool leerArchivo(string path, Documento data)
        {
            string archivo = IOArchivos.leerArchivo(path);

            bool   tag      = false;
            bool   tagColor = false;
            bool   omitir   = false;
            string color    = "";

            foreach (char c in archivo)
            {
                //Identificar si hay un tag de color
                if (c == '<')
                {
                    tag   = true;
                    color = "";
                }
                else if (c == '/')
                {
                }
                //Identificar cual es el color
                else if (c == '=')
                {
                    if (color == "color")
                    {
                        color    = "";
                        tagColor = true;
                        tag      = false;
                    }
                }
                else if (c == '>')
                {
                    tagColor = false;
                }
                else if (tag)
                {
                    color += c;
                }
                else if (tagColor)
                {
                    color += c;
                }
                else
                {
                    Console.WriteLine(color);
                    System.Drawing.Color color1;
                    switch (color)
                    {
                    case "Red":
                        color1 = System.Drawing.Color.Red;
                        break;

                    case "Green":
                        color1 = System.Drawing.Color.Green;
                        break;

                    case "Blue":
                        color1 = System.Drawing.Color.Blue;
                        break;

                    case "Black":
                        color1 = System.Drawing.Color.Black;
                        break;

                    case "Yellow":
                        color1 = System.Drawing.Color.Yellow;
                        break;

                    default:
                        color1 = System.Drawing.Color.Black;
                        break;
                    }
                    Caracter caracter;
                    if (c == '\t')
                    {
                        caracter = new Caracter(' ', color1);
                    }
                    else
                    {
                        caracter = new Caracter(c, color1);
                    }
                    data.Caracteres.Add(caracter);
                }
            }
            return(true);
        }