/// <summary> /// Construct a new surface. /// </summary> /// <param name="sIdentifier">The unique identifier for this surface. Cannot be null. If this is not unique, it will not be checked until the surface is registered with an authority.</param> public Surface(String sIdentifier) { // If the identifier is not valid, throw an error. if (sIdentifier == null || sIdentifier.Length == 0) { throw new Exception("Surface identifier cannot be empty."); } // Otherwise set the value. HOWEVER.. this is not authorised by the authority. It will be checked on registration. this.Authority_SetIdentifier(sIdentifier); // Load the debug for this surface. //pDebugImageControl = new Image(); //pDebugImageControl.Source = new BitmapImage(new Uri("pack://application:,,,/UbiDisplays;component/Interface/Images/DebugImage.png")); // Generate a key to access the projected surface. sProjectionDisplayKey = System.Guid.NewGuid().ToString(); // A surface control. pSurfaceContent = new SurfaceView(); pSurfaceContent.ShowDebug = true; // Create a projected display for this surface. pProjectionDisplay = ProjectionRenderer.AddDisplay(sProjectionDisplayKey, pSurfaceContent);//, pDebugImageControl); pProjectionDisplay.Visible = true; }
/// <summary> /// Called by the authority to signal that this surface has been deleted. /// </summary> internal void Authority_Delete() { // Remove the projection display. if (pProjectionDisplay != null) { pProjectionDisplay.Visible = false; ProjectionRenderer.RemoveDisplay(pProjectionDisplay); pProjectionDisplay = null; } // Remove the reference to the active display. if (ActiveDisplay != null) { Authority_DetachDisplay(ActiveDisplay); throw new Exception("Error deleting surface. Display still active."); } // Free any resources. this.DeleteResources(); // Remove the debug image. if (pSurfaceContent != null) { pSurfaceContent.Children.Clear(); pSurfaceContent = null; } //pDebugImageControl = null; // Set the deleted flag. bDeleted = true; // Deletion event. if (OnDeleted != null) { OnDeleted(this); } }