Пример #1
0
        private void b_install_apk_Click(object sender, RoutedEventArgs e)
        {
            string[] dirs   = { };
            var      dialog = new CommonOpenFileDialog();

            dialog.IsFolderPicker = true;
            if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                dirs = dialog.FileNames.ToArray();
            }
            Install install = new Install();

            if (dirs.Length < 1)
            {
                util.dc.ConsoleInput = "Path wasn't specified, to complete APK install, give an exist path";
                return;
            }

            //show all apks in the folder
            string[] filePaths = Directory.GetFiles(dirs[0], "*.apk",
                                                    SearchOption.AllDirectories);


            string[] results = { };
            var      items   = new installedItems(filePaths.ToList());

            if ((bool)items.ShowDialog() == true)
            {
                results = System.IO.File.ReadAllLines(con.Get_ToInstall());
            }


            //wait till the list of items to be installed return


            var uiContext = SynchronizationContext.Current;

            if (results.Length > 0)
            {
                this.Dispatcher.Invoke((Action) delegate
                {
                    Task.Run(() => install.Install_APKs(results)).ContinueWith(task => uiContext.Send(x => logItems.Add(Utilities.TextToLog), null));
                });


                //var run = Task.Run(() => install.Install_APKs(results)).ContinueWith(failedTask => Console.WriteLine("APK is already installed"),
                //               TaskContinuationOptions.OnlyOnFaulted);
            }
            else
            {
            }
        }
Пример #2
0
        private void b_push_cal_Click(object sender, RoutedEventArgs e)
        {
            string[] dirs   = { };
            var      dialog = new CommonOpenFileDialog();

            dialog.IsFolderPicker = true;
            if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                dirs = dialog.FileNames.ToArray();
            }
            Install install = new Install();

            if (dirs.Length < 1)
            {
                util.dc.ConsoleInput = "Path wasn't specified, to complete APK install, give an exist path";
                return;
            }

            //show all apks in the folder
            string[] filePaths = Directory.GetFiles(dirs[0], "*.cal",
                                                    SearchOption.AllDirectories);


            string[] results = { };
            var      items   = new installedItems(filePaths.ToList());

            if ((bool)items.ShowDialog() == true)
            {
                results = System.IO.File.ReadAllLines(con.Get_ToInstall());
            }

            var uiContext = SynchronizationContext.Current;



            var t = Task.Run(() => pushCalib(results)).ContinueWith(task => uiContext.Send(x => logItems.Add(Utilities.TextToLog), null));

            if (Utilities.Progress == 100)
            {
                if (t.Status == TaskStatus.Faulted)
                {
                    foreach (var i in t.Exception.InnerExceptions)
                    {
                        Error.Text = i.Message;
                        logItems.Add(Error);
                    }
                }
            }
        }
Пример #3
0
        private void b_install_Click(object sender, RoutedEventArgs e)
        {
            string[] empty   = {};
            string[] dir     = { };
            string[] results = { };
            var      dialog  = new CommonOpenFileDialog();

            dialog.IsFolderPicker = true;

            //CommonFileDialogResult result = dialog.ShowDialog();
            if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                dir = dialog.FileNames.ToArray();
            }
            Install install = new Install();

            if (dir.Length < 1)
            {
                return;
            }


            string[] files = Directory.GetFiles(dir[0], "*.img",
                                                SearchOption.AllDirectories);

            List <string> files_ = new List <string>();
            List <string> inGame = new List <string>();

            JsonParser J_S        = new JsonParser();
            FirsrHirc  jsonObject = J_S.Parse();
            var        t          = jsonObject.install.list;

            foreach (var im in t)
            {
                inGame.Add(im.image);
            }

            foreach (var file in files)
            {
                string g = System.IO.Path.GetFileName(file);
                if (inGame.Contains(g))
                {
                    files_.Add(file);
                }
            }


            //show all images in the folder

            var items = new installedItems(files_.ToList());

            if (!(bool)items.ShowDialog() == true)
            {
                return;
            }

            l_calib_files_val.Content  = "None";
            l_config_files_val.Content = "None";
            l_engine_val.Content       = "None";
            l_hexagon_val.Content      = "None";
            l_release_val.Content      = "None";
            l_config_files_val.Content = "None";
            Utilities.Hexagon          = "";

            Item k = new Item()
            {
                Text = "Start instllation, it may take few minutes."
            };

            logItems.Add(k);
            var backgroundScheduler = TaskScheduler.Default;
            var uiScheduler         = TaskScheduler.FromCurrentSynchronizationContext();
            var uiContext           = SynchronizationContext.Current;

            this.Dispatcher.Invoke((Action) delegate
            {
                Item i = new Item()
                {
                    Text = "wait while device is rebooting, the installation wait 60 sec after reboot"
                };
                Task.Factory.StartNew(delegate { install.Enter_Boot_Loader(empty); },
                                      backgroundScheduler).
                ContinueWith(delegate { uiContext.Send(x => logItems.Add(Utilities.TextToLog), null); }, uiScheduler).
                ContinueWith(delegate { uiContext.Send(x => logItems.Add(i), null); }, uiScheduler).
                ContinueWith(delegate { install.Fastboot_Reboot(); }, backgroundScheduler).
                ContinueWith(delegate { uiContext.Send(x => logItems.Add(i), null); }, uiScheduler);
            });
        }