Exemple #1
0
        // recursive method
        private void CreateTreeNode(FeatureTreeNode parentNode, FeatureType feature, TriStateTreeView treeView)
        {
            if (feature.Items != null)
            {
                foreach (object o in feature.Items)
                {
                    if (o.GetType() == typeof(FeatureType))
                    {
                        FeatureTreeNode node = new FeatureTreeNode();
                        node.Text = ((FeatureType)o).name;

                        if (((FeatureType)o).kind == KindType.Optional || ((FeatureType)o).kind == KindType.FeatureSetFeature)
                        {
                            node.NodeFont = new System.Drawing.Font("Arial", 8, System.Drawing.FontStyle.Bold);
                        }

                        switch (((FeatureType)o).configuration)
                        {
                        case ConfigType.Included:
                            if (((FeatureType)o).kind == KindType.Mandatory)
                            {
                                //treeView.SetChecked(node, TriStateTreeView.CheckState.Checked);
                                treeView.SetChecked(node, TriStateTreeView.CheckState.Greyed);
                            }
                            else
                            {
                                treeView.SetChecked(node, TriStateTreeView.CheckState.Checked);
                            }
                            break;

                        case ConfigType.Unspecified:
                            treeView.SetChecked(node, TriStateTreeView.CheckState.QuestionMark);
                            break;

                        case ConfigType.Excluded:
                            treeView.SetChecked(node, TriStateTreeView.CheckState.Unchecked);
                            break;
                        }

                        parentNode.Nodes.Add(node);
                        CreateTreeNode(node, ((FeatureType)o), treeView);
                    }
                    else
                    {
                        FeatureTreeNode node = new FeatureTreeNode();
                        treeView.SetChecked(node, TriStateTreeView.CheckState.FeatureSet);
                        node.Text = string.Format("FeatureSet [{0}...{1}]", ((FeatureSetType)o).min, ((FeatureSetType)o).max);
                        parentNode.Nodes.Add(node);
                        CreateTreeNode(node, (FeatureSetType)o, treeView);
                    }
                }
            }
        }
Exemple #2
0
        public WindowsForm()
        {
            InitializeComponent();

            // TriStateTreeView
            triStateTreeView             = new TriStateTreeView();
            this.triStateTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                                  | System.Windows.Forms.AnchorStyles.Left)
                                                                                 | System.Windows.Forms.AnchorStyles.Right)));
            this.triStateTreeView.Location = new System.Drawing.Point(5, 19);
            this.triStateTreeView.Name     = "triStateTreeView";
            this.triStateTreeView.Size     = new System.Drawing.Size(890, 390);
            this.triStateTreeView.TabIndex = 0;
            this.triStateTreeView.Visible  = false;

            // Add TriStateTreeView to GroupBox
            this.featureModelGroupBox.Controls.Add(triStateTreeView);
        }
Exemple #3
0
        // create TristateTreeView from XML file
        public void CreateTreeViewFromXmlFile(TriStateTreeView treeView)
        {
            FeatureModelConfiguration fmc = new FeatureModelConfiguration(this.fileName);

            rootFeature = fmc.GetFeatureModelConfigurationModel();


            // Clear TriStateTreeView
            treeView.Nodes.Clear();

            //
            treeView.BeginUpdate();

            treeView.InitializeRootFeature(ref rootFeature);
            FeatureTreeNode rn = new FeatureTreeNode();

            rn.Text = rootFeature.name;
            rn.InitializeRootFeature(ref rootFeature);
            //treeView.SetChecked(rn, TriStateTreeView.CheckState.Checked);
            treeView.SetChecked(rn, TriStateTreeView.CheckState.Greyed);
            treeView.Nodes.Add(rn);


            foreach (object o in rootFeature.Items)
            {
                if (o.GetType() == typeof(FeatureType))
                {
                    FeatureType     ft          = (FeatureType)o;
                    FeatureTreeNode subRootNode = new FeatureTreeNode();
                    subRootNode.Text = ft.name;
                    subRootNode.InitializeFeature(ref ft);

                    if (ft.kind == KindType.Optional || ft.kind == KindType.FeatureSetFeature)
                    {
                        subRootNode.NodeFont = new System.Drawing.Font("Arial", 8, System.Drawing.FontStyle.Bold);
                    }

                    switch (ft.configuration)
                    {
                    case ConfigType.Included:
                        if (ft.kind == KindType.Mandatory)
                        {
                            //treeView.SetChecked(subRootNode, TriStateTreeView.CheckState.Checked);
                            treeView.SetChecked(subRootNode, TriStateTreeView.CheckState.Greyed);
                        }
                        else
                        {
                            treeView.SetChecked(subRootNode, TriStateTreeView.CheckState.Checked);
                        }
                        break;

                    case ConfigType.Excluded:
                        treeView.SetChecked(subRootNode, TriStateTreeView.CheckState.Unchecked);
                        break;

                    case ConfigType.Unspecified:
                        treeView.SetChecked(subRootNode, TriStateTreeView.CheckState.QuestionMark);
                        break;
                    }

                    rn.Nodes.Add(subRootNode);
                    CreateTreeNode(subRootNode, ft, treeView);
                }

                else if (o.GetType() == typeof(FeatureSetType))
                {
                    FeatureSetType  fst         = (FeatureSetType)o;
                    FeatureTreeNode subRootNode = new FeatureTreeNode();
                    subRootNode.Text = string.Format("FeatureSet [{0}...{1}]", fst.min, fst.max);
                    treeView.SetChecked(subRootNode, TriStateTreeView.CheckState.FeatureSet);
                    rn.Nodes.Add(subRootNode);
                    CreateTreeNode(subRootNode, fst, treeView);
                }
            }

            treeView.ExpandAll();
            treeView.EndUpdate();
        }
Exemple #4
0
        private void CreateTreeNode(FeatureTreeNode parentNode, FeatureSetType featureSet, TriStateTreeView treeView)
        {
            if (featureSet.Feature != null)
            {
                foreach (object o in featureSet.Feature)
                {
                    FeatureTreeNode node = new FeatureTreeNode();
                    node.Text = ((FeatureType)o).name;
                    switch (((FeatureType)o).configuration)
                    {
                    case ConfigType.Included:
                        if (((FeatureType)o).kind == KindType.Mandatory)
                        {
                            //treeView.SetChecked(node, TriStateTreeView.CheckState.Checked);
                            treeView.SetChecked(node, TriStateTreeView.CheckState.Greyed);
                        }
                        else
                        {
                            treeView.SetChecked(node, TriStateTreeView.CheckState.Checked);
                        }
                        break;

                    case ConfigType.Excluded:
                        treeView.SetChecked(node, TriStateTreeView.CheckState.Unchecked);
                        break;

                    case ConfigType.Unspecified:
                        treeView.SetChecked(node, TriStateTreeView.CheckState.QuestionMark);
                        break;
                    }
                    node.NodeFont = new System.Drawing.Font("Arial", 8, System.Drawing.FontStyle.Bold);
                    parentNode.Nodes.Add(node);
                }
            }
        }