public void PlayLog(LogEntry logEntry) { try { movieFrames = new List<MovieFrame>(); var logFrame = new MovieFrame(); var allLines = new List<string>(); allLines.Add(logEntry.title); allLines.AddRange(logEntry.lines); logFrame.scanLines = allLines; var dimensions = CalculateWidthHeightFromLines(allLines); logFrame.width = dimensions.Item1; logFrame.height = dimensions.Item2; movieFrames.Add(logFrame); PlayMovieFrames(false); } catch (Exception ex) { MessageBox.Show("Failed to play movie from frames " + ex.Message); } }
public bool LoadMovie(string filenameRoot) { try { LogFile.Log.LogEntry("Loading movie: " + filenameRoot); int frameNo = 0; movieFrames = new List<MovieFrame>(); Assembly _assembly = Assembly.GetExecutingAssembly(); //MessageBox.Show("Showing all embedded resource names"); //string[] names = _assembly.GetManifestResourceNames(); //foreach (string name in names) // MessageBox.Show(name); do { string filename = "RogueBasin.bin.Debug.movies." + filenameRoot + frameNo.ToString() + ".amf"; Stream _fileStream = _assembly.GetManifestResourceStream(filename); //If this is the first frame check if there is at least one frame if (frameNo == 0) { if (_fileStream == null) { throw new ApplicationException("Can't find file: " + filename); } } //Otherwise, not finding a file just means the end of a movie if (_fileStream == null) { break; } //File exists, load the frame MovieFrame frame = new MovieFrame(); using (StreamReader reader = new StreamReader(_fileStream)) { string thisLine; frame.scanLines = new List<string>(); while ((thisLine = reader.ReadLine()) != null) { frame.scanLines.Add(thisLine); } //Set width and height //Calculate dimensions frame.width = 0; foreach (string row in frame.scanLines) { if (row.Length > frame.width) frame.width = row.Length; } frame.height = frame.scanLines.Count; //Add the frame movieFrames.Add(frame); //Increment the frame no frameNo++; } } while (true); return true; } catch (Exception e) { LogFile.Log.LogEntry("Failed to load movie: " + e.Message); return false; } }