Пример #1
0
 private void JumpSimulation(object sender, EventArgs e)
 {
     try
     {
         var steps = uint.Parse(tbJump.Text);
         this.UseWaitCursor = true;
         _computing         = true;
         Stopwatch stopwatch = new Stopwatch();
         stopwatch.Start();
         for (int i = 0; i < steps; i++)
         {
             SimulationStep();
         }
         stopwatch.Stop();
         MessageBoxService.ShowInfo("Elapsed: " + stopwatch.Elapsed);
         this.UseWaitCursor = false;
         _simulationState   = SimulationState.Paused;
         _computing         = false;
         EnableButtons();
     }
     catch (Exception)
     {
         MessageBoxService.ShowError("Provide positive number!");
     }
 }
Пример #2
0
        private async Task <bool> ImportProp(string path)
        {
            var dependencyResolver = this.GetDependencyResolver();
            var pleaseWaitService  = dependencyResolver.Resolve <IPleaseWaitService>();

            pleaseWaitService.Show();
            try
            {
                IModelImport import = new XModelImport();
                var          p      = await import.ImportAsync(path);

                if (p != null)
                {
                    Prop     = p;
                    FilePath = String.Empty;
                    //Switch to selection mode VIX-2784
                    DrawingPanelViewModel.IsDrawing = false;
                }
            }
            catch (Exception e)
            {
                pleaseWaitService.Hide();
                Logging.Error(e, "An error occuring importing the xModel.");
                var mbs = new MessageBoxService();
                mbs.ShowError($"An error occurred importing the xModel. Please notify the Vixen Team.", "Error Importing xModel");
                return(false);
            }

            pleaseWaitService.Hide();

            return(true);
        }
Пример #3
0
        public void ShowGFlagsDialog(int processId)
        {
            var messageBox = new MessageBoxService();

            try
            {
                var settings = Application.Current.Properties[Constants.SettingsKey] as ApplicationSettings;
                if (settings == null)
                {
                    return;
                }

                var dlg = new GFlagsWindow();
                var vm  = new GFlagsViewModel(new GFlags(settings.ToolDirectory, new ProcessHelper()), processId);

                dlg.Owner = Application.Current.MainWindow;
                dlg.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                dlg.DataContext           = vm;
                dlg.ShowDialog();
            }
            catch (Exception ex)
            {
                messageBox.ShowError(ex.Message, "");
            }
        }
Пример #4
0
        private void Apply(object sender, EventArgs e)
        {
            try
            {
                var input = tbWidth.Text;
                var width = uint.Parse(input);
                _k     = int.Parse(tbK.Text);
                _width = width;

                GenerateBoards();

                AppState.Instance.Width  = width;
                AppState.Instance.Solver = new Solver(AppState.Instance.Blocks.Select(b => new MultipleBlock()
                {
                    Count = b.Count,
                    Block = new BoardBlock(b, new Point())
                }).ToList(), (int)_width, _k);

                _width    = width;
                _cellSize = (int)(_panelCanvas.Width / _width);
                _panelCanvas.Invalidate();
            }
            catch (FormatException)
            {
                MessageBoxService.ShowError("Invalid operation!");
            }
        }
        private bool Validate()
        {
            if (string.IsNullOrEmpty(mStringMatch.Value) && string.IsNullOrEmpty(mRegexMatch.Value))
            {
                MessageBoxService.ShowError("Either 'String to Match' or 'Regex to Match' must be specified.");
                return(false);
            }

            return(true);
        }
        private void App_OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            var exception = e.Exception;

            if (exception != null)
            {
                MessageBoxService.ShowError($"{e.Exception.Message}", "Error");
            }
            e.Handled = true;
        }
 public static void Execute(ICommand command)
 {
     try
     {
         command.Execute();
     }
     catch (Exception exception)
     {
         MessageBoxService.ShowError(exception);
     }
 }
Пример #8
0
        private void OnInputChange(object sender, EventArgs e)
        {
            var input = tbBlocksCount.Text;

            try
            {
                var count = int.Parse(input);
                _block.Count = count;
                _form.UpdateForm();
            }
            catch (FormatException)
            {
                MessageBoxService.ShowError("Invalid operation!");
            }
        }
        private void ExecuteShowCommand(object x)
        {
            // Microsoft.TeamFoundation.MVVM.ViewModelBaseのMessageBoxServiceプロパティに、
            // MessageBoxに関するものが設定されている
            var r = MessageBoxService.Show("Yes or No", "title", System.Windows.MessageBoxButton.YesNo);

            if (r == System.Windows.MessageBoxResult.Yes)
            {
                MessageBoxService.ShowInformation("Yes", "info");
            }
            else
            {
                MessageBoxService.ShowError("No", "error");
            }
        }
Пример #10
0
 /// <summary>
 /// Set for every block count given number.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ApplyBlocksCount(object sender, EventArgs e)
 {
     try
     {
         var count = uint.Parse(tbPerBlockCount.Text);
         foreach (var block in _blocks)
         {
             block.Count = (int)count;
         }
         Draw();
     }
     catch (Exception)
     {
         MessageBoxService.ShowError("Provide positive number!");
     }
 }
Пример #11
0
        private void Set(Process process)
        {
            try
            {
                _process = process;
                _process.EnableRaisingEvents = true;
                ProcessId = process.Id;

                _process.Exited += OnProcessExited;

                IsRunning = !process.HasExited;
            }
            catch (Exception ex)
            {
                var message = string.Format(CultureInfo.InvariantCulture, Strings.ErrorSelectProcess, ex.Message);
                var caption = Strings.ProcessCaption;

                _messageBox.ShowError(message, caption);
                Clear();
            }
        }
        public static void Invoke(ICommand command, Action <Exception> onCompleted = null)
        {
            ThreadPool.QueueUserWorkItem(o =>
            {
                Exception error = null;
                try
                {
                    command.Execute();
                }
                catch (Exception exception)
                {
                    MessageBoxService.ShowError(exception);
                    error = exception;
                }

                if (onCompleted != null)
                {
                    onCompleted(error);
                }
            });
        }
Пример #13
0
        private async void LoadingView_Load(object sender, EventArgs e)
        {
            var botMgr = new BotManager(_keys, _logger);

            progressBar.Maximum = _bots.Count;

            int i = 0;

            foreach (var bot in _bots)
            {
                i++;
                progressBar.Value = i;
                decimal percentage = ((decimal)i / _bots.Count) * 100;
                lblPercentage.Text = $"{(int)percentage} %";

                if (_cancelled)
                {
                    lblProgress.Text    = "Operation has been cancelled.";
                    progressBar.Enabled = false;
                    btnCancel.Visible   = false;
                    btnClose.Visible    = true;
                    _mbs.ShowError("Operation cancelled!", "");
                    return;
                }

                if (_newSettings.IsEnabled.HasValue)
                {
                    if (_newSettings.IsEnabled.Value)
                    {
                        await botMgr.Enable(bot.Id);
                    }
                    else
                    {
                        await botMgr.Disable(bot.Id);
                    }
                }

                var updateData = new BotUpdateData(bot);
                if (_newSettings.ActiveSafetyOrdersCount.HasValue)
                {
                    updateData.ActiveSafetyOrdersCount = _newSettings.ActiveSafetyOrdersCount.Value;
                }
                if (_newSettings.BaseOrderVolume.HasValue)
                {
                    updateData.BaseOrderVolume = _newSettings.BaseOrderVolume.Value;
                }
                if (_newSettings.Cooldown.HasValue)
                {
                    updateData.Cooldown = _newSettings.Cooldown.Value;
                }
                if (_newSettings.MartingaleStepCoefficient.HasValue)
                {
                    updateData.MartingaleStepCoefficient = _newSettings.MartingaleStepCoefficient.Value;
                }
                if (_newSettings.MartingaleVolumeCoefficient.HasValue)
                {
                    updateData.MartingaleVolumeCoefficient = _newSettings.MartingaleVolumeCoefficient.Value;
                }
                if (_newSettings.MaxSafetyOrders.HasValue)
                {
                    updateData.MaxSafetyOrders = _newSettings.MaxSafetyOrders.Value;
                }
                if (!string.IsNullOrWhiteSpace(_newSettings.Name))
                {
                    updateData.Name = BotManager.GenerateNewName(_newSettings.Name, bot.Strategy.ToString(), bot.Pairs.Single());
                }
                if (_newSettings.SafetyOrderStepPercentage.HasValue)
                {
                    updateData.SafetyOrderStepPercentage = _newSettings.SafetyOrderStepPercentage.Value;
                }
                if (_newSettings.StartOrderType.HasValue)
                {
                    updateData.StartOrderType = _newSettings.StartOrderType.Value;
                }
                if (_newSettings.SafetyOrderVolume.HasValue)
                {
                    updateData.SafetyOrderVolume = _newSettings.SafetyOrderVolume.Value;
                }
                if (_newSettings.TakeProfit.HasValue)
                {
                    updateData.TakeProfit = _newSettings.TakeProfit.Value;
                }
                if (_newSettings.TrailingDeviation.HasValue)
                {
                    updateData.TrailingDeviation = _newSettings.TrailingDeviation.Value;
                }
                if (_newSettings.TrailingEnabled.HasValue)
                {
                    updateData.TrailingEnabled = _newSettings.TrailingEnabled.Value;
                }
                if (_newSettings.BaseOrderVolumeType.HasValue)
                {
                    updateData.BaseOrderVolumeType = _newSettings.BaseOrderVolumeType.Value;
                }
                if (_newSettings.SafetyOrderVolumeType.HasValue)
                {
                    updateData.SafetyOrderVolumeType = _newSettings.SafetyOrderVolumeType.Value;
                }

                if (_newSettings.DisableAfterDealsCountInfo != null)
                {
                    if (_newSettings.DisableAfterDealsCountInfo.Enable)
                    {
                        updateData.DisableAfterDealsCount = _newSettings.DisableAfterDealsCountInfo.Value;
                    }
                    else
                    {
                        updateData.DisableAfterDealsCount = null;
                    }
                }

                if (_newSettings.DealStartConditions.Any())
                {
                    updateData.Strategies.Clear();
                    updateData.Strategies.AddRange(_newSettings.DealStartConditions);
                }

                var res = await botMgr.SaveBot(bot.Id, updateData);

                if (res.IsSuccess)
                {
                    _logger.LogInformation($"Bot {bot.Id} updated");
                }
                else
                {
                    _logger.LogError($"Could not update Bot {bot.Id}. Reason: {res.Error}");
                }
            }

            _mbs.ShowInformation("Bulk Edit finished. See output section for details.");
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
 protected override void OnUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     MessageBoxService.ShowError(e.Exception.InnerException);
     e.Handled = true;
 }
Пример #15
0
        private void CheckUser(User loginUser)
        {
            // Default UserName and Password for Config
            // UserName = Config and Password = ConfigPass
            if (loginUser.Name == "Config" && loginUser.Password == "096E62FD294491F0D2E9C007012C9E94")
            {
                /*
                 * // Show SQL Connection Config Form
                 * ConnectionConfigWindow objConfigWindow = new ConnectionConfigWindow();
                 * this.Hide();
                 * objConfigWindow.Owner = this;
                 * bool dg = (bool)objConfigWindow.ShowDialog();
                 * if (dg == true)
                 * {
                 *  this.DialogResult = false;
                 * }
                 * else
                 * {
                 *  txbUserName.Focus();
                 * }
                 * objConfigWindow = null;*/
            }
            else
            {
                try
                {
                    User searchUser = (ModelManager as IUserManager).GetList().FirstOrDefault(x => x.Name == loginUser.Name);

                    if (searchUser != null)
                    {
                        // waiter is not allowed to login into this client software
                        if (searchUser.Role.Id == (byte)Role.Waiter)
                        {
                            MessageService.ShowWarning(MessageList.UserNotAllowed);
                        }
                        else
                        {
                            if (searchUser.Password == loginUser.Password)
                            {
                                // get all information of user
                                try
                                {
                                    // get current user that logged in
                                    GlobalObjects.SystemUser = (ModelManager as IUserManager).GetById(searchUser.Id);
                                    // request close the view
                                    this.RaiseCloseRequest(true);
                                }
                                catch (Exception ex)
                                {
                                    MessageBoxService.ShowError("Error: " + ex.Message + "\nError while read information of user");
                                }
                            }
                            else
                            {
                                MessageService.ShowWarning(MessageList.PasswordNotValid);
                            }
                        }
                    }
                    else
                    {
                        MessageService.ShowWarning(MessageList.UserNotValid);
                    }
                }
                catch (Exception ex)
                {
                    MessageService.ShowError(MessageList.UnhandleException + ex.Message);
                }
            }
        }