Exemplo n.º 1
0
 public static void AddConnectionProfile(MtConnectionProfile profile)
 {            
     if (profile != null && string.IsNullOrEmpty(profile.Name) == false)
     {
         SaveConnectionProfileToRegistry(profile);
     }
 }
Exemplo n.º 2
0
 public static void AddConnectionProfile(MtConnectionProfile profile)
 {
     if (profile != null && string.IsNullOrEmpty(profile.Name) == false)
     {
         SaveConnectionProfileToRegistry(profile);
     }
 }
Exemplo n.º 3
0
        private void ExecuteAddProfile(object o)
        {
            var dlg = new AddProfileDialog(App.Current.MainWindow);
            var result = dlg.ShowDialog();

            if (result == true)
            {
                var profile = new MtConnectionProfile(dlg.ProfileName);
                profile.Host = dlg.Host;
                profile.Port = int.Parse(dlg.Port);

                MtRegistryManager.AddConnectionProfile(profile);
                ConnectionProfiles.Add(profile);
            }
        }
Exemplo n.º 4
0
        private static IEnumerable <MtConnectionProfile> LoadConnectionProfilesFromRegisty()
        {
            List <MtConnectionProfile> profiles = null;

            var softwareRegKey = Registry.CurrentUser.OpenSubKey(Software, true);

            if (softwareRegKey != null)
            {
                using (softwareRegKey)
                {
                    var appRegKey = softwareRegKey.OpenSubKey(AppName, true);
                    if (appRegKey != null)
                    {
                        using (appRegKey)
                        {
                            var profilesRegKey = appRegKey.OpenSubKey(ProfilesRegkey, true);
                            if (profilesRegKey != null)
                            {
                                using (profilesRegKey)
                                {
                                    profiles = new List <MtConnectionProfile>();

                                    foreach (var profileNameKey in profilesRegKey.GetSubKeyNames())
                                    {
                                        var tempKey = profilesRegKey.OpenSubKey(profileNameKey);
                                        if (tempKey != null)
                                        {
                                            using (tempKey)
                                            {
                                                var profile = new MtConnectionProfile(profileNameKey)
                                                {
                                                    Host = tempKey.GetValue(HostRegvalueName).ToString(),
                                                    Port = (int)tempKey.GetValue(PortRegvalueName)
                                                };

                                                profiles.Add(profile);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(profiles);
        }
Exemplo n.º 5
0
        private static IEnumerable <MtConnectionProfile> LoadConnectionProfilesFromRegisty()
        {
            List <MtConnectionProfile> profiles = null;

            var softwareRegKey = Registry.CurrentUser.OpenSubKey(SOFTWARE, true);

            if (softwareRegKey != null)
            {
                using (softwareRegKey)
                {
                    var appRegKey = softwareRegKey.OpenSubKey(APP_NAME, true);
                    if (appRegKey != null)
                    {
                        using (appRegKey)
                        {
                            var profilesRegKey = appRegKey.OpenSubKey(PROFILES_REGKEY, true);
                            if (profilesRegKey != null)
                            {
                                using (profilesRegKey)
                                {
                                    profiles = new List <MtConnectionProfile>();

                                    foreach (string profileNameKey in profilesRegKey.GetSubKeyNames())
                                    {
                                        using (RegistryKey tempKey = profilesRegKey.OpenSubKey(profileNameKey))
                                        {
                                            var profile = new MtConnectionProfile(profileNameKey);

                                            profile.Host = tempKey.GetValue(HOST_REGVALUE_NAME).ToString();
                                            profile.Port = (int)tempKey.GetValue(PORT_REGVALUE_NAME);

                                            profiles.Add(profile);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(profiles);
        }
Exemplo n.º 6
0
        private static void SaveConnectionProfileToRegistry(MtConnectionProfile profile)
        {
            var softwareRgKey = Registry.CurrentUser.OpenSubKey(Software, true);

            if (softwareRgKey == null)
            {
                return;
            }

            using (softwareRgKey)
            {
                //app name
                var appRegKey = softwareRgKey.OpenSubKey(AppName, true) ?? softwareRgKey.CreateSubKey(AppName);

                if (appRegKey != null)
                {
                    using (appRegKey)
                    {
                        //ConnectionProfiles key
                        var profilesRegKey = appRegKey.OpenSubKey(ProfilesRegkey, true) ??
                                             appRegKey.CreateSubKey(ProfilesRegkey);

                        if (profilesRegKey != null)
                        {
                            using (profilesRegKey)
                            {
                                var profileKey = profilesRegKey.CreateSubKey(profile.Name);
                                if (profileKey != null)
                                {
                                    using (profileKey)
                                    {
                                        profileKey.SetValue(HostRegvalueName, profile.Host);
                                        profileKey.SetValue(PortRegvalueName, profile.Port);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
        private static MtConnectionProfile LoadConnectionProfileFromRegisty(string profileName)
        {
            MtConnectionProfile profile = null;

            var softwareRegKey = Registry.CurrentUser.OpenSubKey(Software, true);

            if (softwareRegKey != null)
            {
                using (softwareRegKey)
                {
                    var appRegKey = softwareRegKey.OpenSubKey(AppName, true);
                    if (appRegKey != null)
                    {
                        using (appRegKey)
                        {
                            var profilesRegKey = appRegKey.OpenSubKey(ProfilesRegkey, true);
                            if (profilesRegKey != null)
                            {
                                using (profilesRegKey)
                                {
                                    var tempKey = profilesRegKey.OpenSubKey(profileName);
                                    if (tempKey != null)
                                    {
                                        using (tempKey)
                                        {
                                            profile = new MtConnectionProfile(profileName)
                                            {
                                                Host = tempKey.GetValue(HostRegvalueName).ToString(),
                                                Port = (int)tempKey.GetValue(PortRegvalueName)
                                            };
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(profile);
        }
Exemplo n.º 8
0
        private static void SaveConnectionProfileToRegistry(MtConnectionProfile profile)
        {
            RegistryKey softwareRgKey = Registry.CurrentUser.OpenSubKey(SOFTWARE, true);

            if (softwareRgKey == null)
            {
                return;
            }

            using (softwareRgKey)
            {
                //app name
                var appRegKey = softwareRgKey.OpenSubKey(APP_NAME, true);
                if (appRegKey == null)
                {
                    appRegKey = softwareRgKey.CreateSubKey(APP_NAME);
                }

                using (appRegKey)
                {
                    //ConnectionProfiles key
                    var profilesRegKey = appRegKey.OpenSubKey(PROFILES_REGKEY, true);
                    if (profilesRegKey == null)
                    {
                        profilesRegKey = appRegKey.CreateSubKey(PROFILES_REGKEY);
                    }

                    using (profilesRegKey)
                    {
                        var profileKey = profilesRegKey.CreateSubKey(profile.Name);

                        using (profileKey)
                        {
                            profileKey.SetValue(HOST_REGVALUE_NAME, profile.Host);
                            profileKey.SetValue(PORT_REGVALUE_NAME, profile.Port);
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
        private static MtConnectionProfile LoadConnectionProfileFromRegisty(string profileName)
        {
            MtConnectionProfile profile = null;

            var softwareRegKey = Registry.CurrentUser.OpenSubKey(SOFTWARE, true);

            if (softwareRegKey != null)
            {
                using (softwareRegKey)
                {
                    var appRegKey = softwareRegKey.OpenSubKey(APP_NAME, true);
                    if (appRegKey != null)
                    {
                        using (appRegKey)
                        {
                            var profilesRegKey = appRegKey.OpenSubKey(PROFILES_REGKEY, true);
                            if (profilesRegKey != null)
                            {
                                using (profilesRegKey)
                                {
                                    using (RegistryKey tempKey = profilesRegKey.OpenSubKey(profileName))
                                    {
                                        profile = new MtConnectionProfile(profileName);

                                        profile.Host = tempKey.GetValue(HOST_REGVALUE_NAME).ToString();
                                        profile.Port = (int)tempKey.GetValue(PORT_REGVALUE_NAME);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(profile);
        }
Exemplo n.º 10
0
        private static void SaveConnectionProfileToRegistry(MtConnectionProfile profile)
        {
            RegistryKey softwareRgKey = Registry.CurrentUser.OpenSubKey(SOFTWARE, true);

            if (softwareRgKey == null)
                return;

            using (softwareRgKey)
            {
                //app name
                var appRegKey = softwareRgKey.OpenSubKey(APP_NAME, true);
                if (appRegKey == null)
                {
                    appRegKey = softwareRgKey.CreateSubKey(APP_NAME);
                }

                using (appRegKey)
                {
                    //ConnectionProfiles key
                    var profilesRegKey = appRegKey.OpenSubKey(PROFILES_REGKEY, true);
                    if (profilesRegKey == null)
                    {
                        profilesRegKey = appRegKey.CreateSubKey(PROFILES_REGKEY);
                    }

                    using (profilesRegKey)
                    {
                        var profileKey = profilesRegKey.CreateSubKey(profile.Name);

                        using (profileKey)
                        {
                            profileKey.SetValue(HOST_REGVALUE_NAME, profile.Host);
                            profileKey.SetValue(PORT_REGVALUE_NAME, profile.Port);
                        }
                    }
                }
            }
        }
Exemplo n.º 11
0
        private static MtConnectionProfile LoadConnectionProfileFromRegisty(string profileName)
        {
            MtConnectionProfile profile = null;

            var softwareRegKey = Registry.CurrentUser.OpenSubKey(SOFTWARE, true);
            if (softwareRegKey != null)
            {
                using (softwareRegKey)
                {
                    var appRegKey = softwareRegKey.OpenSubKey(APP_NAME, true);
                    if (appRegKey != null)
                    {
                        using (appRegKey)
                        {
                            var profilesRegKey = appRegKey.OpenSubKey(PROFILES_REGKEY, true);
                            if (profilesRegKey != null)
                            {
                                using (profilesRegKey)
                                {
                                    using (RegistryKey tempKey = profilesRegKey.OpenSubKey(profileName))
                                    {
                                        profile = new MtConnectionProfile(profileName);

                                        profile.Host = tempKey.GetValue(HOST_REGVALUE_NAME).ToString();
                                        profile.Port = (int)tempKey.GetValue(PORT_REGVALUE_NAME);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return profile;
        }
Exemplo n.º 12
0
        private static IEnumerable<MtConnectionProfile> LoadConnectionProfilesFromRegisty()
        {
            List<MtConnectionProfile> profiles = null;

            var softwareRegKey = Registry.CurrentUser.OpenSubKey(SOFTWARE, true);
            if (softwareRegKey != null)
            {
                using (softwareRegKey)
                {
                    var appRegKey = softwareRegKey.OpenSubKey(APP_NAME, true);
                    if (appRegKey != null)
                    {
                        using (appRegKey)
                        {
                            var profilesRegKey = appRegKey.OpenSubKey(PROFILES_REGKEY, true);
                            if (profilesRegKey != null)
                            {
                                using (profilesRegKey)
                                {
                                    profiles = new List<MtConnectionProfile>();

                                    foreach (string profileNameKey in profilesRegKey.GetSubKeyNames())
                                    {
                                        using (RegistryKey tempKey = profilesRegKey.OpenSubKey(profileNameKey))
                                        {
                                            var profile = new MtConnectionProfile(profileNameKey);

                                            profile.Host = tempKey.GetValue(HOST_REGVALUE_NAME).ToString();
                                            profile.Port = (int)tempKey.GetValue(PORT_REGVALUE_NAME);

                                            profiles.Add(profile);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return profiles;
        }