117 lines
3.5 KiB
C#
117 lines
3.5 KiB
C#
using Microsoft.Win32;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using System.Windows.Forms.VisualStyles;
|
|
|
|
namespace Kaehler.scr
|
|
{
|
|
public partial class SetupForm : Form
|
|
{
|
|
private int iGrundwert = 30;
|
|
private int iAbweichung = 1;
|
|
|
|
public SetupForm()
|
|
{
|
|
InitializeComponent();
|
|
CheckReg();
|
|
iGrundwert = ReadFromReg("Grundwert", iGrundwert);
|
|
iAbweichung = ReadFromReg("Abweichung", iAbweichung);
|
|
textBox1.Text = iGrundwert.ToString();
|
|
textBox2.Text = iAbweichung.ToString();
|
|
trackBar1.Value = iGrundwert;
|
|
trackBar2.Value = iAbweichung;
|
|
}
|
|
|
|
private void textBox1_TextChanged(object sender, EventArgs e)
|
|
{
|
|
iGrundwert = int.Parse(textBox1.Text);
|
|
trackBar1.Value = iGrundwert;
|
|
}
|
|
|
|
private void textBox2_TextChanged(object sender, EventArgs e)
|
|
{
|
|
iAbweichung = int.Parse(textBox2.Text);
|
|
trackBar2.Value = iAbweichung;
|
|
}
|
|
private void trackBar1_Scroll(object sender, EventArgs e)
|
|
{
|
|
iGrundwert = trackBar1.Value;
|
|
textBox1.Text=iGrundwert.ToString();
|
|
}
|
|
private void trackBar2_Scroll(object sender, EventArgs e)
|
|
{
|
|
iAbweichung = trackBar2.Value;
|
|
textBox2.Text = iAbweichung.ToString();
|
|
}
|
|
private void trackBar1_Move(object sender, EventArgs e)
|
|
{
|
|
iGrundwert = trackBar1.Value;
|
|
textBox1.Text = iGrundwert.ToString();
|
|
}
|
|
private void trackBar2_Move(object sender, EventArgs e)
|
|
{
|
|
iAbweichung = trackBar2.Value;
|
|
textBox2.Text = iAbweichung.ToString();
|
|
}
|
|
|
|
private void CheckReg()
|
|
{
|
|
RegistryKey key = Registry.CurrentUser.OpenSubKey("Software", true);
|
|
RegistryKey subkey = key.OpenSubKey("Kaehler.SCR", true);
|
|
if (subkey == null)
|
|
{
|
|
key.CreateSubKey("Kaehler.SCR");
|
|
}
|
|
subkey = key.OpenSubKey("Kaehler.SCR", true);
|
|
Object oTest1 = subkey.GetValue("Grundwert");
|
|
if (oTest1 == null)
|
|
{
|
|
subkey.SetValue("Grundwert", 30);
|
|
}
|
|
Object oTest2 = subkey.GetValue("Abweichung");
|
|
if (oTest2 == null)
|
|
{
|
|
subkey.SetValue("Abweichung", 10);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
private int ReadFromReg(String sName, int iDefault)
|
|
{
|
|
int iRet = iDefault;
|
|
RegistryKey key = Registry.CurrentUser.OpenSubKey("Software", true);
|
|
RegistryKey subkey = key.OpenSubKey("Kaehler.SCR", true);
|
|
Object oTest = subkey.GetValue(sName);
|
|
if (oTest != null)
|
|
iRet = int.Parse(oTest.ToString());
|
|
|
|
return iRet;
|
|
}
|
|
|
|
private void WriteToReg(String sName, int iWert)
|
|
{
|
|
RegistryKey key = Registry.CurrentUser.OpenSubKey("Software", true);
|
|
RegistryKey subkey = key.OpenSubKey("Kaehler.SCR", true);
|
|
subkey.SetValue(sName, iWert);
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
WriteToReg("Grundwert", iGrundwert);
|
|
WriteToReg("Abweichung", iAbweichung);
|
|
this.Close();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|