示例#1
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;
        }
        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));
                    }
                }
            }
        }