예제 #1
0
        void MSetButton_Click(object sender, EventArgs e)
        {
            if (mSymbols == null)
            {
                mSymbols = new SymbolCollection();
            }

            string symbolName      = mSymbolNameTextBox.Text;
            long   symbolMagnitude = mSymbolValueTextBox.Magnitude;

            Word.Signs  symbolSign  = mSymbolValueTextBox.Sign;
            SymbolBase  symbol      = mSymbols[symbolName];
            ValueSymbol valueSymbol = null;

            if (symbol != null)
            {
                valueSymbol = symbol as ValueSymbol;
                if (valueSymbol == null)
                {
                    return;
                }

                valueSymbol.SetValue(symbolSign, symbolMagnitude);
                var valueText = symbolMagnitude.ToString();
                if (symbolSign.IsNegative())
                {
                    valueText = '-' + valueText;
                }

                mListView.Items[symbolName].SubItems[valueFieldIndex].Text = valueText;
            }
            else
            {
                valueSymbol = ValueSymbol.ParseDefinition(symbolName) as ValueSymbol;

                if (valueSymbol == null)
                {
                    return;
                }

                valueSymbol.SetValue(symbolSign, symbolMagnitude);

                mSymbols.Add(valueSymbol);
                ShowSymbol(valueSymbol);
            }

            SetEnabledStates();
        }
예제 #2
0
 static string GetName(Word.Signs literalSign, long literalMagnitude, int count) =>
 string.Concat("=", (literalSign.IsNegative() ? "-" : ""), literalMagnitude, '=', count);