コード例 #1
0
        void UpdateOpenScenes()
        {
            string[] newFiles = new string[0];
            try
            {
                newFiles = VirtualDirectory.GetFiles("", "*.scene", SearchOption.AllDirectories);

                CollectionUtility.MergeSort(newFiles, delegate(string name1, string name2)
                {
                    var s1 = name1.Replace("\\", " \\");
                    var s2 = name2.Replace("\\", " \\");
                    return(string.Compare(s1, s2));
                });
            }
            catch { }

            bool needUpdate = !newFiles.SequenceEqual(currentOpenScenes);

            if (!needUpdate)
            {
                return;
            }

            currentOpenScenes = newFiles;

            //add items
            try
            {
                var items = new List <ContentBrowser.Item>();

                foreach (var file in currentOpenScenes)
                {
                    if (!file.Contains(@"Base\Tools\NewResourceTemplates"))
                    {
                        var realFileName = VirtualPathUtility.GetRealPathByVirtual(file);

                        var item = new ContentBrowserItem_File(contentBrowserOpenScene, null, realFileName, false);
                        item.SetText(file);
                        item.Tag      = file;
                        item.imageKey = "Scene";

                        items.Add(item);
                    }
                }

                contentBrowserOpenScene.SetData(items, false);
                if (items.Count != 0)
                {
                    contentBrowserOpenScene.SelectItems(new ContentBrowser.Item[] { items[0] });
                }
            }
            catch (Exception exc)
            {
                Log.Warning(exc.Message);
                //contentBrowserOpenScene.SetError( "Error: " + exc.Message );
            }
        }
コード例 #2
0
        void UpdateOpenScenes()
        {
            string[] newFiles = new string[0];
            try
            {
                newFiles = VirtualDirectory.GetFiles("", "*.scene", SearchOption.AllDirectories);

                CollectionUtility.MergeSort(newFiles, delegate(string s1, string s2)
                {
                    {
                        var p  = @"_Tests\";
                        var v1 = s1.Length > p.Length && s1.Substring(0, p.Length) == p;
                        var v2 = s2.Length > p.Length && s2.Substring(0, p.Length) == p;
                        if (!v1 && v2)
                        {
                            return(-1);
                        }
                        if (v1 && !v2)
                        {
                            return(1);
                        }
                    }

                    {
                        var p  = @"Samples\";
                        var v1 = s1.Length > p.Length && s1.Substring(0, p.Length) == p;
                        var v2 = s2.Length > p.Length && s2.Substring(0, p.Length) == p;
                        if (!v1 && v2)
                        {
                            return(-1);
                        }
                        if (v1 && !v2)
                        {
                            return(1);
                        }
                    }

                    return(string.Compare(s1, s2));
                });
            }
            catch { }

            bool needUpdate = !newFiles.SequenceEqual(currentOpenScenes);

            if (!needUpdate)
            {
                return;
            }

            currentOpenScenes = newFiles;

            //add items
            try
            {
                var items = new List <ContentBrowser.Item>();

                foreach (var file in currentOpenScenes)
                {
                    if (!file.Contains(@"Base\Tools\NewResourceTemplates"))
                    {
                        var realFileName = VirtualPathUtility.GetRealPathByVirtual(file);

                        var item = new ContentBrowserItem_File(contentBrowserOpenScene, null, realFileName, false);
                        item.SetText(file);
                        item.Tag      = file;
                        item.imageKey = "Resource";
                        items.Add(item);

                        //var item = new ContentBrowserItem_Virtual( contentBrowserOpenScene, null, file );
                        //item.Tag = file;
                        //item.imageKey = "Resource";
                        //items.Add( item );
                    }
                }

                contentBrowserOpenScene.SetData(items, false);
                if (items.Count != 0)
                {
                    contentBrowserOpenScene.SelectItems(new ContentBrowser.Item[] { items[0] });
                }
            }
            catch (Exception exc)
            {
                contentBrowserOpenScene.SetError("Error: " + exc.Message);
            }
        }