Beispiel #1
0
        private void BuildCommand_Execute()
        {
            if (Apk == null)
            {
                return;
            }

            if (!Apk.HasJava())
            {
                MessBox.ShowDial(StringResources.JavaNotFoundError, StringResources.ErrorLower);
                return;
            }

            ClearVisLog();

            bool success = false;
            var  errors  = new List <Error>();

            LoadingWindow.ShowWindow(
                beforeStarting: () => IsBusy     = true,
                threadActions: source => success = Apk.Compile(out errors),
                finishActions: () =>
            {
                IsBusy = false;

                VisLog(LogLine);
                VisLog(success ? StringResources.Finished : StringResources.ErrorWhileCompiling);
                VisLog(LogLine);

                if (GlobalVariables.AppSettings.ShowNotifications)
                {
                    NotificationService.Instance.ShowMessage(StringResources.CompilationFinished);
                }

                if (!success && errors.Any(error => error.Type != Error.ErrorType.None))
                {
                    if (MessBox.ShowDial("Обнаружены ошибки. Попробовать исправить?", "", MessBox.MessageButtons.Yes, MessBox.MessageButtons.No) == MessBox.MessageButtons.Yes)
                    {
                        Apktools.FixErrors(errors);
                        BuildCommand_Execute();
                    }
                }
                else
                {
                    VisLog(StringResources.FileIsSituatedIn + " " + Apk.NewApk);
                }

                RaiseCommandsCanExecute();
            },
                cancelVisibility: Visibility.Collapsed,
                ownerWindow: _window
                );
        }