Ejemplo n.º 1
0
        public static void ToggleCapture(CaptureCommand command)
        {
            LOG.Info($"Processing toggle capture command: {command}");
            // Don't accept toggle commands until previous one completes
            if (_captureToggleInProgress)
            {
                LOG.Info($"Toggle capture in progress. Ignoring command: {command}");
                return;
            }
            _captureToggleInProgress = true;
            LOG.Info("Toggle capture lock set");

            // Don't execute toggle task on a separate thread if already running on a background thread
            if (Thread.CurrentThread.IsBackground)
            {
                LOG.Info("Executing toggle capture command on the same thread");
                ExecuteToggleCaptureCommand(command);
            }
            else
            {
                LOG.Info("Executing toggle capture command on a new background thread");
                new Thread(() => ExecuteToggleCaptureCommand(command))
                {
                    IsBackground = true
                }.Start();
            }
        }
Ejemplo n.º 2
0
        private void UpdateButtonState()
        {
            if (CaptureCommand == null)
            {
                return;
            }

            CaptureCommand.NotifyCanExecuteChanged();
            StartStopRecordCommand.NotifyCanExecuteChanged();
            ToggleCameraCommand.NotifyCanExecuteChanged();
        }
        private void OnOK(object sender, EventArgs e)
        {
            //TODO:Model database
            //TODO:Display Confirmation
            var modelFFU = new CaptureCommand();

            MessageBox.Show(modelFFU.DISMSafe(modelBox.Text));
            modelFFU.RestoreModel(modelFFU.DISMSafe(modelBox.Text));

            Close();
            //TODO:Something, database query to pre-fill model names
        }
Ejemplo n.º 4
0
        public MainViewModel()
        {
            SetMessage(AutoRefresh ?
                       "MO の Preview Pane を探しています" :
                       "MO の Preview Pane を表示させた状態で、右クリックから「MO を探す」を選択してください。");

            CaptureCommand         = new CaptureCommand(this);
            CopyCardNameCommand    = new CopyCardNameCommand(this);
            CopyEnglishNameCommand = new CopyEnglishNameCommand(this);
            GoToWikiCommand        = new GoToWikiCommand(this);
            OptionCommand          = new OptionCommand(this);
            ArrangeToolbarCommands();

            automation = new AutomationHandler(this);
        }
Ejemplo n.º 5
0
        private void ToggleCapture(CaptureCommand command, bool executeOnNewThread, bool useBackgroundThread)
        {
            LOG.Info($"Processing toggle capture command: {command}");
            // Don't accept toggle commands until previous one completes
            if (_captureToggleInProgress)
            {
                LOG.Info($"Toggle capture in progress. Ignoring command: {command}");
                return;
            }

            if (OnUiThread())
            {
                GetCaptureToggleTrayMenuItem().Enabled = false;
            }
            else
            {
                Invoke(new Action(() =>
                {
                    GetCaptureToggleTrayMenuItem().Enabled = false;
                }));
            }

            _captureToggleInProgress = true;
            LOG.Info("Toggle capture lock set");

            // Don't execute toggle task on a separate thread if already running on a background thread
            if (Thread.CurrentThread.IsBackground)
            {
                LOG.Info("Executing toggle capture command on the same thread");
                ExecuteToggleCaptureCommand(command);
            }
            else
            {
                if (executeOnNewThread)
                {
                    LOG.Info($"Executing toggle capture command on a new Thread[IsBackground = {useBackgroundThread}]");
                    new Thread(() => ExecuteToggleCaptureCommand(command))
                    {
                        IsBackground = useBackgroundThread
                    }.Start();
                }
                else
                {
                    LOG.Info("Executing toggle capture command on the same Thread");
                    ExecuteToggleCaptureCommand(command);
                }
            }
        }
        private void OnOK(object sender, EventArgs e)
        {
            string temp    = txtAssetEntry.Text;
            bool   success = Int32.TryParse(temp, out _);

            if (!success)
            {
                MessageBox.Show("This method is for restoring specific assets and is not suitable for generic images. Please select a different image", "Warning", MessageBoxButtons.OK);
                return;
            }
            else
            {
                var asset = new CaptureCommand();
                asset.RestoreAsset(txtAssetEntry.Text);
                Close();
            }
            //TODO:Fix browse button, display confirmations.
        }
Ejemplo n.º 7
0
        private void ExecuteToggleCaptureCommand(CaptureCommand command)
        {
            try
            {
                switch (command)
                {
                case CaptureCommand.ON:
                    _trayIcon.Icon = Resources.Hyperion_enabled;
                    _trayIcon.Text = AppConstants.TrayIcon.TOOLTIP_CAPTURE_ENABLED;
                    Invoke(new Action(() =>
                    {
                        GetCaptureToggleTrayMenuItem().Text  = AppConstants.TrayIcon.MENU_TXT_STOP_CAPTURE;
                        GetCaptureToggleTrayMenuItem().Image = Resources.disable_capture.ToBitmap();
                    }));
                    EnableCapture();
                    break;

                case CaptureCommand.OFF:
                    _trayIcon.Icon = Resources.Hyperion_disabled;
                    _trayIcon.Text = AppConstants.TrayIcon.TOOLTIP_CAPTURE_DISABLED;
                    Invoke(new Action(() =>
                    {
                        GetCaptureToggleTrayMenuItem().Text  = AppConstants.TrayIcon.MENU_TXT_START_CAPTURE;
                        GetCaptureToggleTrayMenuItem().Image = Resources.enable_capture.ToBitmap();
                    }));
                    DisableCapture();
                    break;

                default:
                    throw new NotImplementedException($"The capture command {command} is not supported");
                }
                LOG.Info($"Toggle capture command {command} completed");
            }
            finally
            {
                Invoke(new Action(() =>
                {
                    GetCaptureToggleTrayMenuItem().Enabled = true;
                }));
                _captureToggleInProgress = false;
                LOG.Info("Toggle capture lock unset");
            }
        }
Ejemplo n.º 8
0
        /*
         * private void DisplayConfirm(string message)
         * {
         *  MessageBox.Show(message, "Confirm", MessageBoxButtons.YesNo);
         * }
         */
        private void OnOK(object sender, EventArgs e)
        {
            bool fileExists = false;
            var  modelFFU   = new CaptureCommand();

            string[] modelLine = System.IO.File.ReadAllLines("I:\\images\\ModelList.txt");
            if (modelFFU.CheckIfExists(modelLine, txtModelEntry.Text, out var message, out var temp))
            {
                DialogResult result = MessageBox.Show(message, "Confirm", MessageBoxButtons.YesNo);
                if (result == DialogResult.No)
                {
                    return;
                }
                else
                {
                    fileExists = true;
                    modelFFU.AddModel(temp);
                }
            }
            if (!fileExists)
            {
                using (System.IO.StreamWriter file = new System.IO.StreamWriter("I:\\images\\ModelList.txt", true))
                {
                    file.WriteLine(temp);
                }
                using (System.IO.StreamWriter fileStar = new System.IO.StreamWriter("I:\\images\\ModelListStar.txt", true))
                {
                    fileStar.WriteLine(modelFFU.StarSafe(temp));
                }
                modelLine = System.IO.File.ReadAllLines("I:\\images\\ModelList.txt");
                Array.Sort(modelLine);

                System.IO.File.WriteAllLines("I:\\images\\ModelList.txt", modelLine);
                modelFFU.AddModel(temp);

                modelLine = System.IO.File.ReadAllLines("I:\\images\\ModelListStar.txt");
                Array.Sort(modelLine);

                System.IO.File.WriteAllLines("I:\\images\\ModelListStar.txt", modelLine);
            }
            Close();
        }
Ejemplo n.º 9
0
        private void OnOK(object sender, EventArgs e)
        {
            /* This has been moved to WimSystemCommand
             * //TODO:Display Confirmation
             * var assetFFU = new WimSystemCommand();
             * assetFFU.Asset = txtAssetEntry.Text;
             * assetFFU.FinalCommand = assetFFU.Base + assetFFU.Asset + assetFFU.End + "\"windows\"";
             * //MessageBox.Show(modelFFU.FinalCommand, "info", MessageBoxButtons.OK, MessageBoxIcon.Information); To see command output
             * var FFUCreate = new ProcessStartInfo();
             * FFUCreate.UseShellExecute = true;
             * FFUCreate.WorkingDirectory = @"X:\Windows\System32";
             * //TODO:Verify directory in startup environment
             * FFUCreate.FileName = @"X:\Windows\System32\cmd.exe";
             * FFUCreate.Verb = "runas";
             * FFUCreate.Arguments = "/c " + assetFFU.FinalCommand;
             * FFUCreate.WindowStyle = ProcessWindowStyle.Maximized; //TODO:indication when it's done
             * Process.Start(FFUCreate);
             */
            var create = new CaptureCommand();

            create.AddAsset(txtAssetEntry.Text);

            Close();
        }
Ejemplo n.º 10
0
        private static void ExecuteToggleCaptureCommand(CaptureCommand command)
        {
            try
            {
                switch (command)
                {
                case CaptureCommand.ON:
                    TrayIcon.Icon   = Resources.Hyperion_enabled;
                    TrayIcon.Text   = AppConstants.TRAY_ICON_MSG_CAPTURE_ENABLED;
                    _captureEnabled = true;
                    _captureThread  = new Thread(TryStartCapture)
                    {
                        IsBackground = true
                    };
                    _captureThread.Start();
                    break;

                case CaptureCommand.OFF:
                    TrayIcon.Icon = Resources.Hyperion_disabled;
                    TrayIcon.Text = AppConstants.TRAY_ICON_MSG_CAPTURE_DISABLED;
                    TerminateScreenCapture();
                    ProtoClient.TryClearPriority(SettingsManager.HyperionMessagePriority);
                    DisconnectProtoClient();
                    break;

                default:
                    throw new NotImplementedException($"The capture command {command} is not supported");
                }
                LOG.Info($"Toggle capture command {command} completed");
            }
            finally
            {
                _captureToggleInProgress = false;
                LOG.Info("Toggle capture lock unset");
            }
        }
Ejemplo n.º 11
0
 public void ToggleCapture(CaptureCommand command)
 {
     ToggleCapture(command, true, true);
 }
Ejemplo n.º 12
0
        public async Task <IList <string> > Handle(CaptureCommand command, CancellationToken cancellationToken)
        {
            var paymentTransaction = command.PaymentTransaction;

            if (paymentTransaction == null)
            {
                throw new ArgumentNullException(nameof(command.PaymentTransaction));
            }

            var canCapture = await _mediator.Send(new CanCaptureQuery()
            {
                PaymentTransaction = paymentTransaction
            });

            if (!canCapture)
            {
                throw new GrandException("Cannot do capture for order.");
            }

            CapturePaymentResult result = null;

            try
            {
                result = await _paymentService.Capture(paymentTransaction);

                //event notification
                await _mediator.CapturePaymentTransactionDetailsEvent(result, paymentTransaction);

                if (result.Success)
                {
                    paymentTransaction = await _paymentTransaction.GetById(paymentTransaction.Id);

                    paymentTransaction.PaidAmount               = paymentTransaction.TransactionAmount;
                    paymentTransaction.CaptureTransactionId     = result.CaptureTransactionId;
                    paymentTransaction.CaptureTransactionResult = result.CaptureTransactionResult;
                    paymentTransaction.TransactionStatus        = result.NewPaymentStatus;

                    await _paymentTransaction.UpdatePaymentTransaction(paymentTransaction);

                    var order = await _orderService.GetOrderByGuid(paymentTransaction.OrderGuid);

                    if (order != null && paymentTransaction.TransactionStatus == TransactionStatus.Paid)
                    {
                        order.PaidAmount      = paymentTransaction.PaidAmount;
                        order.PaymentStatusId = PaymentStatus.Paid;
                        order.PaidDateUtc     = DateTime.UtcNow;
                        await _orderService.UpdateOrder(order);

                        await _mediator.Send(new CheckOrderStatusCommand()
                        {
                            Order = order
                        });

                        if (order.PaymentStatusId == PaymentStatus.Paid)
                        {
                            await _mediator.Send(new ProcessOrderPaidCommand()
                            {
                                Order = order
                            });
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                if (result == null)
                {
                    result = new CapturePaymentResult();
                }
                result.AddError(string.Format("Error: {0}. Full exception: {1}", exc.Message, exc));
            }


            //process errors
            string error = "";

            for (int i = 0; i < result.Errors.Count; i++)
            {
                error += string.Format("Error {0}: {1}", i, result.Errors[i]);
                if (i != result.Errors.Count - 1)
                {
                    error += ". ";
                }
            }
            if (!String.IsNullOrEmpty(error))
            {
                //log it
                await _logger.InsertLog(LogLevel.Error, $"Error capturing order code # {paymentTransaction.OrderCode}. Error: {error}", $"Error capturing order code # {paymentTransaction.OrderCode}. Error: {error}");
            }
            return(result.Errors);
        }
Ejemplo n.º 13
0
 public AutoModeViewModel()
 {
     CaptureCommand.Subscribe(CaptureInteraction);
     OkCommand.Subscribe(OKInteraction);
 }