Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 protected void UpdateMap(FluentState state, object result)
 {
     if (Id != null)
     {
         state.Map?.Add(Id, result);
     }
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        protected override Control OnBuild(FluentState state)
        {
            var result = new ProgressBar();

            SetDefault(result);

            UpdateMap(state, result);
            return(result);
        }
Ejemplo n.º 5
0
        protected override Control OnBuild(FluentState state)
        {
            var result = new Button();

            SetDefault(result);
            result.Click += (o, e) => OnClick?.Invoke();
            UpdateMap(state, result);
            return(result);
        }
Ejemplo n.º 6
0
        protected override Control OnBuild(FluentState state)
        {
            var result = new Control();

            SetDefault(result);

            result.TabStop = false;

            UpdateMap(state, result);
            return(result);
        }
Ejemplo n.º 7
0
        protected override Control OnBuild(FluentState state)
        {
            var result = new CheckBox();

            SetDefault(result);

            result.CheckState = InitialValue;

            UpdateMap(state, result);
            return(result);
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        protected override Control OnBuild(FluentState state)
        {
            var result = new Label();

            SetDefault(result);

            result.TextAlign   = Align;
            result.BorderStyle = BorderStyle;

            UpdateMap(state, result);
            return(result);
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
 public FluentContext(FluentState state)
 {
     _state = state;
 }
Ejemplo n.º 17
0
 protected abstract Control OnBuild(FluentState state);
Ejemplo n.º 18
0
 protected Control[] BuildChildren(FluentState state) =>
 Controls?.Select(c => c?.Build(state)).Where(c => c != null).ToArray();