Esempio n. 1
0
        /// <summary>
        /// This process invokes the save method.
        /// </summary>
        /// <param name="app"></param>
        public void Run(ApplicationManager app)
        {
            SkeletonAnimation animation = app.AnimationManager.CurrentAnimation;

            if (animation == null || animation.Snapshots.Count == 0)
            {
                MessageBox.Show(Messages.ProcessSave_NoRecording);
                return;
            }
            if (animation.Filename == null)
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter = Messages.Animation_Files_Filter + "|*.xml";
                DialogResult r = sfd.ShowDialog(app.MainForm);
                if (r != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }
                animation.Filename = sfd.FileName;
            }

            animation.Name = Path.GetFileNameWithoutExtension(animation.Filename);
            if (app.MainForm != null)
            {
                app.MainForm.Text = animation.Name;
            }
            animation.Save();
            if (app.AnimationManager.CurrentAnimation != null)
            {
                app.MainForm.Text = app.AnimationManager.CurrentAnimation.Name;
            }
            if (app.RecentFiles != null)
            {
                if (app.RecentFiles.Items.Count == 0 || app.RecentFiles.Items[0] != animation.Filename)
                {
                    app.RecentFiles.Items.Insert(0, animation.Filename);
                }
            }
            app.Changed = false;
            app.UpdateMenus();
        }
Esempio n. 2
0
 /// <summary>
 /// Gets a copy of the specified range as a new animation
 /// </summary>
 public void CopyToClipboard(int index, int count)
 {
     ClipboardAnimation = new SkeletonAnimation();
     ClipboardAnimation.Snapshots.AddRange(CurrentAnimation.Snapshots.GetRange(index, count));
 }
Esempio n. 3
0
        /// <summary>
        /// handles the modifications necessary to open the file.
        /// </summary>
        /// <param name="app"></param>
        public void Run(ApplicationManager app)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = Messages.Animation_Files_Filter + "|*.xml"; // the file extension would not be language sensitive.
            DialogResult r = ofd.ShowDialog(app.MainForm);

            if (r != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }
            SkeletonAnimation animation = new SkeletonAnimation();

            animation.Open(ofd.FileName);
            app.AnimationManager.CurrentAnimation = animation;
            if (app.AnimationManager.Playing)
            {
                app.TogglePlay();
            }
            if (string.IsNullOrEmpty(app.AnimationManager.CurrentAnimation.Name))
            {
                animation.Name = Path.GetFileNameWithoutExtension(ofd.FileName);
            }
            animation.Filename = ofd.FileName;
            if (app.AnimationManager.CurrentAnimation != null)
            {
                if (app.ButtonPlay != null)
                {
                    app.ButtonPlay.Enabled = true;
                }
                if (app.Slider != null)
                {
                    app.Slider.Enabled = true;
                    app.Slider.Maximum = app.AnimationManager.SnapshotCount - 1;
                    app.Slider.Value   = 0;
                }
                if (app.MainForm != null)
                {
                    app.MainForm.Text = app.AnimationManager.CurrentAnimation.Name;
                }
                if (app.RecentFiles != null)
                {
                    app.RecentFiles.Add(ofd.FileName);
                }
                ToolStripMenuItem menuSelect = app.GetMenu("menuSelectAll");
                if (menuSelect != null)
                {
                    menuSelect.Enabled = (app.AnimationManager.CurrentAnimation.Snapshots.Count > 0);
                }
                if (app.Viewer != null)
                {
                    if (app.AnimationManager.CurrentAnimation != null && app.AnimationManager.CurrentAnimation.Snapshots != null &&
                        app.AnimationManager.CurrentAnimation.Snapshots.Count > 0)
                    {
                        app.Viewer.DrawSnapshot(app.AnimationManager.CurrentAnimation.Snapshots[0]);
                    }
                }
            }
            app.Changed = false;
            app.ActionManager.Actions.Clear();
            app.UpdateMenus();
        }