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 .ComponentModel;
using System .Drawing;
using System .Windows .Forms;
using Microsoft .Win32;

using MoveGraphLibrary;

namespace UserDrivenApplications
{
    public partial class Form_PersonalData : Form
    {
        enum DataPart { Date, Time, Name, Surname, DOB, Contacts, Address, ProfStatus, Projects };

        int version = 606;
        const string strAddRegKey = "Form_PersonalData";
        Mover mover;
        Point ptMouse_Down, ptMouse_Up;
        ElasticGroup groupData;
        FramedControl fcPressed;
        CommentedControl ccPressed;
        CommentToRect cmntPressed;
        ElasticGroup groupPressed;
        bool bShowAngle = false;
        bool bRestore;
        bool bClearRegistry = false;
        ClosableInfo info;
        string infotext = "All the groups adjust to the sizes and positions of their inner elements.\n" +
                          "Groups can be moved by the inner points and the frames.\n" +
                          "All the TextBoxes are resizable.\n" +
                          "Any pair \"control + comment\" can be moved by the control's border;\n" +
                          "any comment can be moved and rotated individually.\n" +
                          "A lot of tuning can be done via SEVEN different context menus.";

        Point ptMouseInit;

        // -------------------------------------------------
        public Form_PersonalData (Point ptMouseScreen)
        {
            InitializeComponent ();
            ptMouseInit = ptMouseScreen;
            mover = new Mover (this);
        }
        // -------------------------------------------------        OnLoad
        private void OnLoad (object sender, EventArgs e)
        {
            Location = ptMouseInit;
            info = new ClosableInfo (this, new Point (30, 490), infotext);
            info .BackColor = Color .LightYellow;

            foreach (Control ctrl in Controls)
            {
                if (ctrl is TextBox)
                {
                    ctrl .Text = "";
                }
            }
            DateTime dt = DateTime .Now;
            textDate .Text = dt .Date .ToShortDateString ();
            textTime .Text = dt .Hour .ToString () + ":" + dt .Minute .ToString () + ":" + dt .Second .ToString ();

            RestoreFromRegistry ();
            if (!bRestore)
            {
                CommentedControl ccName = new CommentedControl (this, textName, Resizing .WE, Side .W, "Name");
                CommentedControl ccSurname = new CommentedControl (this, textSurname, Resizing .WE, Side .W, "Surname");
                LineCommentsOnLeft (new CommentedControl [] { ccName, ccSurname });

                CommentedControl [] ccsDOB = new CommentedControl [] {
                                                        new CommentedControl (this, textDay, Resizing .WE, Side .N, "Day"), 
                                                        new CommentedControl (this, textMonth, Resizing .WE, Side .N, "Month"), 
                                                        new CommentedControl (this, textYear, Resizing .WE, Side .N, "Year") };
                CommentedControl [] ccsPhones = new CommentedControl [] {
                                                        new CommentedControl (this, textHomePhone, Resizing .WE, Side .E, "Home"), 
                                                        new CommentedControl (this, textOfficePhone, Resizing .WE, Side .E, "Office"), 
                                                        new CommentedControl (this, textMobilePhone, Resizing .WE, Side .E, "Cellular"), 
                                                        new CommentedControl (this, textEMail, Resizing .WE, Side .E, "E-mail") };
                CommentedControl [] ccsAddress = new CommentedControl [] {
                                                        new CommentedControl (this, textStreet, Resizing .WE, Side .W, "Street"), 
                                                        new CommentedControl (this, textTown, Resizing .WE, Side .W, "Town"), 
                                                        new CommentedControl (this, textProvince, Resizing .WE, Side .W, "Province"), 
                                                        new CommentedControl (this, textCountry, Resizing .WE, Side .W, "Country"), 
                                                        new CommentedControl (this, textZipCode, Resizing .WE, Side .W, "Zip code") };
                LineCommentsOnLeft (ccsAddress);

                CommentedControl [] ccsProfessional = new CommentedControl [] {
                                                        new CommentedControl (this, textCompany, Side .E, SideAlignment .Top, "Company"), 
                                                        new CommentedControl (this, textPosition, Side .E, SideAlignment .Top, "Position") };
                groupData = new ElasticGroup (this,
                                      new ElasticGroupElement [] {  new ElasticGroupElement (textDate, Resizing .WE), 
                                                                    new ElasticGroupElement (textTime, Resizing .WE), 
                                                                    new ElasticGroupElement (ccName),                 
                                                                    new ElasticGroupElement (ccSurname),              
                                                                    new ElasticGroupElement (this, ccsDOB, "Day of birth"), 
                                                                    new ElasticGroupElement (this, ccsPhones, "Contacts"),  
                                                                    new ElasticGroupElement (this, ccsAddress, "Address"),  
                                                                    new ElasticGroupElement (this, ccsProfessional, "Professional status"), 
                                            new ElasticGroupElement (this, new Control [] {btnDelete, btnMoveUp, btnMoveDown, listProjects }) },
                                                    "Personal data");
                info .Location = new Point (groupData .Location .X, groupData .FrameArea .Bottom + 16);
                ClientSize = new Size (groupData .FrameArea .Right + 16, info .RectAround .Bottom + 16);
            }
            RenewMover ();
            btnHelp .Enabled = !info .Visible;
        }
        // -------------------------------------------------        LineCommentsOnLeft
        public void LineCommentsOnLeft (CommentedControl [] ccs)
        {
            int cxL = ccs [0] .Comment .RectAround .Left;
            for (int i = 1; i < ccs .Length; i++)
            {
                cxL = Math .Min (cxL, ccs [i] .Comment .RectAround .Left);
            }
            for (int i = 0; i < ccs .Length; i++)
            {
                ccs [i] .Comment .Location = new Point (cxL + ccs [i] .Comment .Width / 2, ccs [i] .Comment .Location .Y);
            }
        }
        // -------------------------------------------------        RenewMover
        private void RenewMover ()
        {
            mover .Clear ();
            groupData .IntoMover (mover, 0);
            if (info .Visible)
            {
                mover .Add (info);
            }
            mover .Insert (0, btnHelp);
        }
        // -------------------------------------------------        OnFormClosing
        private void OnFormClosing (object sender, FormClosingEventArgs e)
        {
            if (bClearRegistry)
            {
                DeleteRegistryEntry ();
            }
            else
            {
                SaveInfoToRegistry ();
            }
        }
        // -------------------------------------------------        Click_btnHelp
        private void Click_btnHelp (object sender, EventArgs e)
        {
            info .Visible = true;
            btnHelp .Enabled = false;
            RenewMover ();
            Invalidate ();
        }
        // -------------------------------------------------        OnPaint
        private void OnPaint (object sender, PaintEventArgs e)
        {
            Graphics grfx = e .Graphics;

            info .Draw (grfx);
            groupData .Draw (grfx);
        }
        // -------------------------------------------------        OnMouseDOwn
        private void OnMouseDown (object sender, MouseEventArgs e)
        {
            ptMouse_Down = e .Location;
            mover .Catch (e .Location, e .Button, bShowAngle);
            ContextMenuStrip = null;
        }
        // -------------------------------------------------        OnMouseUp
        private void OnMouseUp (object sender, MouseEventArgs e)
        {
            ptMouse_Up = e .Location;
            double nDist = Auxi_Geometry .Distance (ptMouse_Down, ptMouse_Up);
            if (e .Button == MouseButtons .Left)
            {
                int iWasObject, iWasNode;
                if (mover .Release (out iWasObject, out iWasNode))
                {
                    if (mover [iWasObject] .Source is ClosableInfo && iWasNode == 0)
                    {
                        (mover [iWasObject] .Source as ClosableInfo) .Visible = false;
                        btnHelp .Enabled = true;
                        RenewMover ();
                        Invalidate ();
                    }
                }
            }
            else if (e .Button == MouseButtons .Right)
            {
                if (mover .Release ())
                {
                    if (nDist <= 3)
                    {
                        MenuSelection (mover .WasCaughtObject);
                    }
                }
                else
                {
                    if (nDist <= 3)
                    {
                        ContextMenuStrip = menuOnEmpty;
                    }
                }
            }
        }
        // -------------------------------------------------        MenuSelection
        private void MenuSelection (int iInMover)
        {
            GraphicalObject grobj = mover [iInMover] .Source;

            if (grobj is ElasticGroup)
            {
                groupPressed = grobj as ElasticGroup;
                if (groupPressed .ID == groupData .ID)
                {
                    ContextMenuStrip = menuOnDataGroup;
                }
                else
                {

                    ContextMenuStrip = menuOnGroup; 
                }
            }
            else if (grobj is FramedControl)
            {
                fcPressed = grobj as FramedControl;
                ContextMenuStrip = menuOnFramedControl;
            }
            else if (grobj is CommentedControl)
            {
                ccPressed = grobj as CommentedControl;
                ContextMenuStrip = menuOnCommentedControl;
            }
            else if (grobj is CommentToRect)
            {
                cmntPressed = grobj as CommentToRect;
                ContextMenuStrip = menuOnComment;
            }
            else if (grobj is ClosableInfo)
            {
                ContextMenuStrip = menuOnInfo;
            }
        }
        // -------------------------------------------------        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 ();
            }
        }
        // -------------------------------------------------        OnContextMenuChanged
        private void OnContextMenuChanged (object sender, EventArgs e)
        {
            if (ContextMenuStrip != null)
            {
                ContextMenuStrip .Show (PointToScreen (ptMouse_Up));
            }
        }

        // *****   menuOnGroup   *****
        // -------------------------------------------------        Opening_menuOnGroup
        private void Opening_menuOnGroup (object sender, CancelEventArgs e)
        {
            ToolStripItemCollection items = menuOnGroup .Items;

            items ["miUnveilHiddenElements"] .Enabled = groupPressed .InvisibleElementsNumber > 0;
            items ["miFixUnfixElements"] .Text = groupPressed .ElementsMovable ? "Fix group's elements" : "Unfix group's elements";
        }
        // -------------------------------------------------        HideElement
        private void HideElement (long idElem, long idParent)
        {
            GraphicalObject grobj;
            for (int i = mover .Count - 1; i >= 0; i--)
            {
                grobj = mover [i] .Source;
                if (grobj is ElasticGroup && grobj .ID == idParent)
                {
                    (grobj as ElasticGroup) .HideElement (idElem);
                    groupData .Update ();
                    RenewMover ();
                    Invalidate ();
                    return;
                }
            }
        }
        // -------------------------------------------------        Click_miHideGroup
        private void Click_miHideGroup (object sender, EventArgs e)
        {
            long idParent = groupPressed .ParentID;
            long idElem = groupPressed .ID;

            if (idParent > 0)
            {
                HideElement (idElem, idParent);
            }
        }
        // -------------------------------------------------        Click_miUnveilInnerElements
        private void Click_miUnveilInnerElements (object sender, EventArgs e)
        {
            for (int i = groupPressed .Elements .Count - 1; i >= 0; i--)
            {
                groupPressed .Elements [i] .Visible = true;
            }
            groupData .Update ();
            RenewMover ();
            Invalidate ();
        }
        // -------------------------------------------------        Click_miModifyGroup
        private void Click_miModifyGroup (object sender, EventArgs e)
        {
            groupPressed .ParametersDialog (this, PointToScreen (ptMouse_Up), ParametersChanged);
        }
        // -------------------------------------------------		ParametersChanged
        private void ParametersChanged (object sender, EventArgs ea)
        {
            groupData .Update ();
            Invalidate ();
        }
        // -------------------------------------------------        Click_miFixUnfixElements
        private void Click_miFixUnfixElements (object sender, EventArgs e)
        {
            groupPressed .ElementsMovable = !groupPressed .ElementsMovable;
            RenewMover ();
        }
        // -------------------------------------------------        Click_miGroupDefaultView
        private void Click_miGroupDefaultView (object sender, EventArgs e)
        {
            groupPressed .DefaultView ();
            groupData .Update ();
            RenewMover ();
            Invalidate ();
        }

        // *****   menuOnDataGroup   *****
        // -------------------------------------------------        Opening_menuOnDataGroup
        private void Opening_menuOnDataGroup (object sender, CancelEventArgs e)
        {
            ToolStripItemCollection items = menuOnDataGroup .Items;

            ((ToolStripMenuItem) (items ["miDate"])) .Checked = groupData .Elements [(int) DataPart .Date] .Visible;
            ((ToolStripMenuItem) (items ["miTime"])) .Checked = groupData .Elements [(int) DataPart .Time] .Visible;
            ((ToolStripMenuItem) (items ["miDayOfBirth"])) .Checked = groupData .Elements [(int) DataPart .DOB] .Visible;
            ((ToolStripMenuItem) (items ["miContacts"])) .Checked = groupData .Elements [(int) DataPart .Contacts] .Visible;
            ((ToolStripMenuItem) (items ["miAddress"])) .Checked = groupData .Elements [(int) DataPart .Address] .Visible;
            ((ToolStripMenuItem) (items ["miProfessionalStatus"])) .Checked = groupData .Elements [(int) DataPart .ProfStatus] .Visible;
            ((ToolStripMenuItem) (items ["miProjects"])) .Checked = groupData .Elements [(int) DataPart .Projects] .Visible;
            items ["miShowAll"] .Enabled = groupData .InvisibleElementsNumber > 0;
            items ["miDataGroupFixUnfixElements"] .Text = groupData .ElementsMovable ? "Fix group's elements" : "Unfix group's elements";
        }
        // -------------------------------------------------        Click_miDate
        private void Click_miDate (object sender, EventArgs e)
        {
            SwitchVisibility ((int) DataPart .Date);
        }
        // -------------------------------------------------        Click_miTime
        private void Click_miTime (object sender, EventArgs e)
        {
            SwitchVisibility ((int) DataPart .Time);
        }
        // -------------------------------------------------        Click_miDayOfBirth
        private void Click_miDayOfBirth (object sender, EventArgs e)
        {
            SwitchVisibility ((int) DataPart .DOB);
        }
        // -------------------------------------------------        Click_miContacts
        private void Click_miContacts (object sender, EventArgs e)
        {
            SwitchVisibility ((int) DataPart .Contacts);
        }
        // -------------------------------------------------        Click_miAddress
        private void Click_miAddress (object sender, EventArgs e)
        {
            SwitchVisibility ((int) DataPart .Address);
        }
        // -------------------------------------------------        Click_miProfessionalStatus
        private void Click_miProfessionalStatus (object sender, EventArgs e)
        {
            SwitchVisibility ((int) DataPart .ProfStatus);
        }
        // -------------------------------------------------        Click_miProjects
        private void Click_miProjects (object sender, EventArgs e)
        {
            SwitchVisibility ((int) DataPart .Projects);
        }
        // -------------------------------------------------        SwitchVisibility
        private void SwitchVisibility (int iPart)
        {
            groupData .Elements [iPart] .Visible = !groupData .Elements [iPart] .Visible;
            groupData .Update ();
            RenewMover ();
            Invalidate ();
        }
        // -------------------------------------------------        Click_miShowAll
        private void Click_miShowAll (object sender, EventArgs e)
        {
            for (int i = 0; i < groupData .Elements .Count; i++)
            {
                groupData .Elements [i] .Visible = true;
            }
            groupData .Update ();
            RenewMover ();
            Invalidate ();
        }
        // -------------------------------------------------        Click_miShowInnerFrames
        private void Click_miShowInnerFrames (object sender, EventArgs e)
        {
            for (int i = 0; i < groupData .Elements .Count; i++)
            {
                if (groupData .Elements [i] .ElementType == ElementType_ElasticGroup .Group)
                {
                    groupData .Elements [i] .Group .ShowFrame = true;
                }
            }
            Invalidate ();
        }

        // *****   menuOnFramedControl   *****
        // -------------------------------------------------        Opening_menuOnFramedControl
        private void Opening_menuOnFramedControl (object sender, CancelEventArgs e)
        {
            menuOnFramedControl .Items ["miHideFramedControl"] .Enabled = !OnlyVisibleElementInGroup (fcPressed .ParentID);
            menuOnFramedControl .Items ["miFramedControlFont"] .Enabled = !(fcPressed .Control is Button);
            menuOnFramedControl .Items ["miFramedControlBackColor"] .Enabled = !(fcPressed .Control is Button);
        }
        // -------------------------------------------------        Click_miHideFramedControl
        private void Click_miHideFramedControl (object sender, EventArgs e)
        {
            long idParent = fcPressed .ParentID;
            long idElem = fcPressed .ID;
            if (idParent > 0)
            {
                HideElement (idElem, idParent);
            }
        }
        // -------------------------------------------------        Click_miFramedControlFont
        private void Click_miFramedControlFont (object sender, EventArgs e)
        {
            FontDialog dlg = new FontDialog ();

            dlg .Font = fcPressed .Control .Font;
            if (dlg .ShowDialog () == DialogResult .OK)
            {
                fcPressed .Control .Font = dlg .Font;
                groupData .Update ();
                RenewMover ();
                Invalidate ();
            }
        }
        // -------------------------------------------------        Click_miFramedControlBackCOlor
        private void Click_miFramedControlBackCOlor (object sender, EventArgs e)
        {
            ColorDialog dlg = new ColorDialog ();

            dlg .Color = fcPressed .Control .BackColor;
            if (dlg .ShowDialog () == DialogResult .OK)
            {
                fcPressed .Control .BackColor = dlg .Color;
                Invalidate ();
            }
        }
        // -------------------------------------------------        OnlyVisibleElementInGroup
        private bool OnlyVisibleElementInGroup (long idGroup)
        {
            if (idGroup > 0)
            {
                GraphicalObject grobj;
                for (int i = 0; i < mover .Count; i++)
                {
                    grobj = mover [i] .Source;
                    if (grobj is ElasticGroup && grobj .ID == idGroup)
                    {
                        return ((grobj as ElasticGroup) .VisibleElementsNumber == 1);
                    }
                }
            }
            return (true);
        }

        // *****   menuOnCommentedControl   *****
        // -------------------------------------------------        Opening_menuOnCommentedControl
        private void Opening_menuOnCommentedControl (object sender, CancelEventArgs e)
        {
            if (ccPressed .Control == textName || ccPressed .Control == textSurname)
            {
                menuOnCommentedControl .Items ["miHideCommentedControl"] .Enabled = false;
            }
            else
            {
                menuOnCommentedControl .Items ["miHideCommentedControl"] .Enabled = !OnlyVisibleElementInGroup (ccPressed .ParentID);
            }
        }
        // -------------------------------------------------        Click_miHideCommentedControl
        private void Click_miHideCommentedControl (object sender, EventArgs e)
        {
            long idParent = ccPressed .ParentID;
            long idElem = ccPressed .ID;

            if (idParent > 0)
            {
                HideElement (idElem, idParent);
            }
        }
        // -------------------------------------------------        Click_miCommentedControlFont
        private void Click_miCommentedControlFont (object sender, EventArgs e)
        {
            FontDialog dlg = new FontDialog ();

            dlg .Font = ccPressed .Font;
            if (dlg .ShowDialog () == DialogResult .OK)
            {
                ccPressed .Font = dlg .Font;

                groupData .Update ();
                RenewMover ();
                Invalidate ();
            }
        }
        // -------------------------------------------------        Click_miCommentedControlBackCOlor
        private void Click_miCommentedControlBackCOlor (object sender, EventArgs e)
        {
            ColorDialog dlg = new ColorDialog ();

            dlg .Color = ccPressed .ControlColor;
            if (dlg .ShowDialog () == DialogResult .OK)
            {
                ccPressed .ControlColor = dlg .Color;
                Invalidate ();
            }
        }
        // -------------------------------------------------        Click_miCommentFont
        private void Click_miCommentFont (object sender, EventArgs e)
        {
            FontDialog dlg = new FontDialog ();

            dlg .Font = cmntPressed .Font;
            if (dlg .ShowDialog () == DialogResult .OK)
            {
                long idCmntCtrl = cmntPressed .ParentID;
                GraphicalObject grobj;
                for (int i = mover .Count - 1; i >= 0; i--)
                {
                    grobj = mover [i] .Source;
                    if (grobj is CommentedControl && grobj .ID == idCmntCtrl)
                    {
                        CommentedControl cc = grobj as CommentedControl;
                        cc .CommentFont = dlg .Font;
                        cc .CommentEnforcedRelocation (mover);
                        groupData .Update ();
                        RenewMover ();
                        Invalidate ();
                        break;
                    }
                }
            }
        }
        // -------------------------------------------------        Click_miCommentColor
        private void Click_miCommentColor (object sender, EventArgs e)
        {
            ColorDialog dlg = new ColorDialog ();

            dlg .Color = cmntPressed .Color;
            if (dlg .ShowDialog () == DialogResult .OK)
            {
                cmntPressed .Color = dlg .Color;
                Invalidate ();
            }
        }

        // *****   menuOnEmpty   *****
        // -------------------------------------------------        Opening_menuOnEmpty
        private void Opening_menuOnEmpty (object sender, CancelEventArgs e)
        {
            ((ToolStripMenuItem) (menuOnEmpty .Items ["miShowRotationAngle"])) .Checked = bShowAngle;
        }
        // -------------------------------------------------        Click_miShowRotationAngle
        private void Click_miShowRotationAngle (object sender, EventArgs e)
        {
            bShowAngle = !bShowAngle;
        }
        // -------------------------------------------------		Click_miDefaultView
        private void Click_miDefaultView (object sender, EventArgs e)
        {
            bClearRegistry = true; 
            DialogResult = DialogResult .Retry;
            Close ();
        }

        // *****   menuOnInfo   *****
        // -------------------------------------------------        Opening_menuOnInfo
        private void Opening_menuOnInfo (object sender, CancelEventArgs e)
        {
            ((ToolStripMenuItem) (menuOnInfo .Items ["miInfoShowFrame"])) .Checked = info .ShowFrame;
        }
        // -------------------------------------------------        Click_miInfoFont
        private void Click_miInfoFont (object sender, EventArgs e)
        {
            FontDialog dlg = new FontDialog ();

            dlg .Font = info .Font;
            if (dlg .ShowDialog () == DialogResult .OK)
            {
                info .Font = dlg .Font;
                //RenewMover ();
                Invalidate ();
            }
        }
        // -------------------------------------------------        Click_miInfoTextColor
        private void Click_miInfoTextColor (object sender, EventArgs e)
        {
            ColorDialog dlg = new ColorDialog ();

            dlg .Color = info .Color;
            if (dlg .ShowDialog () == DialogResult .OK)
            {
                info .Color = dlg .Color;
                Invalidate ();
            }
        }
        // -------------------------------------------------        Click_miInfoBackColor
        private void Click_miInfoBackColor (object sender, EventArgs e)
        {
            ColorDialog dlg = new ColorDialog ();

            dlg .Color = info .BackColor;
            if (dlg .ShowDialog () == DialogResult .OK)
            {
                info .BackColor = dlg .Color;
                Invalidate ();
            }
        }
        // -------------------------------------------------        DropDownOpening_miInfoTransparency
        private void DropDownOpening_miInfoTransparency (object sender, EventArgs e)
        {
            ToolStripMenuItem itemParent = (ToolStripMenuItem) sender;
            ToolStripItemCollection items = itemParent .DropDownItems;

            int A = info .BackColor .A;
            for (int i = 0; i < items .Count; i++)
            {
                ((ToolStripMenuItem) items [i]) .Checked = A == Convert .ToInt32 (255 * (1 - Convert .ToSingle (items [i] .Text)));
            }
        }
        // -------------------------------------------------        Click_miInfoTransparency
        private void Click_miInfoTransparency (object sender, EventArgs e)
        {
            Color clrBack = info .BackColor;
            Color clrNew = Color .FromArgb (Convert .ToInt32 (255 * (1 - Convert .ToSingle ((sender as ToolStripMenuItem) .Text))),
                                            clrBack .R, clrBack .G, clrBack .B);
            info .BackColor = clrNew;
            Invalidate ();
        }
        // -------------------------------------------------        Click_miInfoShowFrame
        private void Click_miInfoShowFrame (object sender, EventArgs e)
        {
            info .ShowFrame = !info .ShowFrame;
            Invalidate ();
        }

        const string nameSize = "Size";
        // -------------------------------------------------        DeleteRegistryEntry
        private void DeleteRegistryEntry ()
        {
            try
            {
                Registry .CurrentUser .DeleteSubKey (Form_Main .strRegKey + strAddRegKey, false);
            }
            catch
            {
            }
            finally
            {
            }
        }
        // -------------------------------------------------        SaveInfoToRegistry
        private void SaveInfoToRegistry ()
        {
            string strRegKey = Form_Main .strRegKey + strAddRegKey;

            RegistryKey regkey = null;
            try
            {
                regkey = Registry .CurrentUser .CreateSubKey (strRegKey);
                if (regkey != null)
                {
                    regkey .SetValue (nameSize, new string [] { version .ToString (),               // 0 
                                                                ClientSize .Width .ToString (),     // 1 
                                                                ClientSize .Height .ToString (),    // 2 
                                                                bShowAngle .ToString (), },         // 3 
                                      RegistryValueKind .MultiString);

                    groupData .IntoRegistry (regkey, "Data");
                    info .IntoRegistry (regkey, "Info");
                }
            }
            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 [] strs = (string []) regkey .GetValue (nameSize);
                    if (strs != null && strs .Length == 4 && Convert .ToInt32 (strs [0]) == 606)
                    {
                        ClientSize = Auxi_Convert .ToSize (strs, 1);
                        bShowAngle = Convert .ToBoolean (strs [3]);
                    }
                    else
                    {
                        return;
                    }
                    groupData = ElasticGroup .FromRegistry (this, regkey, "Data", 
                                                            new Control [] {textDate, textTime, textName, textSurname,
                                                                            textDay, textMonth, textYear, 
                                                                            textHomePhone, textOfficePhone, textMobilePhone, textEMail,
                                                                            textStreet, textTown, textProvince, textCountry, textZipCode, 
                                                                            textCompany, textPosition, 
                                                                            btnDelete, btnMoveUp, btnMoveDown, listProjects } );
                    info = ClosableInfo .FromRegistry (this, regkey, "Info");
                    if (groupData == null  ||  info == null)
                    {
                        return;
                    }
                    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)

Share

About the Author

SergeyAndreyev

United States United States
No Biography provided

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