Ignore:
Timestamp:
Aug 2, 2022, 11:46:25 AM (2 years ago)
Author:
chronos
Message:
  • Modified: Various improvements.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Common/FormDimensions.cs

    r12 r14  
    11using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    52using System.Drawing;
    63using System.Windows.Forms;
     
    129    class FormDimensions
    1310    {
    14         public Form form;
     11        public Form Form;
    1512        public string RegSubKey;
    16         public FormWindowState defaultFormWindowState = FormWindowState.Normal;
     13        public FormWindowState DefaultFormWindowState = FormWindowState.Normal;
    1714
    1815        [DllImport("user32.dll")]
     
    7370        public void Load(Form form, Form parentForm = null)
    7471        {
    75             this.form = form;
     72            this.Form = form;
    7673            RegistryKey regKey = Application.UserAppDataRegistry.OpenSubKey(RegSubKey + "\\" + form.Name);
    7774            if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(RegSubKey + "\\" + form.Name);
     
    103100                (int)regKey.GetValue("RestoreBoundsWidth" + name, restoreBounds.Width),
    104101                (int)regKey.GetValue("RestoreBoundsHeight" + name, restoreBounds.Height));
    105             FormWindowState windowState = (FormWindowState)regKey.GetValue("State" + name, (int)defaultFormWindowState);
     102            FormWindowState windowState = (FormWindowState)regKey.GetValue("State" + name, (int)DefaultFormWindowState);
    106103            if (parentForm != null)
    107104            {
     
    150147        public void Save(Form form, Form parentForm = null)
    151148        {
    152             this.form = form;
     149            this.Form = form;
    153150            RegistryKey regKey = Application.UserAppDataRegistry.OpenSubKey(RegSubKey + "\\" + form.Name, true);
    154151            if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(RegSubKey + "\\" + form.Name);
     
    191188            if (control is ListView)
    192189            {
    193                 RegistryKey regKey = Application.UserAppDataRegistry.OpenSubKey(RegSubKey + "\\" + form.Name + "\\" + control.Name, true);
    194                 if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(RegSubKey + "\\" + form.Name + "\\" + control.Name);
     190                RegistryKey regKey = Application.UserAppDataRegistry.OpenSubKey(RegSubKey + "\\" + Form.Name + "\\" + control.Name, true);
     191                if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(RegSubKey + "\\" + Form.Name + "\\" + control.Name);
    195192
    196193                for (int I = 0; I < (control as ListView).Columns.Count; I++)
     
    202199            if (control is DataGridView)
    203200            {
    204                 RegistryKey regKey = Application.UserAppDataRegistry.OpenSubKey(RegSubKey + "\\" + form.Name + "\\" + control.Name, true);
    205                 if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(RegSubKey + "\\" + form.Name + "\\" + control.Name);
     201                RegistryKey regKey = Application.UserAppDataRegistry.OpenSubKey(RegSubKey + "\\" + Form.Name + "\\" + control.Name, true);
     202                if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(RegSubKey + "\\" + Form.Name + "\\" + control.Name);
    206203
    207204                for (int I = 0; I < (control as DataGridView).Columns.Count; I++)
     
    213210            if (control is SplitContainer)
    214211            {
    215                 RegistryKey regKey = Application.UserAppDataRegistry.OpenSubKey(RegSubKey + "\\" + form.Name + "\\" + control.Name, true);
    216                 if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(RegSubKey + "\\" + form.Name + "\\" + control.Name);
     212                RegistryKey regKey = Application.UserAppDataRegistry.OpenSubKey(RegSubKey + "\\" + Form.Name + "\\" + control.Name, true);
     213                if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(RegSubKey + "\\" + Form.Name + "\\" + control.Name);
    217214
    218215                if (regKey.GetValue("SplitterDistance") != null)
     
    230227            if (control is ListView)
    231228            {
    232                 RegistryKey regKey = Application.UserAppDataRegistry.OpenSubKey(RegSubKey + "\\" + form.Name + "\\" + control.Name, true);
    233                 if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(RegSubKey + "\\" + form.Name + "\\" + control.Name);
     229                RegistryKey regKey = Application.UserAppDataRegistry.OpenSubKey(RegSubKey + "\\" + Form.Name + "\\" + control.Name, true);
     230                if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(RegSubKey + "\\" + Form.Name + "\\" + control.Name);
    234231
    235232                for (int I = 0; I < (control as ListView).Columns.Count; I++)
     
    240237            if (control is DataGridView)
    241238            {
    242                 RegistryKey regKey = Application.UserAppDataRegistry.OpenSubKey(RegSubKey + "\\" + form.Name + "\\" + control.Name, true);
    243                 if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(RegSubKey + "\\" + form.Name + "\\" + control.Name);
     239                RegistryKey regKey = Application.UserAppDataRegistry.OpenSubKey(RegSubKey + "\\" + Form.Name + "\\" + control.Name, true);
     240                if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(RegSubKey + "\\" + Form.Name + "\\" + control.Name);
    244241
    245242                for (int I = 0; I < (control as DataGridView).Columns.Count; I++)
     
    250247            if (control is SplitContainer)
    251248            {
    252                 RegistryKey regKey = Application.UserAppDataRegistry.OpenSubKey(RegSubKey + "\\" + form.Name + "\\" + control.Name, true);
    253                 if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(RegSubKey + "\\" + form.Name + "\\" + control.Name);
     249                RegistryKey regKey = Application.UserAppDataRegistry.OpenSubKey(RegSubKey + "\\" + Form.Name + "\\" + control.Name, true);
     250                if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(RegSubKey + "\\" + Form.Name + "\\" + control.Name);
    254251
    255252                regKey.SetValue("SplitterDistance", (control as SplitContainer).SplitterDistance);
Note: See TracChangeset for help on using the changeset viewer.