示例#1
0
        /// <summary>
        /// Handle a request.
        /// </summary>
        /// <param name="pDisplay">The display which called this function.</param>
        /// <param name="pSurface">The surface which this display is hosted on.</param>
        /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param>
        /// <returns>True if the request was processed sucessfully.  False if there was an error.</returns>
        public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments)
        {
            // Get the first target.
            var pTarget1 = Authority.FindSurface(dArguments.GetValueOrDefault("target1", ""));

            if (pTarget1 == null)
            {
                Log.Write("SwapTargetDisplay: Missing valid 'target1' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return(false);
            }

            // Get the first target.
            var pTarget2 = Authority.FindSurface(dArguments.GetValueOrDefault("target2", ""));

            if (pTarget2 == null)
            {
                Log.Write("SwapTargetDisplay: Missing valid 'target2' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return(false);
            }

            // Check the surface this view is on is not our target.
            if (pTarget1 == pTarget2)
            {
                Log.Write("SwapTargetDisplay: Surface targets are the same.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return(false);
            }

            // Store references to the displays.
            Display pDisplay1 = pTarget1.ActiveDisplay;
            Display pDisplay2 = pTarget2.ActiveDisplay;

            // Remove them both from surfaces.
            if (pDisplay1 != null)
            {
                Authority.RemoveDisplay(pDisplay1);
            }
            if (pDisplay2 != null)
            {
                Authority.RemoveDisplay(pDisplay2);
            }

            // Re-open them on the other surfaces.
            if (pDisplay1 != null)
            {
                Authority.ShowDisplay(pDisplay1, pTarget2);
            }
            if (pDisplay2 != null)
            {
                Authority.ShowDisplay(pDisplay2, pTarget1);
            }

            // Boom.
            return(true);
        }
示例#2
0
        /// <summary>
        /// Handle a request.
        /// </summary>
        /// <param name="pDisplay">The display which called this function.</param>
        /// <param name="pSurface">The surface which this display is hosted on.</param>
        /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param>
        /// <returns>True if the request was processed sucessfully.  False if there was an error.</returns>
        public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments)
        {
            // Find the new surface.
            var pTargetSurface = Authority.FindSurface(dArguments.GetValueOrDefault("target", ""));

            if (pTargetSurface == null)
            {
                Log.Write("Cannot move display to target surface.  Missing valid 'target' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return(false);
            }

            // Check the surface this view is on is not our target.
            if (pTargetSurface == pDisplay.ActiveSurface)
            {
                Log.Write("Cannot move display to target surface because it is already there.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return(false);
            }

            // If the new surface is occupied, bail.
            if (pTargetSurface.ActiveDisplay != null)
            {
                Log.Write("Cannot move display to target surface because it already has a display on it.", this.ToString(), Log.Type.DisplayWarning);
                return(false);
            }

            // Do we want to force a reload of everything with the move.
            var bForceReload = dArguments.GetValueOrDefault("force_reload", false);

            // If we want to force a reload.
            if (bForceReload)
            {
                Authority.DeleteDisplay(pDisplay);
                Authority.ShowDisplay(new Display(pDisplay.LoadInstruction, pDisplay.RenderResolution), pTargetSurface);
                return(true);
            }

            // If not.
            else
            {
                // Just detach it from one and move to the other.
                Authority.MoveDisplay(pDisplay, pTargetSurface);
                return(true);
            }
        }
示例#3
0
        /// <summary>
        /// Handle a request.
        /// </summary>
        /// <param name="pDisplay">The display which called this function.</param>
        /// <param name="pSurface">The surface which this display is hosted on.</param>
        /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param>
        /// <returns>True if the request was processed sucessfully.  False if there was an error.</returns>
        public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments)
        {
            // Find the new surface.
            var sLoad = dArguments.GetValueOrDefault("load", "");

            if (sLoad == null || sLoad == "")
            {
                Log.Write("Cannot open display.  Missing valid 'load' parameter. e.g. 'http://mysite.com'", pDisplay.ToString(), Log.Type.DisplayWarning);
                return(false);
            }

            // Find the new surface.
            var pTargetSurface = Authority.FindSurface(dArguments.GetValueOrDefault("target", ""));

            if (pTargetSurface == null)
            {
                Log.Write("Cannot open display on target surface.  Missing valid 'target' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return(false);
            }

            // Do we want to override if occupied?
            var bOverride = dArguments.GetValueOrDefault("override", false);

            // If a display is already on the target surface.
            if (pTargetSurface.ActiveDisplay != null)
            {
                // Do we close it?
                if (bOverride)
                {
                    Authority.DeleteDisplay(pTargetSurface.ActiveDisplay);
                }

                // Or do we respect it's right to life!
                else
                {
                    Log.Write("Cannot open display on target surface.  Surface is already occupied.", pDisplay.ToString(), Log.Type.DisplayWarning);
                    return(false);
                }
            }

            // Create the new display.
            Authority.ShowDisplay(new Display(sLoad), pTargetSurface);
            return(true);
        }
示例#4
0
        /// <summary>
        /// Handle a request.
        /// </summary>
        /// <param name="pDisplay">The display which called this function.</param>
        /// <param name="pSurface">The surface which this display is hosted on.</param>
        /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param>
        /// <returns>True if the request was processed sucessfully.  False if there was an error.</returns>
        public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments)
        {
            // Find the new surface.
            var pTargetSurface = Authority.FindSurface(dArguments.GetValueOrDefault("target", ""));

            if (pTargetSurface == null)
            {
                Log.Write("Cannot close display on target surface.  Missing valid 'target' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return(false);
            }

            // Close it, if open.
            if (pTargetSurface.ActiveDisplay != null)
            {
                Authority.DeleteDisplay(pTargetSurface.ActiveDisplay);
                return(true);
            }

            // Return false, nothing to do.
            return(false);
        }
示例#5
0
        /// <summary>
        /// Handle a request.
        /// </summary>
        /// <param name="pDisplay">The display which called this function.</param>
        /// <param name="pSurface">The surface which this display is hosted on.</param>
        /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param>
        /// <returns>True if the request was processed sucessfully.  False if there was an error.</returns>
        public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments)
        {
            // Find the new surface.
            var pTargetSurface = Authority.FindSurface(dArguments.GetValueOrDefault("target", ""));

            if (pTargetSurface == null)
            {
                Log.Write("Cannot swap display to target surface.  Missing valid 'target' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return(false);
            }

            // Check the surface this view is on is not our target.
            if (pTargetSurface == pDisplay.ActiveSurface)
            {
                Log.Write("Cannot swap display to target surface because it is already there.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return(false);
            }

            // If the target surface has a display, get a reference and remove it.
            Display pOtherView = pTargetSurface.ActiveDisplay;

            if (pOtherView != null)
            {
                Authority.RemoveDisplay(pOtherView);
            }

            // Remove this display from this surface and put it on the target surface.
            Authority.RemoveDisplay(pDisplay);
            Authority.ShowDisplay(pDisplay, pTargetSurface);

            // Now put the other display on the original surface.
            if (pOtherView != null)
            {
                Authority.ShowDisplay(pOtherView, pSurface);
            }

            // Boom.
            return(true);
        }
示例#6
0
        /// <summary>
        /// Set the surface which we want to update
        /// </summary>
        /// <param name="sSurface"></param>
        public void SetRelativeSurface(String sSurface)
        {
            // If we have a current surface, remove it.
            if (RelativeSurface != null)
            {
                RelativeSurface.OnSurfacePropertiesUpdated -= Surface_OnPropertiesChanged;
                RelativeSurface = null;
            }

            // Find the surface.
            var pSurface = Authority.FindSurface(sSurface);

            if (pSurface == null)
            {
                throw new Exception("Cannot create Cuboid because it has no relative surface.");
            }

            // Store the surface and listen for changes.
            RelativeSurface = pSurface;
            RelativeSurface.OnSurfacePropertiesUpdated += Surface_OnPropertiesChanged;

            // Setup based on bounding corners.
            this.SetBoundingCorners(pSurface.SensorSpace[Surface.BOTTOMLEFT_INDEX], pSurface.SensorSpace[Surface.TOPLEFT_INDEX], pSurface.SensorSpace[Surface.BOTTOMRIGHT_INDEX], pSurface.SensorSpace[Surface.TOPRIGHT_INDEX]);
        }
示例#7
0
        /// <summary>
        /// Handle a request.
        /// </summary>
        /// <param name="pDisplay">The display which called this function.</param>
        /// <param name="pSurface">The surface which this display is hosted on.</param>
        /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param>
        /// <returns>True if the request was processed sucessfully.  False if there was an error.</returns>
        public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments)
        {
            // Get the callback.
            var sCallback = dArguments.GetValueOrDefault("callback", "");

            if (sCallback == null || sCallback == "")
            {
                Log.Write("Please specify a 'callback' value.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return(false);
            }

            // Get the list of surface names we want to find information for.
            var lSurfaces = dArguments.GetValueOrDefault("surfaces", new JSValue[] { });

            if (lSurfaces == null || lSurfaces.Length == 0)
            {
                Log.Write("Please specify a 'surfaces' value. i.e. ['Surface 0', 'Surface 1']", pDisplay.ToString(), Log.Type.DisplayWarning);
                return(false);
            }

            // Create an object to store the information about each surface.
            JSObject dOut = new JSObject();

            foreach (var jsSurf in lSurfaces)
            {
                // If it is a string, find the surface.
                var sSurfName = (jsSurf.IsString) ? (String)jsSurf : null;
                if (sSurfName == null)
                {
                    continue;
                }

                // Find the surface.
                var pSurf = Authority.FindSurface(sSurfName);
                if (pSurf == null)
                {
                    continue;
                }

                // Otherwise, get the information about it.
                var jsSurfObj = new JSObject();
                dOut[pSurf.Identifier] = jsSurfObj;

                // Surface properties.
                jsSurfObj["Name"]        = new JSValue(pSurf.Identifier);
                jsSurfObj["Width"]       = new JSValue(pSurf.Width);
                jsSurfObj["Height"]      = new JSValue(pSurf.Height);
                jsSurfObj["AspectRatio"] = new JSValue(pSurf.AspectRatio);
                jsSurfObj["Angle"]       = new JSValue(pSurf.Angle);

                // Add world coordinates.
                var pWorld = new JSObject();
                pWorld["topleft"]     = JSExtensions.MakeCoordinate(pSurf.SensorSpace[Surface.TOPLEFT_INDEX]);
                pWorld["topright"]    = JSExtensions.MakeCoordinate(pSurf.SensorSpace[Surface.TOPRIGHT_INDEX]);
                pWorld["bottomleft"]  = JSExtensions.MakeCoordinate(pSurf.SensorSpace[Surface.BOTTOMLEFT_INDEX]);
                pWorld["bottomright"] = JSExtensions.MakeCoordinate(pSurf.SensorSpace[Surface.BOTTOMRIGHT_INDEX]);
                pWorld["normal"]      = JSExtensions.MakeCoordinate(pSurf.Plane.Normal);
                jsSurfObj["World"]    = pWorld;

                // Add kinect coordinates.
                var pKinect = new JSObject();
                pKinect["topleft"]     = JSExtensions.MakeCoordinate(pSurf.KinectSpace[Surface.TOPLEFT_INDEX]);
                pKinect["topright"]    = JSExtensions.MakeCoordinate(pSurf.KinectSpace[Surface.TOPRIGHT_INDEX]);
                pKinect["bottomleft"]  = JSExtensions.MakeCoordinate(pSurf.KinectSpace[Surface.BOTTOMLEFT_INDEX]);
                pKinect["bottomright"] = JSExtensions.MakeCoordinate(pSurf.KinectSpace[Surface.BOTTOMRIGHT_INDEX]);
                pKinect["width"]       = 320;
                pKinect["height"]      = 240;
                jsSurfObj["Kinect"]    = pKinect;
            }

            // Dispatch it back on the callback.
            pDisplay.AsyncCallGlobalFunction(sCallback, dOut);
            return(true);
        }
示例#8
0
        /// <summary>
        /// Handle a request.
        /// </summary>
        /// <param name="pDisplay">The display which called this function.</param>
        /// <param name="pSurface">The surface which this display is hosted on.</param>
        /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param>
        /// <returns>True if the request was processed sucessfully.  False if there was an error.</returns>
        public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments)
        {
            // Find the new surface.
            var pCurrentSurface = Authority.FindSurface(dArguments.GetValueOrDefault("source", ""));

            if (pCurrentSurface == null)
            {
                Log.Write("Cannot move target display to target surface.  Missing valid 'source' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return(false);
            }

            // Get the target display.
            var pCurrentDisplay = pCurrentSurface.ActiveDisplay;

            if (pCurrentDisplay == null)
            {
                Log.Write("Cannot move target display to target surface.  Source surface has no display.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return(false);
            }

            // Find the new surface.
            var pTargetSurface = Authority.FindSurface(dArguments.GetValueOrDefault("dest", ""));

            if (pTargetSurface == null)
            {
                Log.Write("Cannot move target display to target surface.  Missing valid 'dest' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return(false);
            }

            // Check the surface this view is on is not our target.
            if (pTargetSurface == pCurrentSurface)
            {
                Log.Write("Cannot move target display to target surface because it is already there.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return(false);
            }

            // If the new surface is occupied, bail.
            if (pTargetSurface.ActiveDisplay != null)
            {
                Log.Write("Cannot move target display to target surface because it already has a display on it.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return(false);
            }

            // Do we want to close the display on the destination?
            var bOverride = dArguments.GetValueOrDefault("override", false);

            // If a display is already on the target surface.
            if (pTargetSurface.ActiveDisplay != null)
            {
                // Do we close it?
                if (bOverride)
                {
                    Authority.DeleteDisplay(pTargetSurface.ActiveDisplay);
                }

                // Or do we respect it's right to life!
                else
                {
                    Log.Write("Cannot move target display to target surface.  Surface is already occupied.", pDisplay.ToString(), Log.Type.DisplayWarning);
                    return(false);
                }
            }

            // Do we want to force a reload of everything with the move.
            var bForceReload = dArguments.GetValueOrDefault("force_reload", false);

            // If we want to force a reload.
            if (bForceReload)
            {
                Authority.DeleteDisplay(pCurrentDisplay);
                Authority.ShowDisplay(new Display(pCurrentDisplay.LoadInstruction, pCurrentDisplay.RenderResolution), pTargetSurface);
                return(true);
            }

            // If not.
            else
            {
                // Just detach it from one and move to the other.
                Authority.MoveDisplay(pCurrentDisplay, pTargetSurface);
                return(true);
            }
        }