private void UpdateCurrentResult (ConsequenceResult result) { try { CurrentResult = result; this.NavigationItem.Title = result.Request.Summary; this.calculatedAmount.Text = result.ComputedValue.ToString (); this.caption.Text = result.FormattedCaption; this.editCaption.Text = result.Calculator.Caption; UIImage image = ArtRepository.GetImage (result.Image); if (image != null && image != iconView.Image) iconView.Image = image; if (result.Calculator.IsUserEditable) this.NavigationItem.SetRightBarButtonItem(EditButton,false); else if (this.NavigationItem.RightBarButtonItem != null) this.NavigationItem.SetRightBarButtonItem(null,false); } catch (Exception ex) { Console.WriteLine (string.Format ("{0} thrown when updating current result: {1}", ex.GetType ().Name, ex.Message)); } }
public int ReplaceResult (ConsequenceResult oldResult, ConsequenceResult newResult) { if (CurrentResults == null) return -1; for (int i = 0; i < CurrentResults.Count; i++) if (CurrentResults [i] == oldResult) { CurrentResults [i] = newResult; return i; } return -1; }
public void SetResult(ConsequenceResult result) { if (CurrentResult == result) return; #if DEBUG //TestFlight.PassCheckpoint ("VIEW_XSLT_WEB"); #endif CurrentResult = result; if (resultWorker != null && resultWorker.IsBusy) resultWorker.CancelAsync (); resultWorker = new BackgroundWorker (); resultWorker.WorkerSupportsCancellation = true; resultWorker.RunWorkerCompleted += HandleRunWorkerCompleted; resultWorker.DoWork += HandleDoWork; resultWorker.RunWorkerAsync (result); }
public void SetCurrentResult (ConsequenceResult result) { if (result == null) return; #if DEBUG //TestFlight.PassCheckpoint ("VIEW_DETAILS"); #endif UpdateCurrentResult (result); ClearDynamicViews (); float offset = LastLabelYOffset + 5; CurrentConfiggers = result.Calculator.ConfigurableValues.Values.Select (x => GetConfigurator (x)).ToArray (); foreach (UIViewController configger in CurrentConfiggers.Where(x => x != null)) { configger.View.Frame = new RectangleF (0, offset, configger.View.Frame.Width, configger.View.Frame.Height); offset += configger.View.Frame.Height + 5; this.scrollView.AddSubview (configger.View); } if (result.Calculator.SupportElements != null && result.Calculator.SupportElements.ContainsKey ("Commentary")) { Commentary commentaryElement = result.Calculator.SupportElements ["Commentary"] as Commentary; NSAttributedString commentaryFormatted = commentaryElement.ToAttributedString (UIFont.FromName ("Baskerville", 17.0f)); CommentView = new CoreTextView (); CommentView.Tag = DYNAMIC_VIEW_TAG; CommentView.Text = commentaryFormatted; SizeF suggestedSize = CommentView.SuggestedFrameSize (new SizeF (this.scrollView.Frame.Width - 12, 10000.0f)); CommentView.Frame = new RectangleF (5, offset, this.scrollView.Frame.Width - 12, suggestedSize.Height); offset += suggestedSize.Height + 5; this.scrollView.AddSubview (CommentView); } this.scrollView.ContentSize = new SizeF (this.scrollView.Frame.Width, offset); this.scrollView.BringSubviewToFront (this.resultSubview); }
public override XElement GetTableData(ConsequenceResult result) { int annualPayments = CompoundingsPerYear (PaymentFrequency); Money paymentPerInstallment = (result.Request.InitialAmount * (decimal)(InvestmentsPerYear (result.Request.TriggerMode))) / annualPayments; var amortization = Financials.Amortization (ExchangeRates.CurrentRates.ConvertToGiven(result.ComputedValue as Money, paymentPerInstallment.CurrencyCode), CompoundingsPerYear (PaymentFrequency), PercentAsDecimal (Rate), 0.0m, paymentPerInstallment, PayoffMode.FlatAmount); return new XElement (new XStreamingElement ("Amortization", new XAttribute ("Title", string.Format ("{0} financed at {1}%", result.ComputedValue as Money, Rate)), from i in amortization select new XElement ("Row", new XElement ("Installment", string.Format ("Payment {0}", i.Installment)), new XElement ("Payment", i.Payment.ToString ()), new XElement ("Interest", i.Interest.ToString ()), new XElement ("Principal", (i.Payment - i.Interest).ToString ()), new XElement ("Balance", i.Balance.ToString ())) ) ); }
/// <summary> /// Dynamically generated tabular data /// </summary> /// <remarks>Any calculator that returns dynamic tabular data, such as amortization tables, should override this and pass a TabularResult to the /// ConsequenceResult they return.</remarks> public virtual XElement GetTableData(ConsequenceResult result) { return null; }
public ResultChangedArgs (ConsequenceResult oldResult, ConsequenceResult newResult) { this.OldResult = oldResult; this.NewResult = newResult; }
public override XElement GetTableData(ConsequenceResult result) { var schedule = Financials.InvestmentSchedule (result.Request, this); return new XElement (new XStreamingElement ("InvestmentSchedule", new XAttribute ("Title", string.Format ("{0} invested at {1:0.00}%", result.Request.Summary, Rate)), from i in schedule select new XElement ("Row", new XElement ("Installment", string.Format ("{0} {1}", result.Request.ModeUnit, i.Installment)), new XElement ("Investment", i.Investment.ToString ()), new XElement ("Earnings", i.Earnings.ToString ()), new XElement ("Balance", i.Balance.ToString ())) ) ); }
public void DisplayConsequenceDetails(ConsequenceResult result) { if (this.DetailController == null) { DetailController = new ConsequenceDetailController (Profile); DetailController.ResultChanged += HandleResultChanged; } DetailController.SetCurrentResult (result); if (this.NavigationController != null) this.NavigationController.PushViewController (DetailController, true); }
public override XElement GetTableData(ConsequenceResult result) { Money localizedMinPayment = ExchangeRates.CurrentRates.ConvertToGiven(MinimumPayment, result.Request.InitialAmount.CurrencyCode); var amortization = Financials.Amortization (result.Request.InitialAmount.Value, CompoundingsPerYear (Compounding), PercentAsDecimal (Rate), PercentAsDecimal (MinPayPercent), localizedMinPayment, PayoffMode); return new XElement (new XStreamingElement ("Amortization", new XAttribute ("Title", string.Format ("{0:C} financed at {1}%", result.Request.InitialAmount, Rate)), from i in amortization select new XElement ("Row", new XElement ("Installment", string.Format ("Payment {0}", i.Installment)), new XElement ("Payment", i.Payment.ToString ()), new XElement ("Interest", i.Interest.ToString ()), new XElement ("Principal", (i.Payment - i.Interest).ToString ()), new XElement ("Balance", i.Balance.ToString ())) ) ); }