private void Save() { this.SaveOutput = true; var lay = MdSessionData.CurrentLayout; var dataCont = new TapDanceDataContainer(); var hasData = false; foreach (var ele in lay.AddonDatas) { if (ele.GetType() == TapDanceDataContainer.DATA_TYPE) { hasData = true; dataCont = ele as TapDanceDataContainer; } } if (!hasData) { lay.AddonDatas.Add(dataCont); } var data = this.Data; hasData = false; var oldDataIndex = 0; if (dataCont != null) { foreach (var ele in dataCont.TapDanceKeys) { if (ele.Index == this.Data.Index) { hasData = true; break; } oldDataIndex++; } if (hasData) { dataCont.TapDanceKeys[oldDataIndex] = data; } else { dataCont.TapDanceKeys.Add(data); } } MdSessionData.CurrentKeyboardUI.DisplayUnsavedChangeSignal(); Close(); }
private void OpenTapDanceMenu() { var lst = new List <string> { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19" }; var fm = new FmSelectTextDialog(lst, lst.Select(ele => "TapDance" + ele).ToList(), "Select a tap dance key to edit"); fm.ShowModal(); var outputInd = fm.OutputIndex; if (outputInd >= 0) { if (!MdSessionData.OpenedTapDanceEdit) { if (MdSessionData.CurrentLayout.KeyDatas.Count == 0) { MessageBox.Show("Error: You must first select a device"); } else { MdSessionData.OpenedTapDanceEdit = true; var lay = MdSessionData.CurrentLayout; var dataCont = new TapDanceDataContainer(); var hasData = false; foreach (var ele in lay.AddonDatas) { if (ele.GetType() == TapDanceDataContainer.DATA_TYPE) { hasData = true; dataCont = ele as TapDanceDataContainer; } } if (!hasData) { lay.AddonDatas.Add(dataCont); } var data = new TapDanceData(); data.Index = outputInd; hasData = false; if (dataCont != null) { foreach (var ele in dataCont.TapDanceKeys) { if (ele.Index == outputInd) { hasData = true; data = ele; } } if (!hasData) { dataCont.TapDanceKeys.Add(data); } } var mdialog = new FmTapDanceEdit(new TapDanceData(data)); mdialog.Show(); } } else { MessageBox.Show("Error: Tap dance editor already opened"); } } }