public void Reorder(Projection Projection) { ProjectionData data = GetProjectionData(Projection); if (data != null) { //Remove ourself from the list Projections.Remove(data); //Insert ourself back in the correct position for (int i = 0; i < Projections.Count; i++) { if (Projection.Priority < Projections[i].projection.Priority) { Projections.Insert(i, data); return; } } //If no correct position found add ourself to the end Projections.Add(data); //Reorder renderers OrderRenderers(); } }
//Registration public bool Register(ProjectionRenderer Instance) { if (Instance != null) { //Determine our projection Projection projection = Instance.Projection; //Check if our projection has been registered ProjectionData data = GetProjectionData(projection); if (data != null) { data.Add(Instance); return(true); } else { //Create and register our projection data data = new ProjectionData(projection); data.Add(Instance); //If we are lower priority than a projection in the list, insert ourself before them for (int i = 0; i < Projections.Count; i++) { if (projection.Priority < Projections[i].projection.Priority) { Projections.Insert(i, data); return(true); } } //If we are higher priority than everything in the list, just add ourself Projections.Add(data); return(true); } } return(false); }