コード例 #1
0
        public void LoadLoginInfo()
        {
            file = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Singleton<ApplicationViewModel>.Instance.ApplicationName, "Profile.config");
            if (File.Exists(file))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(Profile));
                FileStream fs = File.OpenRead(file);
                try
                {
                    profile = serializer.Deserialize(fs) as Profile;
                }
                catch { }
                finally
                {
                    fs.Close();
                }
            }
            if (profile == null)
            {
                profile = CreateDefaultProfile();
            }

            loginEntryVMs.SetValue(new System.Collections.ObjectModel.ObservableCollection<LoginEntryViewModel>());
            foreach (var login in profile.LoginEntries)
            {
                LoginEntryVMs.Add(new LoginEntryViewModel(login));
            }
            if (profile.LastLoginEntry != null)
            {
                LastLoginVM = new LoginEntryViewModel(profile.LastLoginEntry);
            }
            foreach (var login in LoginEntryVMs)
            {
                login.Initialize();
            }
            if (LastLoginVM != null)
            {
                LastLoginVM.Initialize();
            }
        }
コード例 #2
0
        public void Load()
        {
            if (File.Exists(file))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(Profile));
                FileStream fs = File.OpenRead(file);
                try
                {
                    profile = serializer.Deserialize(fs) as Profile;
                }
                catch { }
                finally
                {
                    fs.Close();
                }
            }
            if (profile == null)
            {
                profile = CreateDefaultProfile();
            }

            loginEntryVMs.SetValue(new System.Collections.ObjectModel.ObservableCollection<LoginEntryViewModel>());
            foreach (var login in profile.LoginEntries)
            {
                LoginEntryVMs.Add(new LoginEntryViewModel(login));
            }
            if (profile.LastLoginEntry != null)
            {
                LastLoginVM = new LoginEntryViewModel(profile.LastLoginEntry);
            }
            videoConfigurationVM.SetValue(new VideoConfigurationViewModel(profile.VideoConfiguration));
            audioConfigurationVM.SetValue(new AudioConfigurationViewModel(profile.AudioConfiguration));
            personalInfoConfigurationVM.SetValue(new PersonalInfoConfigurationViewModel(profile.PersonalInfoConfiguration));
            photoSelectorVM.SetValue(new PhotoSelectorViewModel(profile.PhotoSelectorConfiguration));
            securityConfigurationVM.SetValue(new SecurityConfigurationViewModel(profile.SecurityConfiguration));
            SecurityConfigurationVM.AutoLogin = profile.AutoLogin;
            autoLogin.SetValue(profile.AutoLogin);
        }