private FormattedSymbol CreateFormattedSymbol(DefSymbol defSym) { string typeStr; if (defSym.IsConstant) { typeStr = Res.Strings.ABBREV_CONSTANT; } else { typeStr = Res.Strings.ABBREV_ADDRESS; if (defSym.Direction == DefSymbol.DirectionFlags.Read) { typeStr += "<"; } else if (defSym.Direction == DefSymbol.DirectionFlags.Write) { typeStr += ">"; } } FormattedSymbol fsym = new FormattedSymbol( defSym, defSym.GenerateDisplayLabel(mFormatter), mFormatter.FormatValueInBase(defSym.Value, defSym.DataDescriptor.NumBase), typeStr, defSym.HasWidth ? defSym.DataDescriptor.Length.ToString() : NO_WIDTH_STR, defSym.Comment); return(fsym); }
private void RemoveSymbolButton_Click(object sender, RoutedEventArgs e) { // Single-select list view, button dimmed when no selection. Debug.Assert(symbolsList.SelectedItems.Count == 1); int selectionIndex = symbolsList.SelectedIndex; FormattedSymbol item = (FormattedSymbol)symbolsList.SelectedItems[0]; DefSymbol defSym = item.DefSym; mWorkTable.RemoveByLabel(defSym.Label); for (int i = 0; i < Variables.Count; i++) { if (Variables[i].DefSym == defSym) { Variables.RemoveAt(i); break; } } UpdateControls(); // Restore selection to the item that used to come after the one we just deleted, // so you can hit "Remove" repeatedly to delete multiple items. int newCount = symbolsList.Items.Count; if (selectionIndex >= newCount) { selectionIndex = newCount - 1; } if (selectionIndex >= 0) { symbolsList.SelectedIndex = selectionIndex; removeSymbolButton.Focus(); // so you can keep banging on Enter } }
private void EditSymbolButton_Click(object sender, EventArgs e) { // Single-select list view, button dimmed when no selection. Debug.Assert(projectSymbolsList.SelectedItems.Count == 1); FormattedSymbol item = (FormattedSymbol)projectSymbolsList.SelectedItems[0]; DoEditSymbol(item.DefSym); }
private void EditSymbolButton_Click(object sender, EventArgs e) { // Single-select list view, button dimmed when no selection. Debug.Assert(symbolsList.SelectedItems.Count == 1); FormattedSymbol item = (FormattedSymbol)symbolsList.SelectedItems[0]; DefSymbol defSym = mWorkTable.GetByLabel(item.Label); Debug.Assert(defSym != null); DoEditSymbol(defSym); }
private void ProjectSymbolsList_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (!projectSymbolsList.GetClickRowColItem(e, out int unusedRow, out int unusedCol, out object objItem)) { // Header or empty area; ignore. return; } FormattedSymbol item = (FormattedSymbol)objItem; DoEditSymbol(item.DefSym); }
// IComparer interface public int Compare(object o1, object o2) { FormattedSymbol fsym1 = (FormattedSymbol)o1; FormattedSymbol fsym2 = (FormattedSymbol)o2; // Sort primarily by specified field, secondarily by label (which should // be unique). int cmp; switch (mSortField) { case SortField.Label: cmp = string.Compare(fsym1.Label, fsym2.Label); break; case SortField.Value: cmp = fsym1.DefSym.Value - fsym2.DefSym.Value; break; case SortField.Type: cmp = string.Compare(fsym1.Type, fsym2.Type); break; case SortField.Width: cmp = fsym1.Width - fsym2.Width; break; case SortField.Comment: cmp = string.Compare(fsym1.Comment, fsym2.Comment); break; default: Debug.Assert(false); return(0); } if (cmp == 0) { cmp = string.Compare(fsym1.Label, fsym2.Label); } if (!mIsAscending) { cmp = -cmp; } return(cmp); }
private void NewSymbolButton_Click(object sender, RoutedEventArgs e) { EditDefSymbol dlg = new EditDefSymbol(this, mFormatter, mWorkTable.GetSortedByLabel(), null, mSymbolTable, true, false); dlg.ShowDialog(); if (dlg.DialogResult == true) { Debug.WriteLine("ADD: " + dlg.NewSym); mWorkTable.AddOrReplace(dlg.NewSym); // Add it to the display list, select it, and scroll it into view. FormattedSymbol newItem = CreateFormattedSymbol(dlg.NewSym); Variables.Add(newItem); symbolsList.SelectedItem = newItem; symbolsList.ScrollIntoView(newItem); UpdateControls(); } }
private void NewSymbolButton_Click(object sender, RoutedEventArgs e) { EditDefSymbol dlg = new EditDefSymbol(this, mFormatter, mWorkProps.ProjectSyms, null, null, null); dlg.ShowDialog(); if (dlg.DialogResult == true) { Debug.WriteLine("ADD: " + dlg.NewSym); mWorkProps.ProjectSyms[dlg.NewSym.Label] = dlg.NewSym; IsDirty = true; FormattedSymbol newItem = CreateFormattedSymbol(dlg.NewSym); ProjectSymbols.Add(newItem); projectSymbolsList.SelectedItem = newItem; projectSymbolsList.ScrollIntoView(newItem); UpdateControls(); okButton.Focus(); } }
/// <summary> /// Loads entries from the work table into the items source. /// </summary> private FormattedSymbol CreateFormattedSymbol(DefSymbol defSym) { string typeStr; if (defSym.IsConstant) { typeStr = Res.Strings.ABBREV_STACK_RELATIVE; } else { typeStr = Res.Strings.ABBREV_ADDRESS; } FormattedSymbol fsym = new FormattedSymbol( defSym, defSym.GenerateDisplayLabel(mFormatter), mFormatter.FormatValueInBase(defSym.Value, defSym.DataDescriptor.NumBase), typeStr, defSym.DataDescriptor.Length, defSym.Comment); return(fsym); }
private void RemoveSymbolButton_Click(object sender, RoutedEventArgs e) { // Single-select list view, button dimmed when no selection. Debug.Assert(projectSymbolsList.SelectedItems.Count == 1); int selectionIndex = projectSymbolsList.SelectedIndex; FormattedSymbol item = (FormattedSymbol)projectSymbolsList.SelectedItems[0]; DefSymbol defSym = item.DefSym; mWorkProps.ProjectSyms.Remove(defSym.Label); IsDirty = true; for (int i = 0; i < ProjectSymbols.Count; i++) { if (ProjectSymbols[i].DefSym == defSym) { ProjectSymbols.RemoveAt(i); break; } } UpdateControls(); // Restore selection to the item that used to come after the one we just deleted, // so you can hit "Remove" repeatedly to delete multiple items. int newCount = projectSymbolsList.Items.Count; if (selectionIndex >= newCount) { selectionIndex = newCount - 1; } if (selectionIndex >= 0) { projectSymbolsList.SelectedIndex = selectionIndex; removeSymbolButton.Focus(); } }
// IComparer interface public int Compare(object o1, object o2) { FormattedSymbol fsym1 = (FormattedSymbol)o1; FormattedSymbol fsym2 = (FormattedSymbol)o2; // Sort primarily by specified field, secondarily by label (which should // be unique). int cmp; switch (mSortField) { case SortField.Label: cmp = string.Compare(fsym1.Label, fsym2.Label); break; case SortField.Value: cmp = fsym1.DefSym.Value - fsym2.DefSym.Value; break; case SortField.Type: cmp = string.Compare(fsym1.Type, fsym2.Type); break; case SortField.Width: // The no-width case is a little weird, because the actual width will // be 1, but we want it to sort separately. if (fsym1.Width == fsym2.Width) { cmp = 0; } else if (fsym1.Width == NO_WIDTH_STR) { cmp = -1; } else if (fsym2.Width == NO_WIDTH_STR) { cmp = 1; } else { cmp = fsym1.DefSym.DataDescriptor.Length - fsym2.DefSym.DataDescriptor.Length; } break; case SortField.Comment: cmp = string.Compare(fsym1.Comment, fsym2.Comment); break; default: Debug.Assert(false); return(0); } if (cmp == 0) { cmp = string.Compare(fsym1.Label, fsym2.Label); } if (!mIsAscending) { cmp = -cmp; } return(cmp); }