Click here to Skip to main content
15,885,278 members
Articles / Programming Languages / C#

Reconstruction of Charts from Images

Rate me:
Please Sign up or sign in to vote.
4.92/5 (13 votes)
18 Mar 2010CPOL7 min read 37.9K   4.1K   42  
Usage of universal framework for chart reconstruction
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using CategoryTheory;

using DiagramUI.Utils;

using DataPerformer.Interfaces;
using DataPerformer;

namespace DataPerformerUI.UserControls
{
    /// <summary>
    /// Control for delay accumulator
    /// </summary>
    public partial class UserControlDelayAccumulator : UserControl, IPostSetArrow
    {
        #region Fields

        ComboBox cb;

        NumericUpDown count;

        NumericUpDown deg;

        DataPerformer.Advanced.DynamicFunction func;

        private bool postSet = true;

        private bool initEvents = true;

        #endregion

        #region Ctor
        /// <summary>
        /// Default constructor
        /// </summary>
        public UserControlDelayAccumulator()
        {
            InitializeComponent();
            userControlEditList.Types = new Type[] { typeof(ComboBox), typeof(NumericUpDown), typeof(NumericUpDown) };
            cb = userControlEditList[0] as ComboBox;
            count = userControlEditList[1] as NumericUpDown;
            deg = userControlEditList[2] as NumericUpDown;
            this.LoadResources();
        }

        #endregion

        #region IPostSetArrow Members

        void IPostSetArrow.PostSetArrow()
        {
            if (postSet)
            {
                Post();
            }
        }

        #endregion

        #region Public

        /// <summary>
        /// Associated function
        /// </summary>
        public DataPerformer.Advanced.DynamicFunction Function
        {
            get
            {
                return func;
            }
            set
            {
                if (value == null)
                {
                    return;
                }
                if (func != null)
                {
                    throw new Exception();
                }
                func = value;
            }
        }

        #endregion

        #region Private

        void Fill()
        {
            postSet = false;
            Double a = 0;
            IDataConsumer dc = func;
            IList<string> l = dc.GetAllMeasuresType(a);
            cb.Items.Clear();
            cb.FillCombo(l);
        }

        private void InitEvents()
        {
            if (!initEvents)
            {
                return;
            }
            initEvents = false;
            cb.SelectedIndexChanged += SelectedIndexChanged;
            count.ValueChanged += CountChanged;
            deg.ValueChanged += DegreeChanged;
        }

        private void Post()
        {
            if (func == null)
            {
                return;
            }
            Fill();
            cb.SelectCombo(func.Argument);
            count.Value = func.Size;
            deg.Value = func.Degree;
            InitEvents();
        }

        #region Event Handlers

        private void SelectedIndexChanged(object sender, EventArgs e)
        {
            this.PerformWithMessageBox(() =>
            {
                object o = cb.SelectedItem;
                if (o == null)
                {
                    return;
                }
                func.Argument = o + "";
            });
        }

        private void CountChanged(object sender, EventArgs e)
        {
            this.PerformWithMessageBox(() => { func.Size = (int)count.Value; });
        }
        
        private void DegreeChanged(object sender, EventArgs e)
        {
            this.PerformWithMessageBox(() => { func.Degree = (int)deg.Value; });
        }

  
        private void toolStripButtonRefresh_Click(object sender, EventArgs e)
        {
            Fill();
            InitEvents();
        }

        #endregion


        #endregion



    }
}

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


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