Navigation:  Application Architecture > Putting it All Together > Designing an Application Component >

Creating the Presentation Model

Previous pageReturn to chapter overviewNext page

Recall that the primary purpose of the component is to serve as a Presentation Model.  Therefore the component should provide a logical model for the user-interface that it supports.  Let’s add some public methods and properties that model the user-interface shown above:

 

public class TextEditorComponent : ApplicationComponent
{
    private string _text;
    private string _filename;
    private int _wordCount;
 
    public string Filename
    {
        get { return _filename; }
        set { _filename = value; }
    }
 
    public string Text
    {
        get { return _text; }
        set { _text = value; }
    }
 
    public int WordCount
    {
        get { return _wordCount; }
        private set { _wordCount = value; }
    }
 
    public void Save()
    {
    }
 
    public void Cancel()
    {
    }
}

 

The Text property represents the text that is displayed in the editor.  The Filename property is used to determine the file to which the text is saved.  The WordCount property represents the current word-count.  The Save and Cancel methods respond to the user pressing the Save and Cancel buttons respectively.