Esempio n. 1
0
        internal static string GetAssetPath(BaseAsset asset, string posibleName)
        {
            string     path;
            AssetTypes tType;

            if (asset.Type == AssetTypes.Meta)
            {
                MetaAsset MA = ((MetaAsset)asset);
                tType = MA.InfoType;
            }
            else
            {
                tType = asset.Type;
            }

            path = GetAssetTypePath(tType);
            string name = asset.Name;

            if (!string.IsNullOrEmpty(posibleName))
            {
                name = posibleName;
            }
            string file = name + (tType == AssetTypes.Shader ? ShaderExtension : Extension);

            path = Path.Combine(path, file);
            return(path);
        }
Esempio n. 2
0
        public void LoadGlobalReflectionCubeMap(float intensity, string resPath)
        {
            if (string.IsNullOrEmpty(resPath))
            {
                JW.Common.Log.LogE("LoadGlobalReflectionCubeMap Error CubeMap");
            }

            RenderSettings.reflectionIntensity   = intensity;
            RenderSettings.defaultReflectionMode = DefaultReflectionMode.Custom;

            BaseAsset ba = AssetService.GetInstance().LoadPrimitiveAsset(resPath, 4);

            if (ba == null)
            {
                JW.Common.Log.LogE("LoadGlobalReflectionCubeMap Error CubeMap");
            }
            else
            {
                if (_curRefectionCubMapAsset != null)
                {
                    AssetService.GetInstance().Unload(_curRefectionCubMapAsset);
                    _curRefectionCubMapAsset = null;
                }

                RenderSettings.customReflection = ba.Resource.Content as Cubemap;
                _curRefectionCubMapAsset        = ba;
            }
        }
 /// <summary>
 /// Register BaseAssets for dispose it at the end.
 /// </summary>
 /// <param name="asset">BaseAsset to dispose.</param>
 internal void RegisterForDisposal(BaseAsset asset)
 {
     if (!baseAssets.Contains(asset))
     {
         baseAssets.Push(asset);
     }
 }
Esempio n. 4
0
        private void UpdateSelectedEntity(string id)
        {
            if (!string.IsNullOrEmpty(id))
            {
                BaseAsset entity = Global.Instance.Get.GetByID <BaseAsset>(id);
                if (entity != null)
                {
                    lblSelectedItem.Text  = entity.Name;
                    lblSelectedItem.Image = GetEntityImage(entity);
                    lblSelectedItem.Tag   = entity.ID;
                    if (entity.IsClosed)
                    {
                        lblSelectedItem.Font = new Font(lblSelectedItem.Font, FontStyle.Strikeout);
                    }
                    lblSelectedItem.Visible = true;
                }
                else
                {
                    lblSelectedItem.Visible = false;
                }
            }
            else
            {
                lblSelectedItem.Visible = false;
            }

            UpdateButtonState();
        }
Esempio n. 5
0
        private void UpdateRecentItems()
        {
            btnRecentItems.DropDownItems.Clear();
            IList <string> items = Global.Config.RecentItems;
            int            max   = Math.Min(items.Count, MaximumRememberedItems);

            for (int i = 0; i < max; i++)
            {
                string    recentItem = items[i];
                BaseAsset entity     = Global.Instance.Get.GetByID <BaseAsset>(recentItem);
                if (entity != null)
                {
                    ToolStripItem item = btnRecentItems.DropDownItems.Add(entity.Name);
                    item.Image = GetEntityImage(entity);
                    if (entity.IsClosed)
                    {
                        item.Font = new Font(item.Font, FontStyle.Strikeout);
                    }
                    item.Tag    = recentItem;
                    item.Click += RecentItem_ItemClick;
                }
            }

            if (btnRecentItems.DropDownItems.Count == 0)
            {
                btnRecentItems.Enabled = false;
            }
        }
Esempio n. 6
0
 private static void ReopenIfClosed(BaseAsset item)
 {
     if (item.IsClosed && item.CanReactivate)
     {
         ReactivateAsset(item);
     }
 }
Esempio n. 7
0
        public bool LoadAssetFile(BaseAsset asset)
        {
            string path   = NativeFSWorker.GetAssetPath(asset);
            bool   result = true;

            try {
                using (FileStream stream = new FileStream(path, FileMode.Open))
                    using (BinaryReader reader = new BinaryReader(stream)) {
                        /*int len = (int)reader.BaseStream.Length;
                         * byte[] encrypted = reader.ReadBytes(len);
                         *
                         * using (var inStream = new MemoryStream(encrypted))
                         * using (GZipStream gzip = new GZipStream(inStream, CompressionMode.Decompress))
                         * using (var outStream = new MemoryStream()) {
                         *  gzip.CopyTo(outStream);
                         *  using (BinaryReader decompressReader = new BinaryReader(outStream)) {
                         *      var test = outStream.ToArray();
                         *      decompressReader.BaseStream.Position = 0;
                         *      result = asset.LoadAsset(decompressReader);
                         *  }
                         * }*/
                        result = asset.LoadAsset(reader);
                    }
            } catch (Exception ex) {
                Console.WriteLine("Load file error: {0}", ex.Message);
                asset.Type = AssetTypes.Invalid;
                result     = false;
            }
            return(result);
        }
Esempio n. 8
0
        public static void CreateAsset(BaseAsset asset)
        {
            var client     = new MongoClient(Url);
            var db         = client.GetDatabase(DatabaseName);
            var collection = db.GetCollection <BaseAsset>(AssetCollection);

            collection.InsertOne(asset);
        }
Esempio n. 9
0
 public override void Uninitialize()
 {
     if (_curRefectionCubMapAsset != null)
     {
         AssetService.GetInstance().Unload(_curRefectionCubMapAsset);
         _curRefectionCubMapAsset = null;
     }
 }
 private static void DeleteAsset(BaseAsset item) {
     try {
         item.Delete();
     } catch (Exception ex) {
         Console.WriteLine(string.Format("Can't delete {0} item.", item.ID.Token));
         Console.WriteLine(ex.Message);
     }
 } 
 private static void PrepareAssetForDelete(BaseAsset item) {
     try {
         ReopenProjectIfClosed(item);
         ReopenIfClosed(item);
     } catch(Exception ex) {
         Console.WriteLine(ex.Message);
     }
 }
Esempio n. 12
0
 //关闭
 public override void OnClose()
 {
     if (_cachedAsset != null)
     {
         AssetService.GetInstance().Unload(_cachedAsset);
         _cachedAsset = null;
     }
 }
    void OnGUI()
    {
        if (!AssetService.IsValidate())
        {
            return;
        }

        JW.Framework.Asset.AssetManager am        = AssetService.GetInstance().GetAssetManager();
        JWArrayList <BaseAsset>         usingList = am.GetUsingAssetList();

        GUILayout.Space(3f);
        GUILayout.BeginVertical();


        // list title
        GUILayout.BeginHorizontal("Table Title", GUILayout.MinHeight(20f));
        GUILayout.Label("Index", _labelStyle, GUILayout.Width(60f));
        GUILayout.Label("RefCnt", _labelStyle, GUILayout.Width(60f));
        GUILayout.Label("OriPath", _labelStyle, GUILayout.Width(120f));
        GUILayout.Label("Name", _labelStyle, GUILayout.Width(60f));
        GUILayout.EndHorizontal();

        // list
        mScroll = GUILayout.BeginScrollView(mScroll);

        int index = 0;

        for (int i = 0; i < usingList.Count; i++)
        {
            BaseAsset ba = usingList[i];
            if (ba == null)
            {
                continue;
            }

            index++;

            GUILayout.BeginHorizontal("Table Row", GUILayout.MinHeight(20f));

            // index
            GUILayout.Label(index.ToString(), _labelStyle, GUILayout.Width(60f));

            // ref count
            GUILayout.Label(ba.Resource.RefCnt.ToString(), _labelStyle, GUILayout.Width(60f));

            // tag
            GUILayout.Label(ba.Resource.OriginPath, _labelStyle, GUILayout.Width(120f));

            // path
            GUILayout.Label(ba.Resource.Name, _labelStyle);

            GUILayout.EndHorizontal();
        }

        GUILayout.EndScrollView();
        GUILayout.EndVertical();
        GUILayout.Space(3f);
    }
Esempio n. 14
0
 private static void DeleteAsset(BaseAsset item)
 {
     try {
         item.Delete();
     } catch (Exception ex) {
         Console.WriteLine(string.Format("Can't delete {0} item.", item.ID.Token));
         Console.WriteLine(ex.Message);
     }
 }
Esempio n. 15
0
 private static void PrepareAssetForDelete(BaseAsset item)
 {
     try {
         ReopenProjectIfClosed(item);
         ReopenIfClosed(item);
     } catch (Exception ex) {
         Console.WriteLine(ex.Message);
     }
 }
Esempio n. 16
0
 public void UnloadGlobalReflectionCubeMap()
 {
     RenderSettings.customReflection = null;
     if (_curRefectionCubMapAsset != null)
     {
         AssetService.GetInstance().Unload(_curRefectionCubMapAsset);
         _curRefectionCubMapAsset = null;
     }
 }
Esempio n. 17
0
        public void TearDown()
        {
            var assetsToCleanup = new BaseAsset[]
            { task1, task2, task3, story1, story2, iteration, project, schedule, member };

            foreach (var asset in assetsToCleanup.Where(asset => asset != null && asset.CanDelete))
            {
                asset.Delete();
            }
        }
        private static void ReopenProjectIfClosed(BaseAsset item) {
            if (!(item is Workitem)) {
                return;
            }

            var workitem = ((Workitem)item);
            
            if (workitem.Project.IsClosed && workitem.Project.CanReactivate) {
                ReactivateAsset(workitem.Project);
            }
        }
Esempio n. 19
0
        public ExcelAsset(string excelName, string path = null)
        {
            mPath = new ExcelPath(excelName, path);
            var ass  = Assembly.Load("Assembly-CSharp");
            var type = ass.GetType(mPath.ClassName);

            if (type != null)
            {
                mValue = (BaseAsset)ScriptableObject.CreateInstance(type);
            }
        }
Esempio n. 20
0
        public async Task <bool> RemoveAssetFromWallet(string userId, BaseAsset asset)
        {
            var wallet = await Context.Wallets.Where(w => w.UserId == userId).Include(w => w.Assets).SingleOrDefaultAsync();

            var assetToRemove = wallet.Assets.Where(a => a.Name.Equals(asset.Name)).FirstOrDefault();

            wallet.Assets.Remove(assetToRemove);
            await Context.SaveChangesAsync();

            return(true);
        }
Esempio n. 21
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (SymbolId != null ? SymbolId.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ExchangeId != null ? ExchangeId.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ExchangeSymbol != null ? ExchangeSymbol.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (BaseAsset != null ? BaseAsset.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (QuoteAsset != null ? QuoteAsset.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (TradeTypeAsString != null ? TradeTypeAsString.GetHashCode() : 0);
         return(hashCode);
     }
 }
Esempio n. 22
0
        public async Task <bool> AddAssetToWallet(string userId, BaseAsset asset)
        {
            var wallet = await Context.Wallets.Where(w => w.UserId == userId).Include(w => w.Assets).SingleOrDefaultAsync();

            if (wallet != null)
            {
                wallet.Assets.Add(asset);
                await Context.SaveChangesAsync();

                return(true);
            }
            return(false);
        }
Esempio n. 23
0
        private static void ReopenProjectIfClosed(BaseAsset item)
        {
            if (!(item is Workitem))
            {
                return;
            }

            var workitem = ((Workitem)item);

            if (workitem.Project.IsClosed && workitem.Project.CanReactivate)
            {
                ReactivateAsset(workitem.Project);
            }
        }
Esempio n. 24
0
        public async Task <bool> RemoveAssetFromWallet(OrderForm transaction)
        {
            var asset = new BaseAsset()
            {
                InstrumentId = context.Instruments.Where(i => i.Ticker == transaction.Ticker).FirstOrDefault().Id,
                Name         = transaction.Ticker,
                BuyPrice     = (decimal)transaction.Price,
                Volumen      = transaction.Volumen,
                BuyDT        = transaction.TransactionTime,
                SaleDT       = null,
            };
            var result = await repo.RemoveAssetFromWallet(transaction.UserId, asset);

            return(false);
        }
Esempio n. 25
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (ExchangeId != null ? ExchangeId.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (BaseAsset != null ? BaseAsset.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (QuoteAsset != null ? QuoteAsset.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (TradeTypeAsString != null ? TradeTypeAsString.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (TradeDirectionAsString != null ? TradeDirectionAsString.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ EventTime.GetHashCode();
         hashCode = (hashCode * 397) ^ (ExchangeSequenceId != null ? ExchangeSequenceId.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Price.GetHashCode();
         hashCode = (hashCode * 397) ^ Amount.GetHashCode();
         return(hashCode);
     }
 }
Esempio n. 26
0
 private bool ExecuteUpload()
 {
     if (HasSelection && HasTitle && HasFilename)
     {
         BaseAsset asset = Global.Instance.Get.GetByID <BaseAsset>(SelectedEntityID);
         FileInfo  info  = new FileInfo(SelectedFilename);
         using (Stream stream = info.OpenRead())
         {
             Attachment attachment = asset.CreateAttachment(TitleText, info.Name, stream);
             if (HasMessage)
             {
                 attachment.Description = Message;
                 attachment.Save();
             }
         }
         return(true);
     }
     return(false);
 }
Esempio n. 27
0
        public bool ImportAsset(string Path, string Name, bool Rewrite, out BaseAsset assetRes)
        {
            string[] arr = Path.Split('.');
            string   ext = arr[arr.Length - 1].ToLower();

            assetRes = null;
            BaseAsset asset;

            if (shaderExts.Contains(ext))
            {
                return(ImportShaderAsset(Path, Name, null, null, true, out assetRes));
            }
            else if (meshExts.Contains(ext))
            {
                asset = new MeshAsset()
                {
                    Name = Name,
                };
            }
            else if (textureExts.Contains(ext))
            {
                asset = new Texture2DAsset()
                {
                    Name = Name,
                    // Hack for forcing srgb image with wrong meta-data
                    ForceSRgb = Name.Contains("Albedo"),
                };
            }
            else
            {
                Console.WriteLine("Unknown asset extension: {0}", ext);
                return(false);
            }

            if (!asset.ImportAsset(Path, ext))
            {
                return(false);
            }
            assetRes = asset;
            return(FSWorker.CreateAssetFile(asset, Rewrite || asset.Type == AssetTypes.Shader));
        }
Esempio n. 28
0
        public bool CreateAssetFile(BaseAsset asset, bool rewrite)
        {
            CreateAssetFilesTree();
            if (asset.Type == AssetTypes.Shader)
            {
                Console.WriteLine("Create asset: {0} type: {1} {2}", asset.Name,
                                  ((ShaderAsset)asset).ShaderType.ToString(), asset.Type.ToString());
            }
            else
            {
                Console.WriteLine("Create asset: {0} type: {1}", asset.Name, asset.Type.ToString());
            }

            string path = NativeFSWorker.GetAssetPath(asset);

            if (!rewrite)
            {
                string actualName = asset.Name;
                int    postfix    = 0;
                while (File.Exists(path))
                {
                    actualName = asset.Name + "_" + (++postfix);
                    path       = NativeFSWorker.GetAssetPath(asset, actualName);
                }
                asset.Name = actualName;
            }

            using (FileStream stream = new FileStream(path, FileMode.Create))
                using (BinaryWriter writer = new BinaryWriter(stream)) {
                    /*using (MemoryStream ms = new MemoryStream()) {
                     *  using (GZipStream compressStream = new GZipStream(ms, CompressionMode.Compress))
                     *  using (BinaryWriter compressWriter = new BinaryWriter(compressStream)) {
                     *      asset.SaveAsset(compressWriter);
                     *      //compressWriter.Close();
                     *  }
                     *  writer.Write(ms.ToArray());
                     * }*/
                    asset.SaveAsset(writer);
                }
            return(true);
        }
Esempio n. 29
0
        //加载粒子资源
        private void LoadRes()
        {
            string realPath = ResPath;

            if (!String.IsNullOrEmpty(realPath))
            {
                //TODO LOD
                _cachedAsset = AssetService.GetInstance().LoadInstantiateAsset(realPath, LifeType.Immediate);
                if (_cachedAsset != null)
                {
                    if (_cachedAsset.RootTf != null)
                    {
                        _cachedAsset.RootTf.SetParent(gameObject.transform);
                        _cachedAsset.RootTf.localPosition = Vector3.zero;
                        _cachedAsset.RootTf.localRotation = Quaternion.identity;
                        _cachedAsset.RootTf.localScale    = Vector3.one;
                        _cachedAsset.RootGo.ExtSetActive(true);
                    }
                }
            }
        }
Esempio n. 30
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = ExchangeId != null?ExchangeId.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ (TradeType != null ? TradeType.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (BaseAsset != null ? BaseAsset.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (QuoteAsset != null ? QuoteAsset.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ TimePeriodStart.GetHashCode();
                hashCode = (hashCode * 397) ^ TimePeriodEnd.GetHashCode();
                hashCode = (hashCode * 397) ^ TimeOpen.GetHashCode();
                hashCode = (hashCode * 397) ^ TimeClose.GetHashCode();
                hashCode = (hashCode * 397) ^ PriceOpen.GetHashCode();
                hashCode = (hashCode * 397) ^ PriceClose.GetHashCode();
                hashCode = (hashCode * 397) ^ PriceLow.GetHashCode();
                hashCode = (hashCode * 397) ^ PriceHigh.GetHashCode();
                hashCode = (hashCode * 397) ^ VolumeTraded.GetHashCode();
                hashCode = (hashCode * 397) ^ TradesCount.GetHashCode();
                hashCode = (hashCode * 397) ^ (Id != null ? Id.GetHashCode() : 0);
                return(hashCode);
            }
        }
        public override void Update(BaseAsset asset)
        {
            MaterialAsset materialAsset = (asset as MaterialAsset);
            var           matInfo       = AssetsLoader.LoadMaterialInfo(asset.Name);
            var           mat           = AssetsLoader.LoadMaterial(asset.Name);

            mat.PropetyBlock = new MaterialPropetyBlock()
            {
                AlbedoColor    = materialAsset.AlbedoColor,
                AlphaValue     = materialAsset.AlphaValue,
                MetallicValue  = materialAsset.MetallicValue,
                RoughnessValue = materialAsset.RoughnessValue,
                Shift          = materialAsset.Shift,
                Tile           = materialAsset.Tile,
            };
            mat.AlbedoMapAsset    = TrimEmptyTexture(materialAsset.AlbedoMapAsset);
            mat.MetallicMapAsset  = TrimEmptyTexture(materialAsset.MetallicMapAsset);
            mat.NormalMapAsset    = TrimEmptyTexture(materialAsset.NormalMapAsset);
            mat.OcclusionMapAsset = TrimEmptyTexture(materialAsset.OcclusionMapAsset);
            mat.RoughnessMapAsset = TrimEmptyTexture(materialAsset.RoughnessMapAsset);

            RendererComponent.SetMaterial(matInfo);
        }
 public virtual void Update(BaseAsset asset)
 {
 }
Esempio n. 33
0
 private Image GetEntityImage(BaseAsset entity)
 {
     return(iconList.Images[entity.GetType().Name]);
 }
 private static void ReopenIfClosed(BaseAsset item) {
     if (item.IsClosed && item.CanReactivate) {
         ReactivateAsset(item);
     }
 }