コード例 #1
0
ファイル: DetailsForm.cs プロジェクト: todo-it/philadelphia
        public DetailsForm()
        {
            _view = new DetailsFormView();

            Func <string, BaseUnboundColumnBuilder <DetailDto> > build = x => UnboundDataGridColumnBuilder.For <DetailDto>(x);

            Details = DataGridModel <DetailDto> .CreateAndBindNonReloadable(
                _view.Items,
                Toolkit.DefaultTableBodyHeightProvider(),
                new List <IDataGridColumn <DetailDto> > {
                build("#")
                .WithValueLocalized(x => Details.Items.IndexOf(x) + 1)
                .Build(),
                build("ParentId")
                .WithValueLocalized(x => x.ParentId)
                .TransformableDefault()
                .Build(),
                build("Id")
                .WithValueLocalized(x => x.Id)
                .TransformableDefault()
                .Build(),
                build("Name")
                .WithValue(x => x.Name)
                .TransformableDefault()
                .Build()
            }).Item1;
        }
コード例 #2
0
        private static SingleChoiceDropDown <SomeDto> CreateSomeDtoSingleChoice()
        {
            Func <string, BaseUnboundColumnBuilder <SomeDto> > bldr = x => UnboundDataGridColumnBuilder.For <SomeDto>(x);

            return(new SingleChoiceDropDown <SomeDto>("Singlechoice dropdown with columns", x => x?.SomeText ?? "",
                                                      bldr("SomeText").WithValue(x => x.SomeText).Build(),
                                                      bldr("SomeNumber").WithValueLocalized(x => x.SomeNumber).Build()
                                                      ));
        }
コード例 #3
0
 public static SingleChoiceDropDown <SomeTraitType?> BuildSomeTraitType()
 {
     return(new SingleChoiceDropDown <SomeTraitType?>(
                "SomeTrait", x => x.HasValue ? x.Value.ToString() : "",
                UnboundDataGridColumnBuilder
                .For <SomeTraitType?>("Choose one")
                .WithValueAsText(x => x, x => x.HasValue ? x.Value.ToString() : "")
                .Build()));
 }
コード例 #4
0
        public DataboundDatagridForm()
        {
            _view = new DataboundDatagridFormView();
            Func <string, BaseUnboundColumnBuilder <SomeDto> > build = x => UnboundDataGridColumnBuilder.For <SomeDto>(x);

            Items = DataGridModel <SomeDto> .CreateAndBindReloadable(
                _view.Items,
                () => Ended?.Invoke(this, Outcome.ReloadData),
                (el, theaderHeight, _) => //most of the time you would use Toolkit.DefaultTableBodyHeightProvider()
                el.GetAvailableHeightForFormElement(0, 2) - theaderHeight - _view.Help.Widget.OffsetHeight,
                new List <IDataGridColumn <SomeDto> > {
                build("#")
                .WithValueLocalized(x => Items.Items.IndexOf(x) + 1)
                .NonTransformable()
                .Build(),
                build("SomeNumber")
                .WithValueLocalized(x => x.SomeNumber)
                .TransformableDefault()
                .Observes(x => nameof(x.SomeNumber))
                .Build(),
                build("SomeText")
                .WithValue(x => x.SomeText)
                .TransformableDefault()
                .Observes(x => nameof(x.SomeText))
                .Build(),
                build("SomeBool")
                .WithValueLocalized(x => x.SomeBool)
                .TransformableDefault()
                .Observes(x => nameof(x.SomeBool))
                .Build(),
                build("SomeTrait")
                .WithValueAsText(x => x.SomeTrait, x => x.ToString())
                .TransformableAsText()
                .Observes(x => nameof(x.SomeTrait))
                .Build(),
            }).model;

            Items.Activated.Changed += (sender, oldValue, newValue, errors, isUserChange) => {
                if (newValue == null)
                {
                    return;
                }
                ChoosenItem = Items.Activated.Value;
                Ended?.Invoke(this, Outcome.EditItemDemanded);
            };

            LocalActionBuilder.Build(_view.Creator, () => Ended?.Invoke(this, Outcome.CreateItemDemanded));

            //button that is activated only if exactly one record is selected in the datagarid
            var activateEditor = LocalActionBuilder.Build(_view.Editor, () => {
                ChoosenItem = Items.Selected[0];
                Ended?.Invoke(this, Outcome.EditItemDemanded);
            });

            activateEditor.BindSelectionIntoEnabled(Items, SelectionNeeded.ExactlyOneSelected);
        }
コード例 #5
0
        public TestRunnerForm(IReadOnlyCollection <TestModel> tests)
        {
            void RunAll()
            {
                foreach (var test in tests)
                {
                    test.Run();
                }
            }

            RunAll();
            var view = new TestRunnerView();

            BaseUnboundColumnBuilder <TestModel> Column(string x) => UnboundDataGridColumnBuilder.For <TestModel>(x);

            ValueContainingUnboundColumnBuilder <TestModel, string> TextColumn(string x, Func <TestModel, string> val) =>
            UnboundDataGridColumnBuilder.For <TestModel>(x).WithValue(val);

            var gridGuts = DataGridModel <TestModel> .CreateAndBindNonReloadable(
                view.Grid,
                Toolkit.DefaultTableBodyHeightProvider(-50),
                TextColumn("Name", x => x.Name)
                .TransformableDefault()
                .Build()
                .With(x => x.MinimumWidth = 500),
                Column("Outcome").WithValueAsText(x => x.Outcome, x => x.ToString())
                .TransformableAsText()
                .Observes(x => nameof(x.Outcome))
                .Build().With(x => x.MinimumWidth = 30),
                TextColumn("Log", x => x.Log)
                .TransformableDefault()
                .Observes(x => nameof(x.Log))
                .Build().With(x => x.MinimumWidth = 400)
                );

            gridGuts.model.Items.Replace(tests);

            gridGuts.model.Selected.Changed += (insertedAt, inserted, removed) => {
                switch (inserted.FirstOrDefault())
                {
                case null:
                    view.SummaryText = "";
                    break;

                case var x:
                    view.SummaryText = x.Log;
                    break;
                }
            };

            View = view;
        }
コード例 #6
0
        public HeadersForm()
        {
            _view = new HeadersFormView();

            Func <string, BaseUnboundColumnBuilder <HeaderDto> > build = x => UnboundDataGridColumnBuilder.For <HeaderDto>(x);

            Headers = DataGridModel <HeaderDto> .CreateAndBindNonReloadable(
                _view.Items,
                (el, theaderHeight, _) => //most of the time you would use Toolkit.DefaultTableBodyHeightProvider()
                el.GetAvailableHeightForFormElement(0, 2) - theaderHeight - _view.Help.Widget.OffsetHeight,
                new List <IDataGridColumn <HeaderDto> > {
                build("#")
                .WithValueLocalized(x => Headers.Items.IndexOf(x) + 1)
                .Build(),
                build("Id")
                .WithValueLocalized(x => x.Id)
                .TransformableDefault()
                .Build(),
                build("Name")
                .WithValue(x => x.Name)
                .TransformableDefault()
                .Build()
            }).Item1;

            Headers.Selected.Changed += (_, __, ___) => {
                if (Headers.Selected.Length != 1)
                {
                    return;
                }
                ChoosenHeader = Headers.Selected.First();
                Ended?.Invoke(this, Outcome.ChoosenHeader);
            };
            Headers.Activated.Changed += (sender, oldValue, newValue, errors, isUserChange) => {
                if (newValue == null)
                {
                    return;
                }
                ChoosenHeader = Headers.Activated.Value;
                Ended?.Invoke(this, Outcome.ChoosenHeader);
            };
        }