Exemple #1
0
        private void StartButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Assert(deviceList.SelectedIndex != -1, "No connected devices!\n\r" +
                       "Check connection and required drivers.");

                Assert(deviceBootloader.SelectedIndex != -1, "Couldn't find any valid bootloader!");
            }
            catch
            {
                return;
            }

            IsEnabled = false;

            var eventArgs = new FormEventArgs
            {
                TargetMode = IsSelectedDeviceInFastbootMode
                    ? UsbController.Device.DMode.Fastboot
                    : UsbController.Device.DMode.DownloadVCOM,
                Target        = deviceList.SelectedItem.ToString(),
                DisableFBLOCK = disableFBLOCK.IsChecked.Value,
                Reboot        = reboot.IsChecked.Value
            };

            if (!IsSelectedDeviceInFastbootMode)
            {
                eventArgs.Bootloader = bootloaders.First(x => x.Title == deviceBootloader.SelectedItem.ToString());
            }

            OnFormSubmit?.Invoke(eventArgs);
        }
Exemple #2
0
        public bool NotifySubmit(IStringLocalizer <MComponentsLocalization> pLocalizer)
        {
            bool submitSuccessful = true;

            lock (mLocker)
            {
                if (OnFormSubmit == null)
                {
                    return(submitSuccessful);
                }

                var args = new MFormContainerContextSubmitArgs()
                {
                    UserInterated = true
                };

                foreach (var handler in OnFormSubmit.GetInvocationList())
                {
                    try
                    {
                        handler.Method.Invoke(handler.Target, new object[] { this, args });
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Error in the handler {0}: {1}", handler.Method.Name, e.Message);

                        string msg = e.ToString();

                        if (e is TargetInvocationException te)
                        {
                            msg = te.InnerException.ToString();

                            if (te.InnerException is UserMessageException ue)
                            {
                                msg = ue.Message;
                            }
                        }

                        Notificator.InvokeNotification(true, msg);
                        submitSuccessful = false;
                    }
                }

                Notificator.InvokeNotification(false, pLocalizer["Gespeichert!"]);
            }

            return(submitSuccessful);
        }
Exemple #3
0
        private void StartButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Assert(deviceList.SelectedIndex != -1, "No connected devices!\n\r" +
                       "Check connection and required drivers.");

                Assert(deviceBootloader.SelectedIndex != -1, "Couldn't find any valid bootloader!");

                Assert(VerifyNVValue(nvSerialNumber.Text), "Serial number is not valid.");

                Assert(VerifyNVValue(nvBidNumber.Text), "BoardID is not valid.");

                Assert(VerifyNVValue(nvUnlockCode.Text, true), "Unlock code is not valid.");
            }
            catch
            {
                return;
            }

            IsEnabled = false;

            var eventArgs = new FormEventArgs
            {
                TargetMode = IsSelectedDeviceInFastbootMode
                    ? UsbController.Device.DMode.Fastboot
                    : UsbController.Device.DMode.DownloadVCOM,
                Target        = deviceList.SelectedItem.ToString(),
                BoardID       = nvBidNumber.Text,
                UnlockCode    = nvUnlockCode.Text,
                SerialNumber  = nvSerialNumber.Text,
                DisableFBLOCK = disableFBLOCK.IsChecked.Value
            };

            if (!IsSelectedDeviceInFastbootMode)
            {
                eventArgs.Bootloader = bootloaders.First(x => x.Title == deviceBootloader.SelectedItem.ToString());
            }

            OnFormSubmit?.Invoke(eventArgs);
        }
        public async Task <bool> NotifySubmit(IStringLocalizer <MComponentsLocalization> pLocalizer)
        {
            if (OnFormSubmit == null)
            {
                return(true);
            }

            bool submitSuccessful = true;

            try
            {
                await mLocker.WaitAsync();

                var args = new MFormContainerContextSubmitArgs()
                {
                    UserInterated = true
                };

                foreach (AsyncEventHandler <MFormContainerContextSubmitArgs> handler in OnFormSubmit.GetInvocationList())
                {
                    try
                    {
                        await handler(this, args);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Error in the handler {0}: {1}", handler.Method.Name, e.Message);

                        string msg = e.ToString();

                        if (e is TargetInvocationException te)
                        {
                            msg = te.InnerException.ToString();

                            if (te.InnerException is UserMessageException ue)
                            {
                                msg = ue.Message;
                            }
                        }

                        Notificator.InvokeNotification(true, msg);
                        submitSuccessful = false;
                    }
                }

                if (FormContainer.OnAfterAllFormsSubmitted.HasDelegate)
                {
                    await FormContainer.OnAfterAllFormsSubmitted.InvokeAsync(new MFormContainerAfterAllFormsSubmittedArgs()
                    {
                        AllFormsSuccessful = submitSuccessful
                    });
                }

                Notificator.InvokeNotification(false, pLocalizer["Gespeichert!"]);
            }
            finally
            {
                mLocker.Release();
            }

            return(submitSuccessful);
        }