private static void TicketRender(Ticket ticket) { Chunk c = ticket.Chunk; for (int z = 0; z < Chunk.Depth; z++) { for (int y = 0; y < Chunk.Height; y++) { for (int x = 0; x < Chunk.Width; x++) { if (ItemCache.Get(c[x, y, z]).Identifier != "isocrash:air") { Renderer.volumes.Add( new C_VOLUME() { rotation = new C_QUATERNION(), position = new C_VECTOR3(new Vector3D(ticket.Position.X * Chunk.Width + x, y, ticket.Position.Y + Chunk.Depth + z)), scale = new C_VECTOR3(new Vector3D(1, 1, 1)), type = volumeType.box } ); } } } } }
private void UpdateHotbarSelected(ContainerItem item, int index) { WObject wobj = PlayerEntity.PlayerHandWobject; Material material = ItemCache.AtlasMaterial; Mesh mesh = null; Item aitem; if (item == null) { aitem = ItemCache.Get <Item>("winecrash:air"); } else { aitem = item.Item; } if (aitem.Identifier == "winecrash:air") { material = Player.LocalPlayer.Entity.SkinMaterial; mesh = PlayerEntity.PlayerRightArmMesh; } else { mesh = aitem.Model; ItemDisplayName(aitem); } wobj.LocalPosition = aitem.HandPosition; wobj.LocalRotation = aitem.HandRotation; wobj.LocalScale = aitem.HandScale; MeshRenderer mr = wobj.GetModule <MeshRenderer>(); mr.Material = material; mr.Mesh = mesh; Image img = HotbarSelector.GetModule <Image>(); Vector2D min = new Vector2D(-0.0055D, 0.01D); Vector2D max = new Vector2D(0.1265, 1.0725D); double magicNumber = 0.989D; min.X += (index / 9D) * magicNumber; max.X += (index / 9D) * magicNumber; img.MinAnchor = min; img.MaxAnchor = max; }
///// <summary> ///// Проверка доступности ссылки ///// </summary> ///// <param name="link"></param> ///// <returns></returns> //private bool IsLinkAlive(ItemLink link) //{ // string path = WebDavPath.Combine(link.MapTo, link.Name); // try // { // var entry = _cloud.GetItem(path).Result; // return entry != null; // } // catch (AggregateException e) // when ( // let's check if there really no file or just other network error // e.InnerException is WebException we && // (we.Response as HttpWebResponse)?.StatusCode == HttpStatusCode.NotFound // ) // { // return false; // } //} /// <summary> /// /// </summary> /// <param name="path"></param> /// <param name="doResolveType">Resolving file/folder type requires addition request to cloud</param> /// <returns></returns> public async Task <Link> GetItemLink(string path, bool doResolveType = true) { var cached = _itemCache.Get(path); if (null != cached) { return((Link)cached); } //TODO: subject to refact string parent = path; ItemLink wp; string right = string.Empty; do { string name = WebDavPath.Name(parent); parent = WebDavPath.Parent(parent); wp = _itemList.Items.FirstOrDefault(ip => parent == ip.MapTo && name == ip.Name); if (null == wp) { right = WebDavPath.Combine(name, right); } } while (parent != WebDavPath.Root && null == wp); if (null == wp) { return(null); } string addhref = string.IsNullOrEmpty(right) ? string.Empty : '/' + Uri.EscapeDataString(right.TrimStart('/')); var link = new Link(wp, path, wp.Href + addhref); //resolve additional link properties, e.g. OriginalName, ItemType, Size if (doResolveType) { await ResolveLink(link); } _itemCache.Add(link.FullPath, link); return(link); }
private IEntry CacheGetEntry(string path, int requiredDepth) { var cached = _itemCache.Get(path); if (null != cached) { //TODO: and what if depth > 1 ? return(cached); // if (cached is File || requiredDepth <= 1) //return cached; // if (cached is Folder cfolder) // { // if (cfolder.Folders.All(f => _itemCache.Get(f.FullPath) != null)) // return cfolder; // } } return(null); }
void SetItem(ProjectBudgetLineLocal rec) { var item = (InvItem)ItemCache.Get(rec._Item); if (item == null) { return; } if (item._CostPrice != 0d) { if (rec._Qty == 0) { rec.Qty = 1d; } rec.CostPrice = item._CostPrice; } double price = 0d; int pg = PriceGrp; if (pg == 3) { price = item._SalesPrice3; if (price == 0) { pg = 2; } } if (pg == 2) { price = item._SalesPrice2; } if (price == 0) { price = item._SalesPrice1; } if (price != 0d) { if (rec._Qty == 0) { rec.Qty = 1d; } rec.SalesPrice = price; } if (item._Dim1 != null) { rec.Dimension1 = item._Dim1; } if (item._Dim2 != null) { rec.Dimension2 = item._Dim2; } if (item._Dim3 != null) { rec.Dimension3 = item._Dim3; } if (item._Dim4 != null) { rec.Dimension4 = item._Dim4; } if (item._Dim5 != null) { rec.Dimension5 = item._Dim5; } if (item._PrCategory != null) { rec.PrCategory = item._PrCategory; } if (item._PayrollCategory != null) { rec.PayrollCategory = item._PayrollCategory; PayrollCat(rec, false); } if (item._Unit != 0 && rec._Unit != item._Unit) { rec._Unit = item._Unit; rec.NotifyPropertyChanged("Unit"); } globalEvents.NotifyRefreshViewer(NameOfControl, item); }
private IEntry CacheGetEntry(string path) { var cached = _itemCache.Get(path); return(cached); }
///// <summary> ///// Get list of files and folders from account. ///// </summary> ///// <param name="path">Path in the cloud to return the list of the items.</param> ///// <param name="itemType">Unknown, File/Folder if you know for sure</param> ///// <param name="resolveLinks">True if you know for sure that's not a linked item</param> ///// <returns>List of the items.</returns> public virtual async Task <IEntry> GetItemAsync(string path, ItemType itemType = ItemType.Unknown, bool resolveLinks = true) { path = WebDavPath.Clean(path); var cached = _itemCache.Get(path); if (null != cached) { return(cached); } //TODO: subject to refact!!! var ulink = resolveLinks ? await _linkManager.GetItemLink(path) : null; // bad link detected, just return stub // cause client cannot, for example, delete it if we return NotFound for this item if (ulink != null && ulink.IsBad) { var res = ulink.ToBadEntry(); _itemCache.Add(res.FullPath, res); return(res); } if (itemType == ItemType.Unknown && ulink != null) { itemType = ulink.ItemType; } // TODO: cache (parent) folder for file //if (itemType == ItemType.File) //{ // var cachefolder = datares.ToFolder(path, ulink); // _itemCache.Add(cachefolder.FullPath, cachefolder); // //_itemCache.Add(cachefolder.Files); //} var entry = await Account.RequestRepo.FolderInfo(path, ulink); if (null == entry) { return(null); } if (itemType == ItemType.Unknown) { itemType = entry is Folder ? ItemType.Folder : ItemType.File; } // fill folder with links if any if (itemType == ItemType.Folder && entry is Folder folder) { var flinks = _linkManager.GetItems(folder.FullPath); if (flinks.Any()) { //var z = flinks.Where(f => f.IsFile).Skip(1).ToList(); // Take(15).ToList(); foreach (var flink in flinks) { string linkpath = WebDavPath.Combine(folder.FullPath, flink.Name); if (!flink.IsFile) { folder.Folders.Add(new Folder(0, linkpath) { CreationTimeUtc = flink.CreationDate ?? DateTime.MinValue }); } else { if (folder.Files.All(inf => inf.FullPath != linkpath)) { var newfile = new File(linkpath, flink.Size) { PublicLink = flink.Href, }; if (flink.CreationDate != null) { newfile.LastWriteTimeUtc = flink.CreationDate.Value; } folder.Files.Add(newfile); } } } } } _itemCache.Add(entry.FullPath, entry); if (entry is Folder cfolder) { _itemCache.Add(cfolder.Files.Select(f => new KeyValuePair <string, IEntry>(f.FullPath, f))); } return(entry); }