private int ConvertFromItemToFlat(int index, bool removed) { ReadOnlyObservableCollection <object> groups = BaseGroups; if (groups != null) { int start = 1; for (int i = 0; i < groups.Count; i++) { CollectionViewGroup group = groups[i] as CollectionViewGroup; if (group != null) { index++; int end = start + group.ItemCount; if ((start <= index) && ((!removed && index < end) || (removed && index <= end))) { break; } start = end + 1; } } } return(index); }
public object Convert(object values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (values == null) { return(string.Empty); } CollectionViewGroup group = values as CollectionViewGroup; long total = 0; if (group.IsBottomLevel) { foreach (EventStat s in group.Items) { total += s.Count; } } else { foreach (CollectionViewGroup g in group.Items) { foreach (EventStat s in g.Items) { total += s.Count; } } } return(total); }
/// <summary> /// This currently only supports one level of grouping. /// Returns CollectionViewGroups if the index matches a header. /// Otherwise, maps the index into the base range to get the /// actual item. /// </summary> public override object GetItemAt(int index) { int delta = 0; ReadOnlyObservableCollection <object> groups = BaseGroups; if (groups != null) { int totalCount = 0; for (int i = 0; i < groups.Count; i++) { CollectionViewGroup group = groups[i] as CollectionViewGroup; if (group != null) { if (index == totalCount) { return(group); } delta++; int numInGroup = group.ItemCount; totalCount += numInGroup + 1; if (index < totalCount) { break; } } } } object item = base.GetItemAt(index - delta); return(item); }
// This converts the DateTime object to the string to display. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { CollectionViewGroup cvg = value as CollectionViewGroup; string param = parameter as string; switch (param) { case "Kills": return(cvg.Items.Sum(x => (x as AllMatches).Kills)); case "Deaths": return(cvg.Items.Sum(x => (x as AllMatches).Deaths)); case "Assists": return(cvg.Items.Sum(x => (x as AllMatches).Assists)); case "Wards": return(cvg.Items.Sum(x => (x as AllMatches).Wards)); case "Pinks": return(cvg.Items.Sum(x => (x as AllMatches).Pinks)); case "DamageOutput": return(cvg.Items.Sum(x => (x as AllMatches).DamageOutput)); default: return(0); } }
private static GroupStyle SelectGroupStyle(this DropDownButton button, CollectionViewGroup group, int level) { //we select a proper GroupStyle from the owner's GroupStyle collection var index = Math.Min(level, button.GroupStyle.Count - 1); return(button.GroupStyle.Any() ? button.GroupStyle[index] : null); }
private void viewModel_SequenceUpdated(object sender, EventArgs e) { CollectionViewSource source = (CollectionViewSource)(this.Resources["SequenceView"]); ListCollectionView view = (ListCollectionView)source.View; if (view != null && view.Groups != null && view.Groups.Count > 0) { view.Refresh(); CollectionViewGroup cvg = view.Groups.First() as CollectionViewGroup; if (cvg.Name.ToString() == Constants.HOLDING_CHARACTERS_GROUP_NAME && view.Groups.Count > 1) { cvg = view.Groups[1] as CollectionViewGroup; } GroupItem groupItem = this.SequenceViewListBox.ItemContainerGenerator.ContainerFromItem(cvg) as GroupItem; if (groupItem != null) { groupItem.UpdateLayout(); Expander expander = Helper.GetDescendantByType(groupItem, typeof(Expander)) as Expander; if (expander != null) { expander.IsExpanded = true; } } } }
private void ShowTextByGroup(CollectionViewGroup @group, int startsCategoryCount) { if (@group == null) { return; } CategoryText categoryText = GetCategoryFromName(@group == null ? "" : @group.Name.ToString()); if (categoryText == null) { categoryText = new CategoryText { Name = @group == null ? "" : @group.Name.ToString(), Collapsed = true }; _category.Add(categoryText); } categoryText.SetVisualNameAndIsNew(@group.Items); // если список категорий был пуст (т.е. тексты автора обновились полностью) // и в категории есть новые произведение, то раскрыть if ((startsCategoryCount == 0) && (categoryText.IsNew)) { categoryText.Collapsed = false; } _outputCollection.Add(categoryText); if (!categoryText.Collapsed) { foreach (object item in @group.Items) { _outputCollection.Add(item); } } }
public override DataTemplate SelectTemplate(object item, DependencyObject container, ViewDefinitionBase activeViewDeifinition) { CollectionViewGroup cvg = item as CollectionViewGroup; if (cvg != null && cvg.Name is IResource) { if (activeViewDeifinition.GetOrientation() == Orientation.Vertical) { if (this.HorizontalResourceTemplate != null) { return(this.HorizontalResourceTemplate); } } else { if (this.VerticalResourceTemplate != null) { return(this.VerticalResourceTemplate); } } } if (cvg != null && cvg.Name is DateTime) { if (activeViewDeifinition.GetOrientation() == Orientation.Vertical) { return(this.HorizontalTemplate); } else { return(this.VerticalTemplate); } } return(base.SelectTemplate(item, container, activeViewDeifinition)); }
internal Group( GroupGeneratorNode node, CollectionViewGroup group, LateGroupLevelDescription groupLevelDescription, DataGridContext dataGridContext) { if (node == null) { throw new ArgumentNullException("node"); } if (group == null) { throw new ArgumentNullException("group"); } if (groupLevelDescription == null) { throw new ArgumentNullException("groupLevelDescription"); } if (dataGridContext == null) { throw new ArgumentNullException("dataGridContext"); } m_collectionViewGroup = group; // Initialization is done through setters to register for events. this.DataGridContext = dataGridContext; this.GeneratorNode = node; this.GroupLevelDescription = groupLevelDescription; }
public override DataTemplate SelectTemplate(object item, DependencyObject container) { ContentPresenter cp = container as ContentPresenter; if (cp != null) { CollectionViewGroup cvg = cp.Content as CollectionViewGroup; if (cvg.Items.Count > 0) { UserCase stinfo = cvg.Items[0] as UserCase; if (stinfo != null) { return(GroupCategoryTemplate); } else { return(GroupNameTemplate); } } } return(base.SelectTemplate(item, container)); }
public override GroupStyle SelectTemplate(CollectionViewGroup @group, int level) { //'group' is the parent of current group item (and null for level=0). current group item is not available! // string groupKey = "GroupName:"+(@group==null ? "{Null}" : (@group.Name==null ? "{Null}" : @group.Name.ToString())); // var levelKey = "Level:"+level; // // string key = groupKey+"+"+levelKey; // if(!Resources.Contains(key)) { // key = groupKey; // if(!Resources.Contains(key)) { // key = levelKey; // if(!Resources.Contains(key)) return null; // } // } var key = level.ToString(CultureInfo.InvariantCulture); if (!Resources.Contains(key)) { return(null); } var groupStyle = Resources[key] as GroupStyle; return(groupStyle); }
private static CollectionViewGroup GetCollectionViewGroupHelper(DataGridContext dataGridContext, ObservableCollection <GroupDescription> groupDescriptions, object item, int groupLevel) { if (item == null) { return(null); } int levelOfRecursion = groupDescriptions.Count - groupLevel - 1; CollectionViewGroup retval = dataGridContext.GetParentGroupFromItemCore(item, true); if (retval == null) { return(null); } for (int i = 0; i < levelOfRecursion; i++) { retval = dataGridContext.GetParentGroupFromItemCore(retval, true) as CollectionViewGroup; if (retval == null) { return(null); } } return(retval); }
protected override void RestoringVisit(DataGridContext sourceContext, CollectionViewGroup group, object[] namesTree, int groupLevel, bool isExpanded, bool isComputedExpanded) { if (sourceContext != m_rootDataGridContext) { throw new InvalidOperationException("Group does not belong to the root DataGridContext."); } if (groupLevel > m_maxGroupLevel) { return; } GroupNamesTreeKey groupNamesTreeKey = new GroupNamesTreeKey(namesTree); bool wasExpanded; if (m_groupsStateDictionary.TryGetValue(groupNamesTreeKey, out wasExpanded)) { if (wasExpanded) { sourceContext.ExpandGroup(group, true); } else { sourceContext.CollapseGroup(group, true); } } else if (m_stopAtFirstCollapsedGroup) { sourceContext.CollapseGroup(group, true); } }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { CollectionViewGroup group = (CollectionViewGroup)value; ReadOnlyObservableCollection <object> items = group.Items; return(items.Count); }
private double GetSubTotal(CollectionViewGroup collectionViewGroup) { double tot = Double.MaxValue; if (collectionViewGroup.Items[0] is PayrollItem) { return((from i in collectionViewGroup.Items.AsEnumerable() select((DataLayer.PayrollItem)i).Amount).Sum()); } if (collectionViewGroup.Items[0] is PayrollEmployeeSetup) { return((Double)(from i in collectionViewGroup.Items select((DataLayer.PayrollEmployeeSetup)i).Amount).Sum()); } if (collectionViewGroup.Items[0] is AccountEntry) { return((Double)(from i in collectionViewGroup.Items.AsEnumerable() select((DataLayer.AccountEntry)i).Total).Sum()); } if (collectionViewGroup.Items[0] is PayrollItemsReportModel.PayrollReportLine) { return((Double)(from i in collectionViewGroup.Items.AsEnumerable() select((PayrollItemsReportModel.PayrollReportLine)i).Amount).Sum()); } return(tot); }
private void HandleGroupCheckRecursive_Internal(CollectionViewGroup group, bool check, ref List <object> selectedItems) { foreach (var itemOrGroup in group.Items) { if (itemOrGroup is CollectionViewGroup) { // Found a nested group - recursively run this method again this.HandleGroupCheckRecursive(itemOrGroup as CollectionViewGroup, check); } else if (itemOrGroup is TraceLineDesign) { var item = (TraceLineDesign)itemOrGroup; item.IsChecked = check; if (check) { selectedItems.Add(item); } else { selectedItems.Remove(item); } } } }
internal void PopulateGroupItemPeers() { Dictionary <object, DataGridGroupItemAutomationPeer> oldChildren = new Dictionary <object, DataGridGroupItemAutomationPeer>(_groupItemPeers); _groupItemPeers.Clear(); if (this.OwningDataGrid.DataConnection.CollectionView != null && this.OwningDataGrid.DataConnection.CollectionView.CanGroup && this.OwningDataGrid.DataConnection.CollectionView.Groups != null && this.OwningDataGrid.DataConnection.CollectionView.Groups.Count > 0) { List <object> groups = new List <object>(this.OwningDataGrid.DataConnection.CollectionView.Groups); while (groups.Count > 0) { CollectionViewGroup cvGroup = groups[0] as CollectionViewGroup; groups.RemoveAt(0); if (cvGroup != null) { // Add the group's peer to the collection DataGridGroupItemAutomationPeer peer = null; if (oldChildren.ContainsKey(cvGroup)) { peer = oldChildren[cvGroup] as DataGridGroupItemAutomationPeer; } else { peer = new DataGridGroupItemAutomationPeer(cvGroup, this.OwningDataGrid); } if (peer != null) { DataGridRowGroupHeaderAutomationPeer rghPeer = peer.OwningRowGroupHeaderPeer; if (rghPeer != null) { rghPeer.EventsSource = peer; } } // This guards against the addition of duplicate items if (!_groupItemPeers.ContainsKey(cvGroup)) { _groupItemPeers.Add(cvGroup, peer); } // Look for any sub groups if (!cvGroup.IsBottomLevel) { int position = 0; foreach (object subGroup in cvGroup.Items) { groups.Insert(position, subGroup); position++; } } } } } }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { CollectionViewGroup group = (CollectionViewGroup)value; ReadOnlyObservableCollection <object> items = group.Items; var sum = (from p in items select((ProjectCompletedModel)p).SomeValueToSum).Sum(); return(sum); }
// Group selection is done with FastListView private void HandleGroupCheckRecursive(CollectionViewGroup group, bool check) { List <object> items = new List <object>(lvTrace.SelectedItems as IEnumerable <object>); HandleGroupCheckRecursive_Internal(group, check, ref items); lvTrace.SelectItems(items); }
public GroupExpansionChangingEventArgs(RoutedEvent routedEvent, Group group, CollectionViewGroup collectionViewGroup, DataGridContext dataGridContext, bool isExpanding) : base(routedEvent) { this.CollectionViewGroup = collectionViewGroup; this.DataGridContext = dataGridContext; this.Group = group; this.IsExpanding = isExpanding; }
private void OpenFournAction(object parameters) { GroupItem groupItem = (GroupItem)parameters; CollectionViewGroup collectionViewGroup = (CollectionViewGroup)groupItem.Content; Commande commande = (Commande)collectionViewGroup.Items[0]; Process.Start(cdeRepos.getSagePath(), $"{cdeRepos.fichierGescom} -u={cdeRepos.user} -cmd=\"Tiers.Show(Tiers='{commande.CtNum}')\""); }
public static int GetItemCount(this CollectionViewGroup collectionViewGroup) { if (collectionViewGroup is DataGridVirtualizingCollectionViewGroupBase) { return((( DataGridVirtualizingCollectionViewGroupBase )collectionViewGroup).VirtualItemCount); } return(collectionViewGroup.ItemCount); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { GroupItem groupItem = (GroupItem)value; CollectionViewGroup collectionViewGroup = (CollectionViewGroup)groupItem.Content; Commande commande = (Commande)collectionViewGroup.Items[0]; return((string.IsNullOrEmpty(commande.AcheteurPrinc)) ? string.Empty : $"{commande.AcheteurPrinc}"); }
public GroupGeneratorNode(CollectionViewGroup group, GeneratorNode parent, GroupConfiguration groupConfig) : base(parent) { Debug.Assert(group != null, "group cannot be null for GroupGeneratorNode"); Debug.Assert(groupConfig != null); m_group = group; m_groupConfig = groupConfig; }
private void TagCloudListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { CollectionViewGroup selected = (CollectionViewGroup)((ListBox)sender).SelectedItem; if (selected != null) { RaiseEvent(new RoutedEventArgs(TagSelectionChangedEvent, selected.Name)); } }
// Token: 0x06004E0B RID: 19979 RVA: 0x0015FC70 File Offset: 0x0015DE70 internal override string GetPlainText() { CollectionViewGroup collectionViewGroup = base.Content as CollectionViewGroup; if (collectionViewGroup != null && collectionViewGroup.Name != null) { return collectionViewGroup.Name.ToString(); } return base.GetPlainText(); }
protected virtual void RestoringVisit(DataGridContext sourceContext, CollectionViewGroup group, object[] namesTree, int groupLevel, bool isExpanded, bool isComputedExpanded) { throw new NotImplementedException(); }
private void HistogramListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { CollectionViewGroup selected = (CollectionViewGroup)((ListBox)sender).SelectedItem; if (selected != null) { string categoryLabel = GetCategoryLabel(selected.Name); RaiseEvent(new RoutedEventArgs(CategorySelectionChangedEvent, categoryLabel)); } }
public GroupHeaderFooterItem(CollectionViewGroup collectionViewGroup, object template) { if (!(template is DataTemplate) && !(template is GroupHeaderFooterItemTemplate)) { throw new ArgumentException("A GroupHeaderFooterItem can only be created with a DataTemplate or VisibleWhenCollapsed objects.", "template"); } m_template = template; m_weakGroup = new WeakReference(collectionViewGroup); }
internal void ClearGroup() { m_groupDescription = null; m_collectionViewGroup = null; m_propertyChanged = null; this.DataGridContext = null; this.GeneratorNode = null; this.GroupLevelDescription = null; }