示例#1
0
        private void OnMessagesCollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
        {
            switch (args.Action)
            {
            case NotifyCollectionChangedAction.Add:
                var newIndexPaths = CreateNSIndexPathArray(args.NewStartingIndex, args.NewItems.Count);
                TableView.InsertRows(newIndexPaths, UITableViewRowAnimation.Automatic);
                TableView.ScrollToRow(NSIndexPath.FromRowSection(Messages.Count - 1, 0), UITableViewScrollPosition.Bottom, true);
                break;

            case NotifyCollectionChangedAction.Remove:
                var oldIndexPaths = CreateNSIndexPathArray(args.OldStartingIndex, args.OldItems.Count);
                TableView.DeleteRows(oldIndexPaths, UITableViewRowAnimation.Automatic);
                break;
            }
        }
示例#2
0
        public void UpdateDocumentColor(NSUrl documentUrl, ListColor newColor)
        {
            ListInfo listInfo = new ListInfo(documentUrl);

            int index = listInfos.IndexOf(listInfo);

            if (index != -1)
            {
                listInfo       = listInfos[index];
                listInfo.Color = newColor;

                NSIndexPath indexPath = NSIndexPath.FromRowSection(index, 0);
                ListCell    cell      = (ListCell)TableView.CellAt(indexPath);
                cell.ListColorView.BackgroundColor = AppColors.ColorFrom(newColor);
            }
        }
        private UITableViewCell GetDatePickerCell(UITableView tableView, EntityTableViewModel model)
        {
            var cell = tableView.DequeueReusableCell("DatePickerCell") as EntityDatePickerCell;

            cell.DatePicker.Hidden = true;
            cell.DatePicker.TranslatesAutoresizingMaskIntoConstraints = false;

            cell.DatePicker.ValueChanged += (sender, e) =>
            {
                EntityPresenter.Model[0][SelectedRow].Value = iOSHelper.NSDateToDateTime((sender as UIDatePicker).Date).Date.ToString("yyyy-MM-dd");

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

            return(cell);
        }
示例#4
0
        private void DoUpdate(Action <NSIndexPath[]> method, IEnumerable <int> update, int section)
        {
            var toChange = update
                           .Select(x => NSIndexPath.FromRowSection(x, section))
                           .ToArray();

            if (this.IsDebugEnabled)
            {
                this.Log().Debug(
                    "Calling {0}: [{1}]",
                    method.Method.Name,
                    string.Join(",", toChange.Select(x => x.Section + "-" + x.Row)));
            }

            method(toChange);
        }
示例#5
0
        public void Failed(CLLocationManager manager, NSError error)
        {
            if (!selectedLocationCellIndex.HasValue)
            {
                return;
            }

            var index     = selectedImageCellIndex.Value;
            var indexPath = NSIndexPath.FromRowSection(index, 0);

            var cell = TableView.CellAt(indexPath) as LocationFieldTableViewCell;

            EndLocationLookupForCell(cell);
            cell.ErrorLabel.Hidden = false;
            cell.ErrorLabel.LayoutIfNeeded();
        }
示例#6
0
        public void SetOpenedDocument(int docIndex, bool animated)
        {
            var row = docIndex;

            if (row >= 0 && row < Items.Count)
            {
                var oldIndex = IndexPathForSelectedRow;

                if (oldIndex != null && oldIndex.Row == row)
                {
                    return;
                }

                SelectRow(NSIndexPath.FromRowSection(row, 0), animated, UITableViewScrollPosition.Middle);
            }
        }
示例#7
0
        void InsertVisual(int idx, UITableViewRowAnimation anim, int count)
        {
            if (Root == null || Root.TableView == null)
            {
                return;
            }

            int sidx  = Root.IndexOf(this);
            var paths = new NSIndexPath [count];

            for (int i = 0; i < count; i++)
            {
                paths [i] = NSIndexPath.FromRowSection(idx + i, sidx);
            }
            Root.TableView.InsertRows(paths, anim);
        }
示例#8
0
        void AddNewItem(object sender, EventArgs args)
        {
            var quote = new GreatQuote();

            QuoteManager.Instance.Quotes.Insert(0, quote);

            using (var indexPath = NSIndexPath.FromRowSection(0, 0))
            {
                TableView.InsertRows(new[] { indexPath }, UITableViewRowAnimation.Automatic);
            }

            var editQuoteVC = (EditQuoteViewController)this.Storyboard.InstantiateViewController("EditQuote");

            editQuoteVC.SetQuote(quote);
            NavigationController.PushViewController(editQuoteVC, true);
        }
示例#9
0
        private void SelectItem(string item)
        {
            Throw.IfArgumentNullOrWhitespace(item, nameof(item));

            if (this.selectedItem != item)
            {
                int index = this.IndexOf(item);
                if (index < 0)
                {
                    throw new ArgumentException("Item (" + item + ") does not exist in the list of items.", nameof(item));
                }

                this.SetSelectedItem(item);
                this.SelectRow(NSIndexPath.FromRowSection(index, 0), false, UITableViewScrollPosition.None);
            }
        }
示例#10
0
        async private void GetAccounts(string accessToken)
        {
            OrganizationDataWebServiceProxy orgService = new OrganizationDataWebServiceProxy
            {
                ServiceUrl  = CrmUrl,
                AccessToken = accessToken
            };

            //Get "Sample" Accounts - make this more meaningful & add paging
            QueryExpression query = new QueryExpression
            {
                EntityName = "account",
                ColumnSet  = new ColumnSet("name", "address1_latitude", "address1_longitude"),
                TopCount   = 10,
                Orders     = new DataCollection <OrderExpression>
                {
                    new OrderExpression
                    {
                        AttributeName = "name",
                        OrderType     = OrderType.Descending
                    }
                },
                Criteria = new FilterExpression
                {
                    Conditions =
                    {
                        new ConditionExpression
                        {
                            EntityName    = "account",
                            AttributeName = "name",
                            Operator      = ConditionOperator.Like,
                            Values        = { "%sample%" }
                        }
                    }
                }
            };

            EntityCollection response = await orgService.RetrieveMultiple(query);

            foreach (Entity account in response.Entities)
            {
                _dataSource.Objects.Insert(0, account);

                using (var indexPath = NSIndexPath.FromRowSection(0, 0))
                    TableView.InsertRows(new[] { indexPath }, UITableViewRowAnimation.Automatic);
            }
        }
示例#11
0
        void PerformAnimation()
        {
            var cellsToMove = new List <UITableViewCell>();
            var otherCells  = TableView.VisibleCells.ToList();

            for (int i = 0; i < 3; i++)
            {
                if (TableView.CellAt(NSIndexPath.FromRowSection(i, 0)) == null)
                {
                    break;
                }
                cellsToMove.Add(TableView.CellAt(NSIndexPath.FromRowSection(i, 0)));
                otherCells.RemoveAt(0);
            }

            if (cellsToMove.Count == 0)
            {
                return;
            }

            foreach (var visible_cell in TableView.VisibleCells)
            {
                var cell_center = visible_cell.Center;
                cell_center.Y      -= visible_cell.Frame.Height;
                visible_cell.Center = cell_center;
            }

            UIView.AnimateNotify(0.56, 0, (nfloat)0.5, 15, UIViewAnimationOptions.TransitionNone, () =>
            {
                foreach (var cell in cellsToMove)
                {
                    var cellCenter = cell.Center;
                    cellCenter.Y  += cell.Frame.Height;
                    cell.Center    = cellCenter;
                }
            }, null);

            UIView.Animate(0.24, () =>
            {
                foreach (var visible_cell in otherCells)
                {
                    var cell_center     = visible_cell.Center;
                    cell_center.Y      += visible_cell.Frame.Height;
                    visible_cell.Center = cell_center;
                }
            }, null);
        }
示例#12
0
        private void FilterMonsters()
        {
            Monster oldM = _selectedMonster;

            if (_sortedMonsters == null)
            {
                _sortedMonsters = new List <Monster>();
                _sortedMonsters.AddRange(Monster.Monsters);
                _sortedMonsters.Sort((a, b) => a.Name.CompareTo(b.Name));
            }

            _currentViewMonsters = new List <Monster>();

            int index         = 0;
            int selectedIndex = -1;

            foreach (Monster m in _sortedMonsters)
            {
                if (_filterText == "" || m.Name.ToLower().Contains(_filterText.ToLower()))
                {
                    _currentViewMonsters.Add(m);

                    if (m == oldM)
                    {
                        selectedIndex = index;
                    }
                    index++;
                }
            }

            if (selectedIndex == -1 && _currentViewMonsters.Count > 0)
            {
                selectedIndex = 0;
            }

            monsterTable.ReloadData();
            if (selectedIndex != -1)
            {
                NSIndexPath path = NSIndexPath.FromRowSection(selectedIndex, 0);
                monsterTable.SelectRow(path, false, UITableViewScrollPosition.Top);
                _selectedMonster = _currentViewMonsters[selectedIndex];
            }
            else
            {
                _selectedMonster = null;
            }
        }
示例#13
0
        void HandleCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (!loadedView)
            {
                return;
            }

            NSAction act = () => {
                if (e.Action == NotifyCollectionChangedAction.Reset)
                {
                    TableView.ReloadData();
                }

                if (e.Action == NotifyCollectionChangedAction.Add)
                {
                    var count = e.NewItems.Count;
                    var paths = new NSIndexPath[count];
                    for (var i = 0; i < count; i++)
                    {
                        paths [i] = NSIndexPath.FromRowSection(e.NewStartingIndex + i, 0);
                    }
                    TableView.InsertRows(paths, AddAnimation);
                }
                else if (e.Action == NotifyCollectionChangedAction.Remove)
                {
                    var count = e.OldItems.Count;
                    var paths = new NSIndexPath[count];
                    for (var i = 0; i < count; i++)
                    {
                        paths [i] = NSIndexPath.FromRowSection(e.OldStartingIndex + i, 0);
                    }
                    TableView.DeleteRows(paths, DeleteAnimation);
                }
            };

            var isMainThread = System.Threading.Thread.CurrentThread == mainThread;

            if (isMainThread)
            {
                act();
            }
            else
            {
                NSOperationQueue.MainQueue.AddOperation(act);
                NSOperationQueue.MainQueue.WaitUntilAllOperationsAreFinished();
            }
        }
示例#14
0
 private void OnColorItemDeleted(NSNotification notification)
 {
     // As there are two instances of colorData between `ColorsViewControllerStoryboard` and
     // `ColorsViewControllerCode`, this method must only process notification callbacks when
     // the instances of colorData match.
     if (notification.Object is ColorData colorData)
     {
         // Grab the index of the deleted object from the userInfo dictionary
         if (notification.UserInfo != null &&
             notification.UserInfo.TryGetValue(new NSString("index"), out NSObject @object) &&
             @object is NSNumber number)
         {
             var indexPath = NSIndexPath.FromRowSection(number.Int32Value, 0);
             base.TableView.DeleteRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Automatic);
         }
     }
 }
        private async Task SetCurrentNodeWithAnimationAsync(UICollectionView collectionView, TreeNode <T, TKey> selectedNode)
        {
            var diffResult = TreeMenuDiff.Calculate(_currentNode, selectedNode);

            diffResult
            .ChangedIndexes
            .Select(x => (cell: collectionView.CellForItem(NSIndexPath.FromRowSection(x.Index, 0)), relation: x.Relation))
            .Where(x => x.cell != null)
            .ForEach((_, x) => _itemStateChanged(x.cell, x.relation));

            _currentNode = selectedNode;
            _itemCollection.CurrentNode = selectedNode;

            await AnimateDiffAsync(collectionView, diffResult);

            NodeSelected?.Invoke(this, selectedNode);
        }
        public TasksTableViewSource(UITableView tableView, TaskManager taskManager)
        {
            _taskManager = taskManager;
            _taskManager.TodoItems.CollectionChanged += (object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) => {
//				if (e.OldItems != null)
//				{
//					NSIndexPath[] oldPaths = e.OldItems.OfType<TodoItem>().Select(oi => NSIndexPath.FromRowSection(tasks.IndexOf(oi), 0)).ToArray();
//					tableView.DeleteRows(oldPaths, UITableViewRowAnimation.Top);
//				}

                if (e.NewItems != null)
                {
                    var newPaths = e.NewItems.OfType <TodoItem>().Select(ni => NSIndexPath.FromRowSection(_taskManager.TodoItems.Count - 1, 0)).ToArray();
                    tableView.InsertRows(newPaths, UITableViewRowAnimation.Top);
                }
            };
        }
示例#17
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.View.BackgroundColor = UIColor.White;
            this.Title = "Settings";

            this.Table = new UITableView(this.View.Bounds);
            this.Table.RegisterClassForCellReuse(typeof(UITableViewCell), new NSString("cell"));
            this.Table.DataSource = new TableViewDataSource(this);
            this.Table.Delegate   = new TableViewDelegate(this);
            this.View.AddSubview(this.Table);

            NSIndexPath path = NSIndexPath.FromRowSection(this.owner.SelectedOption, 0);

            this.Table.SelectRow(path, false, UITableViewScrollPosition.Middle);
        }
示例#18
0
        public void BindSequencesOfElementsToTableViewRows()
        {
            var tableView    = new UITableView();
            var items        = Observable.Return(new[] { "First Item", "Second Item", "Third Item" });
            var subscription = items.BindTo(tableView.Rx().Items((UITableView tv, int row, string element) =>
            {
                var cell            = new UITableViewCell();
                cell.TextLabel.Text = element;
                return(cell);
            }));

            var indexPath = NSIndexPath.FromRowSection(0, 0);

            Assert.AreEqual(tableView.Source.GetCell(tableView, indexPath).TextLabel.Text, "First Item");

            subscription.Dispose();
        }
        // Finds the home in the Homes property and reloads the corresponding row.
        protected override void HomeDidUpdateName(HMHome home)
        {
            var index = Homes.IndexOf(home);

            if (index >= 0)
            {
                var listIndexPath    = NSIndexPath.FromRowSection(index, (int)HomeListSection.Homes);
                var primaryIndexPath = NSIndexPath.FromRowSection(index, (int)HomeListSection.PrimaryHome);

                TableView.ReloadRows(new [] { listIndexPath, primaryIndexPath }, UITableViewRowAnimation.Automatic);
            }
            else
            {
                // Just reload the data since we don't know the index path.
                TableView.ReloadData();
            }
        }
示例#20
0
		protected NSIndexPath GetIndexPath(int index)
		{
			if (navigation.Root == null)
				return NSIndexPath.FromRowSection(0, 0);
			int currentCount = 0;
			int section = 0;
			foreach (Section element in navigation.Root)
			{
				if (element.Count + currentCount > index)
					break;
				currentCount += element.Count;
				section ++;
			}

			int row = index - currentCount;
			return NSIndexPath.FromRowSection(row, section);
		}
        void UpdateVoiceShortcuts()
        {
            var weakThis = new WeakReference <OrderDetailViewController>(this);

            VoiceShortcutDataManager.UpdateVoiceShortcuts(() =>
            {
                var indexPath = NSIndexPath.FromRowSection(0, 3);
                DispatchQueue.MainQueue.DispatchAsync(() =>
                {
                    if (weakThis.TryGetTarget(out var orderDetailViewController))
                    {
                        orderDetailViewController.TableView.ReloadRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Automatic);
                    }
                });
            });
            DismissViewController(true, null);
        }
示例#22
0
 public void AddComparison(ComparisonModel comparison)
 {
     if (Comparisons.Count == 0)
     {
         Comparisons.Add(comparison);
         ReloadRows(new NSIndexPath[] { NSIndexPath.FromRowSection(0, 0) }, UITableViewRowAnimation.Fade);
     }
     else
     {
         Comparisons.Add(comparison);
         Comparisons = Comparisons.OrderBy(c => c.Name).ToList();
         BeginUpdates();
         InsertRows(new NSIndexPath[] { NSIndexPath.FromRowSection(Comparisons.IndexOf(comparison), 0) }, UITableViewRowAnimation.Fade);
         EndUpdates();
     }
     SetScrollAndSelection();
 }
示例#23
0
        public void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status)
        {
            if (!selectedLocationCellIndex.HasValue)
            {
                return;
            }

            int index     = selectedImageCellIndex.Value;
            var indexPath = NSIndexPath.FromRowSection(index, 0);
            var cell      = (LocationFieldTableViewCell)TableView.CellAt(indexPath);

            cell.LookUpButton.Enabled = status != CLAuthorizationStatus.Denied;
            if (status == CLAuthorizationStatus.AuthorizedWhenInUse)
            {
                RequestLocationForCell(cell);
            }
        }
示例#24
0
        partial void switchCellValueChanged(UISwitch sender)
        {
            var uiswitch = sender as UISwitch;

            if ((int)uiswitch.Tag == 0)
            {
                //delete passcode from secure internal storage
                Keychain.RemoveItemFromKeychain(Keychain.AuthService);

                if (uiswitch.On)
                {
                    //get touchid switch value
                    NSIndexPath     touchid_idx  = NSIndexPath.FromRowSection(1, 0);
                    UITableViewCell touchid_cell = TableView.CellAt(touchid_idx);
                    ((UISwitch)touchid_cell.AccessoryView).Enabled = true;

                    //update flag
                    IsCommingFromSetPasscode = true;

                    //go and set a new passcode
                    UIViewController uiview = Storyboard.InstantiateViewController("SetPasscodeViewController");
                    NavigationController.PushViewController(uiview, true);
                }
                else
                {
                    //get touchid switch value
                    NSIndexPath     touchid_idx  = NSIndexPath.FromRowSection(1, 0);
                    UITableViewCell touchid_cell = TableView.CellAt(touchid_idx);
                    ((UISwitch)touchid_cell.AccessoryView).On      = false;
                    ((UISwitch)touchid_cell.AccessoryView).Enabled = false;

                    UpdateSettings();
                }
            }
            else if ((int)uiswitch.Tag == 2)
            {
                //go and set a new face recognition configuration
                var uistoryboard        = UIStoryboard.FromName("Face", null);
                UIViewController uiview = uistoryboard.InstantiateViewController("PeopleViewController");
                NavigationController.PushViewController(uiview, true);
            }
            else
            {
                UpdateSettings();
            }
        }
        private void AddMessage(string message, bool prepend = false, string username = null)
        {
            InvokeOnMainThread(() => {
                if (prepend)
                {
                    chatItems.Insert(0, new ChatAdapter.ChatItem(username, message));
                }
                else
                {
                    chatItems.Add(new ChatAdapter.ChatItem(username, message));
                }

                chatWindow.ReloadData();
                var lastIndex = NSIndexPath.FromRowSection(chatItems.Count - 1, 0);
                chatWindow.ScrollToRow(lastIndex, UITableViewScrollPosition.Bottom, true);
            });
        }
示例#26
0
        public void FinishedPickingMedia(UIImagePickerController picker, NSDictionary info)
        {
            var selectedImage = (UIImage)info [UIImagePickerController.OriginalImage];
            var imageUrl      = GetImageUrl();

            if (selectedImage != null && selectedImageCellIndex.HasValue && imageUrl != null)
            {
                var index     = selectedImageCellIndex.Value;
                var indexPath = NSIndexPath.FromRowSection(index, 0);
                var cell      = (ImageFieldTableViewCell)TableView.CellAt(indexPath);
                var imageData = selectedImage.AsJPEG(0.8f);
                imageData?.Save(imageUrl, atomically: true);
                cell.AssetView.Image  = selectedImage;
                cell.ImageInput.Value = imageUrl;
            }
            picker.DismissViewController(true, null);
        }
示例#27
0
        public void ReloadRowForComparison(int comparisonId)
        {
            var comparison = FindComparison(comparisonId);

            if (comparison == null)
            {
                return;
            }

            var index = Comparisons.IndexOf(comparison);

            Comparisons[index] = DataService.GetComparison(comparisonId);
            var indexPaths = new NSIndexPath[] { NSIndexPath.FromRowSection(index, 0) };

            ReloadRows(indexPaths, UITableViewRowAnimation.None);
            SelectRow(indexPaths[0], false, UITableViewScrollPosition.None);
        }
            void PreparePhotos()
            {
                AssetGroup.Enumerate(PhotoEnumerator);

                _Dispatcher.BeginInvokeOnMainThread(() => {
                    TableView.ReloadData();
                    // scroll to bottom
                    nint section = NumberOfSections(TableView) - 1;
                    nint row     = TableView.NumberOfRowsInSection(section) - 1;
                    if (section >= 0 && row >= 0)
                    {
                        var ip = NSIndexPath.FromRowSection(row, section);
                        TableView.ScrollToRow(ip, UITableViewScrollPosition.Bottom, false);
                    }
                    NavigationItem.Title = SingleSelection ? "Pick Photo" : "Pick Photos";
                });
            }
示例#29
0
            public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
            {
                // check if the edit operation was a delete
                if (editingStyle == UITableViewCellEditingStyle.Delete)
                {
                    // remove the customer from the underlying data
                    _vc.Customers.RemoveAt(indexPath.Row);

                    // remove the associated row from the tableView
                    tableView.DeleteRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Middle);
                }
                else if (editingStyle == UITableViewCellEditingStyle.Insert)
                {
                    _vc.Customers.Add(new Customer("First", "Last"));
                    tableView.InsertRows(new NSIndexPath[] { NSIndexPath.FromRowSection(_vc.Customers.Count - 1, 0) }, UITableViewRowAnimation.Middle);
                }
            }
        public Tuple <NSIndexPath[], PHAssetCollection[]> InsertedIndexPaths(PHAssetCollection[] newAlbums, PHAssetCollection[] oldAlbums, int section)
        {
            var insertedIndexPaths = new List <NSIndexPath>();
            var insertedAlbums     = new List <PHAssetCollection>();

            foreach (var item in newAlbums.Select((value, index) => new { Value = value, Index = index }))
            {
                if (!newAlbums.Contains(item.Value))
                {
                    insertedAlbums.Add(item.Value);
                    insertedIndexPaths.Add(NSIndexPath.FromRowSection(item.Index, section));
                    continue;
                }
            }

            return(Tuple.Create(insertedIndexPaths.ToArray(), insertedAlbums.ToArray()));
        }