public UserControl_AnimationFrameDefinition(AnimationFrameDefinition animationFrameDefinition)
            : base("Animation Frame Definition", false)
        {
            m_animationFrameDefinition = animationFrameDefinition;

            if (DataIsNull())
            {
                m_textBlock_id.Text = "N/A";
                m_textBox_name.Text = string.Empty;
                m_textBox_texture.Text = string.Empty;
                m_doubleUpDown_duration.Value = null;
                m_doubleUpDown_width.Value = null;
                m_doubleUpDown_height.Value = null;
                m_doubleUpDown_texCoordTop.Value = null;
                m_doubleUpDown_texCoordLeft.Value = null;
                m_doubleUpDown_texCoordRight.Value = null;
                m_doubleUpDown_texCoordBottom.Value = null;
            }
            else
            {
                m_textBlock_id.Text = m_animationFrameDefinition.Id.ToString();
                m_textBox_name.Text = m_animationFrameDefinition.Name;
                m_textBox_texture.Text = m_animationFrameDefinition.Texture;

                CreateCanvasControls();

                m_doubleUpDown_duration.Value = m_animationFrameDefinition.Duration;
                m_doubleUpDown_width.Value = m_animationFrameDefinition.Width;
                m_doubleUpDown_height.Value = m_animationFrameDefinition.Height;
                // haha, we actually need to set the left and the top before the right and the bottom;
                // the way that we've bound this data relies on the Canvas.Left and Canvas.Top properties being accurate
                m_doubleUpDown_texCoordTop.Value = m_animationFrameDefinition.TexCoordTop;
                m_doubleUpDown_texCoordLeft.Value = m_animationFrameDefinition.TexCoordLeft;
                m_doubleUpDown_texCoordRight.Value = m_animationFrameDefinition.TexCoordRight;
                m_doubleUpDown_texCoordBottom.Value = m_animationFrameDefinition.TexCoordBottom;
            }
        }
 private void SelectAnimationFrameDefinition(AnimationFrameDefinition animationFrameDefinition)
 {
     RemoveAnimationFrameControls(false);
     m_userControl_animationFrameDefinition = new UserControl_AnimationFrameDefinition(animationFrameDefinition);
     Grid.SetRowSpan(m_userControl_animationFrameDefinition, 4);
     m_userControl_animationFrameDefinition.NewDataAddedEvent += UserControl_AnimationFrameDefinition_NewDataAdded;
     m_userControl_animationFrameDefinition.ExistingDataUpdatedEvent += UserControl_AnimationFrameDefinition_ExistingDataUpdated;
     m_grid_main.SetRowColumn(m_userControl_animationFrameDefinition, 1, 1);
 }
        protected override int AddNewData()
        {
            m_animationFrameDefinition = DataManager.Generate<AnimationFrameDefinition>();
            m_animationFrameDefinition.Name = m_textBox_name.Text;
            m_animationFrameDefinition.Texture = m_textBox_texture.Text;
            m_animationFrameDefinition.Duration = m_doubleUpDown_duration.Value;
            m_animationFrameDefinition.Width = m_doubleUpDown_width.Value.Value;
            m_animationFrameDefinition.Height = m_doubleUpDown_height.Value.Value;
            m_animationFrameDefinition.TexCoordTop = m_doubleUpDown_texCoordTop.Value.Value;
            m_animationFrameDefinition.TexCoordRight = m_doubleUpDown_texCoordRight.Value.Value;
            m_animationFrameDefinition.TexCoordBottom = m_doubleUpDown_texCoordBottom.Value.Value;
            m_animationFrameDefinition.TexCoordLeft = m_doubleUpDown_texCoordLeft.Value.Value;

            DataManager.AnimationFrameDefinitions.Add(m_animationFrameDefinition);

            SaveTextureInformation(m_animationFrameDefinition.Texture);

            return m_animationFrameDefinition.Id;
        }
 private FrameworkElement CreateLevelLayoutControlWithAnimationFrame(AnimationFrameDefinition animationFrame)
 {
     var image = new Image();
     image.Source =
         Extensions.BitmapSourceFromTextureCoords
         (
             animationFrame.Texture,
             animationFrame.TexCoordTop,
             animationFrame.TexCoordRight,
             animationFrame.TexCoordBottom,
             animationFrame.TexCoordLeft,
             animationFrame.Width,
             animationFrame.Height
         );
     return image;
 }
        private void DisplayAnimationFrame(AnimationFrameDefinition animationFrameDefinition)
        {
            if (!string.IsNullOrWhiteSpace(animationFrameDefinition.Texture))
            {
                m_bitmapSource = Extensions
                    .BitmapSourceFromTextureCoords
                    (
                        animationFrameDefinition.Texture,
                        animationFrameDefinition.TexCoordTop,
                        animationFrameDefinition.TexCoordRight,
                        animationFrameDefinition.TexCoordBottom,
                        animationFrameDefinition.TexCoordLeft,
                        animationFrameDefinition.Width,
                        animationFrameDefinition.Height
                    );
            }
            else
                m_bitmapSource = null;

            m_image.Source = m_bitmapSource;
        }