public override string Serialize()
 {
     return(AppResourcesHelper.Get("Formula_Operator_Not"));
 }
        private async void RegisterAction()
        {
            IsSending = true;
            if (string.IsNullOrEmpty(_username) || string.IsNullOrEmpty(_password) || string.IsNullOrEmpty(_email))
            {
                ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramLoginErrorCaption"),
                                                                 AppResourcesHelper.Get("Main_UploadProgramMissingLoginData"), MissingLoginDataCallback, MessageBoxOptions.Ok);
            }
            else
            {
                JSONStatusResponse statusResponse = await ServiceLocator.WebCommunicationService.LoginOrRegisterAsync(_username, _password, _email,
                                                                                                                      ServiceLocator.CultureService.GetCulture().TwoLetterISOLanguageName,
                                                                                                                      RegionInfo.CurrentRegion.TwoLetterISORegionName);

                Context.CurrentToken     = statusResponse.token;
                Context.CurrentUserName  = _username;
                Context.CurrentUserEmail = _email;

                switch (statusResponse.statusCode)
                {
                case StatusCodes.ServerResponseOk:
                    if (NavigationCallback != null)
                    {
                        NavigationCallback();
                    }
                    else
                    {
                        //TODO: Throw error because of navigation callback shouldn't be null
                        throw new Exception("This error shouldn't be thrown. The navigation callback must not be null.");
                    }
                    break;

                case StatusCodes.ServerResponseRegisterOk:
                    ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramRegistrationSucessful"),
                                                                     string.Format(AppResourcesHelper.Get("Main_UploadProgramWelcome"), _username), RegistrationSuccessfulCallback, MessageBoxOptions.Ok);
                    break;

                case StatusCodes.ServerResponseLoginFailed:
                    ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramLoginErrorCaption"),
                                                                     AppResourcesHelper.Get("Main_UploadProgramRegisterExistingUser"), WrongLoginDataCallback, MessageBoxOptions.Ok);
                    break;

                case StatusCodes.HTTPRequestFailed:
                    ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramLoginErrorCaption"),
                                                                     AppResourcesHelper.Get("Main_NoInternetConnection"), WrongLoginDataCallback, MessageBoxOptions.Ok);
                    break;

                default:
                    string messageString = string.IsNullOrEmpty(statusResponse.answer) ? string.Format(AppResourcesHelper.Get("Main_UploadProgramUndefinedError"), statusResponse.statusCode.ToString()) :
                                           string.Format(AppResourcesHelper.Get("Main_UploadProgramLoginError"), statusResponse.answer);
                    ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramLoginErrorCaption"),
                                                                     messageString, WrongLoginDataCallback, MessageBoxOptions.Ok);
                    break;
                }
            }
            IsSending = false;
        }
Beispiel #3
0
        private void CheckSensorSupportOfBricks()
        {
            bool supported = true;

            foreach (Sprite sprite in CurrentProgram.Sprites)
            {
                foreach (Script script in sprite.Scripts)
                {
                    foreach (Brick brick in script.Bricks)
                    {
                        if (brick.GetType().Equals(typeof(SetSizeBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((SetSizeBrick)brick).Percentage);
                        }
                        else if (brick.GetType().Equals(typeof(SetPositionXBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((SetPositionXBrick)brick).Value);
                        }
                        else if (brick.GetType().Equals(typeof(SetPositionYBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((SetPositionYBrick)brick).Value);
                        }
                        else if (brick.GetType().Equals(typeof(SetPositionBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((SetPositionBrick)brick).ValueX);
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((SetPositionBrick)brick).ValueY);
                        }
                        else if (brick.GetType().Equals(typeof(SetRotationBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((SetRotationBrick)brick).Value);
                        }
                        else if (brick.GetType().Equals(typeof(SetBrightnessBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((SetBrightnessBrick)brick).Percentage);
                        }
                        else if (brick.GetType().Equals(typeof(SetTransparencyBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((SetTransparencyBrick)brick).Percentage);
                        }
                        else if (brick.GetType().Equals(typeof(AnimatePositionBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((AnimatePositionBrick)brick).Duration);
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((AnimatePositionBrick)brick).ToX);
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((AnimatePositionBrick)brick).ToY);
                        }
                        else if (brick.GetType().Equals(typeof(RepeatBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((RepeatBrick)brick).Count);
                        }
                        else if (brick.GetType().Equals(typeof(IfBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((IfBrick)brick).Condition);
                        }
                        else if (brick.GetType().Equals(typeof(ChangeBrightnessBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((ChangeBrightnessBrick)brick).RelativePercentage);
                        }
                        else if (brick.GetType().Equals(typeof(ChangeSizeBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((ChangeSizeBrick)brick).RelativePercentage);
                        }
                        else if (brick.GetType().Equals(typeof(ChangePositionXBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((ChangePositionXBrick)brick).RelativeValue);
                        }
                        else if (brick.GetType().Equals(typeof(ChangePositionYBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((ChangePositionYBrick)brick).RelativeValue);
                        }
                        else if (brick.GetType().Equals(typeof(ChangeRotationBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((ChangeRotationBrick)brick).RelativeValue);
                        }
                        else if (brick.GetType().Equals(typeof(MoveBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((MoveBrick)brick).Steps);
                        }
                        else if (brick.GetType().Equals(typeof(ChangeTransparencyBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((ChangeTransparencyBrick)brick).RelativePercentage);
                        }
                        else if (brick.GetType().Equals(typeof(DecreaseZOrderBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((DecreaseZOrderBrick)brick).RelativeValue);
                        }
                        else if (brick.GetType().Equals(typeof(DelayBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((DelayBrick)brick).Duration);
                        }
                        else if (brick.GetType().Equals(typeof(PlayNxtToneBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((PlayNxtToneBrick)brick).Duration);
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((PlayNxtToneBrick)brick).Frequency);
                        }
                        else if (brick.GetType().Equals(typeof(SetNxtMotorSpeedBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((SetNxtMotorSpeedBrick)brick).Percentage);
                        }
                        else if (brick.GetType().Equals(typeof(ChangeNxtMotorAngleBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((ChangeNxtMotorAngleBrick)brick).RelativeValue);
                        }
                        else if (brick.GetType().Equals(typeof(SetVolumeBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((SetVolumeBrick)brick).Percentage);
                        }
                        else if (brick.GetType().Equals(typeof(ChangeVolumeBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((ChangeVolumeBrick)brick).RelativePercentage);
                        }
                        else if (brick.GetType().Equals(typeof(SetVariableBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((SetVariableBrick)brick).Value);
                        }
                        else if (brick.GetType().Equals(typeof(ChangeVariableBrick)))
                        {
                            supported &= this.CheckSensorSupportOfBrickFormula(brick, ((ChangeVariableBrick)brick).RelativeValue);
                        }
                    }
                }
            }

            if (!supported)
            {
                ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get(AppResources.Main_MessageBoxSensorsMissing),
                                                                 AppResourcesHelper.Get(AppResources.Main_NotAllFeaturesSupported), delegate { /* no action */ }, MessageBoxOptions.Ok);
            }
        }
Beispiel #4
0
 private async void OnSelectFolderButtonClicked(object sender, RoutedEventArgs e)
 {
     await Util.ConfirmActionAndExecute(AppResourcesHelper.GetString("PersonGroupDetailsPage_ConfirmSelectFolder"), async() => { await PickFolderASync(); });
 }
Beispiel #5
0
        private async void NewPasswordAction()
        {
            IsSending = true;
            if (string.IsNullOrEmpty(_newPassword) || string.IsNullOrEmpty(_repeatedPassword))
            {
                ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramPasswordRecoveryErrorCaption"),
                                                                 AppResourcesHelper.Get("Main_UploadProgramMissingPassword"), MissingPasswordDataCallback, MessageBoxOptions.Ok);
            }
            else
            {
                JSONStatusResponse statusResponse = await ServiceLocator.WebCommunicationService.ChangePasswordAsync(_newPassword, _repeatedPassword, ServiceLocator.CultureService.GetCulture().TwoLetterISOLanguageName);

                switch (statusResponse.statusCode)
                {
                case StatusCodes.ServerResponseOk:
                    this.GoBackAction();
                    ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramNewPassword"),
                                                                     AppResourcesHelper.Get("Main_UploadProgramPasswordChangeSucess"), PasswordInvalidCallback, MessageBoxOptions.Ok);
                    break;

                // because of typing-error in server-message
                case StatusCodes.ServerResponseRecoveryHashNotFound:
                    ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramPasswordRecoveryErrorCaption"),
                                                                     AppResourcesHelper.Get("Main_UploadProgramRecoveryHashError"), RecoveryHashNotFoundCallback, MessageBoxOptions.Ok);
                    break;

                // may be checked locally
                case StatusCodes.ServerResponsePasswordMatchFailed:
                    ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramPasswordRecoveryErrorCaption"),
                                                                     AppResourcesHelper.Get("Main_UploadProgramRecoveryPasswordMatchError"), PasswordInvalidCallback, MessageBoxOptions.Ok);
                    break;

                case StatusCodes.HTTPRequestFailed:
                    ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramPasswordRecoveryErrorCaption"),
                                                                     AppResourcesHelper.Get("Main_NoInternetConnection"), MissingPasswordDataCallback, MessageBoxOptions.Ok);
                    break;

                default:
                    string messageString = string.IsNullOrEmpty(statusResponse.answer) ? string.Format(AppResourcesHelper.Get("Main_UploadProgramUndefinedError"), statusResponse.statusCode.ToString()) : statusResponse.answer;
                    ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramPasswordRecoveryErrorCaption"),
                                                                     messageString, MissingPasswordDataCallback, MessageBoxOptions.Ok);
                    break;
                }
            }
            IsSending = false;
        }
        public string Convert(FormulaKey value, string language)
        {
            var culture = new CultureInfo(language);

            switch (value.Key)
            {
            case FormulaEditorKey.D0: return(0.ToString(culture));

            case FormulaEditorKey.D1: return(1.ToString(culture));

            case FormulaEditorKey.D2: return(2.ToString(culture));

            case FormulaEditorKey.D3: return(3.ToString(culture));

            case FormulaEditorKey.D4: return(4.ToString(culture));

            case FormulaEditorKey.D5: return(5.ToString(culture));

            case FormulaEditorKey.D6: return(6.ToString(culture));

            case FormulaEditorKey.D7: return(7.ToString(culture));

            case FormulaEditorKey.D8: return(8.ToString(culture));

            case FormulaEditorKey.D9: return(9.ToString(culture));

            case FormulaEditorKey.DecimalSeparator: return(culture.NumberFormat.NumberDecimalSeparator);

            case FormulaEditorKey.ParameterSeparator: return(",");

            case FormulaEditorKey.Pi: return("π");

            case FormulaEditorKey.True: return(AppResourcesHelper.Get("Formula_Constant_True"));

            case FormulaEditorKey.False: return(AppResourcesHelper.Get("Formula_Constant_False"));

            case FormulaEditorKey.Plus: return("+");

            case FormulaEditorKey.Minus: return("-");

            case FormulaEditorKey.Multiply: return("*");

            case FormulaEditorKey.Divide: return("/");

            case FormulaEditorKey.Caret: return("^");

            case FormulaEditorKey.Equals: return("=");

            case FormulaEditorKey.NotEquals: return("≠");

            case FormulaEditorKey.Greater: return(">");

            case FormulaEditorKey.GreaterEqual: return("≥");

            case FormulaEditorKey.Less: return("<");

            case FormulaEditorKey.LessEqual: return("≤");

            case FormulaEditorKey.And: return(AppResourcesHelper.Get("Formula_Operator_And"));

            case FormulaEditorKey.Or: return(AppResourcesHelper.Get("Formula_Operator_Or"));

            case FormulaEditorKey.Not: return(AppResourcesHelper.Get("Formula_Operator_Not"));

            case FormulaEditorKey.Mod: return(AppResourcesHelper.Get("Formula_Operator_Mod"));

            case FormulaEditorKey.Exp: return("exp");

            case FormulaEditorKey.Log: return("log");

            case FormulaEditorKey.Ln: return("ln");

            case FormulaEditorKey.Min: return(AppResourcesHelper.Get("Formula_Function_Min"));

            case FormulaEditorKey.Max: return(AppResourcesHelper.Get("Formula_Function_Max"));

            case FormulaEditorKey.Sin: return("sin");

            case FormulaEditorKey.Cos: return("cos");

            case FormulaEditorKey.Tan: return("tan");

            case FormulaEditorKey.Arcsin: return("arcsin");

            case FormulaEditorKey.Arccos: return("arccos");

            case FormulaEditorKey.Arctan: return("arctan");

            case FormulaEditorKey.Sqrt: return(AppResourcesHelper.Get("Formula_Function_Sqrt"));

            case FormulaEditorKey.Abs: return(AppResourcesHelper.Get("Formula_Function_Abs"));

            case FormulaEditorKey.Round: return(AppResourcesHelper.Get("Formula_Function_Round"));

            case FormulaEditorKey.Random: return(AppResourcesHelper.Get("Formula_Function_Random"));

            case FormulaEditorKey.AccelerationX: return(AppResourcesHelper.Get("Formula_Sensor_AccelerationX"));

            case FormulaEditorKey.AccelerationY: return(AppResourcesHelper.Get("Formula_Sensor_AccelerationY"));

            case FormulaEditorKey.AccelerationZ: return(AppResourcesHelper.Get("Formula_Sensor_AccelerationZ"));

            case FormulaEditorKey.Compass: return(AppResourcesHelper.Get("Formula_Sensor_Compass"));

            case FormulaEditorKey.InclinationX: return(AppResourcesHelper.Get("Formula_Sensor_InclinationX"));

            case FormulaEditorKey.InclinationY: return(AppResourcesHelper.Get("Formula_Sensor_InclinationY"));

            case FormulaEditorKey.Loudness: return(AppResourcesHelper.Get("Formula_Sensor_Loudness"));

            case FormulaEditorKey.Brightness: return(AppResourcesHelper.Get("Formula_Property_Brightness"));

            case FormulaEditorKey.Layer: return(AppResourcesHelper.Get("Formula_Property_Layer"));

            case FormulaEditorKey.Transparency: return(AppResourcesHelper.Get("Formula_Property_Transparency"));

            case FormulaEditorKey.PositionX: return(AppResourcesHelper.Get("Formula_Property_PositionX"));

            case FormulaEditorKey.PositionY: return(AppResourcesHelper.Get("Formula_Property_PositionY"));

            case FormulaEditorKey.Rotation: return(AppResourcesHelper.Get("Formula_Property_Rotation"));

            case FormulaEditorKey.Size: return(AppResourcesHelper.Get("Formula_Property_Size"));

            case FormulaEditorKey.LocalVariable: return(value.LocalVariable == null || value.LocalVariable.Name == null ? string.Empty : value.LocalVariable.Name);

            case FormulaEditorKey.GlobalVariable: return(value.GlobalVariable == null || value.GlobalVariable.Name == null ? string.Empty : value.GlobalVariable.Name);

            case FormulaEditorKey.OpeningParenthesis: return("(");

            case FormulaEditorKey.ClosingParenthesis: return(")");

            default: throw new ArgumentOutOfRangeException("value");
            }
        }
Beispiel #7
0
 private async void OnDeletePersonGroupClicked(object sender, RoutedEventArgs e)
 {
     await Util.ConfirmActionAndExecute(AppResourcesHelper.GetString("PersonGroupDetailsPage_ConfirmDeleteGroup"), async() => { await DeletePersonGroupAsync(); });
 }
        public async Task <Program> RestoreDefaultProgram(string programName)
        {
            IProgramGenerator projectGenerator = new ProgramGeneratorWhackAMole();

            return(await projectGenerator.GenerateProgram(AppResourcesHelper.Get("Main_DefaultProgramName"), true));
        }
Beispiel #9
0
        public MultiModeEditorCommandBar()
        {
            this.RequestedTheme = ElementTheme.Dark;
            SolidColorBrush appBarBackgroundBrush = new SolidColorBrush();

            appBarBackgroundBrush.Color = Color.FromArgb(255, 25, 165, 184);
            this.Background             = appBarBackgroundBrush;

            _playButton = new AppBarButton
            {
                Label = AppResourcesHelper.Get("Editor_ButtonPlayProgram"),
                Icon  = new SymbolIcon(Symbol.Play)
            };

            _newButton = new AppBarButton
            {
                // Label will be chosen in UpdateAddText(...)
                Icon = new SymbolIcon(Symbol.Add)
            };

            _selectButton = new AppBarButton
            {
                Label = AppResourcesHelper.Get("Editor_ButtonSelect"),
                Icon  = new SymbolIcon(Symbol.SelectAll)
            };

            _reorderButton = new AppBarButton
            {
                Label = AppResourcesHelper.Get("Editor_ButtonStartReordering"),
                //Icon = new SymbolIcon(Symbol.Bullets)
                //Icon = new SymbolIcon(Symbol.ShowResults)
                Icon = new SymbolIcon(Symbol.Sort)
            };

            _selectButton.Click += (sender, args) =>
                                   SetMode(MultiModeEditorCommandBarMode.Select);
            _reorderButton.Click += (sender, args) =>
                                    SetMode(MultiModeEditorCommandBarMode.Reorder);


            _finishedReorderingButton = new AppBarButton
            {
                Label = AppResourcesHelper.Get("Editor_ButtonFinishedReordering"),
                Icon  = new SymbolIcon(Symbol.Accept)
            };

            _finishedReorderingButton.Click += (sender, args) =>
                                               SetMode(MultiModeEditorCommandBarMode.Normal);

            _deleteButton = new AppBarButton
            {
                Label = AppResourcesHelper.Get("Editor_ButtonDelete"),
                Icon  = new SymbolIcon(Symbol.Delete)
            };
            //_deleteButton.Command = new RelayCommand(() =>
            //{
            //    SetMode(MultiModeEditorCommandBarMode.Normal);

            //    if (_deleteCommand != null)
            //        _deleteCommand.Execute(null);
            //});

            _copyButton = new AppBarButton
            {
                Label = AppResourcesHelper.Get("Editor_ButtonCopy"),
                Icon  = new SymbolIcon(Symbol.Copy)
            };
            //_copyButton.Command = new RelayCommand(() =>
            //{
            //    SetMode(MultiModeEditorCommandBarMode.Normal);

            //    if (_copyCommand != null)
            //        _copyCommand.Execute(null);
            //});

            _cancelSelectionButton = new AppBarButton
            {
                Label = AppResourcesHelper.Get("Editor_ButtonClearSelection"),
                Icon  = new SymbolIcon(Symbol.ClearSelection)
            };

            _cancelSelectionButton.Click += (sender, args) =>
                                            SetMode(MultiModeEditorCommandBarMode.Normal);


            SetMode(MultiModeEditorCommandBarMode.Normal);
        }
Beispiel #10
0
        public async void RecievedFiles(IEnumerable <object> files)
        {
            var fileArray = files as object[] ?? files.ToArray();

            if (fileArray.Length == 0)
            {
                ServiceLocator.DispatcherService.RunOnMainThread(() =>
                                                                 ServiceLocator.NavigationService.NavigateTo <NewLookSourceSelectionViewModel>());
            }
            StorageFile file = (StorageFile)fileArray[0];

            var fileStream = await file.OpenReadAsync();

            var memoryStream = new MemoryStream();

            fileStream.AsStreamForRead().CopyTo(memoryStream);
            memoryStream.Seek(0, SeekOrigin.Begin);

            BitmapImage imagetobind = new BitmapImage();
            await imagetobind.SetSourceAsync(memoryStream.AsRandomAccessStream());

            WriteableBitmap writeableBitmap = new WriteableBitmap(imagetobind.PixelWidth, imagetobind.PixelHeight);
            await writeableBitmap.FromStream(memoryStream.AsRandomAccessStream());

            memoryStream.Seek(0, SeekOrigin.Begin);
            PortableImage portableImage = new PortableImage(writeableBitmap)
            {
                Width       = writeableBitmap.PixelWidth,
                Height      = writeableBitmap.PixelHeight,
                EncodedData = memoryStream
            };

            if (_lookToEdit == null)
            {
                if (portableImage != null) // TODO: check if image is ok
                {
                    var message = new GenericMessage <PortableImage>(portableImage);
                    Messenger.Default.Send(message, ViewModelMessagingToken.LookImageListener);

                    ServiceLocator.DispatcherService.RunOnMainThread(() =>
                                                                     ServiceLocator.NavigationService.NavigateTo <LookNameChooserViewModel>());
                }
                else
                {
                    ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Editor_MessageBoxWrongImageFormatHeader"),
                                                                     AppResourcesHelper.Get("Editor_MessageBoxWrongImageFormatText"), delegate { /* no action */ }, MessageBoxOptions.Ok);
                }
            }
            else
            {
                using (var storage = StorageSystem.GetStorage())
                {
                    var filePath = Path.Combine(_program.BasePath,
                                                StorageConstants.ProgramLooksPath, _lookToEdit.FileName);

                    await storage.DeleteImageAsync(filePath);

                    var lookFileStream = await storage.OpenFileAsync(filePath,
                                                                     StorageFileMode.Create, StorageFileAccess.Write);

                    await(await file.OpenReadAsync()).AsStream().CopyToAsync(lookFileStream);

                    lookFileStream.Dispose();

                    await storage.TryCreateThumbnailAsync(filePath);

                    _lookToEdit.Image = await storage.LoadImageThumbnailAsync(filePath);
                }

                _lookToEdit = null;
            }
        }
        public async Task TryImportWithStatusNotifications()
        {
            _cancellationTokenSource = new CancellationTokenSource();
            Debug.WriteLine("Starting with ExtractProgram");
            ExtractProgramResult extractionResult = await ServiceLocator.ProgramImportService.ExtractProgram(_cancellationTokenSource.Token);

            if (_cancellationTokenSource.Token.IsCancellationRequested == true)
            {
                await CleanUpImport();

                return;
            }
            if (extractionResult.Status == ExtractProgramStatus.Error)
            {
                ServiceLocator.NotifictionService.ShowToastNotification(
                    AppResourcesHelper.Get("Import_ProgramDamaged"),
                    AppResourcesHelper.Get("Import_CatrobatDamagedText"),
                    ToastDisplayDuration.Long);
                return;
            }

            Debug.WriteLine("Starting with CheckProgram");
            var validateResult = await ServiceLocator.ProgramValidationService.CheckProgram(StorageConstants.TempProgramImportPath);

            if (_cancellationTokenSource.Token.IsCancellationRequested == true)
            {
                await CleanUpImport();

                return;
            }

            switch (validateResult.State)
            {
            case ProgramState.Valid:
                _programName = validateResult.ProgramHeader.ProjectName;
                break;

            case ProgramState.Damaged:
                ServiceLocator.NotifictionService.ShowToastNotification("",
                                                                        AppResourcesHelper.Get("Import_ProgramDamaged"),
                                                                        ToastDisplayDuration.Long);
                break;

            case ProgramState.VersionTooOld:
                ServiceLocator.NotifictionService.ShowToastNotification("",
                                                                        AppResourcesHelper.Get("Import_ProgramOutdated"),
                                                                        ToastDisplayDuration.Long);
                break;

            case ProgramState.VersionTooNew:
                ServiceLocator.NotifictionService.ShowToastNotification("",
                                                                        AppResourcesHelper.Get("Import_AppTooOld"),
                                                                        ToastDisplayDuration.Long);
                break;

            case ProgramState.ErrorInThisApp:
                ServiceLocator.NotifictionService.ShowToastNotification("",
                                                                        AppResourcesHelper.Get("Import_GeneralError"),
                                                                        ToastDisplayDuration.Long);
                break;

            case ProgramState.Unknown:
                ServiceLocator.NotifictionService.ShowToastNotification("",
                                                                        AppResourcesHelper.Get("Import_GeneralError"),
                                                                        ToastDisplayDuration.Long);
                break;

            case ProgramState.FilesMissing:
                ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Import_Canceled"),
                                                                 AppResourcesHelper.Get("Import_FilesMissing"), MissingFilesCallback, MessageBoxOptions.Ok);
                return;

            default:
                throw new ArgumentOutOfRangeException();
            }

            Debug.WriteLine("Starting with AcceptTempProgram");
            await ServiceLocator.ProgramImportService.AcceptTempProgram();

            var localProgramsChangedMessage = new MessageBase();

            Messenger.Default.Send(localProgramsChangedMessage,
                                   ViewModelMessagingToken.LocalProgramsChangedListener);

            ServiceLocator.NotifictionService.ShowToastNotification("",
                                                                    AppResourcesHelper.Get("Import_ProgramAdded"),
                                                                    ToastDisplayDuration.Long,
                                                                    ToastTag.ImportFin);

            Debug.WriteLine("Finished");
        }
Beispiel #12
0
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var color = (Color)value;

            return(color == AppResourcesHelper.GetResourceColor("IconActivated") ? true : false);
        }
Beispiel #13
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var isAlarmed = (bool)value;

            return(isAlarmed ? AppResourcesHelper.GetResourceColor("IconActivated") : AppResourcesHelper.GetResourceColor("CustomGrey"));
        }
Beispiel #14
0
        private async void RecoverAction()
        {
            IsSending = true;
            if (string.IsNullOrEmpty(_passwordRecoveryData))
            {
                ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramPasswordRecoveryErrorCaption"),
                                                                 AppResourcesHelper.Get("Main_UploadProgramMissingRecoveryData"), MissingRecoveryDataCallback, MessageBoxOptions.Ok);
            }
            else
            {
                JSONStatusResponse statusResponse = await ServiceLocator.WebCommunicationService.RecoverPasswordAsync(_passwordRecoveryData, ServiceLocator.CultureService.GetCulture().TwoLetterISOLanguageName);

                if (statusResponse.statusCode == StatusCodes.ServerResponseOk)
                {
                    // since 08-2014 this only works on the test-server (https://catroid-test.catrob.at/)
                    //string recoveryLink = statusResponse.answer;
                    //string hashMarker = "?c=";
                    //int position = recoveryLink.LastIndexOf(hashMarker) + hashMarker.Length;
                    //string recoveryHash = recoveryLink.Substring(position, recoveryLink.Length - position);
                    //ServiceLocator.WebCommunicationService.SetRecoveryHash(recoveryHash);
                    //ResetViewModel();
                    //ServiceLocator.NavigationService.NavigateTo<UploadProgramNewPasswordViewModel>();
                    //ServiceLocator.NavigationService.RemoveBackEntry();

                    // since 08-2014 pocketcode-server sends an email with the recovery hash in it
                    ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramRecoverPassword"),
                                                                     statusResponse.answer, MissingRecoveryDataCallback, MessageBoxOptions.Ok);
                    this.GoBackAction();
                }
                else
                {
                    switch (statusResponse.statusCode)
                    {
                    case StatusCodes.HTTPRequestFailed:
                        ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramPasswordRecoveryErrorCaption"),
                                                                         AppResourcesHelper.Get("Main_NoInternetConnection"), MissingRecoveryDataCallback, MessageBoxOptions.Ok);
                        break;

                    default:
                        string messageString = string.IsNullOrEmpty(statusResponse.answer) ? string.Format(AppResourcesHelper.Get("Main_UploadProgramUndefinedError"), statusResponse.statusCode.ToString()) :
                                               string.Format(AppResourcesHelper.Get("Main_UploadProgramLoginError"), statusResponse.answer);
                        ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramPasswordRecoveryErrorCaption"),
                                                                         messageString, MissingRecoveryDataCallback, MessageBoxOptions.Ok);
                        break;
                    }
                }
            }
            IsSending = false;
        }
Beispiel #15
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            EnterKioskMode();

            if (string.IsNullOrEmpty(SettingsHelper.Instance.FaceApiKey))
            {
                await new MessageDialog(AppResourcesHelper.GetString("AutomaticPhotoCapturePage_MissingAPI_Content"), AppResourcesHelper.GetString("AutomaticPhotoCapturePage_MissingAPI_Title")).ShowAsync();
            }
            else
            {
                await this.cameraControl.StartStreamAsync();
            }

            base.OnNavigatedTo(e);
        }
Beispiel #16
0
        public async Task ExportToPocketCodeOrgWithNotifications(string programName, string currentUserName, string currentToken)
        {
            _cancellationTokenSource = new CancellationTokenSource();
            JSONStatusResponse statusResponse = await Task.Run(() =>
                                                               ServiceLocator.WebCommunicationService.UploadProgramAsync(
                                                                   programName, currentUserName, currentToken, _cancellationTokenSource.Token,
                                                                   ServiceLocator.CultureService.GetCulture().TwoLetterISOLanguageName), _cancellationTokenSource.Token);

            if (_cancellationTokenSource.Token.IsCancellationRequested == true)
            {
                ServiceLocator.NotifictionService.ShowToastNotification(
                    AppResourcesHelper.Get("Export_CanceledText"),
                    AppResourcesHelper.Get("Export_CanceledText"),
                    ToastDisplayDuration.Long);
                return;
            }
            switch (statusResponse.statusCode)
            {
            case StatusCodes.ServerResponseOk:
                break;

            case StatusCodes.HTTPRequestFailed:
                ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramErrorCaption"),
                                                                 AppResourcesHelper.Get("Main_NoInternetConnection"), UploadErrorCallback, MessageBoxOptions.Ok);
                break;

            default:
                string messageString = string.IsNullOrEmpty(statusResponse.answer) ? string.Format(AppResourcesHelper.Get("Main_UploadProgramUndefinedError"), statusResponse.statusCode.ToString()) :
                                       string.Format(AppResourcesHelper.Get("Main_UploadProgramError"), statusResponse.answer);
                ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramErrorCaption"),
                                                                 messageString, UploadErrorCallback, MessageBoxOptions.Ok);
                break;
            }

            if (ServiceLocator.WebCommunicationService.NoUploadsPending())
            {
                ServiceLocator.NotifictionService.ShowToastNotification(null,
                                                                        AppResourcesHelper.Get("Main_NoUploadsPending"), ToastDisplayDuration.Short);
            }
        }
 public override string Serialize()
 {
     return(AppResourcesHelper.Get("Formula_Sensor_InclinationX"));
 }
Beispiel #18
0
 public override string Serialize()
 {
     return(AppResourcesHelper.Get("Formula_Function_Max"));
 }