private void OnItemChanged(PriceTileModel itemModel)
        {
            if (IsViewLoaded)
            {
                var indexOfItem = _model.ActiveCurrencyPairs.IndexOf(itemModel);

                NSIndexPath    path = NSIndexPath.FromRowSection(indexOfItem, 0);
                IPriceTileCell cell = (IPriceTileCell)TableView.CellAt(path);

                if (cell != null)
                {
                    // TODO: Batch the updates up, to only call ReloadRows once per main event loop loop?

                    if (ShouldUpdateCell(itemModel.Status, cell))
                    {
                        //						System.Console.WriteLine ("Cell is APPROPRIATE", indexOfItem);
                        cell.UpdateFrom(itemModel);
                    }
                    else
                    {
                        TableView.ReloadRows(
                            new [] {
                            NSIndexPath.Create(0, indexOfItem)
                        }, UITableViewRowAnimation.None);
                    }
                }
            }
        }
예제 #2
0
        private IPriceTileCell GetCell(UITableView tableView, PriceTileModel model)
        {
            IPriceTileCell priceTileCell = null;

            switch (model.Status)
            {
            case PriceTileStatus.Done:
            case PriceTileStatus.DoneStale:
                priceTileCell = tableView.DequeueReusableCell(PriceTileTradeAffirmationViewCell.Key) as PriceTileTradeAffirmationViewCell;
                if (priceTileCell == null)
                {
                    priceTileCell = PriceTileTradeAffirmationViewCell.Create();
                }
                break;

            case PriceTileStatus.Streaming:
            case PriceTileStatus.Executing:
                priceTileCell = tableView.DequeueReusableCell(PriceTileViewCell.Key) as PriceTileViewCell;
                if (priceTileCell == null)
                {
                    priceTileCell = PriceTileViewCell.Create();
                }
                break;

            case PriceTileStatus.Stale:
                priceTileCell = tableView.DequeueReusableCell(PriceTileErrorViewCell.Key) as PriceTileViewCell;
                if (priceTileCell == null)
                {
                    priceTileCell = PriceTileErrorViewCell.Create();
                }
                break;
            }

            return(priceTileCell);
        }
예제 #3
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            PriceTileModel model = priceTilesModel [indexPath.Row];

            var cell = GetCell(tableView, model);

            cell.UpdateFrom(model);

            return(( UITableViewCell)cell);
        }
예제 #4
0
 void SwapBuySellSides(PriceTileModel model)
 {
     if (model.NotionalCcy == model.Base)
     {
         model.NotionalCcy = model.Counter;
     }
     else
     {
         model.NotionalCcy = model.Base;
     }
 }
예제 #5
0
        private void OnCurrencyPairUpdates(IEnumerable <ICurrencyPairUpdate> updates)
        {
            foreach (var update in updates)
            {
                if (update.UpdateType == Adaptive.ReactiveTrader.Client.Domain.Models.UpdateType.Add)
                {
                    var tileModel = new PriceTileModel(update.CurrencyPair, this._reactiveTrader.PriceLatencyRecorder, this._concurrencyService);

                    _activeCurrencyPairs.Add(tileModel);
                }
                else
                {
                    // todo handle removal of price tile
                }
            }
        }
예제 #6
0
        void SetBuySellSides(PriceTileModel model)
        {
            if (model.NotionalCcy == model.Base)
            {
                this.LeftSideAction.Text  = "SELL";
                this.RightSideAction.Text = "BUY";
            }
            else
            {
                this.LeftSideAction.Text  = "BUY";
                this.RightSideAction.Text = "SELL";
            }

            this.NotionalCCY.SetTitle(model.NotionalCcy, UIControlState.Normal);
            this.NotionalCCY.SetTitle(model.NotionalCcy, UIControlState.Disabled);
            this.NotionalCCY.SetTitle(model.NotionalCcy, UIControlState.Selected);

            // Show what it WILL be, when user is mid tap...

            this.NotionalCCY.SetTitle((model.NotionalCcy == model.Base)?model.Counter:model.Base, UIControlState.Highlighted);
        }
예제 #7
0
        public void UpdateFrom(PriceTileModel model)
        {
            _priceTileModel = model;

            //
            // Trading enabled UI may change based on executing vs not executing...
            //

            DecorateWithTradingEnabled(UserModel.Instance.OneTouchTradingEnabled);

            this.CurrencyPair.Text = model.Symbol;

            SetBuySellSides(model);

            if (this.Notional.IsEditing)
            {
                // TODO: Determine what it really means to update the Notional via the model.
                // System.Console.WriteLine ("Notional {0} is mid edit, so not updating to {1}", this.Notional.Text, model.Notional);
            }
            else
            {
                this.Notional.Text = Styles.FormatNotional(model.Notional, true);
            }

            // Price and spread...

            this.LeftSideNumber.Text    = model.LeftSideNumber;
            this.LeftSideBigNumber.Text = model.LeftSideBigNumber;
            this.LeftSidePips.Text      = model.LeftSidePips;

            this.RightSideNumber.Text    = model.RightSideNumber;
            this.RightSideBigNumber.Text = model.RightSideBigNumber;
            this.RightSidePips.Text      = model.RightSidePips;

            this.Spread.Text = model.Spread;

            // Movement...

            switch (model.Movement)
            {
            case PriceMovement.Down:
                this.PriceMovementDown.Hidden = false;
                this.PriceMovementUp.Hidden   = true;
                break;

            case PriceMovement.Up:
                this.PriceMovementDown.Hidden = true;
                this.PriceMovementUp.Hidden   = false;
                break;

            case PriceMovement.None:
                this.PriceMovementDown.Hidden = true;
                this.PriceMovementUp.Hidden   = true;
                break;
            }

            // Other status...

            bool isExecuting = (model.Status != PriceTileStatus.Executing);

            this.Executing.Hidden = isExecuting;
            this.Activity.Hidden  = isExecuting;

            // TODO: Update this when date/time changes, not just when the model updates!

            this.SpotDate.Text = "SP. " + DateTime.Now.AddDays(2).ToString("dd MMM");

            model.Rendered();
        }
예제 #8
0
        private void OnItemChanged(PriceTileModel itemModel)
        {
            if (IsViewLoaded)
            {
                var indexOfItem = _model.ActiveCurrencyPairs.IndexOf(itemModel);

                NSIndexPath    path = NSIndexPath.FromRowSection(indexOfItem, 0);
                IPriceTileCell cell = (IPriceTileCell)TableView.CellAt(path);

                if (cell == null)
                {
                    //					System.Console.WriteLine ("Row {0} not found", indexOfItem);
                    // There's no cell bound to that index in the data, so we can ignore the update.
                }
                else
                {
                    //					System.Console.WriteLine ("Row {0} FOUND {1}", indexOfItem, cell.GetType ().ToString ());

                    bool bAppropriateCell = false;                     // TODO: Refactor this elsewhere.

                    switch (itemModel.Status)
                    {
                    case PriceTileStatus.Done:
                    case PriceTileStatus.DoneStale:
                        if (cell.GetType().Equals(Type.GetType("Adaptive.ReactiveTrader.Client.iOSTab.PriceTileTradeAffirmationViewCell", false)))
                        {
                            bAppropriateCell = true;
                        }
                        break;

                    case PriceTileStatus.Streaming:
                    case PriceTileStatus.Executing:
                        if (cell.GetType().Equals(Type.GetType("Adaptive.ReactiveTrader.Client.iOSTab.PriceTileViewCell", false)))
                        {
                            bAppropriateCell = true;
                        }
                        break;

                    case PriceTileStatus.Stale:
                        if (cell.GetType().Equals(Type.GetType("Adaptive.ReactiveTrader.Client.iOSTab.PriceTileErrorViewCell", false)))
                        {
                            bAppropriateCell = true;
                        }
                        break;
                    }

                    // TODO: Batch the updates up, to only call ReloadRows once per main event loop loop?

                    if (bAppropriateCell)
                    {
                        //						System.Console.WriteLine ("Cell is APPROPRIATE", indexOfItem);
                        cell.UpdateFrom(itemModel);
                    }
                    else
                    {
                        // TODO: If the cell is of the wrong type, reload the row instead.

                        TableView.ReloadRows(
                            new [] {
                            NSIndexPath.Create(0, indexOfItem)
                        }, UITableViewRowAnimation.None);
                    }
                }
            }
        }