// create node and ParametricFunction group
        TreeNode AddGroup(TreeNode node, string name, string[] fnames, string[] fcodesx, string[] fcodesy,
                          double tmin, double tmax)
        {
            TreeNode gn = new TreeNode(name);

            FunctionBase[] fs = new FunctionBase[fnames.Length];            //!!VBSubst Dim fs(fnames.Length-1) As FunctionBase

            for (int i = 0; i < fs.Length; i++)
            {
                ParametricFunction f = new ParametricFunction();
                f.Label               = fnames[i];
                f.LineStyle.Color     = clrs[i];
                f.LineStyle.Thickness = 2;
                f.MinT = tmin;
                f.MaxT = tmax;
                fs[i]  = f;
            }

            FunctionsGroup fg = new FunctionsGroup(fs, fcodesx, fcodesy);

            gn.Tag = fg;
            node.Nodes.Add(gn);

            return(gn);
        }
        private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
        {
            AnimateStop();
            btnAnimate.Enabled = false;

            TreeNode sn = treeView1.SelectedNode;

            // if group of functions are associated with this node
            if (sn != null && sn.Tag != null)
            {
                FunctionsCollection fc = c1Chart1.ChartGroups[0].ChartData.FunctionsList;

                // clear previous functions and listview
                fc.Clear();
                listView1.Items.Clear();

                FunctionsGroup fg = (FunctionsGroup)sn.Tag;
                fg.Load(statusBar1);

                // fill listview
                for (int i = 0; i < fg.FunctionList.Length; i++)
                {
                    FunctionBase f   = fg.FunctionList[i];
                    ListViewItem lvi = new ListViewItem(f.Label);
                    lvi.Checked   = true;
                    lvi.ForeColor = f.LineStyle.Color;
                    lvi.Tag       = f;
                    listView1.Items.Add(lvi);
                    fc.Add(f);
                }

                fg.ApplyOptions(c1Chart1);
            }
        }
        // create node and YFunction group
        TreeNode AddGroup(TreeNode node, string name, string[] fnames, string[] fcodes,
                          double xmin, double xmax, double ymin, double ymax, int npoints)
        {
            TreeNode gn = new TreeNode(name);

            FunctionBase[] fs = new FunctionBase[fnames.Length];            //!!VBSubst Dim fs(fnames.Length-1) As FunctionBase

            for (int i = 0; i < fs.Length; i++)
            {
                YFunction f = new YFunction();
                f.Label               = fnames[i];
                f.LineStyle.Color     = clrs[i];
                f.LineStyle.Thickness = 2;
                if (npoints > 0)
                {
                    f.PlotNumPoints = npoints;
                }

                fs[i] = f;
            }

            FunctionsGroup fg = new FunctionsGroup(fs, fcodes, xmin, xmax, ymin, ymax);

            gn.Tag = fg;
            node.Nodes.Add(gn);

            return(gn);
        }