Пример #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var whiteBackground = new UIView(new RectangleF(0, 0, View.Frame.Width, View.Frame.Height));

            whiteBackground.BackgroundColor = UIColor.White;
            View.AddSubview(whiteBackground);

            Title = _comparison.Name;
            NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Add, (sender, args) => { OnAddComparable.Fire(this, new EventArgs()); });

            _tableView = new ComparisonLineupTableView(_comparison, new RectangleF(0, 0, View.Frame.Width, View.Frame.Height - 88), UITableViewStyle.Plain);
            _tableView.OnComparableSelected += (sender, args) => { OnComparableSelected.Fire(this, EventArgs.Empty); };
            _tableView.OnComparableDeleted  += (sender, args) =>
            {
                if (_tableView.Comparables.Count > 0)
                {
                    return;
                }

                _trashButton.Enabled = false;

                if (_tableView.Editing)
                {
                    NavigationItem.RightBarButtonItem.Enabled = true;
                    _tableView.SetEditing(false, true);
                }
            };
            _tableView.OnNewCheaper += (sender, args) =>
            {
                OnNewCheaper.Fire(this, EventArgs.Empty);
            };

            View.AddSubview(_tableView);

            _toolbar           = new UIToolbar(new RectangleF(0, View.Frame.Height - 88, View.Frame.Width, 44));
            _toolbar.TintColor = UIColor.DarkGray;
            var toolbarItems   = new List <UIBarButtonItem>();
            var editButtonItem = new UIBarButtonItem("Edit comparison", UIBarButtonItemStyle.Bordered, (sender, args) => { OnModify.Fire(this, new EventArgs()); });

            _trashButton = new UIBarButtonItem(UIBarButtonSystemItem.Trash, (sender, args) =>
            {
                NavigationItem.RightBarButtonItem.Enabled = _tableView.Editing;
                _tableView.SetEditing(!_tableView.Editing, true);
            });

            toolbarItems.Add(editButtonItem);
            toolbarItems.Add(new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace));
            toolbarItems.Add(_trashButton);
            _toolbar.SetItems(toolbarItems.ToArray(), false);
            View.AddSubview(_toolbar);

            if (_tableView.Comparables.Count == 0)
            {
                _trashButton.Enabled = false;
            }
        }
Пример #2
0
 public void UpdateCheapestComparable(ComparableModel comparable)
 {
     Comparison.CheapestComparableId = comparable == null ? (int?)null : comparable.Id;
     DataService.UpdateComparison(Comparison);
     OnNewCheaper.Fire(this, EventArgs.Empty);
 }