public string DeleteSetting(Setting s) { var db = new x360ceModelContainer(); var setting = db.Settings.FirstOrDefault(x => x.InstanceGuid == s.InstanceGuid && x.FileName == s.FileName && x.FileProductName == s.FileProductName); if (setting == null) return "Setting not found"; db.Settings.DeleteObject(setting); db.SaveChanges(); return ""; }
/// <summary> /// Read PAD settings from INI file. /// </summary> /// <param name="padSectionName">INI section.</param> /// <param name="s">Settings.</param> /// <param name="p">PAD Settings.</param> /// <remarks>use 'ref' to indicate that objects will be updated inside.</remarks> void ReadWritePadSettings(string padSectionName, ref Setting s, ref PadSetting p, bool write) { s = new Setting(); p = new PadSetting(); // Get PAD1 settings data as a reference. var items = SettingsMap.Where(x => x.MapTo == MapTo.Controller1).ToArray(); var sProps = s.GetType().GetProperties(); var pProps = p.GetType().GetProperties(); var ini2 = new Ini(IniFileName); foreach (var item in items) { string key = item.IniPath.Split('\\')[1]; // Try to find property inside Settings object. var sProp = sProps.FirstOrDefault(x => x.Name == item.PropertyName); if (sProp != null) { if (write) { var sv = (string)sProp.GetValue(s, null) ?? ""; // Write value to INI file. ini2.SetValue(padSectionName, key, sv); } else { // Read value from INI file. var sv = ini2.GetValue(padSectionName, key) ?? ""; sProp.SetValue(s, sv, null); } continue; } // Try to find property inside PAD Settings object. var pProp = pProps.FirstOrDefault(x => x.Name == item.PropertyName); if (pProp != null) { if (write) { var pv = (string)pProp.GetValue(p, null) ?? ""; // Write value to INI file. ini2.SetValue(padSectionName, key, pv); } else { // Read value from INI file. var pv = ini2.GetValue(padSectionName, key) ?? ""; sProp.SetValue(s, pv, null); } continue; } // Property was not found. var message = string.Format("ReadWritePadSettings: Property '{0}' was not found", item.PropertyName); // Inform developer with the message. MessageBoxForm.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Create a new Setting object. /// </summary> /// <param name="settingId">Initial value of the SettingId property.</param> /// <param name="instanceGuid">Initial value of the InstanceGuid property.</param> /// <param name="instanceName">Initial value of the InstanceName property.</param> /// <param name="productGuid">Initial value of the ProductGuid property.</param> /// <param name="productName">Initial value of the ProductName property.</param> /// <param name="deviceType">Initial value of the DeviceType property.</param> /// <param name="fileName">Initial value of the FileName property.</param> /// <param name="fileProductName">Initial value of the FileProductName property.</param> /// <param name="comment">Initial value of the Comment property.</param> /// <param name="dateCreated">Initial value of the DateCreated property.</param> /// <param name="dateUpdated">Initial value of the DateUpdated property.</param> /// <param name="isEnabled">Initial value of the IsEnabled property.</param> /// <param name="padSettingChecksum">Initial value of the PadSettingChecksum property.</param> /// <param name="dateSelected">Initial value of the DateSelected property.</param> public static Setting CreateSetting(global::System.Guid settingId, global::System.Guid instanceGuid, global::System.String instanceName, global::System.Guid productGuid, global::System.String productName, global::System.Int32 deviceType, global::System.String fileName, global::System.String fileProductName, global::System.String comment, global::System.DateTime dateCreated, global::System.DateTime dateUpdated, global::System.Boolean isEnabled, global::System.Guid padSettingChecksum, global::System.DateTime dateSelected) { Setting setting = new Setting(); setting.SettingId = settingId; setting.InstanceGuid = instanceGuid; setting.InstanceName = instanceName; setting.ProductGuid = productGuid; setting.ProductName = productName; setting.DeviceType = deviceType; setting.FileName = fileName; setting.FileProductName = fileProductName; setting.Comment = comment; setting.DateCreated = dateCreated; setting.DateUpdated = dateUpdated; setting.IsEnabled = isEnabled; setting.PadSettingChecksum = padSettingChecksum; setting.DateSelected = dateSelected; return setting; }
/// <summary> /// Deprecated Method for adding a new object to the Settings EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToSettings(Setting setting) { base.AddObject("Settings", setting); }
public string SaveSetting(Setting s, PadSetting ps) { var checksum = ps.GetCheckSum(); var db = new x360ceModelContainer(); var s1 = db.Settings.FirstOrDefault(x => x.InstanceGuid == s.InstanceGuid && x.FileName == s.FileName && x.FileProductName == s.FileProductName); var n = DateTime.Now; if (s1 == null) { s1 = new Setting(); s1.SettingId = Guid.NewGuid(); s1.DateCreated = n; db.Settings.AddObject(s1); } s1.Comment = s.Comment; s1.DateUpdated = n; s1.DateSelected = n; s1.DeviceType = s.DeviceType; s1.FileName = s.FileName; s1.FileProductName = s.FileProductName; s1.InstanceGuid = s.InstanceGuid; s1.InstanceName = s.InstanceName; s1.ProductGuid = s.ProductGuid; s1.ProductName = s.ProductName; s1.IsEnabled = s.IsEnabled; s1.PadSettingChecksum = checksum; // Save Pad Settings. var p1 = db.PadSettings.FirstOrDefault(x => x.PadSettingChecksum == checksum); if (p1 == null) { p1 = new PadSetting(); p1.PadSettingChecksum = checksum; db.PadSettings.AddObject(p1); } p1.AxisToDPadDeadZone = ps.AxisToDPadDeadZone; p1.AxisToDPadEnabled = ps.AxisToDPadEnabled; p1.AxisToDPadOffset = ps.AxisToDPadOffset; p1.ButtonA = ps.ButtonA; p1.ButtonB = ps.ButtonB; p1.ButtonBig = string.IsNullOrEmpty(ps.ButtonBig) ? "" : ps.ButtonBig; p1.ButtonGuide = string.IsNullOrEmpty(ps.ButtonGuide) ? "" : ps.ButtonGuide; p1.ButtonBack = ps.ButtonBack; p1.ButtonStart = ps.ButtonStart; p1.ButtonX = ps.ButtonX; p1.ButtonY = ps.ButtonY; p1.DPad = ps.DPad; p1.DPadDown = ps.DPadDown; p1.DPadLeft = ps.DPadLeft; p1.DPadRight = ps.DPadRight; p1.DPadUp = ps.DPadUp; p1.ForceEnable = ps.ForceEnable; p1.ForceOverall = ps.ForceOverall; p1.ForceSwapMotor = ps.ForceSwapMotor; p1.ForceType = ps.ForceType; p1.GamePadType = ps.GamePadType; p1.LeftMotorPeriod = ps.LeftMotorPeriod; p1.LeftMotorStrength = string.IsNullOrEmpty(ps.LeftMotorStrength) ? "100" : ps.LeftMotorStrength; p1.LeftShoulder = ps.LeftShoulder; p1.LeftThumbAntiDeadZoneX = ps.LeftThumbAntiDeadZoneX; p1.LeftThumbAntiDeadZoneY = ps.LeftThumbAntiDeadZoneY; p1.LeftThumbAxisX = ps.LeftThumbAxisX; p1.LeftThumbAxisY = ps.LeftThumbAxisY; p1.LeftThumbButton = ps.LeftThumbButton; p1.LeftThumbDeadZoneX = ps.LeftThumbDeadZoneX; p1.LeftThumbDeadZoneY = ps.LeftThumbDeadZoneY; p1.LeftThumbLinearX = string.IsNullOrEmpty(ps.LeftThumbLinearX) ? "" : ps.LeftThumbLinearX; p1.LeftThumbLinearY = string.IsNullOrEmpty(ps.LeftThumbLinearY) ? "" : ps.LeftThumbLinearY; p1.LeftThumbDown = ps.LeftThumbDown; p1.LeftThumbLeft = ps.LeftThumbLeft; p1.LeftThumbRight = ps.LeftThumbRight; p1.LeftThumbUp = ps.LeftThumbUp; p1.LeftTrigger = ps.LeftTrigger; p1.LeftTriggerDeadZone = ps.LeftTriggerDeadZone; p1.PassThrough = ps.PassThrough; p1.RightMotorPeriod = ps.RightMotorPeriod; p1.RightMotorStrength = string.IsNullOrEmpty(ps.RightMotorStrength) ? "100" : ps.RightMotorStrength; p1.RightShoulder = ps.RightShoulder; p1.RightThumbAntiDeadZoneX = ps.RightThumbAntiDeadZoneX; p1.RightThumbAntiDeadZoneY = ps.RightThumbAntiDeadZoneY; p1.RightThumbLinearX = string.IsNullOrEmpty(ps.RightThumbLinearX) ? "" : ps.RightThumbLinearX; p1.RightThumbLinearY = string.IsNullOrEmpty(ps.RightThumbLinearY) ? "" : ps.RightThumbLinearY; p1.RightThumbAxisX = ps.RightThumbAxisX; p1.RightThumbAxisY = ps.RightThumbAxisY; p1.RightThumbButton = ps.RightThumbButton; p1.RightThumbDeadZoneX = ps.RightThumbDeadZoneX; p1.RightThumbDeadZoneY = ps.RightThumbDeadZoneY; p1.RightThumbDown = ps.RightThumbDown; p1.RightThumbLeft = ps.RightThumbLeft; p1.RightThumbRight = ps.RightThumbRight; p1.RightThumbUp = ps.RightThumbUp; p1.RightTrigger = ps.RightTrigger; p1.RightTriggerDeadZone = ps.RightTriggerDeadZone; db.SaveChanges(); db.Dispose(); db = null; return ""; }
public void DeleteSettingAsync(Setting s, object userState = null) { InvokeAsync("DeleteSetting", DeleteSettingCompleted, userState, new object[] { s }); }
public string DeleteSetting(Setting s) { object[] results = Invoke("DeleteSetting", new object[] { s }); return (string)results[0]; }
public void SaveSettingAsync(Setting s, PadSetting ps, object userState = null) { InvokeAsync("SaveSetting", SaveSettingCompleted, userState, new object[] { s, ps }); }
public string SaveSetting(Setting s, PadSetting ps) { object[] results = Invoke("SaveSetting", new object[] { s, ps }); return (string)results[0]; }
void SettingsDataGridView_SelectionChanged(object sender, EventArgs e) { var grid = (DataGridView)sender; var rows = grid.SelectedRows; SettingSelection = rows.Count == 0 ? null : (Setting)rows[0].DataBoundItem; CommentSelectedTextBox.Text = rows.Count == 0 ? "" : SettingSelection.Comment; //UpdateActionButtons(); grid.Refresh(); }
//Setting CurrentSetting; //bool refreshed = false; //void UpdateActionButtons() //{ // var settingsSelected = MyDevicesDataGridView.SelectedRows.Count; // var controllerSelected = ControllerComboBox.Items.Count > 0; // MySettingsLoadButton.Enabled = controllerSelected && settingsSelected > 0; // GlobalSettingsLoadButton.Enabled = controllerSelected && SummariesDataGridView.SelectedRows.Count > 0; // CurrentSetting = GetCurrentSetting(); // MySettingsSaveButton.Enabled = controllerSelected && refreshed; // MySettingsSaveButton.Image = ContainsSetting(CurrentSetting) // ? Properties.Resources.save_16x16 // : Properties.Resources.save_add_16x16; // MySettingsDeleteButton.Enabled = settingsSelected == 1; // MapToDropDownButton.Enabled = settingsSelected > 0; // MyDevicesDataGridView.Refresh(); //} bool ContainsSetting(Setting setting) { for (int i = 0; i < SettingManager.Settings.Items.Count; i++) { var s = SettingManager.Settings.Items[i]; if (setting.InstanceGuid == s.InstanceGuid && setting.FileName == s.FileName && setting.FileProductName == s.FileProductName) { return true; } } return false; }
/// <summary> /// Read PAD settings from INI file. /// </summary> /// <param name="padSectionName">INI section.</param> /// <param name="s">Settings.</param> /// <param name="p">PAD Settings.</param> public void ReadPadSettingsFromIni(string padSectionName, out Setting s, out PadSetting p) { s = new Setting(); p = new PadSetting(); ReadWritePadSettings(padSectionName, ref s, ref p, false); }
/// <summary> /// Write PAD settings to INI file. /// </summary> /// <param name="padSectionName">INI section.</param> /// <param name="s">Settings.</param> /// <param name="p">PAD Settings.</param> public void WritePadSettingsToIni(string padSectionName, Setting s, PadSetting p) { ReadWritePadSettings(padSectionName, ref s, ref p, true); }