Click here to Skip to main content
15,893,722 members
Articles / Programming Languages / C#

Universal Framework for Science and Engineering - Part 2: Regression

Rate me:
Please Sign up or sign in to vote.
4.77/5 (19 votes)
11 Jul 20067 min read 51.2K   5K   76  
An article on universal scalable engineering framework applications.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using CategoryTheory;
using DiagramUI;
using DataPerformer;

namespace DataPerformerUI
{
    public partial class FormIteratorFilter : Form, IUpdatableForm
    {
        private IObjectLabel label;

        private FormulaFilterIterator filter;

        private PanelFormula panel;


        private PanelConsumer pConsumer;

        private FormIteratorFilter()
        {
            InitializeComponent();
        }

        public FormIteratorFilter(IObjectLabel label)
        {
            InitializeComponent();
            ResourceService.Resources.LoadControlResources(this);
            this.label = label;
            filter = label.Object as FormulaFilterIterator;
            Text = label.Name;
            dataGridViewConst.DataSource = dataSetConst.Tables[0];
            prepare();
        }

        #region IUpdatableForm Members

        void IUpdatableForm.UpdateFormUI()
        {
            Text = label.Name;
        }

        #endregion


        protected void prepare()
        {
            panel = new PanelFormula("Condition", this, splitContainerMain.Panel1.Width, 200,
                    "abcdfghijklmnopqrstuvwxyz", false, null, null);
            panel.Dock = DockStyle.Fill;
            splitContainerMain.Panel1.Controls.Add(panel);
            panel.Formula = filter.Formula;
            check();
            pConsumer = new PanelConsumer(filter, filter.VariableDictionary, filter.Variables);
            panelMeaCenter.Controls.Add(pConsumer);
            fillConst();
        }

        private void buttonAcceptForm_Click(object sender, EventArgs e)
        {
            try
            {
                filter.Formula = panel.Formula;
                check();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void check()
        {
            string s = filter.AllVariables;
            string check = filter.Constants;
            DefaultForm.CheckList(checkedListBoxConst, s, check);

        }

        private void buttonAcceptPar_Click(object sender, EventArgs e)
        {
            try
            {
                filter.VariableDictionary = pConsumer.Selected; 
   
            }
            catch (Exception ex)
            {
            }
        }



        private void buttonAcceptConst_Click(object sender, EventArgs e)
        {
            filter.Constants = DefaultForm.GetCheckedString(checkedListBoxConst);
            pConsumer.Vars = filter.Variables;

            fillConst();
        }


        private void fillConst()
        {
            Dictionary<string, object> l = new Dictionary<string, object>();
            DataTable t = dataSetConst.Tables[0];
            foreach (DataRow row in t.Rows)
            {
                l["" + row[0]] = row[1];
            }
            t.Rows.Clear();
            Dictionary<string, object> consts = filter.ConstDictionary;
            foreach (string key in consts.Keys)
            {
                object o = consts[key];
                if (l.ContainsKey(key))
                {
                    o = l[key];
                }
                t.Rows.Add(new object[] {key, o});
            }
            dataGridViewConst.Refresh();
        }

        private void buttonAcceptValues_Click(object sender, EventArgs e)
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            DataTable t = dataSetConst.Tables[0];
            foreach (DataRow row in t.Rows)
            {
                string key = row[0] + "";
                d[key] = (double)row[1];
            }
            filter.ConstDictionary = d;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect
Russian Federation Russian Federation
Ph. D. Petr Ivankov worked as scientific researcher at Russian Mission Control Centre since 1978 up to 2000. Now he is engaged by Aviation training simulators http://dinamika-avia.com/ . His additional interests are:

1) Noncommutative geometry

http://front.math.ucdavis.edu/author/P.Ivankov

2) Literary work (Russian only)

http://zhurnal.lib.ru/editors/3/3d_m/

3) Scientific articles
http://arxiv.org/find/all/1/au:+Ivankov_Petr/0/1/0/all/0/1

Comments and Discussions