/// <summary> /// Constructor. /// </summary> /// <param name="owner">Parent window.</param> /// <param name="proj">Disassembly project.</param> /// <param name="formatter">Text formatter.</param> /// <param name="curValue">Current value, or null if none set.</param> public EditDataBank(Window owner, DisasmProject proj, Formatter formatter, CodeAnalysis.DbrValue curValue) { InitializeComponent(); Owner = owner; DataContext = this; mProject = proj; mFormatter = formatter; PopulateComboBox(); DataBankStr = DbrValueToString(curValue); // sets combo box IsValid = true; }
private string DbrValueToString(CodeAnalysis.DbrValue value) { if (value == null) { return(string.Empty); } else if (value.FollowPbr) { return(PROG_BANK_STR); } else { return(mFormatter.FormatHexValue(value.Bank, 2)); } }
/// <summary> /// Creates an UndoableChange for a data bank register update. /// </summary> /// <param name="offset"></param> /// <param name="oldValue"></param> /// <param name="newValue"></param> /// <returns></returns> public static UndoableChange CreateDataBankChange(int offset, CodeAnalysis.DbrValue oldValue, CodeAnalysis.DbrValue newValue) { if (oldValue == newValue) { Debug.WriteLine("No-op DBR change at +" + offset.ToString("x6") + ": " + oldValue); } UndoableChange uc = new UndoableChange(); uc.Type = ChangeType.SetDataBank; uc.Offset = offset; uc.OldValue = oldValue; uc.NewValue = newValue; // We don't strictly need to re-analyze the code, since the current implementation // handles it as a post-analysis fixup, but this lets us avoid having to compute the // affected offsets. uc.ReanalysisRequired = ReanalysisScope.CodeAndData; return(uc); }
/// <summary> /// Sets the selected item in the combo box based on the value in the text edit box. /// </summary> private void SetComboBoxSelection(CodeAnalysis.DbrValue dbrVal) { mSettingComboBox = true; // recursion guard //CodeAnalysis.DbrValue dbrVal = StringToDbrValue(DataBankStr); int index = 0; if (dbrVal != null && !dbrVal.FollowPbr) { // skip first entry for (int i = 1; i < BankLabels.Count; i++) { if (BankLabels[i].Bank == dbrVal.Bank) { index = i; break; } } } bankCombo.SelectedIndex = index; mSettingComboBox = false; }
private void UpdateControls() { CodeAnalysis.DbrValue dbrVal = StringToDbrValue(DataBankStr); IsValid = (string.IsNullOrEmpty(DataBankStr) || dbrVal != null); SetComboBoxSelection(dbrVal); }