private void RefreshProfiles()
 {
     Task.Run(() =>
     {
         Profiles        = new ObservableCollection <string>(selectedInterface.GetProfiles());
         SelectedProfile = Profiles.FirstOrDefault(x => x.Equals(selectedInterface.ProfileName));
         NotifyPropertyChanged("Profiles");
     });
 }
Exemplo n.º 2
0
        public static void ReadFromFile(InterfaceModel interFace)
        {
            var dialog = new Microsoft.Win32.OpenFileDialog
            {
                DefaultExt      = ".xml",
                Filter          = Resources.ProfileInfoLoc.ExportFilter,
                CheckPathExists = true,
                AddExtension    = true,
                FileName        = Resources.ProfileInfoLoc.ExportDefaultFilename
            };

            if (!dialog.ShowDialog() ?? false)
            {
                return;
            }

            var reader = new System.Xml.Serialization.XmlSerializer(typeof(ProfileInfoExport));

            var importedProfiles = new ProfileInfoExport();

            try
            {
                if (System.IO.File.Exists(dialog.FileName))
                {
                    using (var file = new System.IO.StreamReader(dialog.FileName))
                    {
                        importedProfiles = (ProfileInfoExport)reader.Deserialize(file);
                    }
                }

                var existingProfiles = interFace.GetProfiles();
                foreach (var profile in importedProfiles.Profiles)
                {
                    if (!existingProfiles.Contains(profile.ProfileName))
                    {
                        interFace.interFace.SetProfile(profile.Flags, profile.Profile, false);
                    }
                }
            }
            catch (Exception ex)
            {
                Show.Message(string.Format(Resources.ProfileInfoLoc.ErrorImportingLocations, Environment.NewLine, dialog.FileName, ex.Message));
                return;
            }
        }