|
using System;
using System .Collections .Generic;
using System .Drawing;
using System .Windows .Forms;
using Microsoft .Win32;
using MoveGraphLibrary;
namespace UserDrivenApplications
{
public class AreaOnScreen
{
int version = 605;
long id;
MSPlot msplot;
List<FunctionDesigned> funcs = new List<FunctionDesigned> ();
// -------------------------------------------------
public AreaOnScreen (MSPlot plot, List<FunctionDesigned> functions)
{
id = Auxi_Common .UniqueID;
msplot = plot;
funcs = functions;
}
// ------------------------------------------------- ID
public long ID
{
get { return (id); }
set { id = value; }
}
// ------------------------------------------------- Plot
public MSPlot Plot
{
get { return (msplot); }
}
// ------------------------------------------------- FunctionInArea
public bool FunctionInArea (long idFunc)
{
for (int i = 0; i < funcs .Count; i++)
{
if (idFunc == funcs [i] .ID)
{
return (true);
}
}
return (false);
}
// ------------------------------------------------- Draw
public void Draw (Graphics grfx)
{
msplot .Draw (grfx);
DrawPlots (grfx);
}
// ------------------------------------------------- DrawPlots
public void DrawPlots (Graphics grfx)
{
for (int i = 0; i < funcs .Count; i++)
{
funcs [i] .Draw (grfx, msplot, i);
}
}
// ------------------------------------------------- SaveAreaIntoFunctions
public void SaveAreaIntoFunctions ()
{
if (funcs .Count == 1)
{
funcs [0] .MSPlot = msplot;
}
}
// ------------------------------------------------- CloseTuningForms
public void CloseTuningForms ()
{
msplot .CloseTuningForms ();
}
const string nameMain = "Area_";
// ------------------------------------------------- IntoRegistry
public void IntoRegistry (RegistryKey regkey, string strAdd)
{
try
{
string [] strs = new string [3 + funcs .Count * 2];
strs [0] = version .ToString ();
strs [1] = id .ToString ();
strs [2] = funcs .Count .ToString ();
int k0 = 3;
for (int i = 0; i < funcs .Count; i++)
{
strs [k0 + i * 2] = ((int) (funcs [i] .Origin)) .ToString ();
strs [k0 + i * 2 + 1] = funcs [i] .ID .ToString ();
}
regkey .SetValue (nameMain + strAdd, strs, RegistryValueKind .MultiString);
msplot .IntoRegistry (regkey, strAdd);
}
catch
{
}
finally
{
}
}
// ------------------------------------------------- FromRegistry
public static AreaOnScreen FromRegistry (Form form, RegistryKey regkey, string strAdd,
List<FunctionDesigned> funcsPredef, List<FunctionDesigned> funcsNew)
{
try
{
string [] strs = (string []) regkey .GetValue (nameMain + strAdd);
if (form == null ||
strs == null || strs .Length < 5 ||
Convert .ToInt32 (strs [0]) != 605 || // version
funcsPredef == null || funcsNew == null || (funcsPredef .Count + funcsNew .Count == 0))
{
return (null);
}
List<FunctionDesigned> funcsCheck;
List<FunctionDesigned> funs = new List<FunctionDesigned> ();
int nFunc = Convert .ToInt32 (strs [2]);
int k0 = 3;
for (int i = 0; i < nFunc; i++)
{
FuncAuthor origin = (FuncAuthor) Convert .ToInt32 (strs [k0 + i * 2]);
long idRead = Convert .ToInt64 (strs [k0 + i * 2 + 1]);
if (origin == FuncAuthor .Developer)
{
funcsCheck = funcsPredef;
}
else
{
funcsCheck = funcsNew;
}
for (int j = 0; j < funcsCheck .Count; j++)
{
if (funcsCheck [j] .ID == idRead)
{
funs .Add (funcsCheck [j]);
break;
}
}
}
if (funs .Count <= 0)
{
return (null);
}
MSPlot plot = MSPlot .FromRegistry (form, regkey, strAdd);
if (plot == null)
{
return (null);
}
AreaOnScreen area = new AreaOnScreen (plot, funs);
if (area != null)
{
area .ID = Convert .ToInt64 (strs [1]);
}
return (area);
}
catch
{
return (null);
}
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.