Пример #1
0
        public MainViewModel(IMessageBoxService service)
        {
            this.service = service;
            MiListilla = new List<string>
                             {
                                 "Hello",
                                 "I enjoy a lot",
                                 "doing Drag",
                                 "and",
                                 "Drop!",
                                 "Oh yeah!",
                             };

            ShowMessageCommand = new SimpleCommand<object, object>(o => service.ShowInformation(string.Format("You've dropped a {0} into a {1}",  o.ToString(), DropTarget)));
        }
 public void UploadUserImageCompleted(int userId)
 {
     messageBoxService.ShowInformation(String.Format("Image for user {0} was uploaded", userId));
 }
Пример #3
0
 private void EditedOrderSuccessfullyMessageSink(Boolean dummy)
 {
     CurrentCustomerOrder.EndEdit();
     messageBoxService.ShowInformation("Need to do this, and same for edit");
 }
        private void Command_Executed()
        {
            IMessageBoxService messageBox = this.GlobalServiceProvider.Resolve <IMessageBoxService>();

            messageBox.ShowInformation("Command executed");
        }
Пример #5
0
 private void HelpOnClick()
 {
     mMessageBoxService.ShowInformation("Filters form a chain that the event has to pass through. Any filter along the way can accept the event and stop processing, deny the event and stop processing, or allow the event on to the next filter. If the event gets to the end of the filter chain without being denied it is implicitly accepted and will be logged. To reorder filters, click either '↑' or '↓'.");
 }
Пример #6
0
        /// <summary>
        /// Navigate forward command executed.
        /// </summary>
        protected virtual void PluginInformationCommandExecuted()
        {
            IMessageBoxService messageBox = this.GlobalServiceProvider.Resolve <IMessageBoxService>();

            messageBox.ShowInformation("Plugins need to be placed at the location of the editor in the '/plugins' directory");
        }
        private void btnCreate_Click(object sender, EventArgs e)
        {
            if (!HasChanges)
            {
                _mbs.ShowInformation("No changes to save.");
                return;
            }

            if (IsValid())
            {
                var dr = _mbs.ShowQuestion($"Save these settings to {_botCount} bots now?");
                if (dr == DialogResult.Yes)
                {
                    if (chkChangeIsEnabled.Checked)
                    {
                        if (cmbIsEnabled.SelectedItem.ToString() == "Enable")
                        {
                            EditDto.IsEnabled = true;
                        }
                        else if (cmbIsEnabled.SelectedItem.ToString() == "Disable")
                        {
                            EditDto.IsEnabled = false;
                        }
                    }

                    if (chkChangePair.Checked)
                    {
                        EditDto.Pair = cmbPair.SelectedItem.ToString();
                    }
                    if (chkChangeMaxActiveDeals.Checked)
                    {
                        EditDto.MaxActiveDeals = (int)numMaxActiveDeals.Value;
                    }

                    if (chkChangeProfitCurrency.Checked)
                    {
                        Enum.TryParse(cmbProfitCurrency.SelectedItem.ToString(), out ProfitCurrency profitCurrency);
                        EditDto.ProfitCurrency = profitCurrency;
                    }

                    if (chkChangeStartOrderType.Checked)
                    {
                        Enum.TryParse(cmbStartOrderType.SelectedItem.ToString(), out StartOrderType startOrderType);
                        EditDto.StartOrderType = startOrderType;
                    }
                    if (chkChangeBaseOrderSize.Checked)
                    {
                        EditDto.BaseOrderVolume = numBaseOrderVolume.Value;
                    }
                    if (chkChangeBaseOrderSizeType.Checked)
                    {
                        EditDto.BaseOrderVolumeType = (VolumeType?)((ComboBoxItem)cmbBaseOrderVolumeType.SelectedItem).EnumValue;
                    }
                    if (chkChangeName.Checked)
                    {
                        EditDto.Name = txtName.Text;
                    }
                    if (chkChangeSafetyOrderSize.Checked)
                    {
                        EditDto.SafetyOrderVolume = numSafetyOrderVolume.Value;
                    }
                    if (chkChangeSafetyOrderSizeType.Checked)
                    {
                        EditDto.SafetyOrderVolumeType = (VolumeType?)((ComboBoxItem)cmbSafetyOrderVolumeType.SelectedItem).EnumValue;
                    }
                    if (chkChangeTargetProfit.Checked)
                    {
                        EditDto.TakeProfit = numTargetProfit.Value;
                    }
                    if (chkChangeTakeProfitType.Checked)
                    {
                        Enum.TryParse(cmbTakeProfitType.SelectedItem.ToString(), out TakeProfitType takeProfitType);
                        EditDto.TakeProfitType = takeProfitType;
                    }
                    if (chkChangeTrailingEnabled.Checked)
                    {
                        EditDto.TrailingEnabled = cmbTtpEnabled.SelectedItem.ToString() == "Enable" ? true : false;
                    }
                    if (chkChangeTrailingDeviation.Checked)
                    {
                        EditDto.TrailingDeviation = numTrailingDeviation.Value;
                    }
                    if (chkChangeMaxSafetyTradesCount.Checked)
                    {
                        EditDto.MaxSafetyOrders = (int)numMaxSafetyTradesCount.Value;
                    }
                    if (chkChangeMaxActiveSafetyTradesCount.Checked)
                    {
                        EditDto.ActiveSafetyOrdersCount = (int)numMaxActiveSafetyTradesCount.Value;
                    }
                    if (chkChangePriceDeviationToOpenSafetyOrders.Checked)
                    {
                        EditDto.SafetyOrderStepPercentage = numPriceDeviationToOpenSafetyOrders.Value;
                    }
                    if (chkChangeSafetyOrderVolumeScale.Checked)
                    {
                        EditDto.MartingaleVolumeCoefficient = numSafetyOrderVolumeScale.Value;
                    }
                    if (chkChangeSafetyOrderStepScale.Checked)
                    {
                        EditDto.MartingaleStepCoefficient = numSafetyOrderStepScale.Value;
                    }
                    if (chkChangeCooldownBetweenDeals.Checked)
                    {
                        EditDto.Cooldown = (int)numCooldownBetweenDeals.Value;
                    }
                    if (chkChangeDealStartCondition.Checked)
                    {
                        EditDto.DealStartConditions = _startConditions;
                    }
                    if (chkStopLossPercentage.Checked)
                    {
                        EditDto.StopLossPercentage = numStopLossPercentage.Value;
                    }
                    if (chkChangeLeverageType.Checked)
                    {
                        Enum.TryParse(cmbLeverageType.SelectedItem.ToString(), out LeverageType leverageType);
                        EditDto.LeverageType = leverageType;
                    }
                    if (chkChangeCustomLeverageValue.Checked)
                    {
                        EditDto.LeverageCustomValue = numLeverageCustomValue.Value;
                    }
                    if (chkStopLossType.Checked)
                    {
                        Enum.TryParse(cmbStopLossType.SelectedItem.ToString(), out StopLossType stopLossType);
                        EditDto.StopLossType = stopLossType;
                    }
                    if (chkStopLossTimeoutEnabled.Checked)
                    {
                        EditDto.StopLossTimeoutEnabled = cmbStopLossTimeoutEnabled.SelectedItem.ToString() == "Enable" ? true : false;
                    }
                    if (chkStopLossTimeout.Checked)
                    {
                        EditDto.StopLossTimeout = (int)numStopLossTimeout.Value;
                    }

                    if (chkDisableAfterDealsCount.Checked)
                    {
                        EditDto.DisableAfterDealsCountInfo = new DisableAfterDealsCountDto();
                        if (cmbDisableAfterDealsCount.SelectedItem.ToString() == "Enable")
                        {
                            EditDto.DisableAfterDealsCountInfo.Enable = true;
                            EditDto.DisableAfterDealsCountInfo.Value  = (int)numDisableAfterDealsCount.Value;
                        }
                    }

                    this.DialogResult = DialogResult.OK;
                }
            }
        }
Пример #8
0
        /// <summary>
        /// Executes the SaveOrderCommand
        /// </summary>
        private void ExecuteSaveOrderCommand()
        {
            try
            {
                SaveOrderCommand.CommandSucceeded = false;

                if (!CurrentCustomerOrder.IsValid)
                {
                    messageBoxService.ShowError("There order is invalid");
                    SaveOrderCommand.CommandSucceeded = false;
                    return;
                }

                //Order is valid, so end the edit and try and save/update it
                this.CurrentCustomerOrder.EndEdit();

                switch (currentViewMode)
                {
                    #region AddMode
                //AddMode
                case ViewMode.AddMode:
                    Int32 orderId =
                        DataService.AddOrder(
                            TranslateUIOrderToDataLayerOrder(CurrentCustomerOrder));

                    if (orderId > 0)
                    {
                        this.CurrentCustomerOrder.OrderId.DataValue = orderId;
                        messageBoxService.ShowInformation(
                            "Sucessfully saved order");
                        this.CurrentViewMode = ViewMode.ViewOnlyMode;
                    }
                    else
                    {
                        messageBoxService.ShowError(
                            "There was a problem saving the order");
                    }
                    SaveOrderCommand.CommandSucceeded = true;
                    //Use the Mediator to send a Message to AddEditCustomerViewModel to tell it a new
                    //or editable Order needs actioning
                    Mediator.NotifyColleagues <Boolean>("AddedOrderSuccessfullyMessage", true);
                    break;

                    #endregion
                    #region EditMode
                //EditMode
                case ViewMode.EditMode:
                    Boolean orderUpdated =
                        DataService.UpdateOrder(
                            TranslateUIOrderToDataLayerOrder(CurrentCustomerOrder));

                    if (orderUpdated)
                    {
                        messageBoxService.ShowInformation(
                            "Sucessfully updated order");
                        this.CurrentViewMode = ViewMode.ViewOnlyMode;
                    }
                    else
                    {
                        messageBoxService.ShowError(
                            "There was a problem updating the order");
                    }
                    SaveOrderCommand.CommandSucceeded = true;
                    //Use the Mediator to send a Message to AddEditCustomerViewModel to tell it a new
                    //or editable Order needs actioning
                    Mediator.NotifyColleagues <Boolean>("AddedOrderSuccessfullyMessage", true);
                    break;
                    #endregion
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                messageBoxService.ShowError(
                    "There was a problem saving the order");
            }
        }
Пример #9
0
        private void ExecuteSaveDiagramCommand(object parameter)
        {
            if (!DiagramViewModel.Items.Any())
            {
                messageBoxService.ShowError("There must be at least one item in order save a diagram");
                return;
            }

            IsBusy = true;
            DiagramItem wholeDiagramToSave = null;

            Task <int> task = Task.Factory.StartNew <int>(() =>
            {
                if (SavedDiagramId != null)
                {
                    int currentSavedDiagramId = (int)SavedDiagramId.Value;
                    wholeDiagramToSave        = storageService.FetchDiagram(currentSavedDiagramId);

                    //If we have a saved diagram, we need to make sure we clear out all the removed items that
                    //the user deleted as part of this work sesssion
                    foreach (var itemToRemove in itemsToRemove)
                    {
                        DeleteFromDatabase(wholeDiagramToSave, itemToRemove);
                    }
                    //start with empty collections of connections and items, which will be populated based on current diagram
                    wholeDiagramToSave.ConnectionIds = new List <int>();
                    wholeDiagramToSave.DesignerItems = new List <DiagramItemData>();
                }
                else
                {
                    wholeDiagramToSave = new DiagramItem();
                }

                //ensure that itemsToRemove is cleared ready for any new changes within a session
                itemsToRemove = new List <SelectableDesignerItemViewModelBase>();

                foreach (var model in DiagramViewModel.Items)
                {
                    DiagramItemData item = new DiagramItemData(model.Id, model.GetType());
                    storageService.SaveDiagramItem(item);
                    wholeDiagramToSave.DesignerItems.Add(item);
                }
                //Save all connections which should now have their Connection.DataItems filled in with correct Ids
                foreach (var connectionVM in DiagramViewModel.Items.OfType <ConnectorViewModel>())
                {
                    FullyCreatedConnectorInfo sinkConnector = connectionVM.SinkConnectorInfo as FullyCreatedConnectorInfo;
                    Connection connection = new Connection(
                        connectionVM.Id,
                        connectionVM.SourceConnectorInfo.DataItem.Id,
                        GetOrientationFromConnector(connectionVM.SourceConnectorInfo.Orientation),
                        GetTypeOfDiagramItem(connectionVM.SourceConnectorInfo.DataItem),
                        sinkConnector.DataItem.Id,
                        GetOrientationFromConnector(sinkConnector.Orientation),
                        GetTypeOfDiagramItem(sinkConnector.DataItem));

                    connectionVM.Id = storageService.SaveConnection(connection);
                    wholeDiagramToSave.ConnectionIds.Add(connectionVM.Id);
                }

                wholeDiagramToSave.Id = storageService.SaveDiagram(wholeDiagramToSave);
                return(wholeDiagramToSave.Id);
            });

            task.ContinueWith((ant) =>
            {
                int wholeDiagramToSaveId = ant.Result;
                if (!savedDiagrams.Contains(wholeDiagramToSaveId))
                {
                    List <int> newDiagrams = new List <int>(savedDiagrams);
                    newDiagrams.Add(wholeDiagramToSaveId);
                    SavedDiagrams = newDiagrams;
                }
                IsBusy = false;
                messageBoxService.ShowInformation(string.Format("Finished saving Diagram Id : {0}", wholeDiagramToSaveId));
            }, TaskContinuationOptions.OnlyOnRanToCompletion);
        }
Пример #10
0
        private void ExecuteCommenceDrawingCommand(Object parameter)
        {
            try
            {
                if (assemblyManipulationService.SelectedTreeValues.Count > SettingsViewModel.Instance.MaximumNumberOfClassesToAllowOnDiagram)
                {
                    messageBoxService.ShowError("Can not show that many classes, it exceeds the MaximumNumberOfClassesToAllowOnDiagram setting\r\n" +
                                                "Which you may change, but be advised this may cause the diagram drawing/layout time to be unacceptable");

                    return;
                }


                DrawerAsyncState = AsyncType.Busy;
                isGenerallyBusy  = true;
                hasActiveGraph   = false;
                ApplicationHelper.DoEvents();

                Task <GraphResults> task =
                    assemblyManipulationService.CreateGraph();

                int timeout = SettingsViewModel.Instance.GraphDrawingTimeOutInSeconds * 1000;

                bool finishedOk = task.Wait(timeout); // wait 20 seconds before timing out

                if (finishedOk)
                {
                    AddItemsToGraph(task.Result);

                    graphPrintableWindow.ZoomToFit();

                    //TODO Need to also show the non connected ones in a ComboBox
                    //which will launch the popup
                    hasActiveGraph = true;
                }
                else
                {
                    messageBoxService.ShowError(String.Format(
                                                    "The generating of the class diagram took longer than {0} seconds, maybe try increase this setting and try again",
                                                    SettingsViewModel.Instance.GraphDrawingTimeOutInSeconds));
                }
            }
            catch (AggregateException AggEx)
            {
                messageBoxService.ShowError(AggEx.InnerException.Message);
            }
            catch (Exception ex)
            {
                messageBoxService.ShowError("Class diagram could not be created\r\n" + ex.Message);
            }
            finally
            {
                DrawerAsyncState = AsyncType.Content;
                ApplicationHelper.DoEvents();
                isGenerallyBusy = false;
                if (graph != null)
                {
                    if (graph.VertexCount == 0)
                    {
                        messageBoxService.ShowInformation("Could not find any connected classes in your chosen classes\r\n\r\n" +
                                                          "So please examine the class definitions using the 'Not Associated Items' drop down in the top right of this application");
                    }
                }
            }
        }