private Flash(Game game, IServiceProvider services, FlashDocument document, int surfaceWidth, int surfaceHeight) : base(null) { if (document == null) throw new ArgumentNullException("document"); if (services == null) throw new ArgumentNullException("services"); ISystemServices system = (ISystemServices)services.GetService(typeof(ISystemServices)); if (system == null) throw new InvalidOperationException("Flash can be used only with ISystemServices registered!"); _surface = system.VectorDevice.CreateSurface(surfaceWidth, surfaceHeight, SurfaceFormat.Color); Root = new RootMovieClip(document, system); SurfaceSize = new Vector2(surfaceWidth, surfaceHeight); SizeInTwips = new Vector2(document.Width, document.Height); }
public void Close() { try { instance.Dispose(); document.Dispose(); } catch (Exception) { } finally { document = null; instance = null; } }
public Flash(IServiceProvider services, FlashDocument document, int surfaceWidth, int surfaceHeight) : this(null, services, document, surfaceWidth, surfaceHeight) { }
public Flash(Game game, FlashDocument document, int surfaceWidth, int surfaceHeight) : this(game, game.Services, document, surfaceWidth, surfaceHeight) { }
public bool Open(string file) { try { using (var fs = new FileStream(file, FileMode.Open)) document = new FlashDocument("document", new XnaFlash.Swf.SwfStream(fs), this); instance = new Flash(gameServiceContainer, document, Math.Min(GraphicsDevice.Adapter.CurrentDisplayMode.Width, VectorDevice.MaxTextureSize), Math.Min(GraphicsDevice.Adapter.CurrentDisplayMode.Height, VectorDevice.MaxTextureSize)); instance.Visible = true; instance.IsTransparent = false; instance.Root.HighQuality = quality; instance.Root.DontLoop = !looping; instance.Enabled = !paused; instance.Root.NextFrame(); lastDraw = startTime = DateTime.Now; return true; } catch (Exception e) { MessageBox.Show("Soubor se nepodařilo načíst!\n\n" + e.Message); return false; } }