Esempio n. 1
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);
            }
        }
Esempio n. 2
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);
            }
        }
Esempio n. 3
0
        private void LoadSWF(Device tDevice)
        {
            if (_FNUIFlashPlayer != null)
            {
                int tTimer = 0;

                while (_DisposeAllowed == false && tTimer < Int32.MaxValue)
                {
                    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);
            }

            //Debug.WriteLine("Create Player");

            //Debug.WriteLine("Create Player :: CreateFlashPlayer");
            _FNUIFlashPlayer = _FNUIMain.CreateFlashPlayer();

            //Debug.WriteLine("Create Player :: SetDelegates");
            _FNUIFlashPlayer.SetDelegates(ResizeTexture, LockRectangle, UnlockRectangle, AddDirtyRectangle);
            //Debug.WriteLine("Create Player :: SetEventNotifier");
            _FNUIFlashPlayer.SetEventNotifier(EventNotifier);

            string tPath = FSWFPath[0];

            if (System.IO.File.Exists(tPath) == false)
            {
                //System.Windows.Forms.MessageBox.Show("Invalid swf path: " + tPath);
                return;
            }

            //Debug.WriteLine("Create Player :: LoadFlashHeader");
            _FNUIMain.LoadFlashHeader(tPath, ref _Width, ref _Height, ref _FrameRate, ref _Frames);

            //FHost.Log(TLogType.Debug, "swf Width: " + _Width);
            //FHost.Log(TLogType.Debug, "swf Height: " + _Height);
            //FHost.Log(TLogType.Debug, "swf Framerate: " + _FrameRate);
            //FHost.Log(TLogType.Debug, "swf Frames: " + _Frames);

            FFrameRateOutput[0] = (int)_FrameRate;

            var pool  = Pool.Managed;
            var usage = Usage.None;

            if (tDevice is DeviceEx)
            {
                pool  = Pool.Default;
                usage = Usage.Dynamic;
            }

            _Texture1 = new Texture(tDevice, _Width, _Height, 1, usage, Format.A8R8G8B8, pool);
            _Texture2 = new Texture(tDevice, _Width, _Height, 1, usage, Format.A8R8G8B8, pool);

            try
            {
                //Debug.WriteLine("Create Player :: CreateFlashControl");
                _FNUIFlashPlayer.CreateFlashControl(2, _Width, _Height, (IntPtr)0, (IntPtr)_BufferMode, false, false);

                _FNUIFlashPlayer.DisableFlashRendering(true);

                //Debug.WriteLine("Create Player :: LoadMovie");
                _FNUIFlashPlayer.LoadMovie(tPath);
            }
            catch (Exception ex)
            {
                FLogger.Log(LogType.Debug, "Exception in FantastiqUI: " + ex.Message);

                if (ex.InnerException != null)
                {
                    FLogger.Log(LogType.Debug, "inner: " + ex.InnerException.Message);
                }
            }
        }