Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

User-driven applications

, 10 Apr 2010 CPOL
User-driven applications are the programs in which full control is given to the users. Designers of such programs are responsible only for developing an instrument for solving some task, but they do not enforce users to work with this instrument according with a predefined scenario.
TheoryOfUserDrivenApplications.zip
TheoryOfUserDrivenApplications
TheoryOfUserDrivenApplications
bin
Debug
TheoryOfUserDrivenApplications.vshost.exe
Release
MoveGraphLibrary.dll
TheoryOfUserDrivenApplications.bin
TheoryOfUserDrivenApplications.exe
TheoryOfUserDrivenApplications.vshost.exe
Properties
Settings.settings
Resources
ArrowDown.bmp
ArrowUp.bmp
DELETE.BMP
Hangar.bmp
Lock.bmp
palette_.bmp
RuralHouse.bmp
RuralLeftPlus.bmp
RuralRightPlus.bmp
SimpleHouse.bmp
User_driven_applications.doc
User_driven_applications.pdf
using System;
using System .Collections .Generic;
using System .IO;
using System .Windows .Forms;

using MoveGraphLibrary;

namespace UserDrivenApplications
{
    public class Data_String
    {
        string name;
        bool bShowToUser;
        string text;       // this is the string itself
        string comment = "";

        // -------------------------------------------------
        public Data_String (string strName, bool bShow, string txt, string cmnt) 
        {
            string trimmedtext = txt .Trim ();
            if (!string .IsNullOrEmpty (trimmedtext))
            {
                name = strName;
                bShowToUser = bShow;
                text = trimmedtext;
                if (!string .IsNullOrEmpty (cmnt))
                {
                    comment = cmnt;
                }
            }
        }
        public Data_String (string strName, bool bShow, string txt)
            : this (strName, bShow, txt, null)
        {
        }
        public Data_String (string strName, string txt, string cmnt) 
            : this (strName, true, txt, cmnt)  
        {
        }
        public Data_String (string strName, string txt)
            : this (strName, true, txt, null)
        {
        }
        // -------------------------------------------------        Name
        public string Name
        {
            get { return (name); }
            set
            {
                if (!string .IsNullOrEmpty (value))
                {
                    name = value;
                }
            }
        }
        // -------------------------------------------------        ShowToUser
        public bool ShowToUser
        {
            get { return (bShowToUser); }
            set { bShowToUser = value; }
        }
        // -------------------------------------------------        HasData
        public bool HasData
        {
            get { return (!string .IsNullOrEmpty (text)); }
        }
        // -------------------------------------------------        Value
        public string Value
        {
            get { return (text); }
            set
            {
                if (!string .IsNullOrEmpty (value))
                {
                    text = value;
                }
            }
        }
        // -------------------------------------------------        Comment
        public string Comment
        {
            get { return (comment); }
            set
            {
                if (value != null)
                {
                    comment = value;
                }
            }
        }
        // -------------------------------------------------        IntoFile
        public void IntoFile (BinaryWriter bw)
        {
            try
            {
                if (HasData)
                {
                    bw .Write (name);           // 0
                    bw .Write (bShowToUser);    // 1
                    bw .Write (text);           // 2
                    bw .Write (comment);        // 3
                }
            }
            catch
            {
            }
            finally
            {
            }
        }
        // -------------------------------------------------        FromFile
        public static void FromFile (BinaryReader br, out Data_String data)
        {
            try
            {
                data = new Data_String (br .ReadString (), br .ReadBoolean (), br .ReadString (), br .ReadString ());
            }
            catch
            {
                data = null;
                string strText = "Can't read Data_String";
                MessageBox .Show (strText, "Problem on Reading", MessageBoxButtons .OK, MessageBoxIcon .Exclamation);
            }
            finally
            {
            }
        }
    }
}

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)

Share

About the Author

SergeyAndreyev

United States United States
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141223.1 | Last Updated 10 Apr 2010
Article Copyright 2010 by SergeyAndreyev
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid