public override UIView GetView(UIPickerView pickerView, nint row, nint component, UIView view) { var item = ItemsSource.ElementAt((int)row) as string; var label = new AppRopio.Base.iOS.Controls.ARLabel() .WithFrame(0, 0, pickerView.Bounds.Width, GetRowHeight(pickerView, component)) .WithTune(tune => { tune.Text = item; tune.TextAlignment = UITextAlignment.Center; }); label.SetupStyle(ThemeConfig.PickerCell.Value); return(label); }
public void Change(T currentItem, T newItem) { if (_readonly) { return; } var i = ItemsSource.IndexOf(currentItem); if (i >= 0) { ItemsSource[i] = newItem; NextFrameActions.Enqueue(() => { }); } }
private void FilterTextBox_TextChanged(object sender, TextChangedEventArgs e) { if (!IsLoaded) { return; } PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Text")); popUp.IsOpen = string.IsNullOrEmpty(Text) ? false : true; if (ItemsSource != null) { ItemsSource.Refresh(); } }
private void SelectedItemChanged() { var selectedIndex = ItemsSource.IndexOf(SelectedItem); var carouselTabs = Children.Cast <StackLayout>().ToList(); foreach (var ct in carouselTabs) { UnselectTab(ct); } if (selectedIndex > -1) { SelectTab(carouselTabs[selectedIndex]); } }
void SelectedItemChanged() { var selectedIndex = ItemsSource.IndexOf(SelectedItem); var pagerIndicators = Children.Cast <Button> ().ToList(); foreach (var pi in pagerIndicators) { UnselectDot(pi); } if (selectedIndex > -1) { SelectDot(pagerIndicators[selectedIndex]); } }
private string GetDisplayValue(object dataItem) { if (Binding?.Path != null && dataItem != null) { var value = dataItem.GetType().GetProperty(Binding.Path.Path).GetValue(dataItem); var item = ItemsSource?.Cast <object>().FirstOrDefault(x => x.GetType().GetProperty(Binding.Path.Path).GetValue(x).Equals(value)); var displayValue = item?.GetType().GetProperty(DisplayMemberPath).GetValue(item) ?? string.Empty; return(displayValue as string ?? displayValue.ToString()); } return(string.Empty); }
/* If the new item that is appearing on the screen is the last one in the * collection, we execute the LoadMoreCommand so our ViewModel knows we * want to load more data for our user from the data service. */ private void OnItemAppearing(object sender, ItemVisibilityEventArgs e) { if (ItemAppearingCommand != null) { ItemAppearingCommand?.Execute(e.Item); } if (LoadMoreCommand != null) { //If its the last item execute command and load more data. if (e.Item == ItemsSource.Cast <object>().Last()) { LoadMoreCommand?.Execute(null); } } }
protected virtual void CacheCellAttributes(NSIndexPath indexPath, CGSize size) { if (!ItemsSource.IsIndexPathValid(indexPath)) { // The upate might be coming from a cell that's being removed; don't cache it. return; } var item = ItemsSource[indexPath]; if (item != null) { ItemsViewLayout.CacheCellSize(item, size); } }
void UpdateTemplatedSupplementaryView(TemplatedCell cell, NSString elementKind, NSIndexPath indexPath) { DataTemplate template = elementKind == UICollectionElementKindSectionKey.Header ? ItemsView.GroupHeaderTemplate : ItemsView.GroupFooterTemplate; var bindingContext = ItemsSource.Group(indexPath); cell.Bind(template, bindingContext, ItemsView); if (cell is ItemsViewCell) { cell.ConstrainTo(GetLayoutSpanCount() * ItemsViewLayout.ConstrainedDimension); } }
private Type GetItemsSourceType() { if (ItemsSource == null) { return(null); } var typeItemsSource = ItemsSource.GetType(); if (typeItemsSource.IsGenericType) { return(typeItemsSource.GetGenericArguments().First()); } return(typeItemsSource); }
private void SelectedItemChanged() { var selectedIndex = ItemsSource.IndexOf(SelectedItem); var pagerIndicators = Children.Cast <StackLayout>().ToList(); foreach (var pi in pagerIndicators) { UnselectTab(pi); } if (selectedIndex > -1) { SelectTab(pagerIndicators[selectedIndex]); } }
public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath) { if (ItemsSource.Cast <FieldControlModel>().ElementAt(indexPath.Row).Type == FieldType.Header) { return(Sizes.MenuHeaderHeight); } else if (ItemsSource.Cast <FieldControlModel>().ElementAt(indexPath.Row).Type == FieldType.MenuButton) { return(Sizes.CenterInputCellHeight); } else { return(Sizes.FieldCellHeight); } }
private void HandleFocus(bool isFocused) { MainEntry.TextChanged -= SearchText_TextChanged; try { if (isFocused) { if (string.Equals(MainEntry.Text, Placeholder, StringComparison.OrdinalIgnoreCase)) { //MainEntry.Text = string.Empty; MainEntry.TextColor = TextColor; } if (OpenOnFocus) { if (!string.IsNullOrEmpty(MainEntry.Text)) { FilterSuggestions(MainEntry.Text); } } } else { var items = ItemsSource.Cast <object>(); if (!string.IsNullOrEmpty(MainEntry.Text)) { if (MainEntry.Text.Length == 0 || (items.Any() && !items.Any(x => string.Equals(GetSearchMember(items.First().GetType()).GetValue(x).ToString(), MainEntry.Text, StringComparison.Ordinal)))) { //SelectedItem = new MyCensus.Models.Census.SalesProduct() { ProductName = MainEntry.Text }; //MainEntry.Text = Placeholder; MainEntry.TextColor = PlaceholderTextColor; } else { MainEntry.TextColor = TextColor; } } ShowHideListbox(false); } } finally { MainEntry.TextChanged += SearchText_TextChanged; } }
public void RemoveSelection(string key) { var option = ItemsSource.FirstOrDefault(x => x.Key == key); if (option == null) { return; } CascadedEditContext?.NotifyFieldChanged(FieldIdentifier); if (MultiSelect) { if (!SelectedOptions.Contains(option)) { throw new Exception("This option was not already selected."); } if (OnChange.HasDelegate) { OnChange.InvokeAsync(new BFUDropdownChangeArgs(option, false)); } SelectedOptions = SelectedOptions.Where(x => x != option).ToList(); if (SelectedOptionsChanged.HasDelegate) { SelectedOptionsChanged.InvokeAsync(SelectedOptions); } } else { if (SelectedOption != null) { SelectedOption = null; if (OnChange.HasDelegate) { OnChange.InvokeAsync(new BFUDropdownChangeArgs(option, false)); } if (SelectedOptionChanged.HasDelegate) { SelectedOptionChanged.InvokeAsync(SelectedOption); } } } StateHasChanged(); }
/// <summary> /// Save data to file /// </summary> /// <param name="Attempts">Number of attempts</param> /// <returns>True, if save was succesful</returns> protected async Task <bool> SaveDataAsync(int Attempts = 0) { try { foreach (var item in ItemsSource.Where(x => x.Secured && !x.Encrypted)) { item.Name = Crypting.Encrypt(item.Name); item.Description = Crypting.Encrypt(item.Description); item.Encrypted = true; } var typeOfItemList = System.Enum.GetValues(typeof(ItemTypeEnum)).Cast <ItemTypeEnum>().ToList(); ItemStorage <T> itemStorage = new ItemStorage <T>() { Items = GetFinalCollection(), TypeOfItem = typeOfItemList[typeOfItemList.IndexOf(typeOfItemList.FirstOrDefault(x => x.ToString() == nameof(T)))] }; XmlSerializer Serializ = new XmlSerializer(typeof(ItemStorage <T>)); using (Stream XmlStream = await ApplicationData.Current.LocalFolder.OpenStreamForWriteAsync(FileName, CreationCollisionOption.ReplaceExisting)) { Serializ.Serialize(XmlStream, /*DeliveredData*/ itemStorage); } foreach (var item in ItemsSource.Where(x => x.Secured && x.Encrypted)) { item.Name = Crypting.Decrypt(item.Name); item.Description = Crypting.Decrypt(item.Description); item.Encrypted = false; } return(true); } // When file is unavailable catch (Exception e) when((e.Message.Contains("denied") || e.Message.Contains("is in use")) && (Attempts < 10)) { return(await SaveDataAsync(Attempts + 1)); } catch (Exception e) { Debug.WriteLine(e.Message); return(false); } }
private IList getPossibleItems() { if (TextBox.Text == "") { return(defaultItems); } else { string[] searchWords = TextBox.Text.Normalize().GetWords().ToArray(); var result = ItemsSource.Cast <object>() .Where(x => x.ToString().WordsStartWith(searchWords)) .ToList(); result.Sort(PriorityComparer); return(result); } }
/* * private void UpdatePins(List<ILocationViewModel> pins) * { * if (Pins == null || Pins.Count == 0) * { * Pins = new ObservableCollection<ILocationViewModel>(pins); * } * else * { * var newPins = pins.ToDictionary(pin => pin.Key); * * for (int i = Pins.Count - 1; i >= 0; i--) * { * var pin = Pins[i]; * if (newPins.ContainsKey(pin.Key)) * { * // Remove pins already available on map * newPins.Remove(pin.Key); * } * else * { * // Remove outside bounds of search * Pins.RemoveAt(i); * } * } * * foreach (var key in newPins.Keys) * { * Pins.Add(newPins[key]); * } * } * }*/ private void PinOnClicked(object sender, EventArgs eventArgs) { var pin = sender as Pin; if (pin == null) { return; } var viewModel = ItemsSource.FirstOrDefault(x => x.Title == pin.Label); if (viewModel == null || viewModel.Command == null) { return; } viewModel.Command.Execute(null); }
private void UpdateSelectedItem(int index) { if (index < 0) { index = ItemsSource.Count() - 1; } if (index > ItemsSource.Count() - 1) { index = 0; } SelectedItem = ItemsSource.ToList()[index]; var item = TabsRepeater.Children[index]; TabsScroll.ScrollToAsync(item, ScrollToPosition.MakeVisible, false); }
private void SvScrollView_Scrolled(object sender, ScrolledEventArgs e) { if (svScrollView.ScrollY > YScroll) { YScroll = svScrollView.ScrollY; } double scrollingSpace = svScrollView.ContentSize.Height - svScrollView.Height - 20; if (scrollingSpace <= e.ScrollY && !IsRefreshing) { if (ItemsSource.Any()) { ItemAppearing?.Invoke(this, new ItemVisibilityEventArgs(ItemsSource[ItemsSource.Count - 1])); } } }
//override GetItem to return the correct item based on the section number public override object GetItem(int position) { var sectionHeader = _headerLocationMap.LastOrDefault(i => position >= i.Key); //Mvx.TaggedTrace(LogTag, "position {0}, key {1}, value {2}", position, sectionHeader.Key, sectionHeader.Value); var section = ItemsSource.ElementAt(sectionHeader.Value) as IEnumerable; var itemIndex = position - sectionHeader.Key - 1; if (position == sectionHeader.Key) { //This is a header row, return the section itself to support binding the key or other properties a section might have return(section); } //Mvx.TaggedTrace(LogTag, "position {0}, key {1}, value {2}, itemIndex {3}, items in section {4}", position, sectionHeader.Key, sectionHeader.Value, itemIndex, section.Count()); return(itemIndex >= 0 ? section.ElementAt(itemIndex) : null); }
private void OnUpdate() { var item = ItemsSource.FirstOrDefault(); if (item == null) { return; } item.IsValid = !item.IsValid; var index = ItemsSource.IndexOf(item); var u = new ItemInfo { Name = item.Name, Comment = item.Comment, IsValid = item.IsValid }; ItemsSource.Insert(index, u); }
protected override object GetItemAt(NSIndexPath indexPath) { if (!SuggestCreation) { return(base.GetItemAt(indexPath)); } var index = (int)indexPath.Item; if (index == 0) { return($"Create client \"{Text.Trim()}\""); } return(ItemsSource.ElementAt(index - 1)); }
/// <summary> /// Causes the column cell being edited to revert to the specified value. /// </summary> /// <param name="editingElement">The element that the column displays for a cell in editing mode.</param> /// <param name="uneditedValue">The previous, unedited value in the cell being edited.</param> protected override void CancelCellEdit(FrameworkElement editingElement, object uneditedValue) { var comboBox = editingElement as ComboBox; if (comboBox != null && uneditedValue != null) { var value = uneditedValue.GetType().GetProperty(Binding.Path.Path).GetValue(uneditedValue); var selection = ItemsSource?.Cast <object>().FirstOrDefault(x => x.GetType().GetProperty(Binding.Path.Path).GetValue(x).Equals(value)); comboBox.SelectedItem = selection; } else if (comboBox != null) { comboBox.SelectedItem = null; } }
public MainPageViewModel(IPageDialogService pageDialog) { var rand = new Random(); for (var i = 0; i < 50; i++) { ItemsSource.Add(new Person { Name = RandomName(rand) }); } Command.Subscribe(async text => { await pageDialog.DisplayAlertAsync(text, "", "OK"); }); }
public override void ItemSelected(UICollectionView collectionView, NSIndexPath indexPath) { var item = (Genre)GetItemAt(indexPath); var firstItem = ItemsSource?.ElementAt(0); if (firstItem != null && firstItem != item) { (firstItem as Genre).IsSelected = false; } else { (firstItem as Genre).IsSelected = true; } GenreSelection.ItemSelectionChanged(item); collectionView.ReloadData(); }
private void SetItems() { stackLayout.Children.Clear(); if (ItemsSource == null) { return; } foreach (var item in ItemsSource) { stackLayout.Children.Add(GetItemView(item)); } SelectedItem = ItemsSource.Cast <object>().FirstOrDefault(); }
protected virtual void SetItems() { ItemsStackLayout.Children.Clear(); if (ItemsSource == null) { return; } foreach (var item in ItemsSource) { ItemsStackLayout.Children.Add(GetItemView(item)); } SelectedItem = ItemsSource.OfType <object>().FirstOrDefault(x => SelectedItem == x); }
private void HeaderCell_OnHeaderTapped(object sender, DataGridColumn dataGridColumn) { if (_currentSortingColumn != dataGridColumn && dataGridColumn.SortingEnabled) { _currentSortingColumn?.ResetOrderType(); _currentSortingColumn = dataGridColumn; } if (_autoSort && _currentSortingColumn != null && _currentSortingColumn.SortingEnabled) { var orderQuery = ItemsSource.AsQueryable().SortBy(_currentSortingColumn.PropertyName, _currentSortingColumn.SortOrderType); SortCommand?.Execute(orderQuery); } HeaderTappedCommand?.Execute(dataGridColumn); }
protected virtual void SetItems() { ItemsStackLayout.Children.Clear(); ItemsStackLayout.Orientation = ListOrientation; if (ItemsSource == null) { return; } foreach (var item in ItemsSource) { ItemsStackLayout.Children.Add(GetItemView(item)); } SelectedItem = ItemsSource.OfType <ISelectable>().FirstOrDefault(x => x.IsSelected); }
public void ScrollTo( TItemData itemData, float alignment, float duration = .1f, Ease ease = Ease.Linear, System.Action onComplete = null) { var itemIndex = ItemsSource.IndexOf(itemData); if (itemIndex < 0) { return; } ScrollTo(itemIndex, alignment, duration, ease, onComplete); }