コード例 #1
0
        private static void TV_DropCommand_Execute(DragEventArgs args)
        {
            args.Handled = true;

            string[] list = args.GetFilesDrop();

            if (list == null)
            {
                return;
            }

            List <IEditableFile> files = list.Select(AndroidFilesUtils.GetSuitableEditableFile).Where(it => it != null).ToList();

            WindowManager.ActivateWindow <EditorWindow>();

            if (files.Count == 0)
            {
                return;
            }

            ManualEventManager.GetEvent <AddEditableFilesEvent>()
            .Publish(new AddEditableFilesEvent(files, false));

            string fileName = files[0].FileName;

            ManualEventManager.GetEvent <EditorScrollToFileAndSelectEvent>()
            .Publish(new EditorScrollToFileAndSelectEvent(f => f.FileName.Equals(fileName, StringComparison.Ordinal)));
        }
コード例 #2
0
        private void LoadFiles(string extension, Func <string, IEditableFile> createNew)
        {
            ConcurrentQueue <IEditableFile> filesList = null;

            LoadingProcessWindow.ShowWindow(
                beforeStarting: () => IsBusy = true,
                threadActions: (cts, invoker) =>
            {
                invoker.IsIndeterminate = true;

                string[] files = Directory.GetFiles(_globalVariables.CurrentProjectFolder.Value, "*" + extension, SearchOption.AllDirectories);

                invoker.IsIndeterminate = false;

                invoker.ProcessMax = files.Length;

                filesList = new ConcurrentQueue <IEditableFile>();

                Parallel.ForEach(files, file =>
                {
                    if (!CommonUtils.CheckFilePath(file))
                    {
                        return;
                    }

                    cts.ThrowIfCancellationRequested();

                    try
                    {
                        filesList.Enqueue(createNew(file));
                    }
                    catch (Exception)
                    {
                        // ignored
                    }

                    invoker.ProcessValue++;
                });
            },
                finishActions: () =>
            {
                List <IEditableFile> res =
                    (filesList ?? Enumerable.Empty <IEditableFile>())
                    .Where(file => file.Details != null && file.Details.Count > 0)
                    .ToList();

                IsBusy = false;

                WindowManager.ActivateWindow <EditorWindow>();

                ManualEventManager.GetEvent <AddEditableFilesEvent>()
                .Publish(new AddEditableFilesEvent(res));
            },
                ownerWindow: _window
                );
        }
コード例 #3
0
        private static void TV_LoadAllInXmlCommand_Execute(FilesTreeViewNodeModel model)
        {
            if (model.Options.Ext != ".xml" || !IOUtils.FileExists(model.Options.FullPath))
            {
                return;
            }

            var file = new XmlFile(model.Options.FullPath, XmlFile.XmlRules, true);

            WindowManager.ActivateWindow <EditorWindow>();

            ManualEventManager.GetEvent <AddEditableFilesEvent>()
            .Publish(new AddEditableFilesEvent(file));
        }
コード例 #4
0
ファイル: App.xaml.cs プロジェクト: bazickoff/TranslatorApk
        protected override void OnStartup(StartupEventArgs e)
        {
            AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
            {
                var ex = args.ExceptionObject is Exception exception ? exception : new Exception("Domain exception");

                Logger.Fatal(ex);
                GlobalVariables.BugSnagClient.Notify(ex);

                Clipboard.SetText("Message: " + (args.ExceptionObject as Exception)?.FlattenToString());
                MessageBox.Show(StringResources.UnhandledExceptionOccured);
            };

            DispatcherUnhandledException += (sender, args) =>
            {
                Logger.Error(args.Exception);
                GlobalVariables.BugSnagClient.Notify(args.Exception);

                Clipboard.SetText(args.Exception.ToString());
                MessageBox.Show(string.Format(StringResources.ExceptionOccured, args.Exception.FlattenToString()));
#if !DEBUG
                args.Handled = true;
#endif
            };

            if (e.Args.FirstOrDefault() == "update")
            {
                new DownloadWindow().Show();
                return;
            }

            CommonUtils.LoadSettings();

#if !DEBUG
            if (!GlobalVariables.Portable)
#endif
            CommonUtils.CheckForUpdate();

            if (string.IsNullOrEmpty(GlobalVariables.AppSettings.ApktoolVersion))
            {
                Logger.Error("Apktool not found");
                MessBox.ShowDial(StringResources.ApktoolNotFound);
            }

            WindowManager.ActivateWindow <MainWindow>();
        }
コード例 #5
0
        /// <summary>
        /// Загружает файл в редактор
        /// </summary>
        /// <param name="pathToFile">Файл</param>
        public static void LoadFile(string pathToFile)
        {
            var ext = Path.GetExtension(pathToFile);

            if (!GlobalVariables.EditableFileExtenstions.Contains(ext))
            {
                Process.Start(pathToFile);
                return;
            }
            
            IEditableFile file;

            try
            {
                switch (ext)
                {
                    case ".xml":
                        file = XmlFile.Create(pathToFile);
                        break;
                    default: //".smali":
                        file = new SmaliFile(pathToFile);
                        break;
                }
            }
            catch (IOException ex)
            {
                // todo: add to string resources
                MessBox.ShowDial($"Не удалось загрузить файл из-за ошибки системы.\nСообщение: {ex.Message}", StringResources.ErrorLower);
                return;
            }

            WindowManager.ActivateWindow<EditorWindow>();

            ManualEventManager.GetEvent<AddEditableFilesEvent>()
                .Publish(new AddEditableFilesEvent(file));

            ManualEventManager.GetEvent<EditorScrollToFileAndSelectEvent>()
                .Publish(new EditorScrollToFileAndSelectEvent(f => f.FileName.Equals(file.FileName, StringComparison.Ordinal)));
        }
コード例 #6
0
 private static void OpenEditorCommand_Execute()
 {
     WindowManager.ActivateWindow <EditorWindow>();
 }
コード例 #7
0
 private static void OpenChangesDetectorCommand_Execute()
 {
     WindowManager.ActivateWindow <ChangesDetectorWindow>(ownerWindow: WindowManager.GetActiveWindow <TranslatorApk.Windows.MainWindow>());
 }