当前位置: 首页>>代码示例>>C#>>正文


C# ReferencedFileSave.GetContainer方法代码示例

本文整理汇总了C#中FlatRedBall.Glue.SaveClasses.ReferencedFileSave.GetContainer方法的典型用法代码示例。如果您正苦于以下问题:C# ReferencedFileSave.GetContainer方法的具体用法?C# ReferencedFileSave.GetContainer怎么用?C# ReferencedFileSave.GetContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FlatRedBall.Glue.SaveClasses.ReferencedFileSave的用法示例。


在下文中一共展示了ReferencedFileSave.GetContainer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RemoveReferencedFile

        public void RemoveReferencedFile(ReferencedFileSave referencedFileToRemove, List<string> additionalFilesToRemove, bool regenerateCode)
        {
            // There are some things that need to happen:
            // 1.  Remove the ReferencedFileSave from the Glue project (GLUX)
            // 2.  Remove the GUI item
            // 3.  Remove the item from the Visual Studio project.

            #region Remove the file from the current Screen or Entity if there is a current Screen or Entity

            IElement container = referencedFileToRemove.GetContainer();

            if (container != null)
            {
                // The referenced file better be a globally referenced file


                if (!container.ReferencedFiles.Contains(referencedFileToRemove))
                {
                    throw new ArgumentException();
                }
                else
                {
                    container.ReferencedFiles.Remove(referencedFileToRemove);

                }
                // Ask about any NamedObjects that reference this file.                
                for (int i = container.NamedObjects.Count - 1; i > -1; i--)
                {
                    var nos = container.NamedObjects[i];
                    if (nos.SourceType == SourceType.File && nos.SourceFile == referencedFileToRemove.Name)
                    {
                        MainGlueWindow.Self.Invoke(() =>
                            {
                                // Ask the user what to do here - remove it?  Keep it and not compile?
                                MultiButtonMessageBox mbmb = new MultiButtonMessageBox();
                                mbmb.MessageText = "The object\n" + nos.ToString() + "\nreferences the file\n" + referencedFileToRemove.Name +
                                    "\nWhat would you like to do?";
                                mbmb.AddButton("Remove this object", DialogResult.Yes);
                                mbmb.AddButton("Keep it (object will not be valid until changed)", DialogResult.No);

                                var result = mbmb.ShowDialog();

                                if (result == DialogResult.Yes)
                                {
                                    container.NamedObjects.RemoveAt(i);
                                }
                            });
                    }
                    nos.ResetVariablesReferencing(referencedFileToRemove);
                }

                MainGlueWindow.Self.Invoke(() =>
                    {
                        if (EditorLogic.CurrentScreenTreeNode != null)
                        {
                            EditorLogic.CurrentScreenTreeNode.UpdateReferencedTreeNodes();
                        }
                        else if (EditorLogic.CurrentEntityTreeNode != null)
                        {
                            EditorLogic.CurrentEntityTreeNode.UpdateReferencedTreeNodes(false);
                        }
                        if (regenerateCode)
                        {
                            ElementViewWindow.GenerateSelectedElementCode();
                        }
                    });
                
            }
            #endregion

            #region else, the file is likely part of the GlobalContentFile

            else
            {
                ProjectManager.GlueProjectSave.GlobalFiles.Remove(referencedFileToRemove);
                ProjectManager.GlueProjectSave.GlobalContentHasChanged = true;

                // Much faster to just remove the tree node.  This was done
                // to reuse code and make things reactive, but this has gotten
                // slow on bigger projects.
                //ElementViewWindow.UpdateGlobalContentTreeNodes(false); // don't save here because projects will get saved below 

                Action refreshUiAction = () =>
                {
                    TreeNode treeNode = GlueState.Self.Find.ReferencedFileSaveTreeNode(referencedFileToRemove);

                    if (treeNode.Tag != referencedFileToRemove)
                    {
                        throw new Exception("Error removing the tree node - the selected tree node doesn't reference the file being removed");
                    }

                    treeNode.Parent.Nodes.Remove(treeNode);
                };

                MainGlueWindow.Self.Invoke((MethodInvoker)delegate
                    {
                        refreshUiAction();
                    }
                    );

//.........这里部分代码省略.........
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:101,代码来源:GluxCommands.cs

示例2: ReferencedFileSaveToString

        public static string ReferencedFileSaveToString(ReferencedFileSave instance)
        {
            string containerText = "";
            if (instance.GetContainerType() == SaveClasses.ContainerType.None)
            {
                containerText = " (in GlobalContent)";
            }
            else
            {
                containerText = " (in " + instance.GetContainer() + ")";
            }
            return instance.Name + containerText;


        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:15,代码来源:ReferencedFileSaveExtensionMethods.cs

示例3: ReferencedFileSaveTreeNode

        public TreeNode ReferencedFileSaveTreeNode(ReferencedFileSave referencedFileSave)
        {
            IElement container = referencedFileSave.GetContainer();

            if (container == null)
            {
                return TreeNodeByTagIn(referencedFileSave, ElementViewWindow.GlobalContentFileNode.Nodes);
            }
            else if (container is ScreenSave)
            {
                ScreenTreeNode screenTreeNode = GlueState.Self.Find.ScreenTreeNode((ScreenSave)container);
                return screenTreeNode.GetTreeNodeFor(referencedFileSave);
            }
            else if (container is EntitySave)
            {
                EntityTreeNode entityTreeNode = GlueState.Self.Find.EntityTreeNode((EntitySave)container);
                return entityTreeNode.GetTreeNodeFor(referencedFileSave);
            }

            return null;

        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:22,代码来源:FindManager.cs

示例4: DragAddFileToGlobalContent

        private static void DragAddFileToGlobalContent(TreeNode treeNodeMoving, ReferencedFileSave referencedFileSave)
        {
            if (referencedFileSave.GetContainerType() == ContainerType.None)
            {
                // This means the user dragged a file from global content onto the global content tree node - 
                // we shouldn't do anything here.  It's not a valid operation, but at the same time, it may have
                // happened accidentally and we don't want to burden the user with popups.
            }
            else
            {
                bool isAlreadyPartOfReferencedFiles = false;
                // If the file is already part of GlobalContent, then warn the user and do nothing
                foreach (ReferencedFileSave fileInGlobalContent in ObjectFinder.Self.GlueProject.GlobalFiles)
                {
                    if (fileInGlobalContent.Name == referencedFileSave.Name)
                    {
                        isAlreadyPartOfReferencedFiles = true;
                        break;
                    }
                }


                if (isAlreadyPartOfReferencedFiles)
                {

                    MessageBox.Show("The file\n\n" + referencedFileSave.Name + "\n\nis already a Global Content File");
                }
                else
                {
                    // If we got here, that means that the file that
                    // the user is dragging in to Global Content Files
                    // can be added to Global Content Files; however, the
                    // owner of the file may not be using global content.  We
                    // should ask the user if the containing IElement should use
                    // global content
                    IElement container = referencedFileSave.GetContainer();



                    if (!container.UseGlobalContent)
                    {
                        string screenOrEntity = "Screen";

                        if (container is EntitySave)
                        {
                            screenOrEntity = "Entity";
                        }

                        DialogResult result = MessageBox.Show("The " + screenOrEntity + " " + container.ToString() +
                            "does not UseGlobalContent.  Would you like " +
                            " to set UseGlobalContent to true?", "Set UseGlobalContent to true?", MessageBoxButtons.YesNo);

                        if (result == DialogResult.Yes)
                        {
                            container.UseGlobalContent = true;
                        }
                    }

                    bool useFullPathAsName = true;
                    ElementCommands.Self.AddReferencedFileToGlobalContent(referencedFileSave.Name, useFullPathAsName);

                    ContentLoadWriter.UpdateLoadGlobalContentCode();

                    ProjectManager.SaveProjects();
                    GluxCommands.Self.SaveGlux();
                }

            }

        }
开发者ID:gitter-badger,项目名称:FlatRedBall,代码行数:70,代码来源:ElementViewWindow.DragDrop.cs


注:本文中的FlatRedBall.Glue.SaveClasses.ReferencedFileSave.GetContainer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。