public void HandleTreeViewRightClick(TreeNode rightClickedTreeNode, ContextMenuStrip menuToModify) { ReferencedFileSave rfs; var getIfShouldShowMenu = GetIfShouldShowRightClickOption(rightClickedTreeNode, out rfs); List <string> availableAtlases = null; if (getIfShouldShowMenu) { string fullFileName = GlueCommands.Self.GetAbsoluteFileName(rfs); if (System.IO.File.Exists(fullFileName)) { // This might be slow, we may want to cache it: TpsLoadResult tpsLoadResult; var model = TpsFileSave.Load(fullFileName, out tpsLoadResult); var succeeded = string.IsNullOrEmpty(tpsLoadResult.ErrorMessage) && string.IsNullOrEmpty(tpsLoadResult.MissingFile); if (succeeded) { availableAtlases = model.AtlasFilters .Select(item => { if (item.EndsWith("/")) { return(item.Substring(0, item.Length - 1)); } else { return(item); } }) .ToList(); } } } if (availableAtlases != null && availableAtlases.Count > 0) { var menuToAddTo = new ToolStripMenuItem("Include Atlas"); menuToModify.Items.Add(menuToAddTo); foreach (var item in availableAtlases) { var atlasMenuItem = new ToolStripMenuItem(item); atlasMenuItem.Click += HandleScreenToAddClick; menuToAddTo.DropDownItems.Add(atlasMenuItem); } } }
private void LoadFileFromRfs(ReferencedFileSave referencedFile) { string absoluteFileName = GlueCommands.Self.GetAbsoluteFileName(referencedFile); if (System.IO.File.Exists(absoluteFileName)) { TpsLoadResult result; loadedFile = TpsFileSave.Load(absoluteFileName, out result); } else { loadedFile = null; } }
public void SetFrom(TpsFileSave model) { SuppressChangedEvents = true; Atlases.Clear(); foreach (var item in model.AtlasFilters) { var vm = new AtlasViewModel(); vm.Folder = item; Atlases.Add(vm); } SuppressChangedEvents = false; }
public void SetRfs(ReferencedFileSave referencedFile) { referencedFileSave = referencedFile; if (referencedFileSave != null) { LoadFileFromRfs(referencedFileSave); viewModel.SetFrom(loadedFile); } else { loadedFile = null; } }
public void SetFrom(TpsFileSave model) { SuppressChangedEvents = true; Atlases.Clear(); foreach(var item in model.AtlasFilters) { var vm = new AtlasViewModel(); vm.Folder = item; Atlases.Add(vm); } SuppressChangedEvents = false; }
public void CreateNewProject() { var newTps = new TpsFileSave(); newTps.SetDefaultValues(); string fileName = AtlasFolder + "TexturePackerProject.tps"; newTps.Save(fileName); bool userCancelled = false; // Select the Global Content tree node to add the file there: GlueState.Self.CurrentTreeNode = FlatRedBall.Glue.FormHelpers.ElementViewWindow.GlobalContentFileNode; var rfs = FlatRedBall.Glue.FormHelpers.RightClickHelper.AddSingleFile( fileName, ref userCancelled); GlueState.Self.CurrentReferencedFileSave = rfs; }
public void CreateNewProject() { var newTps = new TpsFileSave(); newTps.SetDefaultValues(); string fileName = AtlasFolder + "TexturePackerProject.tps"; newTps.Save(fileName); bool userCancelled = false; // Select the Global Content tree node to add the file there: GlueState.Self.CurrentTreeNode = FlatRedBall.Glue.FormHelpers.ElementViewWindow.GlobalContentFileNode; var rfs = FlatRedBall.Glue.FormHelpers.RightClickHelper.AddSingleFile( fileName, ref userCancelled); GlueState.Self.CurrentReferencedFileSave = rfs; }
private void LoadFileFromRfs(ReferencedFileSave referencedFile) { string absoluteFileName = GlueCommands.Self.GetAbsoluteFileName(referencedFile); if (System.IO.File.Exists(absoluteFileName)) { TpsLoadResult result; loadedFile = TpsFileSave.Load(absoluteFileName, out result); } else { loadedFile = null; } }
public void SetRfs(ReferencedFileSave referencedFile) { referencedFileSave = referencedFile; if (referencedFileSave != null) { LoadFileFromRfs(referencedFileSave); viewModel.SetFrom(loadedFile); } else { loadedFile = null; } }