コード例 #1
0
        public void Run(ApplicationManager app)
        {
            string filename = Properties.Settings.Default.RecentFile;

            if (!File.Exists(filename))
            {
                return;
            }
            SkeletonAnimation animation = new SkeletonAnimation();

            animation.Open(filename);
            app.AnimationManager.CurrentAnimation = animation;
            if (app.AnimationManager.Playing)
            {
                app.TogglePlay();
            }
            if (string.IsNullOrEmpty(app.AnimationManager.CurrentAnimation.Name))
            {
                animation.Name = Path.GetFileNameWithoutExtension(filename);
            }
            animation.Filename = 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;
                }

                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();
        }
コード例 #2
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();
        }