示例#1
0
        public void Load(string path, int episode)
        {
            m_path      = path;
            m_episodeNo = episode;
            IWorkbook workbook = Factory.GetWorkbook(path);

            m_episodes = workbook.Worksheets.Count - 1;
            IWorksheet worksheet = workbook.Worksheets[m_episodeNo];

            ShowTitleOriginal    = worksheet.Cells[OriginalTitleCell].Formula;
            ShowTitleDubbed      = worksheet.Cells[TranslatedEpisodeTitleCell].Formula;
            EpisodeNumber        = worksheet.Cells[EpisodeNoCell].Formula;
            EpisodeTitleOriginal = worksheet.Cells[OriginalEpisodeTitleCell].Formula;
            EpisodeTitleDubbed   = worksheet.Cells[TranslatedEpisodeTitleCell].Formula;
            EpisodeTranslator    = worksheet.Cells[TranslatedByCell].Formula;
            try
            {
                EpisodeTranslationDate = !(worksheet.Cells[TranslationDateCell].Value is double) ? (!(worksheet.Cells[TranslationDateCell].Value is DateTime) ? DateTime.ParseExact(worksheet.Cells[TranslationDateCell].Formula, "MM.dd.yyyy", CultureInfo.InvariantCulture) : (DateTime)worksheet.Cells[TranslationDateCell].Value) : DateTime.FromOADate((double)worksheet.Cells[TranslationDateCell].Value);
            }
            catch (ArgumentException ex)
            {
                ShowDateParsingError(worksheet);
            }
            catch (FormatException ex)
            {
                ShowDateParsingError(worksheet);
            }
            Resume = worksheet.Cells[SummaryCell].Formula;
            int        scriptStartRow = ScriptStartRow;
            ScriptLine list           = null;
            ScriptLine scriptLine1    = null;
            Dictionary <string, ScriptLine> dictionary = new Dictionary <string, ScriptLine>();

            while (scriptStartRow <= worksheet.UsedRange.RowCount)
            {
                IRange cell1    = worksheet.Cells[scriptStartRow, CharacterColumn];
                IRange cell2    = worksheet.Cells[scriptStartRow, TimeColumn];
                IRange cell3    = worksheet.Cells[scriptStartRow, LineColumn];
                IRange cell4    = worksheet.Cells[scriptStartRow, CheckboxColumn];
                string key      = cell1.MergeArea.Formula.Trim();
                string formula1 = cell2.MergeArea.Formula;
                string str      = cell3.MergeArea.Formula.Trim();
                string formula2 = cell4.MergeArea.Formula;
                if (!string.IsNullOrEmpty(key))
                {
                    ScriptLine scriptLine2 = new ScriptLine();
                    scriptLine2.Character = key;
                    try
                    {
                        scriptLine2.Offset = MidiTime.Parse(formula1);
                    }
                    catch (FormatException ex)
                    {
                        int num = (int)MessageBox.Show("Invalid time code formatting in sheet " + worksheet.Name + " cell " + cell2.GetAddress(false, false, ReferenceStyle.A1, false, null));
                        scriptLine2.Offset = MidiTime.Zero;
                    }
                    scriptLine2.Line   = str;
                    scriptLine2.IsDone = !string.IsNullOrEmpty(formula2);
                    if (list == null)
                    {
                        list = scriptLine2;
                    }
                    scriptLine2.PrevByTime = scriptLine1;
                    if (scriptLine1 != null)
                    {
                        scriptLine1.NextByTime = scriptLine2;
                    }
                    if (dictionary.ContainsKey(key))
                    {
                        scriptLine2.PrevByCharacter     = dictionary[key];
                        dictionary[key].NextByCharacter = scriptLine2;
                    }
                    scriptLine1     = scriptLine2;
                    dictionary[key] = scriptLine2;
                }
                scriptStartRow += cell1.MergeArea.RowCount;
            }
            m_lines = new ScriptLineCollection(list);
            m_lines.Sort();
            workbook.Close();
        }
示例#2
0
 public ExcelScript()
 {
     m_lines = new ScriptLineCollection(null);
 }