public object Clone() { ProfileKeys NewKeys = new ProfileKeys(); NewKeys._ToggleStereo = _ToggleStereo.Clone() as HotKey; NewKeys._IncreaseConvergence = _IncreaseConvergence.Clone() as HotKey; NewKeys._DecreaseConvergence = _DecreaseConvergence.Clone() as HotKey; NewKeys._IncreaseSeparation = _IncreaseSeparation.Clone() as HotKey; NewKeys._DecreaseSeparation = _DecreaseSeparation.Clone() as HotKey; NewKeys._Preset1 = _Preset1.Clone() as HotKey; NewKeys._Preset2 = _Preset2.Clone() as HotKey; NewKeys._Preset3 = _Preset3.Clone() as HotKey; NewKeys._SwapEyes = _SwapEyes.Clone() as HotKey; NewKeys._ToggleAutofocus = _ToggleAutofocus.Clone() as HotKey; NewKeys._ToggleLasersight = _ToggleLasersight.Clone() as HotKey; NewKeys._StereoScreenshot = _StereoScreenshot.Clone() as HotKey; NewKeys._ToggleWizard = _ToggleWizard.Clone() as HotKey; NewKeys._ToggleFPS = _ToggleFPS.Clone() as HotKey; NewKeys._ToggleHotkeysOSD = _ToggleHotkeysOSD.Clone() as HotKey; NewKeys._IncreasePresenterSleepTime = _IncreasePresenterSleepTime.Clone() as HotKey; NewKeys._DecreasePresenterSleepTime = _DecreasePresenterSleepTime.Clone() as HotKey; NewKeys._IncreasePresenterFlushTime = _IncreasePresenterFlushTime.Clone() as HotKey; NewKeys._DecreasePresenterFlushTime = _DecreasePresenterFlushTime.Clone() as HotKey; NewKeys._ShowDebugInfo = _ShowDebugInfo.Clone() as HotKey; NewKeys._IncreaseZNear = _IncreaseZNear.Clone() as HotKey; NewKeys._DecreaseZNear = _DecreaseZNear.Clone() as HotKey; NewKeys._IncreaseMultiplier = _IncreaseMultiplier.Clone() as HotKey; NewKeys._DecreaseMultiplier = _DecreaseMultiplier.Clone() as HotKey; NewKeys._IncreaseConvergenceShift = _IncreaseConvergenceShift.Clone() as HotKey; NewKeys._DecreaseConvergenceShift = _DecreaseConvergenceShift.Clone() as HotKey; return(NewKeys); }
private void ReadKeys(ProfileKeys profile, XmlReader reader) { reader.Skip(); while (reader.Read()) { if (reader.NodeType != XmlNodeType.Element) { continue; } ProfileValueAttribute attr = null; FieldInfo field = GetFieldInfo(reader.Name, typeof(ProfileKeys), out attr); Debug.Assert(field != null); if (field == null) { continue; } reader.MoveToAttribute(0); field.SetValue(profile, StringToValue(reader.Value, field.FieldType)); } }
private void SaveKeys(ProfileKeys profile, XmlNode node) { XmlNode InsideNode = FindNode(node.ChildNodes, "Keys"); ProfileKeys defaultKeys = DefaultProfile.Keys; bool bDefProfile = (profile == defaultKeys); Type type = typeof(ProfileKeys); foreach (FieldInfo field in type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)) { ProfileValueAttribute attr = null; if (ProfileValueAttribute.IsProfileKey(field, out attr)) { bool bSetValue = false; bool bRemoveValue = false; if (bDefProfile) { bSetValue = !attr.UserProfilesOnly; } else if (!attr.BaseProfileOnly) { bSetValue = !IsEqual(field.GetValue(profile), field.GetValue(defaultKeys)); bRemoveValue = true; } if (bSetValue) { SetKey(node, ref InsideNode, attr.Name, field.GetValue(profile)); } else if (bRemoveValue) { RemoveKey(InsideNode, attr.Name); } } } }
public void ApplyValues(Profile profile) { Type type = typeof(Profile); foreach (FieldInfo field in type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)) { ProfileValueAttribute attr = null; if (ProfileValueAttribute.IsProfileKey(field, out attr)) { object thisValue = field.GetValue(this); object defValue = field.GetValue(profile); //Debug.Assert(defValue == null); if (defValue != null && thisValue == null) { field.SetValue(this, defValue); } } } // PRESETS SECTION for (int i = 0; i < 3; i++) { if (i >= profile.Presets.Count) { break; } if (i >= _Presets.Count) { ProfilePreset preset = new ProfilePreset(); _Presets.Add(preset); } bool bDefPreset = (_Presets[i] == profile.Presets[i]); type = typeof(ProfilePreset); foreach (FieldInfo field in type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)) { ProfileValueAttribute attr = null; if (ProfileValueAttribute.IsProfileKey(field, out attr)) { object thisValue = field.GetValue(_Presets[i]); object defValue = field.GetValue(profile.Presets[i]); //Debug.Assert(defValue == null); if (defValue != null && thisValue == null) { field.SetValue(_Presets[i], defValue); } } } } // KEYS SECTION ProfileKeys defaultKeys = profile.Keys; bool bDefProfile = (profile.Keys == defaultKeys); type = typeof(ProfileKeys); foreach (FieldInfo field in type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)) { ProfileValueAttribute attr = null; if (ProfileValueAttribute.IsProfileKey(field, out attr)) { object thisValue = field.GetValue(Keys); object defValue = field.GetValue(defaultKeys); //Debug.Assert(defValue == null); if (defValue != null && thisValue == null) { field.SetValue(Keys, defValue); } } } }