|
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.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.