示例#1
0
        public void AddUndo(SubtitleScript script, string action)
        {
            if (script.IsMorbid) return;

            undoStack.Push(new UndoRedoSubtitleScript(script, action));
            redoStack.Clear();
        }
示例#2
0
        public AdjustToKeyframe(SubtitleScript script, int iPre, int iPost, int fPre, int fPost, double fps, ArrayList est, ArrayList keyFrame)
        {
            this.script = script;
            this.iPre = iPre;
            this.iPost = iPost;
            this.fPre = fPre;
            this.fPost = fPost;
            this.fps = fps;

            seguridadColisiones = true; //((iPre != fPre) || (iPost != fPost));

            Resultado = new Hashtable();

            estilos = new ArrayList();
            foreach (estiloV4 v in est)
                estilos.Add(v.Name);

            this.keyFrame = (int[])keyFrame.ToArray(typeof(int));

            lineasOrdenadas = new ArrayList();
            for (int i = 0; i < script.GetLineArrayList().GetFullArrayList().Count; i++)
            {
                lineaASS lass = (lineaASS)script.GetLineArrayList().GetFullArrayList()[i];
                if (estilos.Contains(lass.estilo))
                    lineasOrdenadas.Add(new lineaASSidx(lass.ToString(), i));
            }
            lineasOrdenadas.Sort();
        }
示例#3
0
 public AnalizarLineasMax(SubtitleScript script, ArrayList styles, int maxLines, int width, int height, int lowlimit)
 {
     this.script = script;
     this.styles = styles;
     this.maxLines = maxLines;
     this.width = width;
     this.height = height;
     this.lowLimit = lowLimit;
     stop = false;
 }
示例#4
0
 public void LoadFromScript(SubtitleScript script)
 {
     this.GetHeaders().Clear();
     this.GetHeaders().AddRange(script.GetHeaders());
     this.GetStyles().Clear();
     this.GetStyles().AddRange(script.GetStyles());
     this.GetLineArrayList().GetFullArrayList().Clear();
     this.GetLineArrayList().GetFullArrayList().AddRange(script.GetLineArrayList().GetFullArrayList());
     this.Attachments = script.GetAttachments();
     this.FileName = script.FileName;
 }
示例#5
0
        void AutoSaveList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (AutoSaveList.SelectedIndex == -1) return;

            FileInfo info = new FileInfo(mW.autosaveDir + "\\" + AutoSaveList.Items[AutoSaveList.SelectedIndex].ToString());
            SubtitleScript script;
            if (info.Name.EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase))
                script = new ZipSubtitleScript(info.FullName);
            else
                script = new SubtitleScript(info.FullName);

            label1.Text = "Lineas: " + script.LineCount;
            label2.Text = "Estilos: " + script.StyleCount;
            label3.Text = "Fecha: " + info.LastWriteTime.Day.ToString() + "/" + info.LastWriteTime.Month.ToString()+"/"+info.LastWriteTime.Year.ToString();
            label4.Text = "Tamaño: " + info.Length/1024 +"KB";
            label5.Text = "Hora: " + info.LastWriteTime.TimeOfDay.ToString();
            label6.Text = "Adjuntos: "+( (script.HasAttachments)? "Sí ("+script.AttachmentCount+" archivo/s)" : "No");
        }
示例#6
0
        private void button1_Click(object sender, EventArgs e)
        {
            FileInfo info = new FileInfo(Path.Combine(mW.autosaveDir,AutoSaveList.Items[AutoSaveList.SelectedIndex].ToString()));

            SaveFileDialog sfd = new SaveFileDialog();
            sfd.FileName = info.Name.Replace(".TranslateW.AUTOSAVE", "").Replace(".perrySub.AUTOSAVE", "").Replace(".zip", "");
            sfd.Filter = "Archivo ASS (*.ass)|*.ass";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                SubtitleScript script;
                if (info.Name.EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase))
                    script = new ZipSubtitleScript(info.FullName);
                else
                    script = new SubtitleScript(info.FullName);
                script.SaveToFile(sfd.FileName);
                if (MessageBox.Show("Archivo restaurado correctamente.\n¿Deseas cargarlo en el programa principal?", mainW.appTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    mW.openFile = sfd.FileName;
                    mW.loadFile(sfd.FileName);
                }
            }
        }
示例#7
0
        private void cargarEstilosOtroScript_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Archivos de subtítulos conocidos (*.ass; *.ssa; *.txt; *.srt)|*.ass; *.ssa; *.txt; *.srt";
            try
            {
                ofd.InitialDirectory = mW.getFromConfigFile("mainW_WorkDirectory");
            }
            catch
            {
                ofd.InitialDirectory = System.Environment.SpecialFolder.MyDocuments.ToString();
            }
            ofd.FilterIndex = 0;
            ofd.RestoreDirectory = true;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    SubtitleScript nuevo = new SubtitleScript(ofd.FileName);
                    ArrayList toDel = new ArrayList();

                    foreach (estiloV4 estilo in nuevo.GetStyles())
                    {
                        if (listBox1.Items.Contains(estilo.Name))
                        {
                            if (MessageBox.Show("El estilo '" + estilo.Name + "' ya existe en los estilos actuales.\n¿Deseas sobreescribirlo con el cargado desde el archivo?", mainW.appTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                            {
                                int idx = listBox1.Items.IndexOf(estilo.Name);
                                if (idx != -1)
                                    toDel.Add(idx);
                                mW.v4.Add(new estiloV4(estilo.ToString()));
                            }
                        }
                        else
                        {
                            mW.v4.Add(new estiloV4(estilo.ToString()));
                        }
                    }

                    toDel.Reverse();
                    foreach (int i in toDel)
                        mW.v4.RemoveAt(i);

                    listBox1.Items.Clear();
                    foreach (estiloV4 v1 in mW.v4)
                        listBox1.Items.Add(v1.Name);
                }
                catch
                {
                    mW.errorMsg("Error cargando script.");
                }
            }
        }
示例#8
0
        public void loadFile(string s)
        {
            if (s != "")
            {
                // detectar si hay un archivo mas nuevo en el directorio de autosave

                bool checknewer = true;

                try
                {
                    checknewer = Convert.ToBoolean(getFromConfigFile("mainW_NewerCopyAutoSaved"));
                }
                catch { }

                if (checknewer)
                {

                    FileInfo f = new FileInfo(s);

                    string fas_normal = Path.Combine(autosaveDir, f.Name + ".perrySub.AUTOSAVE");
                    string fas_trans = Path.Combine(autosaveDir, f.Name + ".TranslateW.AUTOSAVE");
                    string fas_normal_zip = fas_normal + ".zip";
                    string fas_trans_zip = fas_trans + ".zip";

                    ArrayList upd = new ArrayList();

                    if (File.Exists(fas_normal))
                        upd.Add(fas_normal);
                    if (File.Exists(fas_normal_zip))
                        upd.Add(fas_normal_zip);
                    if (File.Exists(fas_trans))
                        upd.Add(fas_trans);
                    if (File.Exists(fas_trans_zip))
                        upd.Add(fas_trans_zip);

                    bool shown = false;
                    foreach (string fff in upd)
                    {
                        FileInfo auto = new FileInfo(fff);
                        if (auto.LastWriteTime > f.LastWriteTime && !shown)
                        {
                            MessageBox.Show("Hay una versión con fecha más reciente de este archivo en el directorio de auto guardados.\n" +
                                "Si quieres recuperarla, ve a Opciones -> Restaurar archivo del Auto Guardado, y restaura el archivo:\n" +
                                auto.Name, appTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            shown = true;
                        }
                    }
                }

                // carga
                script = new SubtitleScript(s);
                al = script.GetLines();
                v4 = script.GetStyles();
                head = script.GetHeaders();

                splashScreen.Visible = false;
                gridASS.Visible = tabGrid.Visible = true;
                panelTextTools.Visible = true;
                if (!isVideoLoaded)
                    drawPositions();

                // --

                idxListBox.Items.Clear();

                for (int i = 0; i < (script.LineCount / LineArrayList.LineArrayListMax) + 1; i++)
                {
                    idxListBox.Items.Add(i * LineArrayList.LineArrayListMax + "+");
                }

                idxListBox.SelectedIndex = 0;

                updateGridWithArrayList(al);

            }

            if (gridASS.Rows.Count > 0) // forzar refresco de SelectionChanged
                gridASS.Rows[0].Selected = true;

            updatePanelTextTools();
            selectedLine.ForceRefresh();

            if (openFile.EndsWith(".ass", StringComparison.InvariantCultureIgnoreCase))
            {
                updateConcatenateConfigFile("LastASS", openFile);
                SHAddToRecentDocs(SHARD_PATH, openFile);
            }

            setStatus("Archivo " + s + " cargado.");
            AutoSave.Enabled = true;
            if (!InvokedFromCommandline)
                loadAudioVideoFromScript();
            updateMenuEnables();
        }
示例#9
0
        private void ordenarLíneasPorTiemposToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IsModified = true;

            UndoRedo.AddUndo(script, "Ordenar líneas por tiempos");

            SubtitleScript copia = (SubtitleScript)script.Clone();
            copia.GetLineArrayList().GetFullArrayList().Sort();
            //copia.GetLineArrayList().GetFullArrayList().Reverse();
            script = copia;
            al = script.GetLines();
            updateGridWithArrayList(al);
        }
示例#10
0
        private void newFile()
        {
            if (openFile != null)
            {
                launchPerrySubParms("-new");
                return;
            }

            type = ScriptFileType.ASS_SSA;

            splashScreen.Visible = false;
            gridASS.Visible = true;
            panelTextTools.Visible = true;

            openFile = newFileName;
            chgCaption(openFile);

            script = new SubtitleScript();
            script.NewFile();
            script.FileName = openFile;

            al = script.GetLines();
            v4 = script.GetStyles();
            head = script.GetHeaders();

            drawPositions();

            updateGridWithArrayList(al);

            //gridASS.RowCount = 1;

            //fillRowWithLineaASS((lineaASS)al[0],0);

            gridASS.Rows[0].Selected = true;

            updatePanelTextTools();
            selectedLine.ForceRefresh();
            updateMenuEnables();
            AutoSave.Enabled = true;
        }
 public ArchivoProcesadoEventArgs(SubtitleScript script, ArrayList lineas)
 {
     ScriptTratado = script;
     LineasCoincidencias = lineas;
 }
示例#12
0
        public object Clone()
        {
            SubtitleScript nuevo = new SubtitleScript();

            nuevo.FileName = String.Copy(this.FileName);

            foreach (string s in this.Header.GetHeaderList())
            {
                string tmp = String.Copy(s);
                nuevo.GetHeaders().Add(tmp);
            }

            foreach (estiloV4 v in this.Styles)
                nuevo.GetStyles().Add(new estiloV4(v.ToString()));

            foreach (lineaASS l in this.Lines.GetFullArrayList())
                nuevo.GetLineArrayList().Add(new lineaASS(l.ToString()));

            Attachments natt = nuevo.GetAttachments();
            natt = (Attachments)Attachments.Clone();

            return nuevo;
        }
示例#13
0
        private void button5_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            try
            {
                openFileDialog1.InitialDirectory = mW.getFromConfigFile("mainW_WorkDirectory");
            }
            catch
            {
                openFileDialog1.InitialDirectory = System.Environment.SpecialFolder.MyDocuments.ToString();
            }

            openFileDialog1.Filter = "Archivo de Subtítulos (*.ass)|*.ass";
            //openFileDialog1.FilterIndex = 1;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    SubtitleScript s = new SubtitleScript(openFileDialog1.FileName);
                    string l = "";
                    if ((l = s.GetHeader().GetHeaderValue("AutoComplete")) != string.Empty)
                    {
                        string[] perry = l.Split('|');
                        for (int i = 0; i < perry.Length; i++)
                        {
                            if (!autoComplete.Contains(perry[i]))
                                autoComplete.Add(perry[i]);
                        }
                        updateAutoCompleteList();
                    }
                }
                catch { }

            }
        }
示例#14
0
        void archivosView_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (archivosView.SelectedIndices.Count != 1)
                return;

            SubtitleScript script = new SubtitleScript(archivosView.SelectedItems[0].Text);

            string archivo = "";
            foreach (lineaASS linea in script.GetLineArrayList().GetFullArrayList())
            {
                archivo += ((linea.personaje!="")? linea.personaje + ": " : "")+ linea.texto;
                archivo += "\n";
            }

            richTextBox1.Text = archivo;
            tabControl1.TabPages["tabVisor"].Text = "Visor ("+archivosView.SelectedItems[0].Text+")";
        }
示例#15
0
        void coincidenciasView_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (coincidenciasView.SelectedIndices.Count != 1)
                return;

            lineasCoincidencias.Enabled = true;
            lineasCoincidencias.Items.Clear();

            foreach (SubtitleScript script in found.Keys)
            {
                if (script.FileName.Equals(coincidenciasView.SelectedItems[0].Text))
                {
                    foreach (int i in (ArrayList)found[script])
                    {
                        string[] tmp = new string[2];
                        tmp[0] = i.ToString();
                        lineaASS actual = (lineaASS)script.GetLineArrayList().GetFullArrayList()[i];
                        tmp[1] = lineaASS.cleanText(actual.texto);
                        lineasCoincidencias.Items.Add(new ListViewItem(tmp,2));
                    }
                    current = script;
                    lineasCoincidencias.Columns[1].Width = -2; // autosize
                }
            }
        }
        public void RealizarAnalisis()
        {
            bool totalmatch = false;
            for (int j = 0; j < lista.Count; j++)
            {
                bool filematch = false;
                SubtitleScript script = null;
                ArrayList lineasConCoincidencia = new ArrayList();
                try
                {
                    // primero generamos SubtitleScript
                    script = new SubtitleScript(lista[j].ToString());
                    // hay coincidencias?
                    for (int i = 0; i < script.LineCount; i++)
                    {
                        bool ismatch = false;
                        lineaASS actual = (lineaASS)script.GetLineArrayList().GetFullArrayList()[i];

                        if (isregex)
                        {
                            try
                            {
                                Regex r = new Regex(buscar);
                                ismatch = r.IsMatch(actual.texto);
                            }
                            catch
                            {
                                throw new Exception("Fallo al compilar la expresión regular");
                            }
                        }
                        else
                        {
                            ismatch = (casesens) ?
                                (actual.texto.ToLower().Contains(buscar.ToLower())) :
                                (actual.texto.Contains(buscar));
                        }

                        if (ismatch)
                        {
                            filematch = true;
                            lineasConCoincidencia.Add(i);
                        }
                    }

                }
                catch (Exception x) { Console.WriteLine("Excepción " + x.ToString() + " : " + x.Message); }
                    if (filematch)
                    {
                        // tenemos : script (todo el script), lineasConCoincidencia (lineas donde hay coincidencias)

                        if (ArchivoProcesado != null)
                            ArchivoProcesado(this, new ArchivoProcesadoEventArgs(script, lineasConCoincidencia));

                        totalmatch = true;
                    }
                    else
                    {

                        if (ArchivoProcesado != null)
                            ArchivoProcesado(this, new ArchivoProcesadoEventArgs(script, null));

                    }

                // ------ archivo procesado

            }

            // --- todos los archivos procesados

            if (AnalisisFinalizado!=null)
                AnalisisFinalizado(this, new EventArgs());
        }
示例#17
0
        private void CallUndo()
        {
            if (UndoRedo.UndoLevels > 0)
            {
                script = UndoRedo.GetUndo(script); //al = (ArrayList)UndoStack.Pop();
                al = script.GetLines();
                v4 = script.GetStyles();
                head = script.GetHeaders();

                updateGridWithArrayList(al);
                updatePanelTextTools();
            }
        }
示例#18
0
        public UndoRedoSubtitleScript(SubtitleScript script, string action)
        {
            actionName = action;

            SubtitleScript tmp = (SubtitleScript)script.Clone();
            this.Header = tmp.GetHeader();
            this.Styles = tmp.GetStyles();
            this.Lines = tmp.GetLineArrayList();
            this.FileName = tmp.FileName;
        }
示例#19
0
        private void closeFile()
        {
            if (isModified)
                if (MessageBox.Show("¿Deseas cerrar el archivo actual de subtítulos sin guardar los cambios?", appTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    return;

            AutoSave.Enabled = false;

            type = ScriptFileType.Unknown;
            splashScreen.Visible = true;
            gridASS.Visible = false;
            panelTextTools.Visible = false;

            openFile = null;

            script = null;
            drawPositions();
            updateMenuEnables();
        }
示例#20
0
 public SubtitleScript GetUndo(SubtitleScript orig)
 {
     UndoRedoSubtitleScript tmp = (UndoRedoSubtitleScript)undoStack.Pop();
     redoStack.Push(new UndoRedoSubtitleScript(orig, "Deshacer (" + tmp.ActionName + ")"));
     return (SubtitleScript)tmp;
 }
示例#21
0
 public ZipSubtitleScript(SubtitleScript script)
 {
     LoadFromScript(script);
 }