/// <summary> /// Loads the notification settings from persistent storage. /// If the file does not exist a default object is created. /// </summary> /// <returns>The notification settings.</returns> public static NotificationSettings Load() { #if WINDOWS_PHONE using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication()) #else using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForDomain()) #endif { NotificationSettings settings; if (storage.FileExists(NotificationStrings.SettingsFileName)) { using (IsolatedStorageFileStream stream = storage.OpenFile(NotificationStrings.SettingsFileName, FileMode.Open)) { XmlSerializer xml = new XmlSerializer(typeof(NotificationSettings)); settings = xml.Deserialize(stream) as NotificationSettings; } } else { settings = new NotificationSettings(); } return(settings); } }
/// <summary> /// Initializes a new instance of the <see cref="NotificationManager"/> class. /// </summary> /// <param name="contentManager">The content manager to use for loading assets.</param> /// <param name="spriteBatch">The sprite batch used to render game sprites.</param> /// <param name="displayDimensions">The size of the game display area.</param> private NotificationManager(ContentManager contentManager, SpriteBatch spriteBatch, Vector2 displayDimensions) { this.notificationQueue = new Queue <Notification>(); this.notificationFactory = new NotificationFactory(contentManager, spriteBatch, displayDimensions); this.closeInformation = new RenderableText(); this.closeInformation.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFont, NotificationStrings.CloseNotification); this.closeInformation.Colour = Color.Gray; this.textPosition = new Vector2(displayDimensions.X / 2.0f, displayDimensions.Y / 8.0f); this.notificationSettings = NotificationSettings.Load(); this.delayTimer = NotificationManager.DelayTime; }
/// <summary> /// Initializes a new instance of the <see cref="NotificationManager"/> class. /// </summary> /// <param name="contentManager">The content manager to use for loading assets.</param> /// <param name="spriteBatch">The sprite batch used to render game sprites.</param> /// <param name="displayDimensions">The size of the game display area.</param> private NotificationManager(ContentManager contentManager, SpriteBatch spriteBatch, Vector2 displayDimensions) { this.notificationQueue = new Queue<Notification>(); this.notificationFactory = new NotificationFactory(contentManager, spriteBatch, displayDimensions); this.closeInformation = new RenderableText(); this.closeInformation.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFont, NotificationStrings.CloseNotification); this.closeInformation.Colour = Color.Gray; this.textPosition = new Vector2(displayDimensions.X / 2.0f, displayDimensions.Y / 8.0f); this.notificationSettings = NotificationSettings.Load(); this.delayTimer = NotificationManager.DelayTime; }
/// <summary> /// Loads the notification settings from persistent storage. /// If the file does not exist a default object is created. /// </summary> /// <returns>The notification settings.</returns> public static NotificationSettings Load() { #if WINDOWS_PHONE using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication()) #else using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForDomain()) #endif { NotificationSettings settings; if (storage.FileExists(NotificationStrings.SettingsFileName)) { using (IsolatedStorageFileStream stream = storage.OpenFile(NotificationStrings.SettingsFileName, FileMode.Open)) { XmlSerializer xml = new XmlSerializer(typeof(NotificationSettings)); settings = xml.Deserialize(stream) as NotificationSettings; } } else { settings = new NotificationSettings(); } return settings; } }