Click here to Skip to main content
13,146,315 members (44,003 online)
Click here to Skip to main content

Stats

23.3K views
77 bookmarked
Posted 10 Apr 2010

User-driven applications

, 10 Apr 2010
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
TheoryOfUserDrivenApplications
bin
Debug
TheoryOfUserDrivenApplications.vshost.exe
Release
MoveGraphLibrary.dll
TheoryOfUserDrivenApplications.bin
TheoryOfUserDrivenApplications.exe
TheoryOfUserDrivenApplications.vshost.exe
Properties
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 .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.

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

You may also be interested in...

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