예제 #1
0
        public static void CreateOutput(object sender, object selectedItem)
        {
            if (selectedItem is OutputCollectionViewModel outputCollectionViewModel)
            {
                CreateOutput(sender, outputCollectionViewModel.Parent);
                return;
            }

            if (!(selectedItem is GroupViewModel entityGroupViewModel))
            {
                return;
            }

            var button = (Button)sender;

            var type = (string)button.CommandParameter;

            OutputBase entity;

            switch (type)
            {
            case nameof(RenderArrayHint):
                entity = RenderArrayHint.New();
                break;

            case nameof(RenderNextDate):
                entity = RenderNextDate.New("Name", "0001-01-01", "Weekly");
                break;

            case nameof(RenderIndex):
                entity = RenderIndex.New();
                break;

            case nameof(RenderEntity):
                entity = RenderEntity.New();
                break;

            case nameof(RenderLink):
                entity = RenderLink.New();
                break;

            case nameof(RenderProperty):
                entity = RenderProperty.New("Display Name", "Property Name");
                break;

            case nameof(RenderValue):
                entity = RenderValue.New("Name", "Value");
                break;

            case nameof(RenderTypeName):
                entity = RenderTypeName.New("Name");
                break;

            case nameof(RenderTaxPeriodDate):
                entity = RenderTaxPeriodDate.New("Name", "2020", "1");
                break;

            case nameof(RenderConstant):
                entity = RenderConstant.New("Name", "Constant Name", typeof(DateTime));
                break;

            case nameof(RenderTaxPeriod):
                entity = RenderTaxPeriod.New("Name", "Monthly", "0001-01-01");
                break;

            case nameof(RenderDateAdd):
                entity = RenderDateAdd.New("Name", "0001-01-01", "Day", "1");
                break;

            case nameof(RenderUniqueKeyFromLink):
                entity = RenderUniqueKeyFromLink.New("Name", "[Link]");
                break;

            case nameof(Avg):
                entity = Avg.New("Name", "Property");
                break;

            case nameof(Max):
                entity = Max.New("Name", "Property");
                break;

            case nameof(Min):
                entity = Min.New("Name", "Property");
                break;

            case nameof(Sum):
                entity = Sum.New("Name", "Property");
                break;

            case nameof(Count):
                entity = Count.New("Name");
                break;

            case nameof(ExpressionCalculator):
                entity = ExpressionCalculator.New("Name", "1 + 2 - 3 * 4 / 5", rounding: RoundingOption.NotSet);
                break;

            case nameof(Distinct):
                entity = Distinct.New("Name", "Property");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            entityGroupViewModel.Element.Outputs.Add(entity);
            var viewModelCollection = entityGroupViewModel.Children.OfType <OutputCollectionViewModel>().First();

            var viewModel = new OutputViewModel(entity, viewModelCollection);

            viewModelCollection.Children.Add(viewModel);

            entityGroupViewModel.IsExpanded = true;
            viewModelCollection.IsExpanded  = true;
            viewModel.IsSelected            = true;
            viewModel.IsExpanded            = true;
        }