Esempio n. 1
0
        public static Panel Create <T>(Page page, Node node) where T : Argument
        {
            var activity  = node.Activity;
            var variables = page.Variables;
            var dataTypes = DataType.GetCommonTypes();
            var arguments = activity.GetArguments <T>();

            if (arguments == null)
            {
                return(null);
            }

            var form = new ArgumentForm();

            form.CreateColumnsForArguments <T>(dataTypes, variables);
            form.argumentButtonsPanel.Visible = activity.AllowUserToEditArgumentRowList;

            var grid = form.argumentDataGridView;

            grid.Columns[0].ReadOnly = !activity.AllowUserToEditArgumentColumn1;
            grid.Columns[1].ReadOnly = !activity.AllowUserToEditArgumentColumn2;
            grid.Columns[2].ReadOnly = !activity.AllowUserToEditArgumentColumn3;

            form.argumentPanel.ParentChanged += (sender, e) =>
            {
                grid.DataSource = new BindingList <T>(arguments); // perfect.
            };

            return(form.argumentPanel);
        }
Esempio n. 2
0
 public NodeForm(Page page, Node node) : this()
 {
     ArgumentForm.Create(page, node).Parent = this.argumentPanel;
     VariableForm.Create(page).Parent       = this.variablePanel;
     this.nodeNameTextBox.DataBindings.Add("Text", node, "Name", false, DataSourceUpdateMode.OnPropertyChanged);
     this.nodeNameTextBox.PreviewKeyDown += NodeNameTextBox_PreviewKeyDown;
     this.Text = "Activity Editor - " + node.Activity.GetType().FullName;
 }
Esempio n. 3
0
        public static TableLayoutPanel Create(Page page, Node node)
        {
            var activity  = node.Activity;
            var variables = page.Variables;

            var argumentPanels = new List <Panel>();

            if (ArgumentForm.Create <InArgument>(page, node) is Panel inArgumentPanel)
            {
                argumentPanels.Add(inArgumentPanel);
            }
            if (ArgumentForm.Create <OutArgument>(page, node) is Panel outArgumentPanel)
            {
                argumentPanels.Add(outArgumentPanel);
            }
            if (ArgumentForm.Create <InOutArgument>(page, node) is Panel inOutArgumentPanel)
            {
                argumentPanels.Add(inOutArgumentPanel);
            }

            var argumentTableLayoutPanel = new TableLayoutPanel
            {
                ColumnCount = 1,
                RowCount    = argumentPanels.Count,
                Dock        = DockStyle.Fill,
            };

            argumentTableLayoutPanel.RowStyles.Clear();
            foreach (var argumentPanel in argumentPanels)
            {
                argumentTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100F / argumentPanels.Count));
                argumentTableLayoutPanel.Controls.Add(argumentPanel, 0, argumentTableLayoutPanel.RowStyles.Count - 1);
            }

            return(argumentTableLayoutPanel);
        }
Esempio n. 4
0
        public static Panel Create <T>(Page page, Node node) where T : Argument
        {
            var activity  = node.Activity;
            var variables = page.Variables;
            var dataTypes = DataType.GetCommonTypes();
            var arguments = activity.GetArguments <T>();

            if (arguments == null)
            {
                return(null);
            }

            var form = new ArgumentForm();

            form.CreateColumnsForArguments <T>(dataTypes, variables);
            form.argumentButtonsPanel.Visible = activity.AllowUserToEditArgumentRowList;

            var grid = form.argumentDataGridView;

            grid.Columns[0].ReadOnly = !activity.AllowUserToEditArgumentColumn1;
            grid.Columns[1].ReadOnly = !activity.AllowUserToEditArgumentColumn2;
            grid.Columns[2].ReadOnly = !activity.AllowUserToEditArgumentColumn3;

            grid.GetType().GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(grid, true);

            grid.Tag = new BindingList <T>(arguments); // see AllowUserToEditArgumentRowList

            UpdateRowList(grid);

            grid.CellValueChanged += (sender, e) =>
            {
                var value = grid[e.ColumnIndex, e.RowIndex].Value;
                if (arguments[e.RowIndex] is InArgument inArgument)
                {
                    if (e.ColumnIndex == 0)
                    {
                        inArgument.Name = (string)value;
                    }
                    if (e.ColumnIndex == 1)
                    {
                        inArgument.DataTypeId = (string)value;
                    }
                    if (e.ColumnIndex == 2)
                    {
                        inArgument.Expression = (string)value;
                    }
                }
                else if (arguments[e.RowIndex] is OutArgument outArgument)
                {
                    if (e.ColumnIndex == 0)
                    {
                        outArgument.Name = (string)value;
                    }
                    if (e.ColumnIndex == 1)
                    {
                        outArgument.DataTypeId = (string)value;
                    }
                    if (e.ColumnIndex == 2)
                    {
                        outArgument.VariableId = (Guid)value;
                    }
                }
                else if (arguments[e.RowIndex] is InOutArgument inOutArgument)
                {
                    if (e.ColumnIndex == 0)
                    {
                        inOutArgument.DataTypeId = (string)value;
                    }
                    if (e.ColumnIndex == 1)
                    {
                        inOutArgument.VariableId = (Guid)value;
                    }
                    if (e.ColumnIndex == 2)
                    {
                        inOutArgument.Expression = (string)value;
                    }
                }
                else
                {
                    throw new NotSupportedException();
                }
            };

            grid.CurrentCellDirtyStateChanged += (sender, e) =>
            {
                if (grid.IsCurrentCellDirty)
                {
                    grid.CommitEdit(DataGridViewDataErrorContexts.Commit);
                }
            };

            return(form.argumentPanel);
        }