Exemple #1
0
        /// <summary>
        /// Tell the display logic (Javascript) that there has been an update to the surface.
        /// </summary>
        public void SignalSurfacePropertiesChanged()
        {
            // If we have no surface or web control, bail.
            if (ActiveSurface == null || ActiveControl == null)
            {
                return;
            }

            // If the web control is not live, skip.
            if (!ActiveControl.IsProcessCreated)
            {
                return;
            }

            /*
             * // ASYNC HACK!
             * var pSurfaceObject = new JSObject();
             * pSurfaceObject["Name"] = new JSValue(ActiveSurface.Identifier);
             * pSurfaceObject["Width"] = new JSValue(ActiveSurface.Width);
             * pSurfaceObject["Height"] = new JSValue(ActiveSurface.Height);
             * pSurfaceObject["AspectRatio"] = new JSValue(ActiveSurface.AspectRatio);
             * pSurfaceObject["Angle"] = new JSValue(ActiveSurface.Angle);
             *
             * ActiveControl.ExecuteJavascript("window.Surface = "+ToJSON(pSurfaceObject)+";");
             * //Log.Write("SignalSurfacePropertiesChanged", this.ToString(), Log.Type.AppError);
             */

            // Create a surface object.
            using (JSObject pSurface = ActiveControl.CreateGlobalJavascriptObject(Authority.APIObject_Surface))
            {
                // Say if we couldn't create the object.
                if (pSurface == null)
                {
                    Log.Write("Error setting surface properties.  Should be fixed in the next version.", this.ToString(), Log.Type.AppError);
                }

                pSurface["Name"]        = new JSValue(ActiveSurface.Identifier);
                pSurface["Width"]       = new JSValue(ActiveSurface.Width);
                pSurface["Height"]      = new JSValue(ActiveSurface.Height);
                pSurface["AspectRatio"] = new JSValue(ActiveSurface.AspectRatio);
                pSurface["Angle"]       = new JSValue(ActiveSurface.Angle);
            }

            // Call a method to say we have updated the surface properties.
            AsyncCallGlobalFunction("Surface_PropertiesChanged");
        }