private void HandleIfAchx(TreeNode selectedTreeNode)
{
ReferencedFileSave rfs = selectedTreeNode?.Tag as ReferencedFileSave;
bool shouldShowAnimationChainUi = rfs != null && rfs.Name != null && FileManager.GetExtension(rfs.Name) == "achx";
if (shouldShowAnimationChainUi)
{
if (!mContainer.Controls.Contains(mTab))
{
mContainer.Controls.Add(mTab);
mContainer.SelectTab(mContainer.Controls.Count - 1);
}
if (mAchxControl == null)
{
mAchxControl = new MainControl();
ToolStripMenuItem saveToolStripItem = new ToolStripMenuItem("Force Save", null, HandleSaveClick);
mAchxControl.AddToolStripMenuItem(saveToolStripItem, "File");
ToolStripMenuItem forceSaveAllItem = new ToolStripMenuItem("Re-Save all .achx files in this Glue project", null, HandleForceSaveAll);
mAchxControl.AddToolStripMenuItem(forceSaveAllItem, "File");
mAchxControl.AnimationChainChange += new EventHandler(HandleAnimationChainChange);
mAchxControl.Dock = DockStyle.Fill;
}
mTab.Text = " Animation"; // add spaces to make room for the X to close the plugin
if(!mTab.Controls.Contains(mAchxControl))
{
mTab.Controls.Add(mAchxControl);
}
if(mTab.Controls.Contains(mTextureCoordinateControl))
{
mTab.Controls.Remove(mTextureCoordinateControl);
}
string fullFileName = FlatRedBall.Glue.ProjectManager.MakeAbsolute(rfs.Name);
mLastFile = fullFileName;
if (System.IO.File.Exists(fullFileName))
{
mAchxControl.LoadAnimationChain(fullFileName);
}
}
else if (mContainer.Controls.Contains(mTab))
{
mContainer.Controls.Remove(mTab);
}
}