Click here to Skip to main content
15,878,748 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.8K   4.1K   42  
Usage of universal framework for chart reconstruction
using System;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Runtime.Serialization;

using CategoryTheory;

using DiagramUI;
using DiagramUI.Interfaces;
using DiagramUI.Utils;
using DiagramUI.Labels;
using Diagram.UI.Interfaces;

using DataPerformer;
using DataPerformer.Interfaces;



using ToolBox;

using Calculator;


using Chart;
using Chart.Interfaces;
using Chart.Drawing.Interfaces;
using Chart.Objects;
using Chart.Panels;

using DataPerformerUI.UserControls;

using DataPerformerUI.Interfaces;



namespace DataPerformerUI.Labels
{
    /// <summary>
    /// Label of graph
    /// </summary>
    [Serializable()]
    public partial class GraphLabel : UserControlBaseLabel, IBlocking,
       INonstandardLabel, IStartStop, IStartStopConsumer, IGraphLabel
    {

        #region Specific Fields



        private DataConsumer consumer;

 
        private string argument = "";

        private string condition = "";

        private Dictionary<string, string> dicText = new Dictionary<string, string>();
        
        private Dictionary<string, string> texts = new Dictionary<string, string>();

 
        private Dictionary<string, Color> colors = new Dictionary<string, Color>();

        private Dictionary<string, bool> stepChart = new Dictionary<string, bool>();


        private PictureBox pb = new PictureBox();

        private Label lt = new Label();

        private string start = "";

        private string step = "";

        private string stepCount = "";

        private Forms.FormGraph form = null;
   
   
        int dist = 0;

        private string points = "";

  
        UserControlGraph child;


        #endregion

        #region Ctor

        /// <summary>
        /// Default constructor
        /// </summary>
        public GraphLabel()
            : base(typeof(DataConsumer), "", ResourceImage.Graph.ToBitmap())
        {
        }

 
        /// <summary>
        /// Deserialization constructor
        /// </summary>
        /// <param name="info">Serialization info</param>
        /// <param name="context">Streaming context</param>
        protected GraphLabel(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }

        #endregion

        #region ISerializable Members

        /// <summary>
        /// ISerializable interface implementation
        /// </summary>
        /// <param name="info">Serialization info</param>
        /// <param name="context">Streaming context</param>
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            base.GetObjectData(info, context);
            info.AddValue("Colors", colors, typeof(Dictionary<string, Color>));
            info.AddValue("Argument", argument, typeof(string));
            info.AddValue("Condition", condition, typeof(string));
            info.AddValue("Texts", texts, typeof(Dictionary<string, string>));
            info.AddValue("Start", start, typeof(string));
            info.AddValue("Step", step, typeof(string));
            info.AddValue("StepCount", stepCount, typeof(string));
            info.AddValue("Split", dist);
            info.AddValue("StepChart", stepChart, typeof(Dictionary<string, bool>));
            info.AddValue("Points", points);
        }

        #endregion

        #region IBlocking Members

        bool IBlocking.IsBlocked
        {
            get
            {
                IBlocking b = child;
                return b.IsBlocked;
            }
            set
            {
                IBlocking b = child;
                b.IsBlocked = value;
            }
        }

        #endregion

        #region Create form members

        /// <summary>
        /// Initialization
        /// </summary>
        new public void Initialize()
        {
        }

        /// <summary>
        /// Resize
        /// </summary>
        new public void Resize()
        {
        }

        /// <summary>
        /// Creates editor form
        /// </summary>
        public override void CreateForm()
        {
            form = new Forms.FormGraph(this);   
        }

        /// <summary>
        /// Editor form
        /// </summary>
        public override object Form
        {
            get
            {
                return form;
            }
        }

 
        /// <summary>
        /// Post operation
        /// </summary>
        public override void Post()
        {
            child.Post();
        }



        #endregion

        #region Members

        internal Dictionary<string, Color> Colors
        {
            get
            {
                return colors;
            }
        }

  


        internal IDesktop OwnDesktop
        {
            set
            {
                desktop = value;
            }
        }

        private void ResizeLabel(object sender, EventArgs e)
        {
            child.SetVisible();
        }



        void PreInit()
        {
            child.PreInit();
        }




  
        #endregion

        #region Overriden Members

        /// <summary>
        /// Internal control
        /// </summary>
        protected override UserControl Control
        {
            get 
            {
                child = new UserControlGraph(true);
                this.Copy(child);
                child.ParentLabel = this;
                return child;
            }
        }


        /// <summary>
        /// Object
        /// </summary>
        public override ICategoryObject Object
        {
            get
            {
                return consumer;
            }
            set
            {
                if (!(value is DataConsumer))
                {
                    CategoryException.ThrowIllegalSourceException();
                }
                consumer = value as DataConsumer;
                consumer.Object = this;
                child.Consumer = consumer;
            }
        }

        /// <summary>
        /// Load operation
        /// </summary>
        /// <param name="info">Serialization info</param>
        /// <param name="context">Streaming context</param>
        protected override void Load(SerializationInfo info, StreamingContext context)
        {
            base.Load(info, context);
            try
            {
                colors = info.GetValue("Colors", typeof(Dictionary<string, Color>)) as Dictionary<string, Color>;
                argument = info.GetValue("Argument", typeof(string)) as string;
                condition = info.GetValue("Condition", typeof(string)) as string;
                texts = info.GetValue("Texts", typeof(Dictionary<string, string>)) as Dictionary<string, string>;
                start = info.GetValue("Start", typeof(string)) as string;
                step = info.GetValue("Step", typeof(string)) as string;
                stepCount = info.GetValue("StepCount", typeof(string)) as string;
                dist = info.GetInt32("Split");
                stepChart = info.GetValue("StepChart", typeof(Dictionary<string, bool>)) as Dictionary<string, bool>;
                points = info.GetString("Points");
            }
            catch (Exception ex)
            {
                ex.Log();
            }
        }

        #endregion

        #region IGraphLabel Members

        Dictionary<string, Color> IGraphLabel.Colors
        {
            get
            {
                return colors;
            }
            set
            {
                colors = value;
            }
        }

        Dictionary<string, bool> IGraphLabel.StepChart
        {
            get
            {
                return stepChart;
            }
            set
            {
                stepChart = value;
            }
        }

        string IGraphLabel.Argument
        {
            get
            {
                return argument;
            }
            set
            {
                argument = value;
            }
        }

        int IGraphLabel.SplitDistance
        {
            get
            {
                return dist;
            }
            set
            {
                dist = value;
            }
        }

        string IGraphLabel.Condition
        {
            get
            {
                return condition;
            }
            set
            {
                condition = value;
            }
        }

        Dictionary<string, string> IGraphLabel.Texts
        {
            get
            {
                return texts;
            }
            set
            {
                texts = value;
            }
        }

        string IGraphLabel.Start
        {
            get
            {
                return start;
            }
            set
            {
                start = value;
            }
        }

        string IGraphLabel.Step
        {
            get
            {
                return step;
            }
            set
            {
                step = value;
            }
        }

        string IGraphLabel.StepCount
        {
            get
            {
                return stepCount;
            }
            set
            {
                stepCount = value;
            }
        }

        string IGraphLabel.Points
        {
            get
            {
                return points;
            }
            set
            {
                points = value;
            }
        }


        #endregion

        #region IStartStop Members

        void IStartStop.Action(object type, bool start)
        {
            IStartStop ss = child;
            ss.Action(type, start);
        }

        #endregion

        #region IStartStopConsumer Members

        public IStartStop StartStop
        {
            get
            {
                IStartStopConsumer ssc = child;
                return ssc.StartStop;
            }
            set
            {
                IStartStopConsumer ssc = child;
                ssc.StartStop = value;
            }
        }

        #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