Ejemplo n.º 1
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.Reset();
            openFileDialog1.Title = Localizable.OpenTitle;
            openFileDialog1.Filter = Localizable.OpenFileType;
            openFileDialog1.ShowDialog();
            if (openFileDialog1.FileName.Length == 0) return;

            StreamReader fileReader = new StreamReader(openFileDialog1.FileName);
            subtitles = new AdvancedSubStationAlpha();
            subtitles.LoadAss(fileReader.ReadToEnd());
            fileReader.Close();
            fromXS = false;
            LoadSubtitles();
        }
Ejemplo n.º 2
0
        private void changeEffectsMode(bool mode, bool open)
        {
            subtitles = new AdvancedSubStationAlpha();  //重置字幕对象

            if (open)
            {
                appConfig.EffectMode = mode;
                offsetMenuItem.Enabled = mode;
                stylesToolStripMenuItem.Enabled = !mode;
                importMenuItem.Enabled = !mode;
                normalModeMenuItem.Checked = !mode;
                effectsModeMenuItem.Checked = mode;

                if (mode)
                {
                    this.Text = String.Format(Localizable.Title, Localizable.EffectsMode, fileName);
                }
                else
                {
                    this.Text = String.Format(Localizable.Title, Localizable.NormalMode, fileName);
                }
            }
        }
Ejemplo n.º 3
0
        private void openMenuItem_Click(object sender, EventArgs e)
        {
            if (askToSave())
            {
                openFileDialog1.Reset();
                openFileDialog1.Filter = Localizable.OpenFileType;
                openFileDialog1.Title = Localizable.OpenTitle;
                openFileDialog1.ShowDialog();

                if (openFileDialog1.FileName.Length == 0) return;
                fileName = openFileDialog1.FileName;

                string fileContent = readFromFile(fileName);
                subtitles = new AdvancedSubStationAlpha();

                switch (Path.GetExtension(fileName))
                {
                    case ".xss":
                        subtitles.LoadXss(fileContent);
                        ScriptTextBox.Text = fileContent;
                        changeEffectsMode(false, true);
                        this.Text = String.Format(Localizable.Title, Localizable.NormalMode, fileName);
                        break;
                    case ".ass":
                        subtitles.LoadAss(fileContent);
                        ScriptTextBox.Text = subtitles.ToXingSub();
                        changeEffectsMode(false, true);
                        this.Text = String.Format(Localizable.Title, Localizable.NormalMode, fileName);
                        break;
                    case ".xse":
                        ScriptTextBox.Text = fileContent;
                        changeEffectsMode(true, true);
                        this.Text = String.Format(Localizable.Title, Localizable.EffectsMode, fileName);
                        break;
                    default:
                        ScriptTextBox.Text = fileContent;
                        changeEffectsMode(false, true);
                        this.Text = String.Format(Localizable.Title, Localizable.NormalMode, fileName);
                        break;
                }

                isSaved = true;
            }
        }
Ejemplo n.º 4
0
        private void changeEffectsMode(bool mode)
        {
            appConfig.EffectMode = mode;
            offsetMenuItem.Enabled = mode;
            stylesToolStripMenuItem.Enabled = !mode;
            importMenuItem.Enabled = !mode;
            normalModeMenuItem.Checked = !mode;
            effectsModeMenuItem.Checked = mode;

            subtitles = new AdvancedSubStationAlpha();  //重置字幕对象

            if (mode)
            {
                if (Path.GetExtension(fileName) != ".xse")  //如果扩展名不符,要求另存。
                {
                    fileName = "";
                    isSaved = false;
                }

                if (fileName.Length == 0)
                {
                    this.Text = String.Format(Localizable.Title, Localizable.EffectsMode, Localizable.NewFile + "*");
                }
                else
                {
                    this.Text = String.Format(Localizable.Title, Localizable.EffectsMode, fileName + "*");
                }
            }
            else
            {
                if (Path.GetExtension(fileName) != ".xss" && Path.GetExtension(fileName) != ".ass")  //如果扩展名不符,要求另存。
                {
                    fileName = "";
                    isSaved = false;
                }

                if (fileName.Length == 0)
                {
                    this.Text = String.Format(Localizable.Title, Localizable.NormalMode, Localizable.NewFile + "*");
                }
                else
                {
                    this.Text = String.Format(Localizable.Title, Localizable.NormalMode, fileName + "*");
                }
            }
        }
Ejemplo n.º 5
0
 private void newMenuItem_Click(object sender, EventArgs e)
 {
     if (askToSave())
     {
         ScriptTextBox.Text = "";
         fileName = "";
         isSaved = true;
         if (appConfig.EffectMode)
         {
             this.Text = String.Format(Localizable.Title, Localizable.EffectsMode, Localizable.NewFile);
         }
         else
         {
             this.Text = String.Format(Localizable.Title, Localizable.NormalMode, Localizable.NewFile);
         }
         subtitles = new AdvancedSubStationAlpha();
         subtitles.Styles.Add(new SubStationStyle());
     }
 }
Ejemplo n.º 6
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            // 读取配置文件
            if (File.Exists(configFile))
            {
                FileStream fs = new FileStream(configFile, FileMode.Open);
                XmlSerializer xs = new XmlSerializer(typeof(XSConfig));
                try
                {
                    appConfig = (XSConfig)xs.Deserialize(fs);
                }
                catch (InvalidOperationException)
                {
                    appConfig = new XSConfig();
                    MessageBox.Show(Localizable.ConfigWarningMessage, Localizable.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                fs.Close();
            }
            else
            {
                appConfig = new XSConfig();
            }

            // 设置窗口大小和位置
            if (appConfig.DesktopBounds.Equals(new Rectangle(-1, -1, -1, -1)))
            {
                appConfig.DesktopBounds = this.DesktopBounds;
            }
            else
            {
                this.DesktopBounds = appConfig.DesktopBounds;
            }

            // 应用自动关闭设置
            autocloseTimeWindowToolStripMenuItem.Checked = appConfig.AutoClose;

            // 应用特效模式设置
            offsetMenuItem.Enabled = appConfig.EffectMode;
            normalModeMenuItem.Checked = !appConfig.EffectMode;
            effectsModeMenuItem.Checked = appConfig.EffectMode;

            if (appConfig.EffectMode)
            {
                this.Text = String.Format(Localizable.Title, Localizable.EffectsMode, Localizable.NewFile);
            }
            else
            {
                this.Text = String.Format(Localizable.Title, Localizable.NormalMode, Localizable.NewFile);
            }

            // 应用偏移设置
            offsetBySpaceMenuItem.Checked = (appConfig.TimeOffset == 0);
            offsetOneMenuItem.Checked = (appConfig.TimeOffset == 1);
            offsetTwoMenuItem.Checked = (appConfig.TimeOffset == 2);

            // 应用捕获目标设置
            NWEToolStripMenuItem.Checked = (appConfig.TimeSource == TimingApp.NeroWaveEditor);
            MPCToolStripMenuItem.Checked = (appConfig.TimeSource == TimingApp.MediaPlayerClassic);

            //初始化字幕对象
            subtitles = new AdvancedSubStationAlpha();
            subtitles.Styles.Add(new SubStationStyle());

            LoadXSPlugins();
        }
Ejemplo n.º 7
0
 void resyncForm_SaveToXingSub(AdvancedSubStationAlpha sub)
 {
     subtitles = sub;
     ScriptTextBox.Text = subtitles.ToXingSub();
 }
Ejemplo n.º 8
0
        private void importMenuItem_Click(object sender, EventArgs e)
        {
            if (askToSave())
            {
                List<int> pluginsId = new List<int>();
                StringBuilder filter = new StringBuilder(255);
                filter.Append(Localizable.FileTypeAss);
                for (int i = 0; i < pluginsList.Count; i++)
                {
                    IXSPlugin plug = (IXSPlugin)Activator.CreateInstance(pluginsList[i]);
                    if (plug.GetPluginType() == 0)
                    {
                        pluginsId.Add(i);
                        filter.AppendFormat("{0}|*{1}|", plug.GetFileType(), plug.GetFileExt());
                    }
                }

                openFileDialog1.Reset();
                openFileDialog1.Filter = filter.ToString().TrimEnd("|".ToCharArray());
                openFileDialog1.Title = Localizable.ImportTitle;
                openFileDialog1.ShowDialog();

                if (openFileDialog1.FileName.Length == 0) return;

                if (openFileDialog1.FilterIndex == 1)
                {
                    subtitles.LoadAss(readFromFile(openFileDialog1.FileName));
                }
                else
                {
                    int index = pluginsId[openFileDialog1.FilterIndex - 2];
                    IXSPlugin plugin = (IXSPlugin)Activator.CreateInstance(pluginsList[index]);
                    subtitles = plugin.ReadAsSubtitle(openFileDialog1.FileName);
                }
                ScriptTextBox.Text = subtitles.ToXingSub();
            }
        }
Ejemplo n.º 9
0
 public void LoadFromXingSub(AdvancedSubStationAlpha sub)
 {
     subtitles = sub;
     fromXS = true;
     LoadSubtitles();
 }