/// <summary>
        /// Obtain a text rendering of the resource link.
        /// </summary>
        /// <param name="res">The resource to render.</param>
        /// <returns>The string output for rendering.</returns>
        public string renderResourceLink(Resources.ResourceInfo res)
        {
            string retVal = "";

            if (!res.Link.Equals(""))
            {
                HyperLink link = new HyperLink();
                link.Text        = res.Link;
                link.NavigateUrl = res.Link;
                retVal           = "<a href=\"" + res.Link + "\" target=\"_blank\">(Link)</a>";
            }

            return(retVal);
        }
示例#2
0
        async Task CollectionResource(List <Resources.ResourceInfo> resInfos, float totalProgress, Action <float, string> progressReport)
        {
            float delta = totalProgress / resInfos.Count;

            var collector     = new EngineNS.Bricks.SandBox.ObjectReferencesCollector();
            var collectorData = new EngineNS.Bricks.SandBox.ObjectReferencesCollector.CollectProcessData();

            for (int i = 0; i < resInfos.Count; i++)
            {
                Resources.ResourceInfo rInfo = resInfos[i];
                progressReport?.Invoke(mProgress, $"正在收集资源引用 {rInfo.ResourceName.Name}");
                var rName = rInfo.ResourceName;
                mResInfoDic.Add(rName, rInfo);
                //if (!resInfoDic.TryGetValue(rName, out rInfo))
                //{
                //    rInfo = await EditorCommon.Resources.ResourceInfoManager.Instance.CreateResourceInfoFromResource(rName.Address);
                //    if (rInfo == null)
                //    {
                //        EngineNS.Profiler.Log.WriteLine(EngineNS.Profiler.ELogTag.Warning, "资源丢失", $"找不到资源{rName.Address}");
                //        continue;
                //    }
                //    resInfoDic.Add(rName, rInfo);
                //}

                var rnm = mNameManager.GetRNameIndex(rName);
                if (rnm != null)
                {
                    var loadData = new EditorCommon.Assets.AssetsPakage.LoadResourceData()
                    {
                        ObjType     = null,
                        RNameMapper = rnm,
                    };
                    await rInfo.AssetsOption_LoadResource(loadData);

                    rName.NameIndexInPakage = rnm.Index;

                    //收集res直接、间接用到的资源RName
                    if (rnm.ResObject != null)
                    {
                        await collector.CollectReferences(rnm.ResObject, OnVisitProperty, OnVisitMember, OnVisitContainer, collectorData);
                    }
                }

                mProgress += delta;
            }
        }
示例#3
0
        /// <summary>
        /// Respond to the update event, when an item is being edited and
        /// subsequently updated, by updating the info object of the
        /// item being edited.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">The event arguments</param>
        private void ResourcesEditor_UpdateCommand(object source, DataGridCommandEventArgs e)
        {
            TextBox tb1      = (TextBox)e.Item.FindControl("DescriptionTextbox");
            TextBox tb2      = (TextBox)e.Item.FindControl("LinkTextbox");
            string  newText1 = SwenetDev.Globals.parseTextInput(tb1.Text);
            string  newText2 = SwenetDev.Globals.parseTextInput(tb2.Text);

            Resources.ResourceInfo ri =
                ((Resources.ResourceInfo)ResourcesEditor.DataList[(int)e.Item.ItemIndex]);
            ri.Text = newText1;
            ri.Link = newText2;

            if (hasDuplicates())
            {
                ResourcesEditor.Text = "That resource has already been added.";
                ResourcesEditor.DataList.RemoveAt((int)e.Item.ItemIndex);
            }
            else
            {
                ResourcesEditor.Text = "";
            }
        }
示例#4
0
        public static async System.Threading.Tasks.Task <Resources.ResourceInfo> SearchFirshResourceInfo(string resourceType, Func <Resources.ResourceInfo, bool> function)
        {
            if (string.IsNullOrEmpty(resourceType))
            {
                return(null);
            }
            var smp = EngineNS.Thread.ASyncSemaphore.CreateSemaphore(1);

            Resources.ResourceInfo tempInfo = null;
            await EngineNS.CEngine.Instance.EventPoster.Post(async() =>
            {
                var meta = EditorCommon.Resources.ResourceInfoManager.Instance.GetResourceInfoMetaData(resourceType);
                foreach (var ext in meta.ResourceExts)
                {
                    var files = EngineNS.CEngine.Instance.FileManager.GetFiles(EngineNS.CEngine.Instance.FileManager.ProjectContent, "*" + ext, System.IO.SearchOption.AllDirectories);
                    foreach (var file in files)
                    {
                        var resInfoFile = file + EditorCommon.Program.ResourceInfoExt;
                        if (!EngineNS.CEngine.Instance.FileManager.FileExists(resInfoFile))
                        {
                            continue;
                        }
                        var info = await EditorCommon.Resources.ResourceInfoManager.Instance.CreateResourceInfoFromFile(resInfoFile, null);
                        if (info != null)
                        {
                            if (function?.Invoke(info) == true)
                            {
                                smp.Release();
                                tempInfo = info;
                            }
                        }
                    }
                }
            }, EngineNS.Thread.Async.EAsyncTarget.AsyncEditor);

            await smp.Await();

            return(tempInfo);
        }