Esempio n. 1
0
        /// <summary>
        /// Initializes the singleton instance of the <see cref="App"/> class. This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += this.OnSuspending;


            // default or recently loaded userSet will be loaded
            appWideUserSet = new DataLoader().Load();

            userSetManager = new UserSetMaintainer(appWideUserSet);
            
            GoBack();

            // userSet opslaan indien het nog niet bewaard is.

        }
Esempio n. 2
0
        // All about filepicker in Windows Phone App
        // https://msdn.microsoft.com/en-us/library/windows/apps/dn642086(v=vs.105).aspx
        // https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn631755.aspx
        // https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn614994.aspx

        public bool Deserialize(string path, out UserSet retval)
        {
            Stream stream = ApplicationData.Current.LocalFolder.OpenStreamForReadAsync(path).Result;

            bool deserializeResult = false;

            try
            {
                //string tmpName = Regex.Replace(path, "[^0-9a-zA-Z]+", "") + ".json";

                //FileOpenPicker fileOpenPicker = new FileOpenPicker();
                //fileOpenPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
                //fileOpenPicker.FileTypeFilter.Add(".json");
                //fileOpenPicker.ViewMode = PickerViewMode.List;
                //fileOpenPicker.PickSingleFileAndContinue();

                // the app will be suspended after calling this 'andContinue' method
                // The handler for the Application.Suspending event in the app.xaml.cs file calls 
                // the SaveAsync method of the SuspensionManager helper class to save application state.
                // 
                // When user finish their task, this app is reactivated. 
                // In the app.xaml.cs file, in the OnActivated event handler, restore application state by calling 
                // the RestoreAsync method of the SuspensionManager helper class. Then check whether this activation is a continuation. 
                //If this activation is a continuation, call the Continue method of the ContinuationManager helper class.




                using (StreamReader streamReader = new StreamReader(stream))
                using (JsonTextReader jsonTextReader = new JsonTextReader(streamReader))
                {
                    //retval = JsonConvert.DeserializeObject<UserSet>(jsonTextReader);
                }


                deserializeResult = true;


            }
            catch (Exception)
            {
                retval = null;
                deserializeResult = false;
                throw;
            }

            retval = null;
            return deserializeResult;
        }
Esempio n. 3
0
        protected async override void OnActivated(IActivatedEventArgs e)
        {
            base.OnActivated(e);

            continuationManager = new ContinuationManager();

            Frame rootFrame = CreateRootFrame();
            await RestoreStatusAsync(e.PreviousExecutionState);

            if (rootFrame.Content == null)
            {
                rootFrame.Navigate(typeof(IndexPivotPage));
            }

            var continuationEventArgs = e as IContinuationActivatedEventArgs;
            FileOpenPickerContinuationEventArgs arguments = continuationEventArgs as FileOpenPickerContinuationEventArgs;

            if (continuationEventArgs != null)
            {
                switch (continuationEventArgs.Kind)
                {
                    case ActivationKind.PickFileContinuation:

                        //string passedData = (string)arguments.ContinuationData["keyParameter"];
                        StorageFile pickedFile = arguments.Files.FirstOrDefault();

                        CardSet pickedCardSet = await new DataLoader().LoadFrom_StorageFile(pickedFile);

                        userSetManager.AddNewCardSet(pickedCardSet);

                        appWideUserSet = userSetManager.UserSet as UserSet;

                        break;
                }
            }
                        //var continuationEventArgs = e as IContinuationActivatedEventArgs;
             

            if (continuationEventArgs != null)
            {
                
                // Call ContinuationManager to handle continuation activation
                continuationManager.Continue(continuationEventArgs);
            }

            Window.Current.Activate();
        }
Esempio n. 4
0
 public void setCurrentCardSet(UserSet userSet, ICardSet cardSet)
 {
     userSet.CurrentCardSet = cardSet;
 }