diff --git a/src/DataStreamSuite/BlueRegistry/BlueRegistry.cs b/src/DataStreamSuite/BlueRegistry/BlueRegistry.cs index 7d001f28e..a569f6111 100644 --- a/src/DataStreamSuite/BlueRegistry/BlueRegistry.cs +++ b/src/DataStreamSuite/BlueRegistry/BlueRegistry.cs @@ -1,192 +1,192 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.Concurrent; -using System.Reflection; -using Microsoft.Win32; - -namespace BCG -{ - public enum RegistryRoot { HKCU, HKLM } - - [Serializable] - public class BlueRegistry - { - public const string BlueSubKey = @"Software\Blue Capital Group\"; - public static readonly string ApplicationPrefix; - protected string myFullPath; - - public BlueRegistry(string subPath) - { - myFullPath = string.Concat(BlueRegistry.ApplicationPrefix, @"\", subPath); - } - - public BlueRegistry(BlueRegistry parent, string subPath) - { - myFullPath = string.Concat(parent.myFullPath, @"\", subPath); - } - - static BlueRegistry() - { - string app = "Applications"; - - Assembly ass = Assembly.GetEntryAssembly(); - if (ass != null) - { - app = ass.GetName().Name; - - object[] attrs = ass.GetCustomAttributes( - Type.GetType("System.Reflection.AssemblyTitleAttribute"), true); - - if (attrs.Length > 0 && ((AssemblyTitleAttribute)attrs[0]).Title != string.Empty) - { - app = ((AssemblyTitleAttribute)attrs[0]).Title; - } - } - - ApplicationPrefix = string.Concat(BlueRegistry.BlueSubKey, app); - } - - public object getValue(string name) - { - return getValue(RegistryRoot.HKCU, name); - } - - public object getValue(string name, object defaultValue) - { - return getValue(RegistryRoot.HKCU, name, defaultValue); - } - - public void setValue(string name, object value) - { - setValue(RegistryRoot.HKCU, name, value); - } - - public void deleteValue(string name) - { - deleteValue(RegistryRoot.HKCU, name); - } - - private RegistryKey myGetRegistryKey(RegistryRoot root) - { - if (root == RegistryRoot.HKCU) - return Registry.CurrentUser.CreateSubKey(myFullPath); - else - return Registry.LocalMachine.CreateSubKey(myFullPath); - } - - #region Generic Methods - internal virtual void setValue(RegistryRoot root, string name, object value) - { - using (RegistryKey rk = myGetRegistryKey(root)) - { - rk.SetValue(name, value); - } - } - - internal virtual object getValue(RegistryRoot root, string name) - { - using (RegistryKey rk = myGetRegistryKey(root)) - { - return rk.GetValue(name); - } - } - - internal virtual void deleteValue(RegistryRoot root, string name) - { - using (RegistryKey rk = myGetRegistryKey(root)) - { - rk.DeleteValue(name); - } - } - - internal virtual object getValue(RegistryRoot root, string name, object defaultValue) - { - using (RegistryKey rk = myGetRegistryKey(root)) - { - return rk.GetValue(name, defaultValue); - } - } - #endregion - - #region Double - internal virtual void setDouble(RegistryRoot root, string name, double value) - { - using (RegistryKey rk = myGetRegistryKey(root)) - { - DoubleRegistryHandler.setValue(rk, name, value); - } - } - - internal virtual double getDouble(RegistryRoot root, string name) - { - using (RegistryKey rk = myGetRegistryKey(root)) - { - return DoubleRegistryHandler.getValue(rk, name); - } - } - #endregion - - #region Enum - internal virtual void setEnum(RegistryRoot root, string name, Enum value) - { - using (RegistryKey rk = myGetRegistryKey(root)) - { - EnumRegistryHandler.setValue(rk, name, value); - } - } - - internal virtual Enum getEnum(RegistryRoot root, string name, Type enumType) - { - using (RegistryKey rk = myGetRegistryKey(root)) - { - return EnumRegistryHandler.getValue(rk, name, enumType); - } - } - #endregion - - #region Array - internal virtual void setArray(RegistryRoot root, string name, Array array) - { - using (RegistryKey rk = myGetRegistryKey(root)) - { - ArrayRegistryHandler.setValue(rk, name, array); - } - } - - internal virtual Array getArray(RegistryRoot root, string name, Type elementType) - { - using (RegistryKey rk = myGetRegistryKey(root)) - { - return ArrayRegistryHandler.getValue(rk, name, elementType); - } - } - #endregion - - #region SortedList - internal virtual void setSortedList(RegistryRoot root, string name, SortedList slist) - { - using (RegistryKey rk = myGetRegistryKey(root)) - { - SortedListRegistryHandler.setValue(rk, name, slist); - } - } - - internal virtual SortedList getSortedList(RegistryRoot root, string name) - { - using (RegistryKey rk = myGetRegistryKey(root)) - { - return SortedListRegistryHandler.getValue(rk, name); - } - } - - internal virtual void deleteSortedList(RegistryRoot root, string name) - { - using (RegistryKey rk = myGetRegistryKey(root)) - { - SortedListRegistryHandler.deleteValue(rk, name); - } - } - #endregion - } -} +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.Concurrent; +using System.Reflection; +using Microsoft.Win32; + +namespace BCG +{ + public enum RegistryRoot { HKCU, HKLM } + + [Serializable] + public class BlueRegistry + { + public const string BlueSubKey = @"Software\Blue Capital Group\"; + public static readonly string ApplicationPrefix; + protected string myFullPath; + + public BlueRegistry(string subPath) + { + myFullPath = string.Concat(BlueRegistry.ApplicationPrefix, @"\", subPath); + } + + public BlueRegistry(BlueRegistry parent, string subPath) + { + myFullPath = string.Concat(parent.myFullPath, @"\", subPath); + } + + static BlueRegistry() + { + string app = "Applications"; + + Assembly ass = Assembly.GetEntryAssembly(); + if (ass != null) + { + app = ass.GetName().Name; + + object[] attrs = ass.GetCustomAttributes( + Type.GetType("System.Reflection.AssemblyTitleAttribute"), true); + + if (attrs.Length > 0 && ((AssemblyTitleAttribute)attrs[0]).Title != string.Empty) + { + app = ((AssemblyTitleAttribute)attrs[0]).Title; + } + } + + ApplicationPrefix = string.Concat(BlueRegistry.BlueSubKey, app); + } + + public object getValue(string name) + { + return getValue(RegistryRoot.HKCU, name); + } + + public object getValue(string name, object defaultValue) + { + return getValue(RegistryRoot.HKCU, name, defaultValue); + } + + public void setValue(string name, object value) + { + setValue(RegistryRoot.HKCU, name, value); + } + + public void deleteValue(string name) + { + deleteValue(RegistryRoot.HKCU, name); + } + + private RegistryKey myGetRegistryKey(RegistryRoot root) + { + if (root == RegistryRoot.HKCU) + return Registry.CurrentUser.CreateSubKey(myFullPath); + else + return Registry.LocalMachine.CreateSubKey(myFullPath); + } + + #region Generic Methods + public virtual void setValue(RegistryRoot root, string name, object value) + { + using (RegistryKey rk = myGetRegistryKey(root)) + { + rk.SetValue(name, value); + } + } + + internal virtual object getValue(RegistryRoot root, string name) + { + using (RegistryKey rk = myGetRegistryKey(root)) + { + return rk.GetValue(name); + } + } + + internal virtual void deleteValue(RegistryRoot root, string name) + { + using (RegistryKey rk = myGetRegistryKey(root)) + { + rk.DeleteValue(name); + } + } + + public virtual object getValue(RegistryRoot root, string name, object defaultValue) + { + using (RegistryKey rk = myGetRegistryKey(root)) + { + return rk.GetValue(name, defaultValue); + } + } + #endregion + + #region Double + internal virtual void setDouble(RegistryRoot root, string name, double value) + { + using (RegistryKey rk = myGetRegistryKey(root)) + { + DoubleRegistryHandler.setValue(rk, name, value); + } + } + + internal virtual double getDouble(RegistryRoot root, string name) + { + using (RegistryKey rk = myGetRegistryKey(root)) + { + return DoubleRegistryHandler.getValue(rk, name); + } + } + #endregion + + #region Enum + internal virtual void setEnum(RegistryRoot root, string name, Enum value) + { + using (RegistryKey rk = myGetRegistryKey(root)) + { + EnumRegistryHandler.setValue(rk, name, value); + } + } + + internal virtual Enum getEnum(RegistryRoot root, string name, Type enumType) + { + using (RegistryKey rk = myGetRegistryKey(root)) + { + return EnumRegistryHandler.getValue(rk, name, enumType); + } + } + #endregion + + #region Array + internal virtual void setArray(RegistryRoot root, string name, Array array) + { + using (RegistryKey rk = myGetRegistryKey(root)) + { + ArrayRegistryHandler.setValue(rk, name, array); + } + } + + internal virtual Array getArray(RegistryRoot root, string name, Type elementType) + { + using (RegistryKey rk = myGetRegistryKey(root)) + { + return ArrayRegistryHandler.getValue(rk, name, elementType); + } + } + #endregion + + #region SortedList + internal virtual void setSortedList(RegistryRoot root, string name, SortedList slist) + { + using (RegistryKey rk = myGetRegistryKey(root)) + { + SortedListRegistryHandler.setValue(rk, name, slist); + } + } + + internal virtual SortedList getSortedList(RegistryRoot root, string name) + { + using (RegistryKey rk = myGetRegistryKey(root)) + { + return SortedListRegistryHandler.getValue(rk, name); + } + } + + internal virtual void deleteSortedList(RegistryRoot root, string name) + { + using (RegistryKey rk = myGetRegistryKey(root)) + { + SortedListRegistryHandler.deleteValue(rk, name); + } + } + #endregion + } +} diff --git a/src/DataStreamSuite/BlueRegistry/BlueRegistry.csproj b/src/DataStreamSuite/BlueRegistry/BlueRegistry.csproj index 01dc70830..cfadb03dd 100644 --- a/src/DataStreamSuite/BlueRegistry/BlueRegistry.csproj +++ b/src/DataStreamSuite/BlueRegistry/BlueRegistry.csproj @@ -1,10 +1,9 @@ - net7.0-windows + net7.0 enable enable - true diff --git a/src/DataStreamSuite/BlueRegistry/PersistWindowState.cs b/src/DataStreamSuite/DataStreamQueryAnalyzer/PersistWindowState.cs similarity index 96% rename from src/DataStreamSuite/BlueRegistry/PersistWindowState.cs rename to src/DataStreamSuite/DataStreamQueryAnalyzer/PersistWindowState.cs index 7b54844af..1d8e71324 100644 --- a/src/DataStreamSuite/BlueRegistry/PersistWindowState.cs +++ b/src/DataStreamSuite/DataStreamQueryAnalyzer/PersistWindowState.cs @@ -1,166 +1,166 @@ -using System; -using System.Reflection; -using System.Windows.Forms; -using System.Drawing; -using System.Diagnostics; -using Microsoft.Win32; - -namespace BCG -{ - public class PersistWindowState - { - // event info that allows form to persist extra window state data - public delegate void WindowStateHandler (object sender, BlueRegistry bluereg); - public event WindowStateHandler LoadState; - public event WindowStateHandler SaveState; - - private Form myParent; - private BlueRegistry myRegistry; - - private int myNormalLeft; - private int myNormalTop; - private int myNormalWidth; - private int myNormalHeight; - private bool myResizable = true; - private FormWindowState myWindowState; - private bool myAllowSaveMinimized = false; - private bool mySavePosition = true; - private bool mySaveState = true; - - public PersistWindowState (bool savePosition) - { - mySavePosition = savePosition; - } - - public PersistWindowState () - { - } - - public bool saveState - { - [DebuggerStepThrough] - set { mySaveState = value; } - } - - public Form parent - { - [DebuggerStepThrough] - get { return myParent; } - set - { - myParent = value; - myRegistry = new BlueRegistry (myParent.Text); - - // subscribe to parent form's events - myParent.Closing += new System.ComponentModel.CancelEventHandler(myOnClosing); - myParent.Resize += new System.EventHandler(myOnResize); - myParent.Move += new System.EventHandler(myOnMove); - myParent.Load += new System.EventHandler(myOnLoad); - - // get initial width and height in case form is never resized - myNormalWidth = myParent.Width; - myNormalHeight = myParent.Height; - } - } - - public BlueRegistry blueRegistry - { - [DebuggerStepThrough] - get { return myRegistry; } - [DebuggerStepThrough] - set { myRegistry = value; } - } - - public bool resizable - { - [DebuggerStepThrough] - set { myResizable = value; } - } - - public bool allowSaveMinimized - { - [DebuggerStepThrough] - set { myAllowSaveMinimized = value; } - } - - private void myOnResize(object sender, System.EventArgs e) - { - // save width and height - if (myParent.WindowState == FormWindowState.Normal && myResizable) - { - myNormalWidth = myParent.Width; - myNormalHeight = myParent.Height; - } - } - - private void myOnMove(object sender, System.EventArgs e) - { - // save position - if(myParent.WindowState == FormWindowState.Normal) - { - myNormalLeft = myParent.Left; - myNormalTop = myParent.Top; - } - // save state - myWindowState = myParent.WindowState; - } - - private void myOnClosing(object sender, System.ComponentModel.CancelEventArgs e) - { - // save position, size and state - if (mySavePosition) - { - myRegistry.setValue (RegistryRoot.HKCU, "Left", myNormalLeft); - myRegistry.setValue (RegistryRoot.HKCU, "Top", myNormalTop); - } - - if (myResizable) - { - myRegistry.setValue (RegistryRoot.HKCU, "Width", myNormalWidth); - myRegistry.setValue (RegistryRoot.HKCU, "Height", myNormalHeight); - } - - // check if we are allowed to save the state as minimized (not normally) - if (!myAllowSaveMinimized) - { - if(myWindowState == FormWindowState.Minimized) - myWindowState = FormWindowState.Normal; - } - - if (mySaveState) - myRegistry.setValue (RegistryRoot.HKCU, "WindowState", (int) myWindowState); - - // fire SaveState event - if (SaveState != null) - SaveState (this, myRegistry); - } - - private void myOnLoad (object sender, System.EventArgs e) - { - if (mySavePosition) - { - int left = (int) myRegistry.getValue (RegistryRoot.HKCU, "Left", myParent.Left); - int top = (int) myRegistry.getValue (RegistryRoot.HKCU, "Top", myParent.Top); - myParent.Location = new Point (left, top); - } - - if (myResizable) - { - int width = (int) myRegistry.getValue (RegistryRoot.HKCU, "Width", myParent.Width); - int height = (int) myRegistry.getValue (RegistryRoot.HKCU, "Height", myParent.Height); - myParent.Size = new Size (width, height); - } - - if (mySaveState) - { - FormWindowState windowState = (FormWindowState) myRegistry.getValue (RegistryRoot.HKCU, "WindowState", - (int) myParent.WindowState); - myParent.WindowState = windowState; - } - - // fire LoadState event - if(LoadState != null) - LoadState (this, myRegistry); - } - } -} +using System; +using System.Reflection; +using System.Windows.Forms; +using System.Drawing; +using System.Diagnostics; +using Microsoft.Win32; + +namespace BCG +{ + public class PersistWindowState + { + // event info that allows form to persist extra window state data + public delegate void WindowStateHandler (object sender, BlueRegistry bluereg); + public event WindowStateHandler LoadState; + public event WindowStateHandler SaveState; + + private Form myParent; + private BlueRegistry myRegistry; + + private int myNormalLeft; + private int myNormalTop; + private int myNormalWidth; + private int myNormalHeight; + private bool myResizable = true; + private FormWindowState myWindowState; + private bool myAllowSaveMinimized = false; + private bool mySavePosition = true; + private bool mySaveState = true; + + public PersistWindowState (bool savePosition) + { + mySavePosition = savePosition; + } + + public PersistWindowState () + { + } + + public bool saveState + { + [DebuggerStepThrough] + set { mySaveState = value; } + } + + public Form parent + { + [DebuggerStepThrough] + get { return myParent; } + set + { + myParent = value; + myRegistry = new BlueRegistry (myParent.Text); + + // subscribe to parent form's events + myParent.Closing += new System.ComponentModel.CancelEventHandler(myOnClosing); + myParent.Resize += new System.EventHandler(myOnResize); + myParent.Move += new System.EventHandler(myOnMove); + myParent.Load += new System.EventHandler(myOnLoad); + + // get initial width and height in case form is never resized + myNormalWidth = myParent.Width; + myNormalHeight = myParent.Height; + } + } + + public BlueRegistry blueRegistry + { + [DebuggerStepThrough] + get { return myRegistry; } + [DebuggerStepThrough] + set { myRegistry = value; } + } + + public bool resizable + { + [DebuggerStepThrough] + set { myResizable = value; } + } + + public bool allowSaveMinimized + { + [DebuggerStepThrough] + set { myAllowSaveMinimized = value; } + } + + private void myOnResize(object sender, System.EventArgs e) + { + // save width and height + if (myParent.WindowState == FormWindowState.Normal && myResizable) + { + myNormalWidth = myParent.Width; + myNormalHeight = myParent.Height; + } + } + + private void myOnMove(object sender, System.EventArgs e) + { + // save position + if(myParent.WindowState == FormWindowState.Normal) + { + myNormalLeft = myParent.Left; + myNormalTop = myParent.Top; + } + // save state + myWindowState = myParent.WindowState; + } + + private void myOnClosing(object sender, System.ComponentModel.CancelEventArgs e) + { + // save position, size and state + if (mySavePosition) + { + myRegistry.setValue (RegistryRoot.HKCU, "Left", myNormalLeft); + myRegistry.setValue (RegistryRoot.HKCU, "Top", myNormalTop); + } + + if (myResizable) + { + myRegistry.setValue (RegistryRoot.HKCU, "Width", myNormalWidth); + myRegistry.setValue (RegistryRoot.HKCU, "Height", myNormalHeight); + } + + // check if we are allowed to save the state as minimized (not normally) + if (!myAllowSaveMinimized) + { + if(myWindowState == FormWindowState.Minimized) + myWindowState = FormWindowState.Normal; + } + + if (mySaveState) + myRegistry.setValue (RegistryRoot.HKCU, "WindowState", (int) myWindowState); + + // fire SaveState event + if (SaveState != null) + SaveState (this, myRegistry); + } + + private void myOnLoad (object sender, System.EventArgs e) + { + if (mySavePosition) + { + int left = (int) myRegistry.getValue (RegistryRoot.HKCU, "Left", myParent.Left); + int top = (int) myRegistry.getValue (RegistryRoot.HKCU, "Top", myParent.Top); + myParent.Location = new Point (left, top); + } + + if (myResizable) + { + int width = (int) myRegistry.getValue (RegistryRoot.HKCU, "Width", myParent.Width); + int height = (int) myRegistry.getValue (RegistryRoot.HKCU, "Height", myParent.Height); + myParent.Size = new Size (width, height); + } + + if (mySaveState) + { + FormWindowState windowState = (FormWindowState) myRegistry.getValue (RegistryRoot.HKCU, "WindowState", + (int) myParent.WindowState); + myParent.WindowState = windowState; + } + + // fire LoadState event + if(LoadState != null) + LoadState (this, myRegistry); + } + } +}