public override void OnApplyTemplate()
    {
      base.OnApplyTemplate();

      if( _calculatorPopup != null )
        _calculatorPopup.Opened -= CalculatorPopup_Opened;

      _calculatorPopup = GetTemplateChild( "PART_CalculatorPopup" ) as Popup;

      if( _calculatorPopup != null )
        _calculatorPopup.Opened += CalculatorPopup_Opened;

      _calculator = GetTemplateChild( "PART_Calculator" ) as Calculator;
    }
示例#2
0
    public override void OnApplyTemplate()
    {
      base.OnApplyTemplate();

      if( _calculatorPopup != null )
        _calculatorPopup.Opened -= CalculatorPopup_Opened;

      _calculatorPopup = GetTemplateChild( PART_CalculatorPopup ) as Popup;

      if( _calculatorPopup != null )
        _calculatorPopup.Opened += CalculatorPopup_Opened;

      if( _calculator != null )
        _calculator.ValueChanged -= OnCalculatorValueChanged;

      _calculator = GetTemplateChild( PART_Calculator ) as Calculator;

      if( _calculator != null )
        _calculator.ValueChanged += OnCalculatorValueChanged;
    }
    private void ProcessMemoryKey( Calculator.CalculatorButtonType buttonType )
    {
      decimal currentValue = CalculatorUtilities.ParseDecimal( DisplayText );

      switch( buttonType )
      {
        case Calculator.CalculatorButtonType.MAdd:
          Memory += currentValue;
          break;
        case Calculator.CalculatorButtonType.MC:
          Memory = decimal.Zero;
          break;
        case Calculator.CalculatorButtonType.MR:
          DisplayText = Memory.ToString();
          break;
        case Calculator.CalculatorButtonType.MS:
          Memory = currentValue;
          break;
        case Calculator.CalculatorButtonType.MSub:
          Memory -= currentValue;
          break;
        default:
          break;
      }

      _showNewNumber = true;
    }