public CalcViewModel() { Model = new CalcModel(); tempNumber = 0; lastOperation = LastOperation.None; bNewEntry = false; }
public void PerformCalculations() { //Reset Reset = true; //Add double value = Double.Parse(ResultLabel.Content.ToString()); if (LastOperation.CompareTo(Flag.Add) == 0) { //Perform math on the total based off the value coming in. Using the Cache. Total += value; Console.WriteLine(Total); //return the Operation to Default Operation = Flag.Default; //Show the total on display ResultLabel.Content = Total.ToString(); } //Subtract else if (LastOperation.CompareTo(Flag.Subtract) == 0) { //Perform math on the total based off the value coming in. Using the Cache. Total -= value; //return the Operation to Default Operation = Flag.Default; //Show the total on display ResultLabel.Content = Total.ToString(); } //Divide else if (LastOperation.CompareTo(Flag.Divide) == 0) { //Perform math on the total based off the value coming in. Using the Cache. Total /= value; //return the Operation to Default Operation = Flag.Default; //Show the total on display ResultLabel.Content = Total.ToString(); } //Multiply else if (LastOperation.CompareTo(Flag.Multiply) == 0) { //Perform math on the total based off the value coming in. Using the Cache. Total *= value; //return the Operation to Default Operation = Flag.Default; //Show the total on display ResultLabel.Content = Total.ToString(); } //Modulo else if (LastOperation.CompareTo(Flag.Modulo) == 0) { //Perform math on the total based off the value coming in. Using the Cache. Total %= value; //return the Operation to Default Operation = Flag.Default; //Show the total on display ResultLabel.Content = Total.ToString(); } }
public AirthmeticViewModel() { Model = new AirthmeticModel(); tempNumber = 0; lastOperation = LastOperation.None; bNewEntry = false; InitializeCommand(); }
public void clearAll() { Model.Number = 0; updateNumber = 0; tempNumber = 0; bNewEntry = false; lastOperation = LastOperation.None; }
public void OnDivideCommand() { if (lastOperation == LastOperation.Divide) { double sum = tempNumber / updateNumber; clear(); updateNumber = sum; } tempNumber = updateNumber; bNewEntry = true; lastOperation = LastOperation.Divide; }
public void OnMultiplyCommand() { if (lastOperation == LastOperation.Multiply) { double sum = tempNumber * updateNumber; clear(); updateNumber = sum; } tempNumber = updateNumber; bNewEntry = true; lastOperation = LastOperation.Multiply; }
public void OnSubtractCommand() { if (lastOperation == LastOperation.Subtract) { double sum = tempNumber - updateNumber; clear(); updateNumber = sum; } tempNumber = updateNumber; bNewEntry = true; lastOperation = LastOperation.Subtract; }
public void Divide() { if (lastOperation == LastOperation.Divide) { double sum = Model.Divide(tempNumber, updateNumber); clear(); updateNumber = sum; } tempNumber = updateNumber; bNewEntry = true; lastOperation = LastOperation.Divide; }
public void Multiply() { if (lastOperation == LastOperation.Multiply) { double sum = Model.Multiply(tempNumber, updateNumber); clear(); updateNumber = sum; } tempNumber = updateNumber; bNewEntry = true; lastOperation = LastOperation.Multiply; }
public void subtract() { if (lastOperation == LastOperation.Subtract) { double sum = Model.subtract(tempNumber, updateNumber); clear(); updateNumber = sum; } tempNumber = updateNumber; bNewEntry = true; lastOperation = LastOperation.Subtract; }
public void OnAddCommand() { if (lastOperation == LastOperation.Add) { double sum = updateNumber + tempNumber; clear(); updateNumber = sum; } tempNumber = updateNumber; bNewEntry = true; lastOperation = LastOperation.Add; }
public void add() { if (lastOperation == LastOperation.Add) { double sum = Model.add(updateNumber, tempNumber); clear(); updateNumber = sum; } tempNumber = updateNumber; bNewEntry = true; lastOperation = LastOperation.Add; }
public string Statement() { StringBuilder sb = new StringBuilder(); sb.AppendLine($"====== Account no. {AccountNumber} ({BankName}) ======"); sb.AppendLine($"Balance: {Balance}\t\tLast Operation: {LastOperation.ToString("yyyy-MM-dd")}"); sb.AppendLine("======================================================="); sb.AppendLine("== MOVEMENTS =========================================="); foreach (IMovement movement in _movements.OrderBy(m => m.IssueDate)) { sb.AppendLine(movement.ToString()); } sb.AppendLine("======================================================="); return(sb.ToString()); }
public void equal() { if (lastOperation == LastOperation.Add) { OnAddCommand(); } else if (lastOperation == LastOperation.Multiply) { OnMultiplyCommand(); } else if (lastOperation == LastOperation.Divide) { OnDivideCommand(); } else if (lastOperation == LastOperation.Subtract) { OnSubtractCommand(); } lastOperation = LastOperation.None; }
public void equal() { if (lastOperation == LastOperation.Add) { add(); } else if (lastOperation == LastOperation.Multiply) { Multiply(); } else if (lastOperation == LastOperation.Divide) { Divide(); } else if (lastOperation == LastOperation.Subtract) { subtract(); } lastOperation = LastOperation.None; }
// Arrange the Adorners. protected override Size ArrangeOverride(Size finalSize) { // desiredWidth and desiredHeight are the width and height of the element that's being adorned. // These will be used to place the ResizingAdorner at the corners of the adorned element. var bbb = CurrentEditor.GetMoleculeBoundingBox(AdornedMolecules); if (LastOperation != null) { bbb = LastOperation.TransformBounds(bbb); } TopLeftHandle.Arrange(new Rect(bbb.Left - _halfThumbWidth, bbb.Top - _halfThumbWidth, _thumbWidth.Value, _thumbWidth.Value)); TopRightHandle.Arrange(new Rect(bbb.Left + bbb.Width - _halfThumbWidth, bbb.Top - _halfThumbWidth, _thumbWidth.Value, _thumbWidth.Value)); BottomLeftHandle.Arrange(new Rect(bbb.Left - _halfThumbWidth, bbb.Top + bbb.Height - _halfThumbWidth, _thumbWidth.Value, _thumbWidth.Value)); BottomRightHandle.Arrange(new Rect(bbb.Left + bbb.Width - _halfThumbWidth, bbb.Height + bbb.Top - _halfThumbWidth, _thumbWidth.Value, _thumbWidth.Value)); //add the rotator _xPlacement = (bbb.Left + bbb.Right) / 2; _yPlacement = bbb.Top - RotateHandle.Height * 3; _rotateThumbPos = new Point(_xPlacement, _yPlacement); if (BigThumb.IsDragging || TopLeftHandle.IsDragging || TopRightHandle.IsDragging || BottomLeftHandle.IsDragging || BottomRightHandle.IsDragging) { RotateHandle.Visibility = Visibility.Hidden; } else { RotateHandle.Visibility = Visibility.Visible; SetCentroid(); } if (Rotating && LastOperation != null) { _rotateThumbPos = LastOperation.Transform(_rotateThumbPos); } Vector rotateThumbTweak = new Vector(-RotateHandle.Width / 2, -RotateHandle.Height / 2); Point newLoc = _rotateThumbPos + rotateThumbTweak; if (Rotating && LastOperation != null) { TopLeftHandle.Visibility = Visibility.Collapsed; TopRightHandle.Visibility = Visibility.Collapsed; BottomLeftHandle.Visibility = Visibility.Collapsed; BottomRightHandle.Visibility = Visibility.Collapsed; BigThumb.Visibility = Visibility.Collapsed; } else { TopLeftHandle.Visibility = Visibility.Visible; TopRightHandle.Visibility = Visibility.Visible; BottomLeftHandle.Visibility = Visibility.Visible; BottomRightHandle.Visibility = Visibility.Visible; BigThumb.Visibility = Visibility.Visible; } RotateHandle.Arrange(new Rect(newLoc.X, newLoc.Y, RotateHandle.Width, RotateHandle.Height)); base.ArrangeOverride(finalSize); return(finalSize); }