private void LoadProfile(string profilePath, Holders.Holder h) { Profile loadedProfile = null; if (!string.IsNullOrWhiteSpace(profilePath) && File.Exists(profilePath)) { try { XmlSerializer serializer = new XmlSerializer(typeof(Profile)); using (FileStream stream = File.OpenRead(profilePath)) using (StreamReader reader = new StreamReader(stream)) { loadedProfile = serializer.Deserialize(reader) as Profile; reader.Close(); stream.Close(); } } catch { } } if (loadedProfile == null) { loadedProfile = UserPrefs.Instance.defaultProfile; } if (loadedProfile != null) { for (int i = 0; i < Math.Min(loadedProfile.controllerMapKeys.Count, loadedProfile.controllerMapValues.Count); i++) { h.SetMapping(loadedProfile.controllerMapKeys[i], loadedProfile.controllerMapValues[i]); CheckIR(loadedProfile.controllerMapKeys[i]); } } }
private void btnConfig_Click(object sender, RoutedEventArgs e) { var config = new ConfigWindow(holder.Mappings, device.Type); config.ShowDialog(); if (config.result) { foreach (KeyValuePair <string, string> pair in config.map) { holder.SetMapping(pair.Key, pair.Value); CheckIR(pair.Key); } } }