Exemplo n.º 1
0
        public async Task SetAsCurrent()
        {
            var toxInstance = new ExtendedTox(new ToxOptions(true, true), _toxData);

            _toxModel.SetCurrent(toxInstance);
            await _toxModel.SaveDataAsync();

            _toxModel.Start();
            await _avatarManager.LoadAvatars();
        }
Exemplo n.º 2
0
        private async Task HandlePreviousExecutionState(ApplicationExecutionState previousExecutionState)
        {
            if (previousExecutionState == ApplicationExecutionState.Terminated ||
                previousExecutionState == ApplicationExecutionState.ClosedByUser ||
                previousExecutionState == ApplicationExecutionState.NotRunning)
            {
                var successfulRestoration = true;
                try
                {
                    await _toxModel.RestoreDataAsync();
                }
                catch
                {
                    successfulRestoration = false;
                }
                // If the restoration was unsuccessful, it means that we are starting up the app the
                // very firs time or something went wrong restoring data.
                // So we save the current Tox instance (newly created, not loaded) as the default one.
                if (!successfulRestoration)
                {
                    await _toxModel.SaveDataAsync();
                }

                if (previousExecutionState != ApplicationExecutionState.NotRunning)
                // We only have to restore session state in the other two cases.
                // See: https://msdn.microsoft.com/en-us/library/ie/windows.applicationmodel.activation.applicationexecutionstate
                {
                    try
                    {
                        await SuspensionManager.RestoreAsync();
                    }
                    catch (SuspensionManagerException)
                    {
                        // Something went wrong restoring state.
                        // Assume there is no state and continue.
                    }
                }
            }
        }
Exemplo n.º 3
0
 public async Task SaveDataAsync()
 {
     await _toxModel.SaveDataAsync();
 }