Catrobat.IDE.Core.ViewModels.Editor.Looks.LookNameChooserViewModel.SaveAction C# (CSharp) Method

SaveAction() private method

private SaveAction ( ) : System.Threading.Tasks.Task
return System.Threading.Tasks.Task
        private async Task SaveAction()
        {
            string validName = await ServiceLocator.ContextService.ConvertToValidFileName(LookName);
            List<string> nameList = new List<string>();
            foreach (var lookItem in _receivedSelectedSprite.Looks)
            {
                nameList.Add(lookItem.Name);
            }
            _lookName = await ServiceLocator.ContextService.FindUniqueName(validName, nameList);
            var message = new GenericMessage<PortableImage>(Image);
            Messenger.Default.Send(message, ViewModelMessagingToken.LookImageToSaveListener);

            ServiceLocator.DispatcherService.RunOnMainThread(() =>
            {
                ServiceLocator.NavigationService.RemoveBackEntry();
                ServiceLocator.NavigationService.NavigateBack(this.GetType());
            });

            //ServiceLocator.DispatcherService.RunOnMainThread(() =>
            //    ServiceLocator.NavigationService.NavigateTo<LookSavingViewModel>());

            var newDimention = new ImageDimension
            {
                Height = SelectedSize.NewHeight,
                Width = SelectedSize.NewWidth
            };

            var look = await LookHelper.Save(Image, LookName, newDimention, CurrentProgram.BasePath);

            ServiceLocator.DispatcherService.RunOnMainThread(() =>
            {
                _receivedSelectedSprite.Looks.Add(look);
                //ServiceLocator.NavigationService.RemoveBackEntryForPlatform(NavigationPlatform.WindowsPhone);
                //ServiceLocator.NavigationService.RemoveBackEntryForPlatform(NavigationPlatform.WindowsPhone);
                ResetViewModel();
                //ServiceLocator.NavigationService.NavigateBack(
                //    new List<NavigationPlatform>{NavigationPlatform.WindowsStore});
            });
        }