Beispiel #1
0
        /// <summary>
        /// Load inking preference from file. A new one will be created none is loaded.
        /// This method will also create drawing attributes to be used by ink canvas.
        /// </summary>
        /// <returns></returns>
        public static async Task <InkingPreference> LoadDrawingPreference()
        {
            // Check drawing preference file
            AppEventSource.Log.Debug("ViewerPage: Checking previously saved drawing preference...");
            StorageFile file = await SuspensionManager.GetSavedFileAsync(INKING_PREFERENCE_FILENAME);

            InkingPreference inkingPreference = await
                                                SuspensionManager.DeserializeFromFileAsync(typeof(InkingPreference), file) as InkingPreference;

            // Discard the inking preference if it is not the current version
            if (inkingPreference != null && inkingPreference.version != InkingPreference.CURRENT_INKING_PREF_VERSION)
            {
                inkingPreference = null;
            }
            // Create drawing preference file if one was not loaded.
            if (inkingPreference == null)
            {
                AppEventSource.Log.Debug("ViewerPage: No saved drawing preference loaded. Creating a new one...");
                inkingPreference = new InkingPreference();
                await inkingPreference.SaveAsync();
            }
            return(inkingPreference);
        }