Example #1
0
        public Game()
        {
            _instance = this;

            TitleContainer.Initialize();

            LaunchParameters = new LaunchParameters();
            _services        = new GameServiceContainer();
            _components      = new GameComponentCollection();
            Content          = new ContentManager(_services);

            Platform              = GamePlatform.Create(this);
            Platform.Activated   += OnActivated;
            Platform.Deactivated += OnDeactivated;
            _services.AddService(typeof(GamePlatform), Platform);

            /* Set the window title
             * TODO: Get the title from the WindowsPhoneManifest.xml for WP7 projects
             */
            string windowTitle = string.Empty;

            // When running unit tests this can return null
            Assembly assembly = Assembly.GetEntryAssembly();

            if (assembly != null)
            {
                // Use the Title attribute of the Assembly if possible
                AssemblyTitleAttribute assemblyTitleAtt = (AssemblyTitleAttribute)
                                                          AssemblyTitleAttribute.GetCustomAttribute(
                    assembly,
                    typeof(AssemblyTitleAttribute)
                    );

                if (assemblyTitleAtt != null)
                {
                    windowTitle = assemblyTitleAtt.Title;
                }

                // Otherwise, fallback to the Name of the assembly
                if (string.IsNullOrEmpty(windowTitle))
                {
                    windowTitle = assembly.GetName().Name;
                }
            }

            Window.Title = windowTitle;
        }
Example #2
0
 public static Stream OpenStream(string name)
 {
     return((Stream)File.OpenRead(TitleContainer.GetFilename(name)));
 }