Esempio n. 1
0
        //Add an animation clip to the currently selected file
        private void BtnAddAnimClip_Click(object sender, RoutedEventArgs e)
        {
            if (_selectedFile == null)
            {
                MessageBox.Show(this, "Cannot add animation clips without an input file.", "Error", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return;
            }
            try
            {
                var newClip = new AnimationClipDesc
                    {
                        BeginFrame = double.Parse(TxtAnimClipBegin.Text),
                        EndFrame = double.Parse(TxtAnimClipEnd.Text),
                        Fps = double.Parse(TxtAnimClipFps.Text)
                    };

                if(newClip.BeginFrame > newClip.EndFrame || newClip.Fps < 0)
                    throw new FormatException();

                _selectedFile.AnimationClips.Add(TxtAnimClipSelected.Text, newClip);
                ListBoxAnimClips.Items.Add(TxtAnimClipSelected.Text);
                TxtAnimClipSelected.Text = "";
                TxtAnimClipBegin.Text = "";
                TxtAnimClipEnd.Text = "";
                TxtAnimClipSelected.Focus();
            }
            catch (ArgumentException)
            {
                MessageBox.Show(this, "An animation clip with this name already exists, please choose a different name.",
                                "Error", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
            catch (FormatException)
            {
                MessageBox.Show(this, "Please ensure you have entered valid numbers for the Begin, End and FPS fields.",
                                "Error", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
Esempio n. 2
0
        //Attempt to read batch.xml to load previous settings
        //If anything goes wrong, just start without any preloaded settings
        public void ReadXml(XmlReader reader)
        {
            try
            {
                FileDescs = new Dictionary<string, FbxFileDesc>();

                reader.ReadToFollowing("BatchConversion");

                reader.ReadToDescendant("Output");
                OutputDir = reader.ReadElementContentAsString();

                while (reader.LocalName == "FbxFile")
                {
                    var newFile = new FbxFileDesc();

                    reader.ReadToDescendant("Filename");
                    var newFilename = reader.ReadElementContentAsString();

                    if (reader.LocalName != "CollisionGeneration")
                        reader.ReadToNextSibling("CollisionGeneration");

                    newFile.CollisionType = reader.ReadElementContentAsString();

                    while (reader.LocalName == "AnimClip")
                    {
                        var newClip = new AnimationClipDesc();

                        reader.ReadToDescendant("Name");
                        var newClipName = reader.ReadElementContentAsString();

                        if (reader.LocalName != "Keyframes")
                        reader.ReadToNextSibling("Keyframes");

                        newClip.BeginFrame = double.Parse(reader.GetAttribute("Begin"));
                        newClip.EndFrame = double.Parse(reader.GetAttribute("End"));
                        newClip.Fps = double.Parse(reader.GetAttribute("FPS"));

                        reader.Read();
                        reader.ReadEndElement();

                        newFile.AnimationClips.Add(newClipName, newClip);
                    }

                    reader.ReadEndElement();
                    FileDescs.Add(newFilename, newFile);
                }
            }
            catch (Exception)
            {
                MessageBox.Show(ParentWindow, "Unable to read batch.xml, starting with a clean slate...",
                                "Error", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                FileDescs = new Dictionary<string, FbxFileDesc>();
                OutputDir = "";
            }
        }