protected override Control OnBuild(FluentState state) { var result = new TextBox(); SetDefault(result); result.Multiline = MultiLine; result.ScrollBars = ScrollBars; result.WordWrap = WordWrap; if (OnChange != null) { result.TextChanged += (o, e) => OnChange?.Invoke(result, result.Text); } result.AllowDrop = AllowDrop; result.DragEnter += (o, e) => { if (result.AllowDrop && e.Data.GetDataPresent(DataFormats.FileDrop)) { e.Effect = DragDropEffects.Link; } }; result.DragDrop += (o, e) => { if (result.AllowDrop && e.Data.GetDataPresent(DataFormats.FileDrop)) { result.Text = string.Join('|', (string[])e.Data.GetData(DataFormats.FileDrop)); } }; UpdateMap(state, result); return(result); }
protected void UpdateMap(FluentState state, object result) { if (Id != null) { state.Map?.Add(Id, result); } }
protected override Control OnBuild(FluentState state) { var result = new TableLayoutPanel(); SetDefault(result); if (Columns != null) { foreach (var style in Columns) { result.ColumnStyles.Add(style); } result.ColumnCount = Columns.Count; } if (Rows != null) { foreach (var style in Rows) { result.RowStyles.Add(style); } result.RowCount = Rows.Count; } var children = BuildChildren(state); if (children != null) { result.Controls.AddRange(children.ToArray()); } UpdateMap(state, result); return(result); }
protected override Control OnBuild(FluentState state) { var result = new ProgressBar(); SetDefault(result); UpdateMap(state, result); return(result); }
protected override Control OnBuild(FluentState state) { var result = new Button(); SetDefault(result); result.Click += (o, e) => OnClick?.Invoke(); UpdateMap(state, result); return(result); }
protected override Control OnBuild(FluentState state) { var result = new Control(); SetDefault(result); result.TabStop = false; UpdateMap(state, result); return(result); }
protected override Control OnBuild(FluentState state) { var result = new CheckBox(); SetDefault(result); result.CheckState = InitialValue; UpdateMap(state, result); return(result); }
public static Control Build(this FluentControl fc, Control parent = null) { var state = new FluentState(); var result = fc.Build(state, parent); parent?.Controls.Add(result); foreach (var callback in state.Callbacks) { callback(); } return(result); }
protected override Control OnBuild(FluentState state) { var result = new Label(); SetDefault(result); result.TextAlign = Align; result.BorderStyle = BorderStyle; UpdateMap(state, result); return(result); }
protected override Control OnBuild(FluentState state) { var result = new MenuStrip(); SetDefault(result); if (Items != null) { result.Items.AddRange(Items.Select(i => i.Build(state)).ToArray()); } UpdateMap(state, result); return(result); }
protected override Control OnBuild(FluentState state) { var result = new TabControl(); SetDefault(result); result.TabIndexChanged += (s, e) => OnChange?.Invoke(result, result.TabIndex); if (Items != null) { result.TabPages.AddRange(Items.Select(tab => (TabPage)tab.Build(state)).ToArray()); } UpdateMap(state, result); return(result); }
protected override Control OnBuild(FluentState state) { var form = new Form(); SetDefault(form); var children = BuildChildren(state); if (children != null) { form.Controls.AddRange(children); } UpdateMap(state, form); return(form); }
protected override Control OnBuild(FluentState state) { var result = new Panel(); SetDefault(result); result.AutoScroll = AutoScroll; result.AutoSizeMode = AutoSizeMode; var children = BuildChildren(state); if (children != null) { result.Controls.AddRange(children.ToArray()); } return(result); }
protected override Control OnBuild(FluentState state) { var result = new TabPage(); SetDefault(result); result.AutoScroll = AutoScroll; result.HorizontalScroll.Enabled = false; result.VerticalScroll.Enabled = AutoScroll; var children = BuildChildren(state); if (children != null) { result.Controls.AddRange(children); } UpdateMap(state, result); return(result); }
public ToolStripItem Build(FluentState state) { var result = new ToolStripMenuItem(); SetDefault(result); if (OnClick != null) { result.Click += (o, e) => OnClick?.Invoke(); } if (Items != null) { result.DropDownItems.AddRange(Items.Select(i => i.Build(state)).ToArray()); } UpdateMap(state, result); AfterBuild?.Invoke(new FluentContext <FluentMenuItem, ToolStripMenuItem>(this, result, state)); return(result); }
public FluentContext(FluentState state) { _state = state; }
protected abstract Control OnBuild(FluentState state);
protected Control[] BuildChildren(FluentState state) => Controls?.Select(c => c?.Build(state)).Where(c => c != null).ToArray();