Example #1
0
 public static void CreateNodeEditor(CommandTreeNode node, object editedObject, Control container, PackageBody body, PropertyHelpCallback helpCallback)
 {
     container.Controls.Clear();
     FlowLayoutPanel flowPanel;
     if (container is FlowLayoutPanel)
     {
         flowPanel = (FlowLayoutPanel)container;
     }
     else
     {
         flowPanel = new FlowLayoutPanel();
         container.Controls.Add(flowPanel);
         flowPanel.FlowDirection = FlowDirection.TopDown;
         flowPanel.Dock = DockStyle.Fill;
     }
     Type type = editedObject.GetType();
     var properties = type.GetProperties();
     foreach (var currentProperty in properties)
     {
         GinArgumentAttribute argumentAttr = (GinArgumentAttribute)currentProperty.GetCustomAttributes(typeof(GinArgumentAttribute), false).FirstOrDefault();
         bool isArgument = argumentAttr != null;
         if (isArgument)
         {
             object value = currentProperty.GetValue(editedObject, null);
             Control control = null;
             control = argumentAttr.GetEditor(value, currentProperty.Name, body, new PropertyChangedDelegate(
                  (propertyName, propertyValue) =>
                  {
                      PropertyInfo changedProperty = type.GetProperty(propertyName);
                      if (changedProperty != null)
                      {
                          changedProperty.SetValue(editedObject, propertyValue, null);
                          if (editedObject is Command)
                          {
                              string name = ((Command)editedObject).GetHumanReadableName();
                              if (name != node.NodeName)
                              {
                                  node.NodeName = name;
                              }
                          }
                      }
                  }),
                  new PropertyActivatedDelegate(propertyName =>
                  {
                      if (helpCallback != null)
                      {
                          helpCallback(propertyName, argumentAttr.Name, argumentAttr.Description, argumentAttr.AllowTemplates, control as ITemplatedEditor);
                      }
                  }));
             if (control != null)
             {
                 control.Tag = currentProperty;
                 flowPanel.Controls.Add(control);
             }
         }
     }
 }
Example #2
0
 public abstract bool HasNested(CommandTreeNode node);
Example #3
0
 public abstract CommandTreeNode InsertAfter(Command command, GinNameAttribute commandAttribute, CommandTreeNode nodeAfter);
Example #4
0
 public abstract CommandTreeNode InsertAfter(Command command, GinNameAttribute commandAttribute, CommandTreeNode nodeAfter);
Example #5
0
 public abstract bool HasNested(CommandTreeNode node);
Example #6
0
 private CommandTreeNode FillTreeNode(CommandTreeNode node, Command command, CommandTreeNode nodeAfter)
 {
     Type type = command.GetType();
     var commandAttr = type.GetCustomAttributes(false).OfType<GinNameAttribute>().FirstOrDefault();
     CommandTreeNode commandNode;
     if (nodeAfter == null)
     {
         commandNode = node.AppendChild(command, commandAttr);
     }
     else
     {
         commandNode = node.InsertAfter(command, commandAttr, nodeAfter);
     }
     var properties = type.GetProperties();
     foreach (PropertyInfo property in properties)
     {
         var propertyAttr = (GinArgumentCommandAttribute)property.GetCustomAttributes(typeof(GinArgumentCommandAttribute), false).FirstOrDefault();
         if (propertyAttr != null)
         {
             CommandTreeNode argumentNode = commandNode.AppendChild(command, commandAttr, property, propertyAttr);
             object nestedCommand = property.GetValue(command, null);
             if (nestedCommand != null)
             {
                 Type nestedType = nestedCommand.GetType();
                 bool isEnumerable = propertyAttr.IsEnumerable;
                 if (isEnumerable)
                 {
                     IEnumerable iEnum = (IEnumerable)nestedCommand;
                     foreach (var item in iEnum)
                     {
                         FillTreeNode(argumentNode, (Command)item, null);
                     }
                 }
                 else
                 {
                     FillTreeNode(argumentNode, (Command)nestedCommand, null);
                 }
             }
         }
     }
     return commandNode;
 }
Example #7
0
 private CommandTreeNode AppendCommandAfter(CommandTreeNode sequenceTreeNode, Command command, CommandTreeNode nodeAfter)
 {
     return FillTreeNode(sequenceTreeNode, command, nodeAfter);
 }
Example #8
0
 protected void SelectCommandTreeNodeHandler(CommandTreeNode node, PackageBody body, Command command, PropertyInfo property)
 {
     if (SelectCommandTreeNode != null)
     {
         SelectCommandTreeNode(node, body, command, property);
     }
 }
Example #9
0
 public override CommandTreeNode InsertAfter(Command command, GinNameAttribute commandAttribute, CommandTreeNode nodeAfter)
 {
     TreeNode node = new TreeNode()
     {
         Text = GetCommandName(command, commandAttribute),
         ToolTipText = commandAttribute.Description,
         ImageIndex = 0,
         Tag = new TreeNodeData()
         {
             Command = command,
             CommandAttribute = commandAttribute,
             Property = null,
             PropertyAttribute = null,
             AcceptedTypes = null,
             NotAcceptedTypes = null
         }
     };
     TreeViewTreeNode afterNode = (TreeViewTreeNode)nodeAfter;
     int index = _node.Nodes.IndexOf(afterNode._node);
     if (index >= 0)
     {
         _node.Nodes.Insert(index + 1, node);
     }
     else
     {
         _node.Nodes.Add(node);
     }
     TreeViewTreeNode treeNode = new TreeViewTreeNode(node);
     ((TreeNodeData)node.Tag).Node = treeNode;
     return treeNode;
 }
Example #10
0
 public override bool HasNested(CommandTreeNode node)
 {
     const int MAX_NESTED_LEVELS_SEARCH = 20;
     int nestedLevel = MAX_NESTED_LEVELS_SEARCH;
     CommandTreeNode currentNode = node.Parent;
     while (nestedLevel > 0 && currentNode != null)
     {
         if (currentNode == this)
         {
             return true;
         }
         currentNode = currentNode.Parent;
     }
     return false;
 }
Example #11
0
        void TreeSelectCommandTreeNode(CommandTreeNode node, PackageBody body, Command command, PropertyInfo property)
        {
            argumentHelp.SetHelp("", "", "", false, null, null);
            panelCommandProperties.SuspendLayout();

            panelCommandProperties.Controls.Clear();

            if (property == null)
            {
                panelCommandProperties.SuspendLayout();
                try
                {
                    if (command == null)
                    {
                        FormsHelper.CreateNodeEditor(node, body, panelCommandProperties, _tree.Body, (propertyProgramName, propertyName, propertyDescription, allowTemplates, editor) => argumentHelp.SetHelp(propertyProgramName, propertyName, propertyDescription, allowTemplates, editor, _tree.Body.GetResultInfos()));
                    }
                    else
                    {
                        FormsHelper.CreateNodeEditor(node, command, panelCommandProperties, _tree.Body, (propertyProgramName, propertyName, propertyDescription, allowTemplates, editor) => argumentHelp.SetHelp(propertyProgramName, propertyName, propertyDescription, allowTemplates, editor, _tree.Body.GetResultInfos()));
                    }
                }
                finally
                {
                    panelCommandProperties.ResumeLayout();
                }
            }

            ResizePropertiesPanelItems();
            panelCommandProperties.ResumeLayout();
        }