// -------------------------------------------------------------------
        // AddCombobox
        // -------------------------------------------------------------------

        public void AddCombobox(NTree <List <object> > node, NTree <List <object> > parentNode, string selected, NTree <List <object> > lastNode)
        {
            ComboBoxCondition comboBox = new ComboBoxCondition(node, parentNode, selected);

            if (selected != "")
            {
                comboBox.Items.Add(selected);
            }
            else
            {
                comboBox.Items.Add("");
                if (node == lastNode)
                {
                    comboBox.Items.Add("And");
                    comboBox.Items.Add("Or");
                }
                else
                {
                    comboBox.Items.Add((string)parentNode.Data[0]);
                }
            }
            comboBox.AutoSize              = true;
            comboBox.DropDownStyle         = ComboBoxStyle.DropDownList;
            comboBox.Size                  = new Size(45, 20);
            comboBox.Anchor                = AnchorStyles.Left;
            comboBox.SelectedItem          = selected;
            comboBox.SelectedIndexChanged += ComboBox_SelectedIndexChanged;
            mainTableLayout.Controls.Add(comboBox, mainTableLayout.ColumnStyles.Count, 0);
            mainTableLayout.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
        }
Ejemplo n.º 2
0
            // -------------------------------------------------------------------
            // CopyTreeNode
            // -------------------------------------------------------------------

            public void CopyTreeNode(NTree <EventCommand> tree, NTree <EventCommand> treeToCopy)
            {
                foreach (NTree <EventCommand> childToCopy in treeToCopy.Children)
                {
                    CopyTreeNode(tree.AddChildData(childToCopy.Data.CreateCopy()), childToCopy);
                }
            }
Ejemplo n.º 3
0
        // -------------------------------------------------------------------
        // CreateCopy
        // -------------------------------------------------------------------

        public override EventCommand CreateCopy()
        {
            NTree <List <object> > tree = new NTree <List <object> >(new List <object>(new object[] { Tree.Data[0] }));

            CopyTreeNode(tree, Tree);

            return(new EventCommandConditions(tree));
        }
Ejemplo n.º 4
0
        public NTree <T> AddChildData(T data)
        {
            NTree <T> child = new NTree <T>(data);

            Children.AddLast(child);

            return(child);
        }
Ejemplo n.º 5
0
            // -------------------------------------------------------------------
            // CreateCopy
            // -------------------------------------------------------------------

            public SystemEventPage CreateCopy()
            {
                NTree <EventCommand> treeCommandsCopy = new NTree <EventCommand>(null);

                CopyTreeNode(treeCommandsCopy, CommandsTree);

                return(new SystemEventPage(Graphic.CreateCopy(), GraphicDrawType, Options.CreateCopy(), Trigger, (EventCommandConditions)ConditionsTree.CreateCopy(), treeCommandsCopy));
            }
Ejemplo n.º 6
0
            // -------------------------------------------------------------------
            // GetDefaultTreeCommands
            // -------------------------------------------------------------------

            public static NTree <EventCommand> GetDefaultTreeCommands()
            {
                NTree <EventCommand> tree = new NTree <EventCommand>(null);

                tree.AddChildData(new EventCommandOther());

                return(tree);
            }
Ejemplo n.º 7
0
        // -------------------------------------------------------------------
        // GetDefaultTreeConditions
        // -------------------------------------------------------------------

        public static NTree <List <object> > GetDefaultTreeConditions()
        {
            NTree <List <object> > tree = new NTree <List <object> >(new List <object>(new object[] { "" }));

            tree.AddChildData(null);

            return(tree);
        }
Ejemplo n.º 8
0
 public SystemEventPage(SystemGraphic graphic, DrawType graphicDrawType, PageOptions options, EventTrigger trigger, EventCommandConditions conditionsTree, NTree <EventCommand> commandsTree)
 {
     Graphic         = graphic;
     GraphicDrawType = graphicDrawType;
     Options         = options;
     Trigger         = trigger;
     ConditionsTree  = conditionsTree;
     CommandsTree    = commandsTree;
 }
Ejemplo n.º 9
0
        // -------------------------------------------------------------------
        // AddCommandNodes
        // -------------------------------------------------------------------

        public void AddCommandNodes(NTree <EventCommand> node, TreeNodeCollection commandNode)
        {
            foreach (NTree <EventCommand> child in node.Children)
            {
                TreeNode commandChild = commandNode.Add(WANOK.ListBeginning + child.Data.ToString());
                commandChild.Tag = child;
                AddCommandNodes(child, commandChild.Nodes);
            }
        }
Ejemplo n.º 10
0
        // -------------------------------------------------------------------
        // AddButton
        // -------------------------------------------------------------------

        public void AddButton(NTree <List <object> > node, NTree <List <object> > parentNode)
        {
            FlatButtonCondition button = new FlatButtonCondition(node, parentNode);

            button.AutoSize   = true;
            button.Text       = node.Data == null ? "New" : Condition.ToString(node.Data);
            button.BackColor  = node.Data == null ? FlatButtonCondition.NoneColor : FlatButtonCondition.FullColor;
            button.Size       = new Size(0, 0);
            button.MouseDown += Button_MouseDown;
            mainTableLayout.Controls.Add(button, mainTableLayout.ColumnStyles.Count, 0);
            mainTableLayout.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
        }
Ejemplo n.º 11
0
 public void CleanTree(NTree <List <object> > node)
 {
     foreach (NTree <List <object> > child in node.Children)
     {
         CleanTree(child);
         if (child.Data != null && child.Data.Count == 1 && child.Children.Count == 1)
         {
             node.DeleteChild(child);
             node.AddChild(child.Children.First.Value);
             break;
         }
     }
 }
Ejemplo n.º 12
0
        // -------------------------------------------------------------------
        // CleanTree
        // -------------------------------------------------------------------

        public void CleanTree()
        {
            CleanTree(Tree);
            if (Tree.Data.Count == 1 && Tree.Children.Count == 1)
            {
                if (Tree.Children.First.Value.Children.Count == 0)
                {
                    Tree.Data = new List <object>(new object[] { "" });
                }
                else
                {
                    Tree = Tree.Children.First.Value;
                }
            }
        }
Ejemplo n.º 13
0
        // -------------------------------------------------------------------
        // TreeContainsAndOr
        // -------------------------------------------------------------------

        public bool TreeContainsAndOr(NTree <List <object> > node, string i)
        {
            foreach (NTree <List <object> > child in node.Children)
            {
                if (node.Data != null && node.Data.Count == 1 && (string)node.Data[0] == i)
                {
                    return(true);
                }
                if (TreeContainsAndOr(child, i))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 14
0
        // -------------------------------------------------------------------
        // CopyTreeNode
        // -------------------------------------------------------------------

        public void CopyTreeNode(NTree <List <object> > tree, NTree <List <object> > treeToCopy)
        {
            foreach (NTree <List <object> > childToCopy in treeToCopy.Children)
            {
                List <object> command = null;
                if (childToCopy.Data != null)
                {
                    command = new List <object>();
                    for (int i = 0; i < childToCopy.Data.Count; i++)
                    {
                        command.Add(childToCopy.Data[i]);
                    }
                }
                CopyTreeNode(tree.AddChildData(command), childToCopy);
            }
        }
Ejemplo n.º 15
0
        private int GetNodesCount(NTree <T> node)
        {
            int count = 0;

            if (node.Children.Count == 0)
            {
                count++;
            }
            else
            {
                foreach (NTree <T> child in node.Children)
                {
                    count += GetNodesCount(child);
                }
            }

            return(count);
        }
Ejemplo n.º 16
0
        // -------------------------------------------------------------------
        // OpenLabelDialogCommand
        // -------------------------------------------------------------------

        public void OpenLabelDialogCommand()
        {
            if (ListCommandsSelectedLabel != null)
            {
                EventCommandKind kind         = (EventCommandKind)ListCommandsSelectedLabel.Tag;
                EventCommand     eventCommand = null;
                switch (kind)
                {
                case EventCommandKind.None:
                    eventCommand = new EventCommandOther();
                    break;

                case EventCommandKind.ChangeSwitches:
                    eventCommand = new EventCommandOther(EventCommandKind.ChangeSwitches, new List <object>(new object[] { 0, 1, 0 }));
                    break;

                case EventCommandKind.Conditions:
                    eventCommand = new EventCommandConditions();
                    break;

                default:
                    break;
                }
                ModelForm dialog = (ModelForm)GetDialogEventCommand(eventCommand);
                if (kind == EventCommandKind.None)
                {
                    WANOK.ShowActionMessage();
                }
                else
                {
                    DontLooseFocus = true;
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        ((NTree <EventCommand>)CommandsView.SelectedNode.Tag).Data = dialog.GetModel();
                        CommandsView.SelectedNode.Text = WANOK.ListBeginning + dialog.GetModel().ToString();
                        TreeNode             node        = CommandsView.Nodes.Add(WANOK.ListBeginning);
                        NTree <EventCommand> commandTree = Control.Model.GetCurrentPage().CommandsTree.AddChildData(new EventCommandOther());
                        node.Tag = commandTree;
                        UpdateTreeCommandsSelection();
                    }
                    DontLooseFocus = false;
                }
            }
        }
Ejemplo n.º 17
0
        private void ComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            string previousSelecteIndex = ((ComboBoxCondition)sender).Index;
            string newSelectedIndex     = ((ComboBox)sender).SelectedItem.ToString();

            if (previousSelecteIndex != newSelectedIndex)
            {
                if ((string)Tree.Data[0] == newSelectedIndex)
                {
                    Tree.AddChildData(null);
                }
                else if ((string)Tree.Data[0] == "")
                {
                    ((ComboBoxCondition)sender).ParentNode.Data = new List <object>(new object[] { newSelectedIndex });
                    ((ComboBoxCondition)sender).ParentNode.AddChildData(null);
                }
                else
                {
                    if (TreeContainsAndOr(Tree, newSelectedIndex))
                    {
                        if (((ComboBoxCondition)sender).ParentNode.Data.Count == 1 && (string)((ComboBoxCondition)sender).ParentNode.Data[0] == newSelectedIndex)
                        {
                            ((ComboBoxCondition)sender).ParentNode.AddChildData(null);
                        }
                        else
                        {
                            List <object> previousData = ((ComboBoxCondition)sender).Node.Data;
                            ((ComboBoxCondition)sender).Node.Data = new List <object>(new object[] { newSelectedIndex });
                            ((ComboBoxCondition)sender).Node.AddChildData(previousData);
                            ((ComboBoxCondition)sender).Node.AddChildData(null);
                        }
                    }
                    else
                    {
                        NTree <List <object> > previousTree = Tree;
                        Tree = new NTree <List <object> >(new List <object>(new object[] { newSelectedIndex }));
                        Tree.AddChild(previousTree);
                        Tree.AddChildData(null);
                    }
                }

                GeneratePanel();
            }
        }
Ejemplo n.º 18
0
        private NTree <T> GetLastNode(NTree <T> node)
        {
            NTree <T> lastNode = null;

            if (node.Children.Count > 0)
            {
                foreach (NTree <T> child in node.Children)
                {
                    NTree <T> lastNodeChild = GetLastNode(child);
                    if (lastNodeChild != null)
                    {
                        lastNode = lastNodeChild;
                    }
                }
            }
            else
            {
                return(node);
            }

            return(lastNode);
        }
Ejemplo n.º 19
0
        private void BrowseNode(NTree <List <object> > node, NTree <List <object> > parent, NTree <List <object> > lastNode)
        {
            if (node.Children.Count > 1)
            {
                AddLabel("(");
            }
            foreach (NTree <List <object> > child in node.Children)
            {
                BrowseNode(child, node, lastNode);
            }
            if (node.Children.Count > 1)
            {
                AddLabel(")");
            }

            if (node.Children.Count == 0)
            {
                // Button
                AddButton(node, parent);

                // ComboBox
                var lastChild = parent.IsLastChild(node);
                if (node.Data != null && lastChild)
                {
                    AddCombobox(node, parent, "", lastNode);
                }
                else if (!lastChild)
                {
                    AddCombobox(node, parent, (string)parent.Data[0], lastNode);
                }
            }
            else
            {
                if (parent.Data != null && parent.Data.Count == 1 && (string)parent.Data[0] != "" && !parent.IsLastChild(node))
                {
                    AddCombobox(node, parent, (string)parent.Data[0], lastNode);
                }
            }
        }
Ejemplo n.º 20
0
 public EventCommandConditions(NTree <List <object> > tree)
 {
     EventCommandKind = EventCommandKind.Conditions;
     Tree             = tree;
 }
Ejemplo n.º 21
0
 public void DeleteChild(NTree <T> child)
 {
     Children.Remove(child);
 }
Ejemplo n.º 22
0
 public bool IsLastChild(NTree <T> d)
 {
     return(d == Children.Last.Value);
 }
Ejemplo n.º 23
0
        public NTree <T> AddChild(NTree <T> child)
        {
            Children.AddLast(child);

            return(child);
        }
Ejemplo n.º 24
0
        // -------------------------------------------------------------------
        // InitializeListParameters
        // -------------------------------------------------------------------

        public void InitializeListParameters(NTree <List <object> > tree)
        {
            Tree = tree;
            GeneratePanel();
        }
Ejemplo n.º 25
0
 public ComboBoxCondition(NTree <List <object> > node, NTree <List <object> > parentNode, string index)
 {
     Node       = node;
     ParentNode = parentNode;
     Index      = index;
 }
Ejemplo n.º 26
0
 public FlatButtonCondition(NTree <List <object> > node, NTree <List <object> > parentNode)
 {
     Node       = node;
     ParentNode = parentNode;
 }