Click here to Skip to main content
15,886,026 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.Text;

using System.Windows.Forms;


using CategoryTheory;

using DiagramUI.Labels;
using DiagramUI;
using Diagram.UI.Factory;

using DataPerformer;
using ControlSystems.UI.Intrefaces;

namespace ControlSystems.Data.UI.Factory
{
    /// <summary>
    /// Factory of control systems
    /// </summary>
    public class ControlSystemsFactory : EmptyUIFactory
    {
        #region Fields

        /// <summary>
        /// Singleton
        /// </summary>
        public static ControlSystemsFactory Object = new ControlSystemsFactory();

        public static readonly ButtonWrapper[] ObjectButtons = new ButtonWrapper[]
        {
                                        new ButtonWrapper(typeof(ControlSystems.Data.RationalTransformControlSystemData),
                    "", "Transformation function", ResourceImage.ControlSystemTransform, ControlSystemsFactory.Object, true, false)

        };

        #endregion

        #region Ctor

        private ControlSystemsFactory()
        {
        }

        #endregion


        #region IUIFactory Members

        public override object CreateForm(INamedComponent comp)
        {
            if (comp is IArrowLabel)
            {
                IArrowLabel lab = comp as IArrowLabel;
                ICategoryArrow arrow = lab.Arrow;
            }
            if (comp is IObjectLabel)
            {
                IObjectLabel lab = comp as IObjectLabel;
                // The object of component
                ICategoryObject obj = lab.Object;
                if (obj is ControlSystems.Data.RationalTransformControlSystemData)
                {
                    return CreateControlSystemForm(lab);
                }
            }
            return null;
        }

        #endregion

        static private Form CreateControlSystemForm(IObjectLabel l)
        {

            ControlSystems.Data.RationalTransformControlSystemData tr =
                l.Object as ControlSystems.Data.RationalTransformControlSystemData;
            ControlSystems.UI.Forms.FormTransformationFunction form =
                new ControlSystems.UI.Forms.FormTransformationFunction(l);
            form.ShowComboBox();
            try
            {
                form.Measurements = tr.InputMeasurements;
                form.SelectedItem = tr.Input;
            }
            catch (Exception ex)
            {
                ex.Log();
            }
            form.SelectMeasure += delegate(object ob)
            {
                if (ob == null)
                {
                    tr.Input = "";
                }
                tr.Input = ob + "";
            };
            try
            {
                form.Feedback = new Feedback(tr);
            }
            catch (Exception exc)
            {
                exc.Log();
            }
            return form;
        }

    }


    #region Helper Class

    class Feedback : IFeedback
    {
        #region Fields

        ControlSystems.Data.RationalTransformControlSystemData tr;


        #endregion

        #region Ctor

        internal Feedback(ControlSystems.Data.RationalTransformControlSystemData tr)
        {
            this.tr = tr;
        }

        #endregion

        #region IFeedback Members

        ICollection<string> IFeedback.Aliases
        {
            get 
            {
                List<string> ali = new List<string>();
                Double a = 0;
                tr.GetAllAliases(ali, a);
                return ali;
            }
        }

        string IFeedback.Alias
        {
            get
            {
                return tr.Alias;
            }
            set
            {
                tr.Alias = value;
            }
        }

        #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