private void FormatOptionMenu_Click(object sender, EventArgs e) { ToolStripMenuItem menuItem = sender as ToolStripMenuItem; if (menuItem == null) { return; } SqlFormatOption checkedFormatOption = menuItem.Tag as SqlFormatOption; if (checkedFormatOption == null) { return; } if (checkedFormatOption.Childs.Any(c => c.IsRadio)) { DisableChildItems(menuItem); } if (checkedFormatOption.IsRadio) { HandleRadioCheckItem(menuItem); } checkedFormatOption.IsChecked = menuItem.Checked; sqlFormatter.QueuePendingChanges(checkedFormatOption); }
internal void QueuePendingChanges(SqlFormatOption checkedFormatOption) { JObject formatValueObject = new JObject(); if (checkedFormatOption.IsCheckable) { formatValueObject.Add(checkedFormatOption.Id, checkedFormatOption.IsChecked); AddPendingOptionChange(formatValueObject); } else { JObject radioFormatValueObject = new JObject(); radioFormatValueObject.Add(checkedFormatOption.FormatOptionType, checkedFormatOption.FormatOptionValue); formatValueObject.Add(checkedFormatOption.FormatOptionId, radioFormatValueObject); AddPendingOptionChange(formatValueObject); } }
internal void FindUserOptionChanges() { JToken optionDifferences = new JsonDiffPatch().Diff(JArray.FromObject(defaultFormatOptions), JArray.FromObject(UserFormatOptions)); List <string> changes = new List <string>(); GetChangedOptionPositions(optionDifferences?.Skip(1).First(), changes); foreach (var change in changes) { Queue <int> parts = new Queue <int>(change.Split('_').Select(c => int.Parse(c))); SqlFormatOption currentFormatOption = UserFormatOptions[parts.Dequeue()]; while (parts.Count > 0) { int level = parts.Dequeue(); currentFormatOption = currentFormatOption.Childs[level]; } QueuePendingChanges(currentFormatOption); } }