示例#1
0
        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            if (listBox1.Items.Count == 0) return;
            if (listBox1.SelectedIndex == -1) return;

            estiloV4 v = (estiloV4)mW.v4[listBox1.SelectedIndex];
            estiloV4 v2 = new estiloV4(v.ToString());

            v2.Name = "Copia de " + v2.Name;
            if (isInStyles(v2.Name))
            {
                for (int i = 1; ; i++)
                    if (!isInStyles(v2.Name + " " + i))
                    {
                        v2.Name = v2.Name + " " + i;
                        break;
                    }
            }

            mW.v4.Add(v2);
            listBox1.Items.Clear();
            foreach (estiloV4 v1 in mW.v4)
                listBox1.Items.Add(v1.Name);

            listBox1.SetSelected(listBox1.Items.Count - 1, true);
        }
示例#2
0
        private void makeTempFile()
        {
            TextWriter o = new StreamWriter(PreviewFile, false, System.Text.Encoding.UTF8);
            o.WriteLine(mW.headerMark);
            o.WriteLine("PlayResY: " + textPlayResY.Text);
            o.WriteLine();
            o.WriteLine(mW.stylesMark);
            estiloV4 e = (estiloV4)mW.v4[listBox1.SelectedIndex];
            estiloV4 e2 = new estiloV4(e.ToString());

            switch (e.Alignment)
            {
                case 4:
                case 7:
                    e2.Alignment = 1;
                    break;
                case 5:
                case 8:
                    e2.Alignment = 2;
                    break;
                case 6:
                case 9:
                    e2.Alignment = 3;
                    break;
                default:
                    e2.Alignment = e.Alignment;
                    break;
            }

            o.WriteLine(e2.ToString());
            o.WriteLine();
            o.WriteLine(mW.dialoguesMark);
            lineaASS l = new lineaASS();
            if (checkBox2.Checked)
                l.texto = "{\\be1}"+previewText.Text;
            else l.texto = previewText.Text;
            l.estilo = e.Name;
            l.t_final.setTiempo(50);
            o.WriteLine(l.ToString());
            o.Close();
        }
示例#3
0
        private void comboCont_SelectedIndexChanged(object sender, EventArgs e)
        {
            StreamReader sr;
            ComboBox c = (ComboBox)sender;
            listBox2.Items.Clear();
            almacen.Clear();

            try
            {
                string fname = mW.stylesDir + "\\" + c.Items[c.SelectedIndex].ToString() + ".Styles";
                sr = FileAccessWrapper.OpenTextFile(fname);

                string linea;
                while ((linea = sr.ReadLine()) != null)
                {
                    estiloV4 v = new estiloV4(linea);
                    listBox2.Items.Add(v.Name);
                    almacen.Add(v);
                }

                sr.Close();
            }
            catch { }
        }
示例#4
0
        void TemplateName_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (TemplateName.SelectedIndex < 1) return;
            headerASS tmp = new headerASS();
            tmp.LoadFrom(templateDir + "\\" + TemplateName.Text + ".template");
            foreach (string s in tmp.GetHeaderList())
            {
                int idx = s.IndexOf(':');
                if (idx > 0)
                {
                    string k = s.Substring(0, idx);
                    string v = s.Substring(idx + 2);
                    script.GetHeader().SetHeaderValue(k, v);
                }
            }

            if (tmp.ExistsHeaderValue("Last Style Storage"))
            {
                StreamReader sr = null;
                try
                {
                    string fname = stylesDir + "\\" + tmp.GetHeaderValue("Last Style Storage") + ".Styles";
                    sr = FileAccessWrapper.OpenTextFile(fname);

                    string linea;
                    while ((linea = sr.ReadLine()) != null)
                    {
                        estiloV4 v = new estiloV4(linea);

                        // si existen -->   == -> no añadir
                        //                  != -> preguntar (si/no/si a todo)
                        bool existe = false;
                        foreach (estiloV4 est in script.GetStyles())
                        {
                            if (est.Name == v.Name)
                                existe = true;
                        }
                        if (!existe)
                            script.GetStyles().Insert(0,v);
                    }

                    sr.Close();
                }
                catch { }
            }
        }
示例#5
0
        private void gridASS_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            switch (e.ColumnIndex)
            {
                case 1:
                    //MessageBox.Show(script.GetLines()[e.RowIndex].ToString());
                    string presx = script.GetHeader().GetHeaderValue("PlayResX");
                    string presy = script.GetHeader().GetHeaderValue("PlayResY");

                    int py = -1, px = -1;

                    if (presx.Equals(string.Empty) && presy.Equals(string.Empty)) return;
                    if (presx.Equals(string.Empty))
                    {
                        py = int.Parse(presy);
                        px = ((py * 4) / 3);
                    }
                    else if (presy.Equals(string.Empty))
                    {
                        px = int.Parse(presx);
                        py = ((px * 3) / 4);
                    }
                    else
                    {
                        px = int.Parse(presx);
                        py = int.Parse(presy);
                    }

                    try
                    {
                        AviSynthScriptEnvironment env = new AviSynthScriptEnvironment();
                        string script0rz = "blankclip(color=$000000,width=" + px + ",height=" + py + ")";
                        AviSynthClip avs = env.ParseScript(script0rz);

                        string vsf_path = AviSynthFunctions.getVSFilterPath(avs);
                        if (vsf_path != null)
                            avs.AviSynthInvoke(avs.GetAVS(), 0, "LoadPlugin", false, vsf_path);

                        // escribir ssa temporal

                        string PreviewFile = "PrevFile-l" + e.RowIndex + ".ass";

                        lineaASS actual = (lineaASS)script.GetLineArrayList().GetFullArrayList()[e.RowIndex];

                        TextWriter o = new StreamWriter(PreviewFile, false, System.Text.Encoding.UTF8);
                        o.WriteLine(headerMark);
                        o.WriteLine(script.GetHeader().ToString());

                        o.WriteLine(stylesMark);
                        foreach (estiloV4 e2 in script.GetStyles())
                        {
                            if (e2.Name.Equals(actual.estilo))
                            {
                                estiloV4 new_est = new estiloV4(e2.ToString());
                                new_est.PrimaryColor = "&H00FFFFFF";
                                new_est.SecondaryColor = "&H00FFFFFF";
                                new_est.OutlineColor = "&H00FFFFFF";
                                new_est.ShadowColor = "&H00FFFFFF";
                                o.WriteLine(new_est.ToString().Replace("\n", string.Empty));
                            }
                        }

                        o.WriteLine(); // ---

                        o.WriteLine(dialoguesMark);

                        actual.t_inicial.setTiempo(0);
                        actual.t_final.setTiempo(50);
                        o.WriteLine(actual.ToString());

                        o.Close();

                        avs.AviSynthInvoke(avs.GetAVS(), 0, "Eval", false, script0rz);
                        avs.AviSynthInvoke(avs.GetAVS(), 0, "TextSub", true, PreviewFile);
                        //LinePreviewBox.Image = (Image)AviSynthFunctions.getBitmapFromFrame(avs, 0, 0);
                        avs.cleanup(true);

                        File.Delete(PreviewFile);
                        //b = BitmapFunctions.Crop(b, 640, 480, 0, 376);
                    }
                    catch
                    {
                        errorMsg("Error cargando AviSynth.");
                    }

                    break;
            }
        }
示例#6
0
        private int CalcularLineas(AviSynthClip avs, string PreviewFile, lineaASS actual)
        {
            int nLineas;

            //lineaASS actual = (lineaASS)lass.Clone();

            TextWriter o = new StreamWriter(PreviewFile, false, System.Text.Encoding.UTF8);
            o.WriteLine(headerMark);
            o.WriteLine(script.GetHeader().ToString());

            o.WriteLine(stylesMark);
            foreach (estiloV4 e2 in script.GetStyles())
            {
                if (e2.Name.Equals(actual.estilo))
                {
                    estiloV4 new_est = new estiloV4(e2.ToString());
                    new_est.PrimaryColor = "&H00FFFFFF";
                    new_est.SecondaryColor = "&H00FFFFFF";
                    new_est.OutlineColor = "&H00FFFFFF";
                    new_est.ShadowColor = "&H00FFFFFF";
                    o.WriteLine(new_est.ToString().Replace("\n", string.Empty));
                }
            }

            o.WriteLine(); // ---

            o.WriteLine(dialoguesMark);

            actual.t_inicial.setTiempo(0);
            actual.t_final.setTiempo(50);
            o.WriteLine(actual.ToString());

            o.Close();

            avs.AviSynthInvoke(avs.GetAVS(), 0, "Eval", false, "blankclip(color=$000000,width=" + width + ",height=" + height + ")");
            avs.AviSynthInvoke(avs.GetAVS(), 0, "TextSub", true, PreviewFile);

            Image iimg = (Image)AviSynthFunctions.getBitmapFromFrame(avs, 0, 0);

            int x,y,x2,y2;

            nLineas = ContarLineas(iimg, out x, out y, out x2, out y2);

            iimg.Dispose();

            File.Delete(PreviewFile);
            return nLineas;
        }