Exemple #1
0
        private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "txt files (*.txt)|*.txt|dat files (*.dat)|*.dat";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                this.path        = openFileDialog.FileName;
                this.tipoArchivo = openFileDialog.FilterIndex;
                switch (this.tipoArchivo)
                {
                case 1:
                {
                    PuntoTxt archivo = new PuntoTxt();
                    this.rchtbCajaDetexto.Text = archivo.Leer(this.path);
                    break;
                }

                case 2:
                {
                    PuntoDat archivo = new PuntoDat();
                    this.rchtbCajaDetexto.Text = (archivo.Leer(this.path)).Contenido;
                    break;
                }
                }
            }
        }
Exemple #2
0
        private void guardarComoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string         filePath;
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = "txt files (*.txt)|*.txt|dat files (*.dat)|*.dat";
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                filePath = saveFileDialog.FileName;
                try
                {
                    if (Path.GetExtension(filePath) == ".txt")
                    {
                        PuntoTxt ptxt = new PuntoTxt();
                        ptxt.GuardarComo(filePath, richTextBox.Text);
                    }
                    else
                    {
                        PuntoDat pdat = new PuntoDat();
                        pdat.Contenido = richTextBox.Text;
                        pdat.GuardarComo(filePath, pdat);
                    }
                    ultimoArchivoAbierto = filePath;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemple #3
0
        private void GuardarArchivo(string texto)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = "txt files (*.txt)|*.txt|dat files (*.dat)|*.dat";
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                this.path        = saveFileDialog.FileName;
                this.tipoArchivo = saveFileDialog.FilterIndex;
                switch (this.tipoArchivo)
                {
                case 1:
                {
                    PuntoTxt archivo = new PuntoTxt();
                    archivo.GuardarComo(this.path, this.rchtbCajaDetexto.Text);
                    break;
                }

                case 2:
                {
                    PuntoDat archivo = new PuntoDat();
                    archivo.Contenido = this.rchtbCajaDetexto.Text;
                    archivo.GuardarComo(this.path, archivo);
                    break;
                }
                }
            }
        }
Exemple #4
0
        private void guardarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!(string.IsNullOrWhiteSpace(this.path)))
            {
                switch (this.tipoArchivo)
                {
                case 1:
                {
                    PuntoTxt archivo = new PuntoTxt();
                    archivo.Guardar(this.path, this.rchtbCajaDetexto.Text);
                    break;
                }

                case 2:
                {
                    PuntoDat archivo = new PuntoDat();
                    archivo.Contenido = this.rchtbCajaDetexto.Text;
                    archivo.Guardar(this.path, archivo);
                    break;
                }
                }
            }
            else
            {
                this.GuardarArchivo(this.rchtbCajaDetexto.Text);
            }
        }
        private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();

            openFile.Title            = "Open Text File";
            openFile.Filter           = "TXT files|*.txt|DAT files|*.dat";
            openFile.InitialDirectory = @"C:\";
            if (openFile.ShowDialog() == DialogResult.OK)
            {
                ruta = openFile.FileName.ToString();
                switch (openFile.FilterIndex)
                {
                case 1:     //selected .txt
                    PuntoTxt leerTxt = new PuntoTxt();
                    richTextBox1.Text = leerTxt.Leer(openFile.FileName);
                    break;

                case 2:     //selected .dat
                    PuntoDat leerDat = new PuntoDat();
                    leerDat           = leerDat.Leer(openFile.FileName);
                    richTextBox1.Text = leerDat.Contenido;
                    break;
                }
            }
        }
Exemple #6
0
        private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string fileContent = string.Empty;
            string filePath    = string.Empty;

            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.Filter = "txt files (*.txt)|*.txt|dat files (*.dat)|*.dat";
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    filePath = openFileDialog.FileName;
                    try
                    {
                        if (Path.GetExtension(filePath) == ".txt")
                        {
                            PuntoTxt ptxt = new PuntoTxt();
                            richTextBox.Text = ptxt.Leer(filePath);
                        }
                        else
                        {
                            PuntoDat pdat = new PuntoDat();
                            pdat             = pdat.Leer(filePath);
                            richTextBox.Text = pdat.Contenido;
                        }
                        ultimoArchivoAbierto = filePath;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
Exemple #7
0
        private void guardarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string datos;

            PuntoDat archivoDat;
            PuntoTxt archivoTxt;

            archivoDat = new PuntoDat();
            archivoTxt = new PuntoTxt();

            datos = rtbEditorDeTexto.Text;

            if (this.PathArchivo is null)
            {
                this.guardarComoToolStripMenuItem_Click(sender, e);
            }
            else
            {
                switch (Path.GetExtension(this.PathArchivo))
                {
                case ".txt":
                    archivoTxt.GuardarComo(this.PathArchivo, datos);
                    break;

                case ".dat":
                    //Guardo el texto en la propiedad contenido
                    archivoDat.Contenido = datos;
                    //Le paso el objeto PuntoDat con el texto cargado
                    archivoDat.GuardarComo(this.PathArchivo, archivoDat);
                    break;
                }
            }
        }
Exemple #8
0
        private void stripAbrir_OnClick(object sender, EventArgs e)
        {
            OpenFileDialog abrir = new OpenFileDialog();

            abrir.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            abrir.Filter           = "Archivos de texto (*.txt)|*.txt|Archivos de datos (*.dat)|*.dat";

            if (abrir.ShowDialog() == DialogResult.OK)
            {
                this.path = abrir.FileName;

                if (Path.GetExtension(this.path) == ".txt")
                {
                    PuntoTxt texto1 = new PuntoTxt();

                    this.richTextBox1.Text = texto1.Leer(this.path);
                }
                else
                {
                    PuntoDat texto = new PuntoDat();

                    this.richTextBox1.Text = texto.Leer(this.path).Contenido;
                }
            }
        }
        private void guardarComoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PuntoTxt txt   = new PuntoTxt();
            PuntoDat dat   = new PuntoDat();
            string   texto = this.richTextBox1.Text.Replace("\n", "\r\n");

            if (TextEditor._saveFileMenu.ShowDialog() == DialogResult.OK)
            {
                this._lastFilePath = TextEditor._saveFileMenu.FileName;
                try
                {
                    if (this._lastFilePath.EndsWith(".txt"))
                    {
                        txt.GuardarComo(this._lastFilePath, texto);
                    }
                    else
                    {
                        dat.Contenido = texto;
                        dat.GuardarComo(this._lastFilePath, dat);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("FATAL ERROR");
                }
            }
        }
Exemple #10
0
        private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //StreamReader sr;

            PuntoTxt archivoTxt = new PuntoTxt();
            PuntoDat archivoDat = new PuntoDat();


            //Muestra una ventana para seleccionar el archivo
            OpenFileDialog abrir = new OpenFileDialog();

            abrir.Filter = "Archivos de texto (*.txt)|*.txt|Archivos de datos (*.dat)|*.dat";

            if (abrir.ShowDialog() == DialogResult.OK)
            {
                this.PathArchivo = abrir.FileName;

                switch (abrir.FilterIndex)
                {
                case 1:    //texto
                    rtbEditorDeTexto.Text = archivoTxt.Leer(this.PathArchivo);
                    break;

                case 2:    //binario
                    //Guardo el .dat en una variable
                    archivoDat = archivoDat.Leer(this.PathArchivo);
                    //Leo el texto que está en la propiedad contenido
                    rtbEditorDeTexto.Text = archivoDat.Contenido;
                    break;
                }
            }
        }
        private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Lectura del archivo.
            PuntoTxt txt = new PuntoTxt();
            PuntoDat dat = new PuntoDat();

            if (TextEditor._openFileMenu.ShowDialog() == DialogResult.OK)
            {
                this._lastFilePath = TextEditor._openFileMenu.FileName;
                try
                {
                    if (this._lastFilePath.EndsWith(".txt"))
                    {
                        this.richTextBox1.Text = txt.Leer(this._lastFilePath);
                    }
                    else
                    {
                        this.richTextBox1.Text = dat.Leer(this._lastFilePath).Contenido;
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("FATAL ERROR");
                }
            }
        }
        private void guardarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PuntoTxt txt   = new PuntoTxt();
            PuntoDat dat   = new PuntoDat();
            string   texto = this.richTextBox1.Text.Replace("\n", "\r\n");

            try
            {
                if (this._lastFilePath.EndsWith(".txt"))
                {
                    txt.Guardar(this._lastFilePath, texto);
                }
                else
                {
                    dat.Contenido = texto;
                    dat.Guardar(this._lastFilePath, dat);
                }
            }
            catch (ArchivoIncorrectoException)
            {
                this.guardarComoToolStripMenuItem_Click(this.guardarComoToolStripMenuItem, new EventArgs());
            }
            catch (Exception)
            {
                MessageBox.Show("FATAL ERROR");
            }
        }
Exemple #13
0
        private void GuardarComo()
        {
            SaveFileDialog guardar = new SaveFileDialog();

            guardar.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            guardar.Filter           = "Archivos de texto (*.txt)|*.txt|Archivos de datos (*.dat)|*.dat";

            if (guardar.ShowDialog() == DialogResult.OK)
            {
                this.path = guardar.FileName;

                if (Path.GetExtension(this.path) == ".txt")
                {
                    PuntoTxt texto1 = new PuntoTxt();

                    texto1.GuardarComo(this.path, this.richTextBox1.Text);
                }
                else
                {
                    PuntoDat texto = new PuntoDat();
                    texto.Contenido = this.richTextBox1.Text;
                    texto.GuardarComo(this.path, texto);
                }
            }
        }
Exemple #14
0
        private void textoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ofdAbrir.ShowDialog() == DialogResult.OK)
            {
                this.path = ofdAbrir.FileName;
            }
            else
            {
                return;
            }
            PuntoTxt archivo = new PuntoTxt();

            rtbEditor.Text = archivo.Leer(path);
            this.tipo      = "texto";
        }
Exemple #15
0
        private void textoToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            sfdGuardar.Filter = "Archivo Texto|*.txt";
            if (sfdGuardar.ShowDialog() == DialogResult.OK)
            {
                this.path = sfdGuardar.FileName;
            }
            else
            {
                return;
            }
            PuntoTxt archivo = new PuntoTxt();

            archivo.Guardar(path, rtbEditor.Text);
            this.tipo = "texto";
        }
Exemple #16
0
        private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "txt files (*.txt)|*.txt|dat files (*.dat)|*.dat|All files (*.*)|*.*";
            ofd.ShowDialog();
            rutaArchivoActual = ofd.FileName;

            if (Path.GetExtension(rutaArchivoActual) == ".txt")
            {
                PuntoTxt stream = new PuntoTxt();
                rtb_texto.Text = stream.Leer(rutaArchivoActual);
            }
            if (Path.GetExtension(rutaArchivoActual) == ".dat")
            {
                PuntoDat stream = new PuntoDat().Leer(rutaArchivoActual);
                rtb_texto.Text = stream.Contenido;
            }
        }
Exemple #17
0
        private void guargarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            switch (this.tipo)
            {
            case "binario":
                PuntoDat dat = new PuntoDat();
                dat.Contenido = rtbEditor.Text;
                dat.Guardar(path, dat);
                break;

            case "texto":
                PuntoTxt txt = new PuntoTxt();
                txt.Guardar(path, rtbEditor.Text);
                break;

            default:
                break;
            }
        }
Exemple #18
0
 private void guardarComoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     guardarArchivo        = new SaveFileDialog();
     guardarArchivo.Filter = "txt files(*.txt)|*.txt|dat files(*.dat)|*.dat";
     if (guardarArchivo.ShowDialog() == DialogResult.OK)
     {
         string ruta = guardarArchivo.FileName;
         if (Path.GetExtension(ruta) == ".txt")
         {
             txt = new PuntoTxt();
             txt.GuardarComo(ruta, richTextBox1.Text);
         }
         else
         {
             dat           = new PuntoDat();
             dat.Contenido = richTextBox1.Text;
             dat.GuardarComo(ruta, dat);
         }
     }
 }
Exemple #19
0
 private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
 {
     abrirArchivo        = new OpenFileDialog();
     abrirArchivo.Filter = "txt files(*.txt)|*.txt|dat files(*.dat)|*.dat";
     if (abrirArchivo.ShowDialog() == DialogResult.OK)
     {
         string ruta = abrirArchivo.FileName;
         if (Path.GetExtension(ruta) == ".txt")
         {
             txt = new PuntoTxt();
             richTextBox1.Text = txt.Leer(ruta);
         }
         else
         {
             dat = new PuntoDat();
             dat = dat.Leer(ruta);
             richTextBox1.Text = dat.Contenido;
         }
     }
 }
Exemple #20
0
        private void guardarComoCtrlMayúsSToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "txt files (*.txt)|*.txt|dat files (*.dat)|*.dat|All files (*.*)|*.*";
            sfd.ShowDialog();
            rutaArchivoActual = sfd.FileName;

            if (Path.GetExtension(rutaArchivoActual) == ".txt")
            {
                PuntoTxt stream = new PuntoTxt();
                stream.Guardar(rutaArchivoActual, rtb_texto.Text);
            }
            if (Path.GetExtension(rutaArchivoActual) == ".dat")
            {
                PuntoDat stream = new PuntoDat();
                stream.Contenido = rtb_texto.Text;
                stream.Guardar(rutaArchivoActual, stream);
            }
        }
 private void guardarToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (ruta == null)
     {
         guardarComoToolStripMenuItem_Click(sender, e);
     }
     else
     {
         if (Path.GetExtension(ruta) == ".txt")
         {
             PuntoTxt guardarTxt = new PuntoTxt();
             bool     aux        = guardarTxt.Guardar(ruta, richTextBox1.Text);
         }
         else if (Path.GetExtension(ruta) == ".dat")
         {
             PuntoDat guardarDat = new PuntoDat();
             guardarDat.Contenido = richTextBox1.Text;
             bool aux2 = guardarDat.Guardar(ruta, guardarDat);
         }
     }
 }
Exemple #22
0
        private void stripGuadar_OnClick(object sender, EventArgs e)
        {
            if (this.path != null)
            {
                if (Path.GetExtension(this.path) == ".txt")
                {
                    PuntoTxt texto1 = new PuntoTxt();

                    texto1.Guardar(this.path, this.richTextBox1.Text);
                }
                else
                {
                    PuntoDat texto = new PuntoDat();
                    texto.Contenido = this.richTextBox1.Text;
                    texto.Guardar(this.path, texto);
                }
            }
            else
            {
                this.GuardarComo();
            }
        }
Exemple #23
0
        public void GuardarComo()
        {
            SaveFileDialog dialog = new SaveFileDialog();       //debería usar using?

            dialog.InitialDirectory = (this.path == null) ? AppDomain.CurrentDomain.BaseDirectory : this.path;
            dialog.Filter           = "Archivos de texto (.txt)|*.txt|Archivos de datos (.dat)|*.dat";
            if (DialogResult.OK == dialog.ShowDialog())
            {
                this.path = dialog.FileName;
                if (Path.GetExtension(this.path) == ".txt")
                {
                    PuntoTxt puntoTxt = new PuntoTxt();
                    puntoTxt.GuardarComo(this.path, richTextBox1.Text);
                }
                else if (Path.GetExtension(this.path) == ".dat")
                {
                    PuntoDat puntoDat = new PuntoDat();
                    puntoDat.Contenido = richTextBox1.Text;
                    puntoDat.GuardarComo(this.path, puntoDat);
                }
            }
        }
Exemple #24
0
        public void GuardarComo()
        {
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.InitialDirectory = (this.path == null) ? AppDomain.CurrentDomain.BaseDirectory : this.path;
            dialog.Filter           = "Archivos de texto (.txt)|*.txt|Archivos de datos (.dat)|*.dat";
            if (DialogResult.OK == dialog.ShowDialog())
            {
                this.path = dialog.FileName;
                if (Path.GetExtension(this.path) == ".txt")
                {
                    PuntoTxt texto = new PuntoTxt();
                    texto.GuardarComo(this.path, rtbTexto.Text);
                }
                else if (Path.GetExtension(this.path) == ".dat")
                {
                    PuntoDat binario = new PuntoDat();
                    binario.Contenido = rtbTexto.Text;
                    binario.GuardarComo(this.path, binario);
                }
            }
        }
Exemple #25
0
 private void guardarToolStripMenuItem_Click(object sender, EventArgs e)
 {
     archivoToolStripMenuItem.HideDropDown();
     if (this.path == null)
     {
         GuardarComo();
     }
     else
     {
         if (Path.GetExtension(this.path) == ".txt")
         {
             PuntoTxt texto = new PuntoTxt();
             texto.Guardar(this.path, rtbTexto.Text);
         }
         else if (Path.GetExtension(this.path) == ".dat")
         {
             PuntoDat binario = new PuntoDat();
             binario.Contenido = rtbTexto.Text;
             binario.GuardarComo(this.path, binario);
         }
     }
 }
Exemple #26
0
 private void toolStripTextBox2_Click(object sender, EventArgs e) //guardar
 {
     toolStripMenuItem1.HideDropDown();
     if (this.path == null)  //si ya se abrió o guardó un archivo path no va a ser null
     {
         GuardarComo();
     }
     else
     {
         if (Path.GetExtension(this.path) == ".txt")
         {
             PuntoTxt puntoTxt = new PuntoTxt();
             puntoTxt.Guardar(this.path, richTextBox1.Text);
         }
         else if (Path.GetExtension(this.path) == ".dat")
         {
             PuntoDat puntoDat = new PuntoDat();
             puntoDat.Contenido = richTextBox1.Text;
             puntoDat.Guardar(this.path, puntoDat);
         }
     }
 }
Exemple #27
0
        private void guardarCtrlSToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (rutaArchivoActual == null)
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter = "txt files (*.txt)|*.txt|dat files (*.dat)|*.dat|All files (*.*)|*.*";

                sfd.ShowDialog();
                rutaArchivoActual = sfd.FileName;

                if (Path.GetExtension(rutaArchivoActual) == ".txt")
                {
                    PuntoTxt stream = new PuntoTxt();
                    stream.Guardar(rutaArchivoActual, rtb_texto.Text);
                    this.tssl_numberOfChars.Text = string.Format("caracteres: {0} - {1}", rtb_texto.Text.Length, this.rutaArchivoActual);
                }
                if (Path.GetExtension(rutaArchivoActual) == ".dat")
                {
                    PuntoDat stream = new PuntoDat();
                    stream.Contenido = rtb_texto.Text;
                    stream.Guardar(rutaArchivoActual, stream);
                    this.tssl_numberOfChars.Text = string.Format("caracteres: {0} - {1}", rtb_texto.Text.Length, this.rutaArchivoActual);
                }
            }
            else
            {
                if (Path.GetExtension(rutaArchivoActual) == ".txt")
                {
                    PuntoTxt stream = new PuntoTxt();
                    stream.Guardar(rutaArchivoActual, rtb_texto.Text);
                }
                if (Path.GetExtension(rutaArchivoActual) == ".dat")
                {
                    PuntoDat stream = new PuntoDat();
                    stream.Contenido = rtb_texto.Text;
                    stream.Guardar(rutaArchivoActual, stream);
                }
            }
        }
Exemple #28
0
        public void Abrir()
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.InitialDirectory = (this.path == null) ? AppDomain.CurrentDomain.BaseDirectory : this.path;
            dialog.Filter           = "Archivos de texto (.txt)|*.txt|Archivos de datos (.dat)|*.dat";

            if (DialogResult.OK == dialog.ShowDialog())
            {
                this.path = dialog.FileName;
                if (Path.GetExtension(this.path) == ".txt")
                {
                    PuntoTxt texto = new PuntoTxt();
                    rtbTexto.Text = texto.Leer(this.path);
                }
                else if (Path.GetExtension(this.path) == ".dat")
                {
                    PuntoDat binario = new PuntoDat();
                    binario       = binario.Leer(this.path);
                    rtbTexto.Text = binario.Contenido;
                }
            }
        }
Exemple #29
0
        private void guardarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string filePath = ultimoArchivoAbierto;

            try
            {
                if (Path.GetExtension(filePath) == ".txt")
                {
                    PuntoTxt ptxt = new PuntoTxt();
                    ptxt.Guardar(filePath, richTextBox.Text);
                }
                else
                {
                    PuntoDat pdat = new PuntoDat();
                    pdat.Contenido = richTextBox.Text;
                    pdat.Guardar(filePath, pdat);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #30
0
        public void Abrir()
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.InitialDirectory = (this.path == null) ? AppDomain.CurrentDomain.BaseDirectory : this.path;
            dialog.Filter           = "Archivos de texto (.txt)|*.txt|Archivos de datos (.dat)|*.dat";

            if (DialogResult.OK == dialog.ShowDialog())  //si click cancel no entra
            {
                this.path = dialog.FileName;
                if (Path.GetExtension(this.path) == ".txt")
                {
                    PuntoTxt puntoTxt = new PuntoTxt();
                    richTextBox1.Text = puntoTxt.Leer(this.path);
                }
                else if (Path.GetExtension(this.path) == ".dat")
                {
                    PuntoDat puntoDat = new PuntoDat();
                    puntoDat          = puntoDat.Leer(this.path);
                    richTextBox1.Text = puntoDat.Contenido;
                }
            }
        }