Beispiel #1
0
        private void SavePlay(String filename)
        {
            Stream stream = new FileStream(filename, FileMode.OpenOrCreate);

            if (stream != null)
            {
                ReplayObject obj = new ReplayObject();
                obj.EnviromentPath = currentEnviromentLocation;
                obj.FinalPlatforms = enviroment.Platforms;

                var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                binaryFormatter.Serialize(stream, obj);
                stream.Close();
            }
        }
Beispiel #2
0
        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = "pla files (*.pla)|*.pla|All files (*.*)|*.*";
            openFileDialog.FilterIndex      = 1;
            openFileDialog.RestoreDirectory = true;

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                String          location     = openFileDialog.FileName;
                FileStream      stream       = new FileStream(location, FileMode.Open);
                BinaryFormatter formatter    = new BinaryFormatter();
                ReplayObject    replayObject = (ReplayObject)formatter.Deserialize(stream);

                if (!File.Exists(replayObject.EnviromentPath))
                {
                    replayObject.EnviromentPath = Path.GetDirectoryName(location) + "\\" + Path.GetFileName(replayObject.EnviromentPath);
                }

                LoadEnviroment(replayObject.EnviromentPath);

                for (int i = 0; i < replayObject.FinalPlatforms.Count; i++)
                {
                    Platform plt         = replayObject.FinalPlatforms[i];
                    Platform envPlatform = enviroment.Platforms.Find(p => p.Equals(plt));
                    envPlatform.ControlPolicy = new ReplayPolicy();
                    //envPlatform = plt;

                    while (plt.ControlPolicy.Trajectory.Count > 0)
                    {
                        Pose p = plt.ControlPolicy.Trajectory.Pop();
                        envPlatform.ControlPolicy.CommandSequence.Push(p);
                    }

                    Logger.Close();
                }
            }
        }