Example #1
0
        // Dispose(bool disposing) executes in two distinct scenarios.
        // If disposing equals true, the method has been called directly
        // or indirectly by a user's code. Managed and unmanaged resources
        // can be disposed.
        // If disposing equals false, the method has been called by the
        // runtime from inside the finalizer and you should not reference
        // other objects. Only unmanaged resources can be disposed.
        protected virtual void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!FDisposed)
            {
                if (disposing)
                {
                    //Debug.WriteLine("Dispose");

                    if (_FNUIFlashPlayer != null)
                    {
                        //Debug.WriteLine("Remove Player");

                        int tTimer = 0;

                        while (_DisposeAllowed == false && tTimer < Int32.MaxValue)
                        {
                            tTimer++;
                        }

                        //Debug.WriteLine("Timer :: " + tTimer);


                        //Debug.WriteLine("Remove Player :: DisableFlashRendering");
                        _FNUIFlashPlayer.DisableFlashRendering(true);

                        _FNUIFlashPlayer.SetDelegates(null, null, null, null);
                        _FNUIFlashPlayer.SetEventNotifier(null);

                        //Debug.WriteLine("Remove Player :: DeleteFlashPlayer");
                        _FNUIMain.DeleteFlashPlayer(_FNUIFlashPlayer);
                    }

                    _FNUIMain.Dispose();

                    _FNUIFlashPlayer = null;
                    _FNUIMain        = null;

                    GC.Collect();
                    GC.SuppressFinalize(this);
                }
                // Release unmanaged resources. If disposing is false,
                // only the following code is executed.

                //FHost.Log(TLogType.Debug, "PluginMeshTemplate is being deleted");

                // Note that this is not thread safe.
                // Another thread could start disposing the object
                // after the managed resources are disposed,
                // but before the disposed flag is set to true.
                // If thread safety is necessary, it must be
                // implemented by the client.
            }
            FDisposed = true;
        }
Example #2
0
        /// <summary>Initializes DirectX graphics</summary>
        /// <returns>true on success, false on failure</returns>
        public bool InitializeGraphics()
        {
            PresentParameters tPresentParas = new PresentParameters();

            tPresentParas.SwapEffect = SwapEffect.Discard;
            tPresentParas.Windowed   = true;

            try
            {
                _Device = new Device(0, DeviceType.Hardware, this.Handle, CreateFlags.SoftwareVertexProcessing, tPresentParas);

                //create main fui class
                _FNUIMain = new FNUIMain();
                _FNUIMain.CreateUI("");


                float tFramerate = 0;
                int   tFrames    = 0;

                _FNUIMain.LoadFlashHeader(_Path, ref _Width, ref _Height, ref tFramerate, ref tFrames);

                this.ClientSize = new Size(_Width, _Height);

                _Vertices    = new CustomVertex.TransformedColoredTextured[4];
                _Vertices[0] = new CustomVertex.TransformedColoredTextured(0, 0, 0, 1.0f, Color.White.ToArgb(), 0.0f, 0.0f);
                _Vertices[1] = new CustomVertex.TransformedColoredTextured(_Width - 1, 0, 0, 1.0f, Color.White.ToArgb(), 1.0f, 0.0f);
                _Vertices[2] = new CustomVertex.TransformedColoredTextured(_Width - 1, _Height - 1, 0, 1.0f, Color.White.ToArgb(), 1.0f, 1.0f);
                _Vertices[3] = new CustomVertex.TransformedColoredTextured(0, _Height - 1, 0, 1.0f, Color.White.ToArgb(), 0.0f, 1.0f);


                _Texture1 = new Texture(_Device, _Width, _Height, 1, 0, Format.A8R8G8B8, Pool.Managed);
                _Texture2 = new Texture(_Device, _Width, _Height, 1, 0, Format.A8R8G8B8, Pool.Managed);



                //create a new flash player instance
                _FNUIFlashPlayer = _FNUIMain.CreateFlashPlayer();
                //set the callback delegates and the event notifier
                _FNUIFlashPlayer.SetDelegates(ResizeTexture, LockRectangle, UnlockRectangle, AddDirtyRectangle);
                _FNUIFlashPlayer.SetEventNotifier(EventNotifier);
                //create the flash control at resolution 512x512 and with tex1 and tex2 as textures,
                //eg. doublebuffering, for singlebuffering, just provide 1 texture
                _FNUIFlashPlayer.CreateFlashControl(0, _Width, _Height, (IntPtr)0, (IntPtr)1, false);
                //load a movie
                _FNUIFlashPlayer.LoadMovie(_Path);

                return(true);
            }
            catch (DirectXException)
            {
                return(false);
            }
        }
Example #3
0
        public DrawFlash(IPluginHost host)
        {
            host.CreateRenderStateInput(TSliceMode.Single, TPinVisibility.True, out FRenderStatePin);
            FRenderStatePin.Order = -2;
            host.CreateTransformInput("Transform", TSliceMode.Single, TPinVisibility.True, out FTransformIn);
            FTransformIn.Order = -1;
            host.CreateLayerOutput("Layer", TPinVisibility.True, out FLayerOutput);
            FLayerOutput.Order = -1;

            FLastKeyState = new List <int>();

            _FNUIMain = new FNUIMain();
            _FNUIMain.SetLicenseKey(0, LICENSENAME, LICENSENUMBER);
            _FNUIMain.CreateUI("");
        }
Example #4
0
        /// <summary>Initializes DirectX graphics</summary>
        /// <returns>true on success, false on failure</returns>
        public bool InitializeGraphics()
        {
            PresentParameters pp = new PresentParameters();

            pp.SwapEffect = SwapEffect.Discard;
            //pp.IsWindowed = true;
            pp.Windowed = true;
            try
            {
                m_device = new Device(0, DeviceType.Hardware, this.Handle, CreateFlags.SoftwareVertexProcessing, pp);

                verts    = new CustomVertex.TransformedColoredTextured[4];
                verts[0] = new CustomVertex.TransformedColoredTextured(
                    0, 0, 0, 1.0f, Color.White.ToArgb(), 0.0f, 0.0f);
                verts[1] = new CustomVertex.TransformedColoredTextured(
                    511, 0, 0, 1.0f, Color.White.ToArgb(), 1.0f, 0.0f);
                verts[2] = new CustomVertex.TransformedColoredTextured(
                    511, 511, 0, 1.0f, Color.White.ToArgb(), 1.0f, 1.0f);
                verts[3] = new CustomVertex.TransformedColoredTextured(
                    0, 511, 0, 1.0f, Color.White.ToArgb(), 0.0f, 1.0f);

                tex1 = new Texture(m_device, 512, 512, 1, 0, Format.A8R8G8B8, Pool.Managed);
                tex2 = new Texture(m_device, 512, 512, 1, 0, Format.A8R8G8B8, Pool.Managed);
                //create main fui class
                fmain = new FNUIMain();
                fmain.CreateUI("");
                //create a new flash player instance
                fplayer = fmain.CreateFlashPlayer();
                //set the callback delegates and the event notifier
                fplayer.SetDelegates(ResizeTexture, GetTextureSurfacePointer, ReleaseTextureSurfacePointer, DirtyRect);
                fplayer.SetEventNotifier(EventNotifier);
                //create the flash control at resolution 512x512 and with tex1 and tex2 as textures,
                //eg. doublebuffering, for singlebuffering, just provide 1 texture
                fplayer.CreateFlashControl(0, 512, 512, (IntPtr)0, (IntPtr)1, true);
                //load a movie to test
                fplayer.LoadMovie(Application.StartupPath + "\\SiemensContent\\index.swf");

                return(true);
            }
            catch (DirectXException)
            {
                return(false);
            }
        }