public bool OpenFile(bool checkSaved = true)
        {
            if (checkSaved && !ShowSaveQuestion())
            {
                return(false);
            }

            string filePath = GetOpenFilename();

            if (string.IsNullOrEmpty(filePath))
            {
                return(false);
            }

            CloseFile(false);
            EditingFile = new MotionFile(false);

            RegisterFileEvents(EditingFile);

            EditingFile.Load(filePath);

            MotionTab.UpdateItemPreviews();

            return(true);
        }
Beispiel #2
0
        public void TestSaveMethod()
        {
            MotionFile motionFile = new MotionFile();

            motionFile.Load(TEST_FILE);

            MemoryStream savedStream = new MemoryStream();

            motionFile.Save(savedStream);

            savedStream.Seek(0, SeekOrigin.Begin);

            MotionFile savedMotionFile = new MotionFile();

            savedMotionFile.Load(savedStream);

            savedStream.Close();

            Assert.AreEqual(motionFile.FramesPerSecond, savedMotionFile.FramesPerSecond, "Frames per second values do not match");
            Assert.AreEqual(motionFile.ChannelCount, savedMotionFile.ChannelCount, "Channel counts do not match");

            for (int i = 0; i < motionFile.ChannelCount; i++)
            {
                Assert.AreEqual(motionFile[i].Type, savedMotionFile[i].Type, "Channel types do not match");
                Assert.AreEqual(motionFile[i].Index, savedMotionFile[i].Index, "Channel index values do not match");
            }

            Assert.AreEqual(motionFile.FramesPerSecond, savedMotionFile.FramesPerSecond, "Frame counts do not match");
        }
Beispiel #3
0
        public void TestLoadMethod()
        {
            Stream stream = File.OpenRead(TEST_FILE);

            stream.Seek(0, SeekOrigin.End);
            long fileSize = stream.Position;

            stream.Seek(0, SeekOrigin.Begin);

            MotionFile motionFile = new MotionFile();

            motionFile.Load(stream);

            long streamPosition = stream.Position;

            stream.Close();

            Assert.AreEqual(fileSize, streamPosition, "Not all of the file was read");
        }
Beispiel #4
0
        public static void LoadFile(string filePath, string fileId = null)
        {
            if (!CheckLoaded(fileId))
            {
                MotionFile file = new MotionFile();
                file.Load(filePath);

                if (fileId == null)
                {
                    MotionStorage.defaultFile = file;
                }
                else
                {
                    MotionStorage.fileDict.Add(fileId, file);
                }
            }
            else
            {
                throw new Exception("Already loaded same fileID.");
            }
        }