本文整理汇总了C#中FlatRedBall.Glue.SaveClasses.ReferencedFileSave.SetNameNoCall方法的典型用法代码示例。如果您正苦于以下问题:C# ReferencedFileSave.SetNameNoCall方法的具体用法?C# ReferencedFileSave.SetNameNoCall怎么用?C# ReferencedFileSave.SetNameNoCall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlatRedBall.Glue.SaveClasses.ReferencedFileSave
的用法示例。
在下文中一共展示了ReferencedFileSave.SetNameNoCall方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenameReferencedFile
public static void RenameReferencedFile(string oldName, string newName, ReferencedFileSave rfs, IElement container)
{
string oldDirectory = FileManager.GetDirectory(oldName);
string newDirectory = FileManager.GetDirectory(newName);
string newFileNameAbsolute = ProjectManager.MakeAbsolute(newName);
string instanceName = FileManager.RemovePath(FileManager.RemoveExtension(newName));
string whyIsntValid;
if (oldDirectory != newDirectory)
{
MessageBox.Show("The old file was located in \n" + oldDirectory + "\n" +
"The new file is located in \n" + newDirectory + "\n" +
"Currently Glue does not support changing directories.", "Warning");
rfs.SetNameNoCall(oldName);
}
else if (NameVerifier.IsReferencedFileNameValid(instanceName, rfs.GetAssetTypeInfo(), rfs, container, out whyIsntValid) == false)
{
MessageBox.Show(whyIsntValid);
rfs.SetNameNoCall(oldName);
}
else
{
bool shouldMove = true;
bool shouldContinue = true;
CheckForExistingFileOfSameName(oldName, rfs, newFileNameAbsolute, ref shouldMove, ref shouldContinue);
if (shouldContinue)
{
MoveFileIfNecessary(oldName, newName, shouldMove);
string rfsType = rfs.RuntimeType;
if (rfsType != null && rfsType.Contains("."))
{
// We dont want the fully qualified type.
rfsType = FileManager.GetExtension(rfsType);
}
UpdateObjectsUsingFile(container, oldName, rfs, rfsType);
RegenerateCodeAndUpdateUiAccordingToRfsRename(oldName, newName, rfs);
UpdateBuildItemsForRenamedRfs(oldName, newName);
AdjustDataFilesIfIsCsv(oldName, rfs);
GluxCommands.Self.SaveGlux();
ProjectManager.SaveProjects();
}
}
}
示例2: CheckForExistingFileOfSameName
private static void CheckForExistingFileOfSameName(string oldName, ReferencedFileSave fileSave, string newFileNameAbsolute, ref bool shouldMove, ref bool shouldContinue)
{
if (FileManager.FileExists(newFileNameAbsolute))
{
string message = "The new file name already exists. What would you like to do?";
MultiButtonMessageBox mbmb = new MultiButtonMessageBox();
mbmb.MessageText = message;
mbmb.AddButton("Use existing file", DialogResult.Yes);
mbmb.AddButton("Cancel the rename", DialogResult.Cancel);
DialogResult result = mbmb.ShowDialog(MainGlueWindow.Self);
if (result == DialogResult.Cancel)
{
fileSave.SetNameNoCall(oldName);
shouldContinue = false;
}
else if (result == DialogResult.Yes)
{
shouldMove = false;
}
}
}
示例3: AddReferencedFileToGlobalContent
public ReferencedFileSave AddReferencedFileToGlobalContent(string fileToAdd, bool useFullPathAsName)
{
var referencedFileSave = new ReferencedFileSave();
referencedFileSave.SetNameNoCall(fileToAdd);
referencedFileSave.IsSharedStatic = true;
referencedFileSave.HasPublicProperty = true;
// We include
// the directory
// as part of the
// name because if
// a user adds multiple
// ReferencedFileSaves to
// GlobalContent it's very
// likely that there will be
// some kind of naming conflict.
// Doing this reduces the chances
// of this to almost 0.
// UPDATE July 18, 2011
// Turns out this method
// is called if either a new
// RFS is added or if it is dragged
// on to GlobalContent from an Entity.
// Therefore, we only want to do this if
// the useFullPathAsName argument is true;
if (useFullPathAsName)
{
referencedFileSave.IncludeDirectoryRelativeToContainer = true;
}
ProjectManager.GlueProjectSave.GlobalFiles.Add(referencedFileSave);
ProjectManager.GlueProjectSave.GlobalContentHasChanged = true;
ProjectManager.UpdateFileMembershipInProject(referencedFileSave);
// Update any element that may reference this file because now it may mean the element
// will simply reference it from GlobalContent instead of using the content manager.
List<IElement> elements = ObjectFinder.Self.GetAllElementsReferencingFile(referencedFileSave.Name);
foreach (IElement element in elements)
{
element.HasChanged = true;
}
GlueCommands.Self.RefreshCommands.RefreshGlobalContent();
return referencedFileSave;
}
示例4: AddReferencedFile
public static ReferencedFileSave AddReferencedFile(this IElement instance, string fileName, AssetTypeInfo ati, EditorObjects.SaveClasses.BuildToolAssociation bta = null)
{
var referencedFileSave = new ReferencedFileSave();
if (ati != null)
{
referencedFileSave.RuntimeType = ati.QualifiedRuntimeTypeName.QualifiedType;
}
referencedFileSave.IsSharedStatic = true;
referencedFileSave.SetNameNoCall(fileName);
#if GLUE
if (ati != null && !string.IsNullOrEmpty(ati.CustomBuildToolName) && bta != null)
{
referencedFileSave.BuildTool = ati.CustomBuildToolName;
referencedFileSave.SourceFile = referencedFileSave.Name;
string newName = FileManager.RemoveExtension(referencedFileSave.Name);
newName += "." + bta.DestinationFileType;
referencedFileSave.SetNameNoCall(newName);
}
#endif
instance.ReferencedFiles.Add(referencedFileSave);
referencedFileSave.IsSharedStatic = true;
return referencedFileSave;
}
示例5: MoveReferencedFileToDirectory
//.........这里部分代码省略.........
if (!FileManager.IsRelativeTo(targetReferencedFileName, targetDirectory))
{
MessageBox.Show("The file\n\n" + file + "\n\nis not relative to the file being moved, so it cannot be moved. You must manually move these files and manually update the file reference.");
canMove = false;
break;
}
}
if (canMove && File.Exists(targetFile))
{
MessageBox.Show("There is already a file by this name located in the directory you're trying to move to.");
canMove = false;
}
if (canMove)
{
foreach (KeyValuePair<string, string> kvp in mOldNewDependencyFileDictionary)
{
if (File.Exists(kvp.Value))
{
MessageBox.Show("Can't move the file because a dependency will be moved to\n\n" + kvp.Value + "\n\nand a file already exists there.");
canMove = false;
break;
}
}
}
if (canMove)
{
// 1 Move the TreeNode from one parent TreeNode to another
//treeNodeMoving.Parent.Nodes.Remove(treeNodeMoving);
//targetNode.Nodes.Add(treeNodeMoving);
// This is updated at the bottom of this method
// 2 Move the file from one folder to another
File.Move(oldFileName, targetFile);
foreach (KeyValuePair<string, string> kvp in mOldNewDependencyFileDictionary)
{
File.Move(kvp.Key, kvp.Value);
}
// 3 Remove the BuildItems from the project and add them back in the VisualStudio project
ProjectBase projectBase = ProjectManager.ProjectBase;
if (ProjectManager.ContentProject != null)
{
projectBase = ProjectManager.ContentProject;
}
ProjectManager.RemoveItemFromProject(projectBase, oldNodeText, false);
projectBase.AddContentBuildItem(targetFile);
foreach (KeyValuePair<string, string> kvp in mOldNewDependencyFileDictionary)
{
string fileFileRelativeToProject = FileManager.MakeRelative(kvp.Key, projectBase.Directory);
ProjectManager.RemoveItemFromProject(projectBase, fileFileRelativeToProject, false);
projectBase.AddContentBuildItem(kvp.Value);
}
// TODO: This should also check to see if something else is referencing this content.
// I'm going to write it to not make this check now since I'm just getting the initial system set up
// 4 Change the ReferencedFileSave's name
referencedFileSave.SetNameNoCall(newNodeText.Replace("\\", "/"));
// No need for this, it'll get updated automatically
// treeNodeMoving.Text = newNodeText;
// 5 Re-generate the containing Element (Screen or Entity)
if (EditorLogic.CurrentElement != null)
{
CodeWriter.GenerateCode(EditorLogic.CurrentElement);
}
else
{
ContentLoadWriter.UpdateLoadGlobalContentCode();
}
// The new 1: Update
if (EditorLogic.CurrentElement != null)
{
EditorLogic.CurrentElementTreeNode.UpdateReferencedTreeNodes();
}
else
{
ElementViewWindow.UpdateGlobalContentTreeNodes(false);
}
// 6 Save everything
GluxCommands.Self.SaveGlux();
ProjectManager.SaveProjects();
}
}