Click here to Skip to main content
15,896,269 members
Articles / Programming Languages / C#

User-driven applications

Rate me:
Please Sign up or sign in to vote.
4.88/5 (24 votes)
10 Apr 2010CPOL136 min read 33.1K   5   78  
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.
using System;
using System .Collections .Generic;
using System .ComponentModel;
using System .Drawing;
using System .Windows .Forms;
using Microsoft .Win32;

using MoveGraphLibrary;

namespace UserDrivenApplications
{
    public partial class Form_Functions : Form
    {
        int version = 605;
        const string strAddRegKey = "Form_Functions";
        Mover mover;
        Point ptMouse_Down, ptMouse_Up;
        ElasticGroup groupFuncs;
        ElasticGroup groupPressed;
        List<FunctionDesigned> funcsPredefined = new List<FunctionDesigned> ();
        List<FunctionDesigned> funcsNew = new List<FunctionDesigned> ();
        List<AreaOnScreen> areas = new List<AreaOnScreen> ();
        bool bShowAngle = false;
        int iNewRect = 0;
        int iAreaTouched = -1;
        int iCmntTouched = -1;
        bool bVerScaleTouched = false;
        bool bHorScaleTouched = false;
        bool bMainAreaCmntTouched = false;
        bool bVerScaleCmntTouched = false;
        bool bHorScaleCmntTouched = false;
        CommentToRect cmntPressed;

        bool bFormInMove = false;
        Size sizeMouseShift;

        bool bRestore;

        // -------------------------------------------------
        public Form_Functions ()
        {
            InitializeComponent ();
            mover = new Mover (this);
            mover .Clipping = Clipping .Safe;
        }
        // -------------------------------------------------        OnLoad
        private void OnLoad (object sender, EventArgs e)
        {
            RestoreFromRegistry ();
            if (!bRestore)
            {
                DeclarePredefinedFunctions ();
                groupFuncs = new ElasticGroup (this, new ElasticGroupElement [] {
                                                            new ElasticGroupElement (listPredefined),
                                                            new ElasticGroupElement (this, new Control [] {btnDeleteFunc, btnFuncUp, btnFuncDown,
                                                                                                           listNew, btnChange, btnNewFunc, 
                                                                                                           btnNewParamFunc}),
                                                            new ElasticGroupElement (btnShowFunctions)},
                                               "Functions");
            }
            FillPredefinedList ();
            FillNewList ();

            RenewMover ();
            ButtonsStatus ();
        }
        // -------------------------------------------------        FillPredefinedList
        private void FillPredefinedList ()
        {
            listPredefined .Items .Clear ();
            for (int i = 0; i < funcsPredefined .Count; i++)
            {
                listPredefined .Items .Add (funcsPredefined [i] .Name);
            }
        }
        // -------------------------------------------------        FillNewList
        private void FillNewList ()
        {
            listNew .Items .Clear ();
            for (int i = 0; i < funcsNew .Count; i++)
            {
                listNew .Items .Add (funcsNew [i] .Name);
            }
        }
        // -------------------------------------------------        OnFormClosing
        private void OnFormClosing (object sender, FormClosingEventArgs e)
        {
            SaveInfoToRegistry ();
        }
        // -------------------------------------------------        DeclarePredefinedFunctions
        private void DeclarePredefinedFunctions ()
        {
            funcsPredefined .Clear ();
            funcsPredefined .Add (new FunctionDesigned ("sine", 0, -6 * Math .PI, 8 * Math .PI, 1.05, -1.05));
            funcsPredefined .Add (new FunctionDesigned ("cosine", 1, -6 * Math .PI, 8 * Math .PI, 1.05, -1.05));
            funcsPredefined .Add (new FunctionDesigned ("tangent", 2, -3 * Math .PI, 5 * Math .PI, 6, -6));
            funcsPredefined .Add (new FunctionDesigned ("Trigonometric-0", 3, 0, 25, 3, -3));
            funcsPredefined .Add (new FunctionDesigned ("Trigonometric-1", 4, 0, 25, 1.0, -3.5));
            funcsPredefined .Add (new FunctionDesigned ("Vibrations", 5, 0, 20, 3, -3));
            funcsPredefined .Add (new FunctionDesigned ("Parametric-0", 6, -20, 30, 30, -30));
            funcsPredefined .Add (new FunctionDesigned ("Parametric-1", 7, -12, 12, 11, -11));
            funcsPredefined .Add (new FunctionDesigned ("Lissajou (5,9)", 8, -1.05, 1.05, 1.05, -1.05));
            funcsPredefined .Add (new FunctionDesigned ("Trigonometric-2", 9, -12, 15, 3, -2));
            funcsPredefined .Add (new FunctionDesigned ("Trigonometric-3", 10, -1.5, 1.0, 5, -5));
            for (int i = 0; i < funcsPredefined .Count; i++)
            {
                Rectangle rc = NewFuncRect;
                FunctionDesigned func = funcsPredefined [i];
                ValuesOnBorders bordvals = func .ValuesOnBorders;
                MSPlot plot = new MSPlot (this, rc, Side .S, bordvals .Left, bordvals .Right, GridOrigin .ByMinLines, 4,
                                                    Side .E, bordvals .Top, bordvals .Bottom, GridOrigin .ByMinLines, 3);
                CommentToRect comment = new CommentToRect (this, rc, new Point (rc .Left + 50, rc .Top + 20),
                                                           func .Name, Font, 0, plot .Line (0) .Color);
                plot .AddComment (comment);
                func .MSPlot = plot;
            }
        }
        // -------------------------------------------------        RenewMover
        private void RenewMover ()
        {
            mover .Clear ();
            for (int iArea = areas .Count - 1; iArea >= 0; iArea--)
            {
                AreaOnScreen aos = areas [iArea];
                aos .Plot .IntoMover (mover, 0);
            }
            groupFuncs .IntoMover (mover, 0);
        }
        // -------------------------------------------------        OnMouseDown
        private void OnMouseDown (object sender, MouseEventArgs e)
        {
            ptMouse_Down = e .Location;
            if (!mover .Catch (e .Location, e .Button, bShowAngle))
            {
                if (e .Button == MouseButtons .Left)
                {
                    bFormInMove = true;
                    sizeMouseShift = new Size (PointToScreen (ptMouse_Down) .X - Location .X, PointToScreen (ptMouse_Down) .Y - Location .Y);
                }
            }
            ContextMenuStrip = null;
        }
        // -------------------------------------------------        OnMouseUp
        private void OnMouseUp (object sender, MouseEventArgs mea)
        {
            ptMouse_Up = mea .Location;
            double nDist = Auxi_Geometry .Distance (ptMouse_Down, ptMouse_Up);
            if (mea .Button == MouseButtons .Left)
            {
                if (mover .Release ())
                {
                    int iInMover = mover .WasCaughtObject;
                    if (mover [iInMover] .Source is MSPlot)
                    {
                        Identification (iInMover);             
                        if (nDist <= 3 && iAreaTouched > 0)
                        {
                            MoveAreaOnTop (iAreaTouched);
                        }
                    }
                }
            }
            else if (mea .Button == MouseButtons .Right)
            {
                if (mover .Release ())
                {
                    if (nDist <= 3)  
                    {
                        MenuSelection (mover .WasCaughtObject);
                    }
                }
                else
                {
                    if (nDist <= 3)
                    {
                        iAreaTouched = -1;
                        ContextMenuStrip = menuOnEmpty;
                    }
                }
            }
            bFormInMove = false;
        }
        // -------------------------------------------------        MoveAreaOnTop
        private void MoveAreaOnTop (int iArea)
        {
            while (iArea > 0)
            {
                areas .Reverse (iArea - 1, 2);
                iArea--;
            }
            RenewMover ();
            Invalidate ();
        }
        // -------------------------------------------------        MenuSelection
        private void MenuSelection (int iInMover)
        {
            GraphicalObject grobj = mover [iInMover] .Source;
            if (grobj is ElasticGroup)
            {
                groupPressed = grobj as ElasticGroup;
                ContextMenuStrip = menuOnGroup;
            }
            else
            {
                Identification (iInMover);        
                if (iAreaTouched >= 0)
                {
                    if (grobj is MSPlot)
                    {
                        ContextMenuStrip = menuOnPlot;
                    }
                    else if (grobj is Scale)
                    {
                        ContextMenuStrip = menuOnScale;
                    }
                    else if (grobj is TextMR)
                    {
                        ContextMenuStrip = menuOnComment;
                    }
                }
            }
        }
        // -------------------------------------------------        Identification
        private void Identification (int iInMover)
        {
            GraphicalObject grobj = mover [iInMover] .Source;
            long id = grobj .ID;
            iAreaTouched = -1;
            iCmntTouched = -1;
            bVerScaleTouched = false;
            bHorScaleTouched = false;
            bMainAreaCmntTouched = false;
            bVerScaleCmntTouched = false;
            bHorScaleCmntTouched = false;

            if (grobj is MSPlot)
            {
                for (iAreaTouched = areas .Count - 1; iAreaTouched >= 0; iAreaTouched--)
                {
                    if (id == areas [iAreaTouched] .Plot .ID)
                    {
                        break;
                    }
                }
            }
            else if (grobj is Scale)
            {
                for (iAreaTouched = areas .Count - 1; iAreaTouched >= 0; iAreaTouched--)
                {
                    if (areas [iAreaTouched] .Plot .VerScaleOrder (id) >= 0)
                    {
                        bVerScaleTouched = true;
                        break;
                    }
                    else if (areas [iAreaTouched] .Plot .HorScaleOrder (id) >= 0)
                    {
                        bHorScaleTouched = true;
                        break;
                    }
                }
            }
            else if (grobj is CommentToRect)
            {
                for (iAreaTouched = areas .Count - 1; iAreaTouched >= 0; iAreaTouched--)
                {
                    MSPlot plot = areas [iAreaTouched] .Plot;
                    for (iCmntTouched = plot .Comments .Count - 1; iCmntTouched >= 0; iCmntTouched--)
                    {
                        if (id == plot .Comments [iCmntTouched] .ID)
                        {
                            bMainAreaCmntTouched = true;
                            cmntPressed = plot .Comments [iCmntTouched];
                            return;
                        }
                    }
                    Scale scale = plot .VerScales [0];
                    for (iCmntTouched = scale .Comments .Count - 1; iCmntTouched >= 0; iCmntTouched--)
                    {
                        if (id == scale .Comments [iCmntTouched] .ID)
                        {
                            bVerScaleCmntTouched = true;
                            cmntPressed = scale .Comments [iCmntTouched];
                            return;
                        }
                    }
                    scale = plot .HorScales [0];
                    for (iCmntTouched = scale .Comments .Count - 1; iCmntTouched >= 0; iCmntTouched--)
                    {
                        if (id == scale .Comments [iCmntTouched] .ID)
                        {
                            bHorScaleCmntTouched = true;
                            cmntPressed = scale .Comments [iCmntTouched];
                            return;
                        }
                    }
                }
            }
        }
        // -------------------------------------------------        OnMouseMove
        private void OnMouseMove (object sender, MouseEventArgs e)
        {
            if (mover .Move (e .Location))
            {
                if (mover .CaughtSource is ElasticGroup || 
                    mover .CaughtSource is FramedControl || 
                    mover .CaughtSource is CommentedControl)
                {
                    Update ();
                }
                Invalidate ();
            }
            else
            {
                if (bFormInMove)
                {
                    Location = PointToScreen (e .Location) - sizeMouseShift;
                }
            }
        }
        // -------------------------------------------------        OnMouseDoubleClick
        private void OnMouseDoubleClick (object sender, MouseEventArgs e)
        {
            if (mover .Catch (e .Location, MouseButtons .Left))
            {
                int iInMover = mover .CaughtObject;
                Identification (iInMover);     
                if (iAreaTouched >= 0)
                {
                    GraphicalObject grobj = mover [iInMover] .Source;
                    if (grobj is MSPlot)
                    {
                        MSPlot plot = areas [iAreaTouched] .Plot;
                        plot .ParametersDialog (this, RenewMover, ParametersChanged);
                    }
                    else if (grobj is Scale)
                    {
                        (grobj as Scale) .ParametersDialog (this, RenewMover, ParametersChanged);
                    }
                }
            }
        }
        // -------------------------------------------------        OnContextMenuChanged
        private void OnContextMenuChanged (object sender, EventArgs e)
        {
            if (ContextMenuStrip != null)
            {
                ContextMenuStrip .Show (PointToScreen (ptMouse_Up));
            }
        }
        // -------------------------------------------------        OnPaint
        private void OnPaint (object sender, PaintEventArgs e)
        {
            Graphics grfx = e .Graphics;

            for (int i = areas .Count - 1; i >= 0; i--)
            {
                areas [i] .Draw (grfx);
            }
            groupFuncs .Draw (grfx);
        }
        // -------------------------------------------------        Opening_menuOnGroup
        private void Opening_menuOnGroup (object sender, CancelEventArgs e)
        {
            ToolStripItemCollection items = menuOnGroup .Items;

            items ["miFixUnfixElements"] .Text = groupPressed .ElementsMovable ? "Fix group's elements" : "Unfix group's elements";
            ((ToolStripMenuItem) items ["miListPredefinedFunctions"]) .Checked = listPredefined .Visible;
        }
        // -------------------------------------------------        Click_miModifyGroup
        private void Click_miModifyGroup (object sender, EventArgs e)
        {
            groupPressed .ParametersDialog (this, PointToScreen (ptMouse_Up), GroupParametersChanged);
        }
        // -------------------------------------------------		GroupParametersChanged
        private void GroupParametersChanged (object sender, EventArgs ea)
        {
            groupFuncs .Update ();
            RenewMover ();
            Invalidate ();
        }
        // -------------------------------------------------        Click_miFixUnfixElements
        private void Click_miFixUnfixElements (object sender, EventArgs e)
        {
            groupFuncs .ElementsMovable = !groupFuncs .ElementsMovable;         // not  groupPressed  !!!  see UDA-53 !!!
            RenewMover ();
        }
        // -------------------------------------------------        Click_miGroupDefaultView
        private void Click_miGroupDefaultView (object sender, EventArgs e)
        {
            groupPressed .DefaultView ();
            groupFuncs .Update ();
            RenewMover ();
            Invalidate ();
        }
        // -------------------------------------------------        Click_miListPredefinedFunctions
        private void Click_miListPredefinedFunctions (object sender, EventArgs e)
        {
            groupFuncs .Elements [0] .Visible = !groupFuncs .Elements [0] .Visible;
            if (!groupFuncs .Elements [0] .Visible)
            {
                listPredefined .SelectedIndices .Clear ();
            }
            groupFuncs .Update ();
            RenewMover ();
            Invalidate ();
        }

        // *****   Opening_menuOnPlot   *****
        // -------------------------------------------------        Opening_menuOnPlot
        private void Opening_menuOnPlot (object sender, CancelEventArgs e)
        {
            ToolStripItemCollection items = menuOnPlot .Items;
            MSPlot plot = areas [iAreaTouched] .Plot;

            items ["miFixUnfixScales"] .Text = plot .VerScales [0] .Movable ? "Fix scales" : "Unfix scales";
            items ["miHideScales"] .Enabled = plot .HorScalesVisible > 0 || plot .VerScalesVisible > 0;
            items ["miUnveilScales"] .Enabled = plot .HorScalesVisible < plot .HorScalesCount || plot .VerScalesVisible < plot .VerScalesCount;
            items ["miHideAreaComments"] .Enabled = plot .ExistVisibleComments;
            items ["miUnveilAreaComments"] .Enabled = plot .ExistHiddenComments;
            items ["miChangeAreaLevel"] .Enabled = areas .Count > 1;
            ((ToolStripMenuItem) items ["miRotationAngle2"]) .Checked = bShowAngle;
        }
        // -------------------------------------------------        Click_miAreaParameters
        private void Click_miAreaParameters (object sender, EventArgs e)
        {
            MSPlot plot = areas [iAreaTouched] .Plot;
            plot .ParametersDialog (this, RenewMover, ParametersChanged);
        }
        // -------------------------------------------------		ParametersChanged
        private void ParametersChanged (object sender, EventArgs ea)
        {
            Invalidate ();
        }
        // -------------------------------------------------        Click_miHorScaleParams
        private void Click_miHorScaleParams (object sender, EventArgs e)
        {
            MSPlot plot = areas [iAreaTouched] .Plot;
            plot .HorScales [0] .ParametersDialog (this, RenewMover, ParametersChanged);
        }
        // -------------------------------------------------        Click_miVerScaleParams
        private void Click_miVerScaleParams (object sender, EventArgs e)
        {
            MSPlot plot = areas [iAreaTouched] .Plot;
            plot .VerScales [0] .ParametersDialog (this, RenewMover, ParametersChanged);
        }
        // -------------------------------------------------        Click_miFixUnfixScales
        private void Click_miFixUnfixScales (object sender, EventArgs e)
        {
            MSPlot plot = areas [iAreaTouched] .Plot;
            bool bMovable = plot .VerScales [0] .Movable;
            bMovable = !bMovable;
            for (int i = 0; i < plot .HorScales .Count; i++)
            {
                plot .HorScales [i] .Movable = bMovable;
            }
            for (int i = 0; i < plot .VerScales .Count; i++)
            {
                plot .VerScales [i] .Movable = bMovable;
            }
        }
        // -------------------------------------------------        Click_miHideScales
        private void Click_miHideScales (object sender, EventArgs e)
        {
            MSPlot plot = areas [iAreaTouched] .Plot;
            for (int i = 0; i < plot .HorScales .Count; i++)
            {
                plot .HorScales [i] .Visible = false;
            }
            for (int i = 0; i < plot .VerScales .Count; i++)
            {
                plot .VerScales [i] .Visible = false;
            }
            RenewMover ();
            Invalidate ();
        }
        // -------------------------------------------------        Click_miUnveilScales
        private void Click_miUnveilScales (object sender, EventArgs e)
        {
            MSPlot plot = areas [iAreaTouched] .Plot;
            for (int i = 0; i < plot .HorScales .Count; i++)
            {
                plot .HorScales [i] .Visible = true;
            }
            for (int i = 0; i < plot .VerScales .Count; i++)
            {
                plot .VerScales [i] .Visible = true;
            }
            RenewMover ();
            Invalidate ();
        }
        // -------------------------------------------------        Click_miHideAreaComments
        private void Click_miHideAreaComments (object sender, EventArgs e)
        {
            areas [iAreaTouched] .Plot .CommentsVisibility = false;
            RenewMover ();
            Invalidate ();
        }
        // -------------------------------------------------        Click_miUnveilAreaComments
        private void Click_miUnveilAreaComments (object sender, EventArgs e)
        {
            areas [iAreaTouched] .Plot .CommentsVisibility = true;
            RenewMover ();
            Invalidate ();
        }
        // -------------------------------------------------        DropDownOpening_miChangeAreaLevel
        private void DropDownOpening_miChangeAreaLevel (object sender, EventArgs e)
        {
            MSPlot plot = areas [iAreaTouched] .Plot;
            ToolStripMenuItem itemParent = (ToolStripMenuItem) (menuOnPlot .Items ["miChangeAreaLevel"]);
            ToolStripItemCollection items = itemParent .DropDownItems;

            items ["miPutOnTop"] .Enabled = iAreaTouched > 0;
            items ["miOneLevelUp"] .Enabled = iAreaTouched > 0;
            items ["miOneLevelDown"] .Enabled = iAreaTouched < areas .Count - 1;
            items ["miSendUnderneath"] .Enabled = iAreaTouched < areas .Count - 1;
        }
        // -------------------------------------------------        Click_miPutAreaOnTop
        private void Click_miPutAreaOnTop (object sender, EventArgs e)
        {
            while (iAreaTouched > 0)
            {
                areas .Reverse (iAreaTouched - 1, 2);
                iAreaTouched--;
            }
            RenewMover ();
            Invalidate ();
        }
        // -------------------------------------------------        Click_miAreaOneLevelUp
        private void Click_miAreaOneLevelUp (object sender, EventArgs e)
        {
            areas .Reverse (iAreaTouched - 1, 2);
            RenewMover ();
            Invalidate ();
        }
        // -------------------------------------------------        Click_miAreaOneLevelDown
        private void Click_miAreaOneLevelDown (object sender, EventArgs e)
        {
            areas .Reverse (iAreaTouched, 2);
            RenewMover ();
            Invalidate ();
        }
        // -------------------------------------------------        Click_miAreaUnderneath
        private void Click_miAreaUnderneath (object sender, EventArgs e)
        {
            AreaOnScreen area = areas [iAreaTouched];
            areas .RemoveAt (iAreaTouched);
            areas .Add (area);
            RenewMover ();
            Invalidate ();
        }
        // -------------------------------------------------        Click_miDeleteArea
        private void Click_miDeleteArea (object sender, EventArgs e)
        {
            if (DialogResult .Yes == MessageBox .Show ("Do you want to delete the touched area", "Delete area",
                                                       MessageBoxButtons .YesNo, MessageBoxIcon .Question, MessageBoxDefaultButton .Button1))
            {
                AreaOnScreen aos = areas [iAreaTouched];
                aos .SaveAreaIntoFunctions ();    // save MSPlot only if there is a single function in this area
                aos .CloseTuningForms ();
                areas .RemoveAt (iAreaTouched);
                RenewMover ();
                Invalidate ();
            }
        }
        // -------------------------------------------------        Click_miPlotIntoMemory
        private void Click_miPlotIntoMemory (object sender, EventArgs e)
        {
            areas [iAreaTouched] .Plot .IntoClipboard (areas [iAreaTouched] .DrawPlots,
                                                       CopyPart .PurePlot, Color .White, Color .White);
        }
        // -------------------------------------------------        Click_miAreaAsIs
        private void Click_miAreaAsIs (object sender, EventArgs e)
        {
            areas [iAreaTouched] .Plot .IntoClipboard (areas [iAreaTouched] .Draw,
                                                       CopyPart .FullPlotArea, areas [iAreaTouched] .Plot .MainArea .BackColor, BackColor);
        }
        // -------------------------------------------------        Click_miAreaOnWhite
        private void Click_miAreaOnWhite (object sender, EventArgs e)
        {
            areas [iAreaTouched] .Plot .IntoClipboard (areas [iAreaTouched] .Draw,
                                                       CopyPart .FullPlotArea, areas [iAreaTouched] .Plot .MainArea .BackColor, Color .White);
        }
        // -------------------------------------------------        Click_miAreaWhiteOnWhite
        private void Click_miAreaWhiteOnWhite (object sender, EventArgs e)
        {
            areas [iAreaTouched] .Plot .IntoClipboard (areas [iAreaTouched] .Draw, CopyPart .FullPlotArea, Color .White, Color .White);
        }
        // -------------------------------------------------        Click_miFormAsIs
        private void Click_miFormAsIs (object sender, EventArgs e)
        {
            ClientRectIntoClipboard (CopyBackType .Original, BackColor);
        }
        // -------------------------------------------------        Click_miFormAsIsOnWhite
        private void Click_miFormAsIsOnWhite (object sender, EventArgs e)
        {
            ClientRectIntoClipboard (CopyBackType .Original, Color .White);
        }
        // -------------------------------------------------        Click_miFormWhitesOnWhite
        private void Click_miFormWhitesOnWhite (object sender, EventArgs e)
        {
            ClientRectIntoClipboard (CopyBackType .WhitePaper, Color .White);
        }
        // -------------------------------------------------        ClientRectIntoClipboard
        private void ClientRectIntoClipboard (CopyBackType areaBackType, Color clrPaper)
        {
            Bitmap bitmap = new Bitmap (ClientRectangle .Width, ClientRectangle .Height);
            Graphics grfx = Graphics .FromImage (bitmap);
            grfx .Clear (clrPaper);

            for (int i = areas .Count - 1; i >= 0; i--)
            {
                if (areaBackType == CopyBackType .WhitePaper)
                {
                    RectArea ra = areas [i] .Plot .MainArea;
                    Color clrBack = ra .BackColor;
                    ra .BackColor = Color .White;
                    areas [i] .Draw (grfx);
                    ra .BackColor = clrBack;
                }
                else
                {
                    areas [i] .Draw (grfx);
                }
            }
            Clipboard .Clear ();
            Clipboard .SetDataObject (bitmap, true);
            grfx .Dispose ();
        }
        // -------------------------------------------------        Click_miRotationAngle
        private void Click_miRotationAngle (object sender, EventArgs e)
        {
            bShowAngle = !bShowAngle;
        }

        // *****   menuOnScale   *****
        // -------------------------------------------------        Opening_menuOnScale
        private void Opening_menuOnScale (object sender, CancelEventArgs e)
        {
            Scale scale;
            if (bVerScaleTouched)
            {
                scale = areas [iAreaTouched] .Plot .VerScales [0];
            }
            else
            {
                scale = areas [iAreaTouched] .Plot .HorScales [0];
            }
            menuOnScale .Items ["miHideScaleComments"] .Enabled = scale .ExistVisibleComments;
            menuOnScale .Items ["miUnveilScaleComments"] .Enabled = scale .ExistHiddenComments;
        }
        // -------------------------------------------------        Click_miModifyScale
        private void Click_miModifyScale (object sender, EventArgs e)
        {
            MSPlot plot = areas [iAreaTouched] .Plot;
            if (bVerScaleTouched)
            {
                plot .VerScales [0] .ParametersDialog (this, RenewMover, ParametersChanged);
            }
            else
            {
                plot .HorScales [0] .ParametersDialog (this, RenewMover, ParametersChanged);
            }
        }
        // -------------------------------------------------        Click_miFlipScale
        private void Click_miFlipScale (object sender, EventArgs e)
        {
            MSPlot plot = areas [iAreaTouched] .Plot;
            if (bVerScaleTouched)
            {
                plot .FlipVerScale (0);
            }
            else
            {
                plot .FlipHorScale (0);
            }
            Invalidate ();
        }
        // -------------------------------------------------        Click_miHideScale
        private void Click_miHideScale (object sender, EventArgs e)
        {
            MSPlot plot = areas [iAreaTouched] .Plot;
            if (bVerScaleTouched)
            {
                plot .VerScales [0] .Visible = false;
            }
            else
            {
                plot .HorScales [0] .Visible = false;
            }
            if (plot .ParamsForm != null)
            {
                plot .ParamsForm .RefreshView ();
            }
            RenewMover ();
            Invalidate ();
        }
        // -------------------------------------------------        Click_miHideScaleComments
        private void Click_miHideScaleComments (object sender, EventArgs e)
        {
            MSPlot plot = areas [iAreaTouched] .Plot;
            if (bVerScaleTouched)
            {
                plot .VerScales [0] .CommentsVisibility = false;
            }
            else
            {
                plot .HorScales [0] .CommentsVisibility = false;
            }
            RenewMover ();
            Invalidate ();
        }
        // -------------------------------------------------        Click_miUnveilScaleComments
        private void Click_miUnveilScaleComments (object sender, EventArgs e)
        {
            MSPlot plot = areas [iAreaTouched] .Plot;
            if (bVerScaleTouched)
            {
                plot .VerScales [0] .CommentsVisibility = true;
            }
            else
            {
                plot .HorScales [0] .CommentsVisibility = true;
            }
            RenewMover ();
            Invalidate ();
        }

        // *****   menuOnComment   *****
        // -------------------------------------------------        Opening_menuOnComment
        private void Opening_menuOnComment (object sender, CancelEventArgs e)
        {
            menuOnComment .Items ["miFixUnfixComment"] .Text = cmntPressed .Movable ? "Fix comment" : "Unfix comment";
        }
        // -------------------------------------------------        Click_miFixUnfixComment
        private void Click_miFixUnfixComment (object sender, EventArgs e)
        {
            cmntPressed .Movable = !cmntPressed .Movable;
            RenewMover ();
        }
        // -------------------------------------------------        Click_miModifyComment
        private void Click_miModifyComment (object sender, EventArgs e)
        {
            MSPlot plot = areas [iAreaTouched] .Plot;
            if (bMainAreaCmntTouched)
            {
                plot .ParametersDialog (this, RenewMover, ParametersChanged);
            }
            else if (bVerScaleCmntTouched)
            {
                plot .VerScales [0] .ParametersDialog (this, RenewMover, ParametersChanged);
            }
            else
            {
                plot .HorScales [0] .ParametersDialog (this, RenewMover, ParametersChanged);
            }
        }
        // -------------------------------------------------        Click_miHideComment
        private void Click_miHideComment (object sender, EventArgs e)
        {
            MSPlot plot = areas [iAreaTouched] .Plot;
            if (bMainAreaCmntTouched)
            {
                plot .HideComment (iCmntTouched);
            }
            else if (bVerScaleCmntTouched)
            {
                plot .VerScales [0] .HideComment (iCmntTouched);
            }
            else if (bHorScaleCmntTouched)
            {
                plot .HorScales [0] .HideComment (iCmntTouched);
            }
            RenewMover ();
            Invalidate ();
        }
        // -------------------------------------------------        Click_miDeleteComment
        private void Click_miDeleteComment (object sender, EventArgs e)
        {
            MSPlot plot = areas [iAreaTouched] .Plot;
            if (bMainAreaCmntTouched)
            {
                plot .RemoveComment (iCmntTouched);
            }
            else if (bVerScaleCmntTouched)
            {
                plot .VerScales [0] .RemoveComment (iCmntTouched);
            }
            else if (bHorScaleCmntTouched)
            {
                plot .HorScales [0] .RemoveComment (iCmntTouched);
            }
            RenewMover ();
            Invalidate ();
        }

        // *****   menuOnEmpty   *****
        // -------------------------------------------------        Opening_menuOnEmpty
        private void Opening_menuOnEmpty (object sender, CancelEventArgs e)
        {
            ((ToolStripMenuItem) menuOnEmpty .Items ["miRotationAngle"]) .Checked = bShowAngle;
        }

        // -------------------------------------------------        Click_btnShowFunctions
        private void Click_btnShowFunctions (object sender, EventArgs e)
        {
            int nSelectedPredefined = listPredefined .SelectedIndices .Count;
            int nSelectedNew = listNew .SelectedIndices .Count;

            if (nSelectedPredefined < 1 && nSelectedNew < 1)
            {
                MessageBox .Show ("Functions to show are not selected", "Show functions", MessageBoxButtons .OK, MessageBoxIcon .Exclamation);
            }
            else if (nSelectedPredefined < 1)
            {
                // only NEW functions
                if (nSelectedNew == 1)
                {
                    // SINGLE new function to show
                    FunctionDesigned func = funcsNew [listNew .SelectedIndices [0]];
                    List<FunctionDesigned> funcs = new List<FunctionDesigned> ();
                    funcs .Add (func);
                    MSPlot plot = func .MSPlot .Copy (this);
                    AreaOnScreen aos = new AreaOnScreen (plot, funcs);
                    areas .Insert (0, aos);
                    RenewMover ();
                    Invalidate ();
                }
                else
                {
                    // SEVERAL new functions to show
                    ValuesOnBorders range = UnitedBorderValues (funcsNew, listNew .SelectedIndices);
                    Rectangle rc = NewFuncRect;
                    MSPlot area = new MSPlot (this, rc, Side .S, range .Left, range .Right, GridOrigin .ByMinLines, 4,
                                                        Side .E, range .Top, range .Bottom, GridOrigin .ByMinLines, 3);
                    List<FunctionDesigned> funcs = new List<FunctionDesigned> ();
                    for (int i = 0; i < nSelectedNew; i++)
                    {
                        FunctionDesigned func = funcsNew [listNew .SelectedIndices [i]];
                        funcs .Add (func);
                        CommentToRect comment = new CommentToRect (this, rc, new Point (rc .Left + 50, rc .Top + (i + 1) * 20),
                                                                   func .Name, Font, 0, area .Line (i) .Color);
                        area .AddComment (comment);
                    }
                    AreaOnScreen aos = new AreaOnScreen (area, funcs);
                    areas .Insert (0, aos);
                    RenewMover ();
                    Invalidate ();
                }
            }
            else if (nSelectedNew < 1)
            {
                // only PREDEFINED functions
                if (nSelectedPredefined == 1)
                {
                    // SINGLE predefined function to show
                    FunctionDesigned func = funcsPredefined [listPredefined .SelectedIndices [0]];
                    List<FunctionDesigned> funcs = new List<FunctionDesigned> ();
                    funcs .Add (func);
                    AreaOnScreen aos = new AreaOnScreen (func .MSPlot, funcs);  
                    areas .Insert (0, aos);
                    RenewMover ();
                    Invalidate ();
                }
                else
                {
                    // SEVERAL predefined functions to show
                    ValuesOnBorders range = UnitedBorderValues (funcsPredefined, listPredefined .SelectedIndices);
                    Rectangle rc = NewFuncRect;
                    MSPlot area = new MSPlot (this, rc, Side .S, range .Left, range .Right, GridOrigin .ByMinLines, 4,
                                                        Side .E, range .Top, range .Bottom, GridOrigin .ByMinLines, 3);
                    List<FunctionDesigned> funcs = new List<FunctionDesigned> ();
                    for (int i = 0; i < nSelectedPredefined; i++)
                    {
                        FunctionDesigned func = funcsPredefined [listPredefined .SelectedIndices [i]];
                        funcs .Add (func);
                        CommentToRect comment = new CommentToRect (this, rc, new Point (rc .Left + 50, rc .Top + (i + 1) * 20),
                                                                   func .Name, Font, 0, area .Line (i) .Color);
                        area .AddComment (comment);
                    }
                    AreaOnScreen aos = new AreaOnScreen (area, funcs);
                    areas .Insert (0, aos);
                    RenewMover ();
                    Invalidate ();
                }
            }
            else
            {
                // COMBINATION of predefined and new functions
                ValuesOnBorders range_0 = UnitedBorderValues (funcsPredefined, listPredefined .SelectedIndices);
                ValuesOnBorders range_1 = UnitedBorderValues (funcsNew, listNew .SelectedIndices);
                ValuesOnBorders range = new ValuesOnBorders (
                                        Math .Min (Math .Min (Math .Min (range_0 .Left, range_1 .Left), range_0 .Right), range_1 .Right),
                                        Math .Max (Math .Max (Math .Max (range_0 .Left, range_1 .Left), range_0 .Right), range_1 .Right),
                                        Math .Max (Math .Max (Math .Max (range_0 .Top, range_1 .Top), range_0 .Top), range_1 .Top),
                                        Math .Min (Math .Min (Math .Min (range_0 .Bottom, range_1 .Bottom), range_0 .Bottom), range_1 .Bottom));
                Rectangle rc = NewFuncRect;
                MSPlot area = new MSPlot (this, rc, Side .S, range .Left, range .Right, GridOrigin .ByMinLines, 4,
                                                    Side .E, range .Top, range .Bottom, GridOrigin .ByMinLines, 3);
                List<FunctionDesigned> funcs = new List<FunctionDesigned> ();
                for (int i = 0; i < nSelectedPredefined; i++)
                {
                    FunctionDesigned func = funcsPredefined [listPredefined .SelectedIndices [i]];
                    funcs .Add (func);
                    CommentToRect comment = new CommentToRect (this, rc, new Point (rc .Left + 50, rc .Top + (i + 1) * 20),
                                                               func .Name, Font, 0, area .Line (i) .Color);
                    area .AddComment (comment);
                }
                int k0 = nSelectedPredefined + 1;
                for (int i = 0; i < nSelectedNew; i++)
                {
                    FunctionDesigned func = funcsNew [listNew .SelectedIndices [i]];
                    funcs .Add (func);
                    CommentToRect comment = new CommentToRect (this, rc, new Point (rc .Left + 50, rc .Top + (i + k0) * 20),
                                                               func .Name, Font, 0, area .Line (i) .Color);
                    area .AddComment (comment);
                }
                AreaOnScreen aos = new AreaOnScreen (area, funcs);
                areas .Insert (0, aos);
                RenewMover ();
                Invalidate ();
            }
        }
        // -------------------------------------------------        UnitedBorderValues
        private ValuesOnBorders UnitedBorderValues (List<FunctionDesigned> funcs, ListView .SelectedIndexCollection indices)
        {
            int iFunc = indices [0];
            double argL = funcs [iFunc] .Arg_Left;
            double argR = funcs [iFunc] .Arg_Right;
            double valT = funcs [iFunc] .Val_Top;
            double valB = funcs [iFunc] .Val_Bottom;
            for (int i = 1; i < indices .Count; i++)
            {
                iFunc = indices [i];
                argL = Math .Min (argL, funcs [iFunc] .Arg_Left);
                argR = Math .Max (argR, funcs [iFunc] .Arg_Right);
                valT = Math .Max (valT, funcs [iFunc] .Val_Top);
                valB = Math .Min (valB, funcs [iFunc] .Val_Bottom);
            }
            return (new ValuesOnBorders (argL, argR, valT, valB));
        }
        // -------------------------------------------------        NewFuncRect
        private Rectangle NewFuncRect
        {
            get
            {
                Rectangle rc = new Rectangle (ClientSize .Width / 3, ClientSize .Height / 15, ClientSize .Width / 3, ClientSize .Height / 3);
                int stepX = 40;
                int stepY = 50;
                rc .X += iNewRect * stepX;
                rc .Y += iNewRect * stepY;
                iNewRect = (iNewRect + 1) % 5;
                return (rc);
            }
        }
        // -------------------------------------------------        Click_btnChange
        private void Click_btnChange (object sender, EventArgs e)
        {
            bool bAddResult;
            int iFunc = listNew .SelectedIndices [0];
            FunctionDesigned func = funcsNew [iFunc];
            if (string .IsNullOrEmpty (func .XText))
            {
                Form_FuncYx form = new Form_FuncYx (func, Point .Empty);
                while (DialogResult .Retry == form .ShowDialog ())
                {
                    form = new Form_FuncYx (func, form .Location);
                }
                if (!form .NewFunctionReady)
                {
                    return;
                }
                func = PrepareFunc_Yx (form, NewFuncRect);
                if (func == null)
                {
                    return;
                }
                bAddResult = form .AddResult;
            }
            else
            {
                Form_FuncXrYr form = new Form_FuncXrYr (func, Point .Empty);
                while (DialogResult .Retry == form .ShowDialog ())
                {
                    form = new Form_FuncXrYr (func, form .Location);
                }
                if (!form .NewFunctionReady)
                {
                    return;
                }
                func = PrepareFunc_XrYr (form, NewFuncRect);
                if (func == null)
                {
                    return;
                }
                bAddResult = form .AddResult;
            }
            if (bAddResult)
            {
                funcsNew .Add (func);
                FillNewList ();
                listNew .Items [listNew .Items .Count - 1] .Selected = true;
                ShowNewAreaWithNewFunction ();
            }
            else
            {
                funcsNew .RemoveAt (iFunc);
                funcsNew .Insert (iFunc, func);
                FillNewList ();
                listNew .Items [iFunc] .Selected = true;
            }
        }
        // -------------------------------------------------        Click_btnNewFunc_Yx
        private void Click_btnNewFunc_Yx (object sender, EventArgs e)
        {
            Form_FuncYx form = new Form_FuncYx (null, Point .Empty);
            while (DialogResult .Retry == form .ShowDialog ())
            {
                form = new Form_FuncYx (null, form .Location);
            }
            if (form .NewFunctionReady)
            {
                FunctionDesigned func = PrepareFunc_Yx (form, NewFuncRect);
                funcsNew .Add (func);
                FillNewList ();
                listNew .Items [listNew .Items .Count - 1] .Selected = true;
                ShowNewAreaWithNewFunction ();
            }
        }
        // -------------------------------------------------        ShowNewAreaWithNewFunction
        private void ShowNewAreaWithNewFunction ()
        {
            FunctionDesigned func = funcsNew [funcsNew .Count - 1];
            List<FunctionDesigned> funcs = new List<FunctionDesigned> ();
            funcs .Add (func);
            AreaOnScreen aos = new AreaOnScreen (func .MSPlot, funcs);
            areas .Insert (0, aos);
            RenewMover ();
            Invalidate ();
        }
        // -------------------------------------------------        PrepareFunc_Yx
        private FunctionDesigned PrepareFunc_Yx (Form_FuncYx form, Rectangle rc)
        {
            MSPlot plot = MSPlot .Copy (this, rc, form .MSPlot);
            CommentToRect comment = new CommentToRect (this, rc, new Point (rc .Left + 50, rc .Top + 20),
                                                       form .NewFunctionName, Font, 0, plot .Line (0) .Color);
            plot .AddComment (comment);
            comment = new CommentToRect (this, rc, new Point (rc .Left + 50, rc .Top + 40), form .NewFunctionText, Font, 0, plot .Line (0) .Color);
            plot .AddComment (comment);
            ValuesOnBorders valborders = plot .ValuesOnBorders;
            FunctionDesigned func = new FunctionDesigned (form .NewFunctionName, form .NewFunctionText, form .NewYPolish,
                                                          valborders .Left, valborders .Right, valborders .Top, valborders .Bottom);
            func .MSPlot = plot;
            return (func);
        }
        // -------------------------------------------------        PrepareFunc_XrYr
        private FunctionDesigned PrepareFunc_XrYr (Form_FuncXrYr form, Rectangle rc)
        {
            MSPlot plot = MSPlot .Copy (this, rc, form .MSPlot);
            CommentToRect comment = new CommentToRect (this, rc, new Point (rc .Left + 50, rc .Top + 20),
                                                       form .NewFunctionName, Font, 0, plot .Line (0) .Color);
            plot .AddComment (comment);
            comment = new CommentToRect (this, rc, new Point (rc .Left + 50, rc .Top + 40),
                                         "X = " + form .NewFunctionTextX, Font, 0, plot .Line (0) .Color);
            plot .AddComment (comment);
            comment = new CommentToRect (this, rc, new Point (rc .Left + 50, rc .Top + 60),
                                         "Y = " + form .NewFunctionTextY, Font, 0, plot .Line (0) .Color);
            plot .AddComment (comment);
            ValuesOnBorders valborders = plot .ValuesOnBorders;
            FunctionDesigned func = new FunctionDesigned (form .NewFunctionName, form .NewFunctionTextX, form .NewFunctionTextY,
                                                          form .NewPolishX, form .NewPolishY,
                                                          valborders .Left, valborders .Right, valborders .Top, valborders .Bottom,
                                                          form .From, form .To, form .Step);
            func .MSPlot = plot;
            return (func);
        }
        // -------------------------------------------------        Click_btnNewFunc_XrYr
        private void Click_btnNewFunc_XrYr (object sender, EventArgs e)
        {
            Form_FuncXrYr form = new Form_FuncXrYr (null, Point .Empty);
            while (DialogResult .Retry == form .ShowDialog ())
            {
                form = new Form_FuncXrYr (null, form .Location);
            }
            if (form .NewFunctionReady)
            {
                FunctionDesigned func = PrepareFunc_XrYr (form, NewFuncRect);
                funcsNew .Add (func);
                FillNewList ();
                listNew .Items [listNew .Items .Count - 1] .Selected = true;
                ShowNewAreaWithNewFunction ();
            }
        }
        // -------------------------------------------------        SelectedIndexChanged_listNew
        private void SelectedIndexChanged_listNew (object sender, EventArgs e)
        {
            ButtonsStatus ();
        }
        // -------------------------------------------------        ButtonsStatus
        private void ButtonsStatus ()
        {
            if (listNew .Items .Count <= 0)
            {
                btnDeleteFunc .Enabled =
                btnFuncUp .Enabled =
                btnFuncDown .Enabled =
                btnChange .Enabled = false;
            }
            else
            {
                int nSelected = listNew .SelectedIndices .Count;
                btnDeleteFunc .Enabled = nSelected == 1;
                btnFuncUp .Enabled = nSelected == 1 && listNew .SelectedIndices [0] > 0;
                btnFuncDown .Enabled = nSelected == 1 && listNew .SelectedIndices [0] < listNew .Items .Count - 1;
                btnChange .Enabled = nSelected == 1;
            }
        }
        // -------------------------------------------------        Click_btnDeleteFunc
        private void Click_btnDeleteFunc (object sender, EventArgs e)
        {
            int iSel = listNew .SelectedIndices [0];
            long idFunc = funcsNew [iSel] .ID;
            for (int i = 0; i < areas .Count; i++)
            {
                if (areas [i] .FunctionInArea (idFunc))
                {
                    if (i > 0)
                    {
                        MoveAreaOnTop (i);
                    }
                    MessageBox .Show ("Function can not be deleted, while shown in any area", "Delete function",
                                      MessageBoxButtons .OK, MessageBoxIcon .Exclamation);
                    return;
                }
            }
            funcsNew .RemoveAt (iSel);
            listNew .Items .RemoveAt (iSel);
            if (funcsNew .Count > 0)
            {
                iSel = Math .Max (iSel, funcsNew .Count - 1);
                Auxi_Common .ListView_LineSelectAndShow (listNew, iSel);
            }
        }
        // -------------------------------------------------        Click_btnFuncUp
        private void Click_btnFuncUp (object sender, EventArgs e)
        {
            int iSel = listNew .SelectedIndices [0];
            funcsNew .Reverse (iSel - 1, 2);
            listNew .Items .RemoveAt (iSel);
            iSel --;
            listNew .Items .Insert (iSel, new ListViewItem (funcsNew [iSel] .Name));
            Auxi_Common .ListView_LineSelectAndShow (listNew, iSel);
        }
        // -------------------------------------------------        Click_btnFuncDown
        private void Click_btnFuncDown (object sender, EventArgs e)
        {
            int iSel = listNew .SelectedIndices [0];
            funcsNew .Reverse (iSel, 2);
            listNew .Items .RemoveAt (iSel);
            iSel++;
            listNew .Items .Insert (iSel, new ListViewItem (funcsNew [iSel] .Name));
            Auxi_Common .ListView_LineSelectAndShow (listNew, iSel);
        }

        const string nameGeneral = "General";
        // -------------------------------------------------        SaveInfoToRegistry
        private void SaveInfoToRegistry ()
        {
            string strRegKey = Form_Main .strRegKey + strAddRegKey;

            RegistryKey regkey = null;
            try
            {
                regkey = Registry .CurrentUser .CreateSubKey (strRegKey);
                if (regkey != null)
                {
                    int nAreas = areas .Count;
                    string [] strGeneral = {version .ToString (),           // 0
                                            ClientSize .Width .ToString (),                 // 1   
                                            ClientSize .Height .ToString (),                // 2
                                            listPredefined .Columns [0] .Width .ToString (),    // 3
                                            listNew .Columns [0] .Width .ToString (),           // 4
                                            funcsPredefined .Count .ToString (),        // 5
                                            funcsNew.Count .ToString (),                // 6
                                            nAreas .ToString (),            // 7
                                            bShowAngle .ToString (),        // 8
                                         };
                    regkey .SetValue (nameGeneral, strGeneral, RegistryValueKind .MultiString);

                    groupFuncs .IntoRegistry (regkey, "GroupFuncs");

                    for (int i = 0; i < funcsPredefined .Count; i++)
                    {
                        funcsPredefined [i] .IntoRegistry (regkey, "Predef" + i .ToString ());
                    }
                    for (int i = 0; i < funcsNew .Count; i++)
                    {
                        funcsNew [i] .IntoRegistry (regkey, "New" + i .ToString ());
                    }
                    for (int i = 0; i < nAreas; i++)
                    {
                        areas [i] .IntoRegistry (regkey, "Area" + i .ToString ());
                    }
                }
            }
            catch
            {
            }
            finally
            {
                if (regkey != null) regkey .Close ();
            }
        }
        // -------------------------------------------------        RestoreFromRegistry
        private void RestoreFromRegistry ()
        {
            string strkey = Form_Main .strRegKey + strAddRegKey;

            RegistryKey regkey = null;
            try
            {
                bRestore = false;
                regkey = Registry .CurrentUser .OpenSubKey (strkey);
                if (regkey != null)
                {
                    string [] strGeneral = (string []) regkey .GetValue (nameGeneral);
                    if (strGeneral != null && strGeneral .Length == 9 && Convert .ToInt32 (strGeneral [0]) == 605)
                    {
                        ClientSize = Auxi_Convert .ToSize (strGeneral, 1);
                        listPredefined .Columns [0] .Width = Convert .ToInt32 (strGeneral [3]);
                        listNew .Columns [0] .Width = Convert .ToInt32 (strGeneral [4]);
                    }
                    else
                    {
                        return;
                    }
                    int nFuncsPredefined = Convert .ToInt32 (strGeneral [5]);
                    int nFuncsNew = Convert .ToInt32 (strGeneral [6]);
                    int nAreas = Convert .ToInt32 (strGeneral [7]);
                    bShowAngle = Convert .ToBoolean (strGeneral [8]);

                    groupFuncs = ElasticGroup .FromRegistry (this, regkey, "GroupFuncs", 
                                                             new Control [] {listPredefined, btnDeleteFunc, btnFuncUp, btnFuncDown, listNew, 
                                                                             btnChange, btnNewFunc, btnNewParamFunc, btnShowFunctions } );
                    if (groupFuncs == null)
                    {
                        return;
                    }

                    for (int i = 0; i < nFuncsPredefined; i++)
                    {
                        FunctionDesigned func = FunctionDesigned .FromRegistry (this, regkey, "Predef" + i .ToString ());
                        if (func != null)
                        {
                            funcsPredefined .Add (func);
                        }
                    }
                    for (int i = 0; i < nFuncsNew; i++)
                    {
                        FunctionDesigned func = FunctionDesigned .FromRegistry (this, regkey, "New" + i .ToString ());
                        if (func != null)
                        {
                            funcsNew .Add (func);
                        }
                    }
                    if (nFuncsPredefined == funcsPredefined .Count && nFuncsNew == funcsNew .Count)
                    {
                        for (int i = 0; i < nAreas; i++)
                        {
                            AreaOnScreen area = AreaOnScreen .FromRegistry (this, regkey, "Area" + i .ToString (), funcsPredefined, funcsNew);
                            if (area != null)
                            {
                                areas .Add (area);
                            }
                        }
                    }
                    bRestore = true;
                }
            }
            catch
            {
            }
            finally
            {
                if (regkey != null) regkey .Close ();
            }
        }

    }
}

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)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions