Click here to Skip to main content
15,888,610 members
Articles / Programming Languages / C#

OOP in the Real World - Creating an Equation Editor

Rate me:
Please Sign up or sign in to vote.
4.87/5 (106 votes)
21 Apr 2015MIT11 min read 137.7K   10.5K   220  
Object Oriented Design and Programming process using a real world example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace Editor
{
    public abstract class SubSuperBase : EquationContainer
    {
        public Position Position { get; set; }        
        protected RowContainer rowContainer;
        EquationBase buddy = null;
        protected EquationBase Buddy
        {
            get { return buddy ?? ParentEquation.ActiveChild; }
            set { buddy = value; }
        }
        
        public SubSuperBase(EquationRow parent, Position position)
            : base(parent)
        {
            Position = position;
            ActiveChild = rowContainer = new RowContainer(this);
            childEquations.Add(rowContainer);
            rowContainer.FontFactor = SmallerFontFactor;
        }
        
        public void SetBuddy(EquationBase buddy)
        {
            this.Buddy = buddy;
            CalculateHeight();
        }

        protected override void CalculateWidth()
        {
            Width = rowContainer.Width;
        }

        public override double Left
        {
            get { return base.Left; }
            set
            {
                base.Left = value;
                rowContainer.Left = this.Left;
            }
        }
    }
}

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 MIT License


Written By
Technical Lead https://mathiversity.com
Unknown
I am a full-stack developer. My skills include JavaScript, C#/.Net, MS Azure cloud etc. I love to work on complex programming tasks requiring deep analysis, planning and use of efficient algorithms and data structures.

Comments and Discussions