/// <summary> /// Encapsulates a layer attached to a loading thread /// </summary> /// <param name="devIf"></param> /// <param name="position"></param> /// <param name="dimensions"></param> /// <param name="id"></param> /// <param name="dependants"></param> /// <param name="dependancies"></param> public LoadingLayer(DeviceInterface devIf, Point position, Size dimensions, string id, IResource[] dependants, ISharableResource[] dependancies) : base(devIf, position, dimensions, id, dependants, dependancies) { AddItem(LayoutManager.AlignItem(progressBar = new GUIProgressBar(new Point(0, 0), new Size(200, 20), Color.Blue), LayoutRules.Positioning.Center, LayoutRules.Positioning.Center)); progressBar.Progress = 0; }
public void Checkin(ISharableResource rz) { SharableResource srz = (SharableResource)rz; srz.RemoveUser(); lock (srz) { if (srz.UsersCount == 0) { resources.Remove(srz.Name); } } }
public SimpleGUILayer(DeviceInterface devIf, Point position, Size dimensions, string id, IResource[] dependants, ISharableResource[] dependancies) : base(id, dependants, dependancies) { this.devIf = devIf; device = devIf.Device; this.position = position; this.dimensions = dimensions; enabled = true; visible = true; itemsList = new List<GUILayerItem>(); itemsLayout = new QuadTree<GUILayerItem>(dimensions.Width, dimensions.Height); checkedOutResources = new List<ISharableResource>(); layoutManager = new LayoutManager(); }
public void Checkin(object resource, string name, out ISharableResource rz) { ResourceSet.SharableResource sRz = new SharableResource(name, this, resource); resources.Add(name, sRz); rz = sRz; }
public IResource GetResource(string url, bool allowShare, ref List <ISharableResource> checkedOutList, out IResource[] unhandledDependants, out IResource[] unhandledDependancies) { // TODO: break-up url here Uri uri = new Uri(url); if (uri.IsFile) { // look for existing ISharableResource sRz = resourceSet.Checkout(url); if (sRz != null) { if (sRz.Value is IResource) { checkedOutList.Add(sRz); unhandledDependants = null; unhandledDependancies = null; return((IResource)sRz.Value); } // throw away resourceSet.Checkin(sRz); } // load up from fresh IResource[] dependants, dependancies; string realRzId; IResource rz = cdi.ResourceLoader.LoadResource(uri, this, out dependants, out dependancies, out realRzId); // share if allowed if (allowShare && rz != null) { resourceSet.Checkin(rz, realRzId, out sRz); checkedOutList.Add(sRz); // deal with dependants & dependancies if (dependants != null) { foreach (IResource item in dependants) { resourceSet.Checkin(item, item.Id, out sRz); checkedOutList.Add(sRz); } } if (dependancies != null) { foreach (IResource item in dependancies) { resourceSet.Checkin(item, item.Id, out sRz); checkedOutList.Add(sRz); } } unhandledDependants = null; unhandledDependancies = null; } else { unhandledDependants = dependants; unhandledDependancies = dependancies; } // double check we have right rz if (realRzId != null) { rz = (IResource)resourceSet.PeekRz(url).Value; } return(rz); } unhandledDependants = null; unhandledDependancies = null; return(null); }
/// <summary> /// Initializes a new instance of the Resource class. /// </summary> /// <param name="id"></param> /// <param name="dependants"></param> /// <param name="sharedDependancies"></param> public Resource(string id, IResource[] dependants, ISharableResource[] sharedDependancies) { this.id = id; this.dependants = dependants; this.sharedDependancies = sharedDependancies; }
public void Checkin(ISharableResource rz) { SharableResource srz = (SharableResource)rz; srz.RemoveUser(); lock (srz) { if (srz.UsersCount == 0) resources.Remove(srz.Name); } }
public void Checkin(object resource, string name, out ISharableResource rz) { ResourceSet.SharableResource sRz = new SharableResource(name, this, resource); resources.Add(name, sRz); rz = sRz; }