// bts - The Bug Tracking System
// Copyright (C) 2004 - Eugene Konkov
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/********************************************************************
This is a part of Eugene Konkov base class library (ECL)
Copyright (c) 2004 Eugene Konkov
*********************************************************************/
using System;
using System.Drawing;
namespace ekon.BaseObjects.Registry{
public class Names
{
public static string Bounds = "Bounds";
public static string Column = "Column";
public static string WindowState = "WindowState";
public static string X = "X";
public static string Y = "Y";
public static string Width = "Width";
public static string Height = "Height";
public static string Software = "Software\\";
}
/// <summary>
/// Summary description for RegistryProfile.
/// </summary>
public class RegistryProfile
{
private string subkey;
public RegistryProfile(string subkey)
{
this.subkey=subkey;
}
public Rectangle Read(string fieldName)
{
Rectangle rect=new Rectangle();
rect.X=ReadInt(fieldName+Names.X);
rect.Y=ReadInt(fieldName+Names.Y);
rect.Width=ReadInt(fieldName+Names.Width);
rect.Height=ReadInt(fieldName+Names.Height);
return rect;
}
public void Write(string fieldName, Rectangle rect)
{
Write(fieldName+Names.X,rect.X);
Write(fieldName+Names.Y,rect.Y);
Write(fieldName+Names.Width,rect.Width);
Write(fieldName+Names.Height,rect.Height);
}
public int ReadInt(string fieldName)
{
Microsoft.Win32.RegistryKey key=Microsoft.Win32.Registry.CurrentUser.OpenSubKey(SubKey);
int val=(int)key.GetValue(fieldName);
return val;
}
public void Write(string fieldName, int value)
{
Microsoft.Win32.RegistryKey key=Microsoft.Win32.Registry.CurrentUser.CreateSubKey(SubKey);
key.SetValue(fieldName, value);
}
public string SubKey
{
get
{
return Names.Software + subkey;
}
}
}
}
|