private void AddFunction()
        {
            var name = Program.Functions.Select(f => f.Name).CreateUniqueName("Function {0}");

            bool wasAccepted = false;

            var textEditService = new TextEditService();

            textEditService.EditText(name, "New Function", "Name", t =>
            {
                name        = t;
                wasAccepted = true;
            },
                                     t => !string.IsNullOrWhiteSpace(t));

            if (wasAccepted)
            {
                var functionHeaderMetadata = new FunctionMetadata()
                {
                    Name     = name,
                    Id       = Guid.NewGuid(),
                    Elements = new ElementMetadata[] { },
                };

                var functionHeaderViewModel = new FunctionHeaderViewModel(functionHeaderMetadata);

                Program.Functions.Add(functionHeaderViewModel);
            }
        }
        private void NewStateMachine()
        {
            try
            {
                var textEditService = new TextEditService();

                string initialName = StateMachines
                                     .Select(sm => sm.Name)
                                     .CreateUniqueName("State Machine {0}");

                textEditService.EditText(initialName, "State Machine Name", "Create State Machine", name =>
                {
                    var model = new StateMachine()
                    {
                        Name    = name,
                        Actions = new StateMachineOutputAction[] { },
                        Inputs  = new StateMachineInput[] { }
                    };

                    var viewService = ApplicationContainer.Container.Resolve <IViewService>();

                    var viewModel = new StateMachineReferenceViewModel(model, viewService, DirtyService, _messageBoxService);

                    StateMachines.Add(viewModel);

                    _dirtyService.MarkDirty();
                });
            }
            catch (Exception ex)
            {
                _messageBoxService.Show(ex);
            }
        }
        protected virtual void Rename()
        {
            //TODO: DI this
            var textEditService = new TextEditService();

            textEditService.EditText(Name, "Name", "Rename Variable", t => Name = t, t => !string.IsNullOrWhiteSpace(t));
        }
        private void Rename()
        {
            try
            {
                var textEditService = new TextEditService();

                textEditService.EditText(Name, "New Name", "Rename", s => Name = s);
            }
            catch (Exception ex)
            {
                _messageBoxService.Show(ex);
            }
        }
        private void Rename()
        {
            var textEditService = new TextEditService();

            textEditService.EditText(Name, "Function", "Rename Function", t => Name = t, t => !string.IsNullOrWhiteSpace(t));
        }
Example #6
0
 public TextEditModule(IConfiguration config, TextEditService service) : base(config)
 {
     _textEditService              = service;
     _textEditService.Config       = config;
     _textEditService.ParentModule = this;
 }