예제 #1
0
        /// <summary>
        /// Returns a new argument if one was created, false otherwise.
        /// </summary>
        /// <returns></returns>
        private IArgument CreateArgument()
        {
            var metadata = new ArgumentMetadata()
            {
                Id = Guid.NewGuid(),
            };

            //Create the view model
            var viewModel = new ArgumentDialogViewModel(metadata, _context.Types);

            //Create the dialog
            var view = new ArgumentDialogView()
            {
                DataContext = viewModel,
                Owner       = WindowUtil.GetActiveWindow()
            };

            //Show the dialog
            if (view.ShowDialog() == true)
            {
                //Create the argument
                return(new Argument(this, viewModel.ToMetadata()));
            }

            return(null);
        }
예제 #2
0
        public static Guid?SelectVplType(this IEnumerable <IVplType> types, Guid?selectedVplType = null)
        {
            if (types == null)
            {
                throw new ArgumentNullException(nameof(types));
            }

            //Create the view model
            var viewModel = new SelectTypeDialogViewModel(types)
            {
                SelectedTypeId = selectedVplType
            };

            //Create the view
            var view = new SelectTypeDialogView()
            {
                Owner       = WindowUtil.GetActiveWindow(),
                DataContext = viewModel
            };

            //Show the dialog
            if (view.ShowDialog() == true)
            {
                return(viewModel.SelectedTypeId);
            }

            return(null);
        }
        public IFunctionReference SelectFunction(Guid?selectedFunctionId)
        {
            var functionService = _owner.GetService <IFunctionService>();

            if (functionService == null)
            {
                var messageBoxService = new MessageBoxService();

                messageBoxService.Show("No function service was provided.");

                return(null);
            }

            var functions = functionService.GetFunctions();

            var viewModel = new FunctionSelectionDialogViewModel(functions, selectedFunctionId);

            var view = new FunctionSelectionDialogView()
            {
                DataContext = viewModel,
                Owner       = WindowUtil.GetActiveWindow()
            };

            if (view.ShowDialog() == true)
            {
                return(viewModel.SelectedFunction);
            }

            return(null);
        }
        private void SelectReturnType()
        {
            //Create the view model
            var viewModel = new SelectTypeDialogViewModel(_context.Types)
            {
                SelectedTypeId = Function.ReturnTypeId
            };

            var view = new SelectTypeDialogView()
            {
                Owner       = WindowUtil.GetActiveWindow(),
                DataContext = viewModel
            };

            if (view.ShowDialog() == true)
            {
                if (ClearReturnType())
                {
                    Function.ReturnTypeId = viewModel.SelectedTypeId;

                    if (Function.ReturnTypeId != null)
                    {
                        //Get the type
                        var type = Function.GetVplTypeOrThrow(Function.ReturnTypeId.Value);

                        //Add the return variable
                        Function.AddVariable(new ReturnValueVariable(Function, type));
                    }
                }
            }
        }
        public void EditFunction(FunctionMetadata metadata, Action <FunctionMetadata> saveAction, bool modal, string displayName)
        {
            var existing = _functionEditorManager.Get(metadata.Id);

            if (existing == null)
            {
                //Create the function view model
                var function = CreateRuntimeFunctionInner(metadata);

                //Create the editor view model
                var editorViewModel = new FunctionEditorDialogViewModel(_serviceContext, function, saveAction,
                                                                        new TextEditService(), displayName, _functionEditorManager);

                //Create the view
                var view = new FunctionEditorDialog(_serviceContext.CustomResources)
                {
                    DataContext = editorViewModel,
                };

                //Show the dialog
                if (modal)
                {
                    view.Owner = WindowUtil.GetActiveWindow();
                    view.ShowDialog();
                }
                else
                {
                    view.Show();
                }
            }
            else
            {
                //Activate this one
                existing.Activate();
            }
        }