private void ItemsListViewSelectedIndexChanged(object sender, EventArgs e)
 {
     if (SelectedItemsChanged != null)
     {
         SelectedItemsChanged.Invoke(this, new SelectedItemsChangeEventArgs(_selectedItemsList.Count));
     }
 }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        protected virtual void OnSelectedItemsChanged(object sender, EventArgs e)
        {
            var Collection = new List <object>();

            SelectedItems.ForEach <object>(i => Collection.Add(i));
            SelectedItemsChanged?.Invoke(this, new EventArgs <IList <object> >(Collection));
        }
Example #3
0
        /// <summary>
        /// Déclenche l'événement SelectedItemsChanged
        /// </summary>
        protected virtual void OnSelectedItemsChanged(NotifyCollectionChangedEventArgs e)
        {
            SelectedItemsChanged?.Invoke(this, e);

            // Refresh Command
            DetailCommand.RaiseCanExecuteChanged();
        }
Example #4
0
        protected override void OnBeforeSelect(TreeViewCancelEventArgs e)
        {
            if (isRightClicked || !SelectableGroups && (e.Node as TreeNode).NodeType == TreeNodeType.GroupItem)
            {
                e.Cancel = true;
                base.OnBeforeSelect(e);
                return;
            }

            if (MultiSelect)
            {
                if (ModifierKeys == Keys.Control && selectedNodes.Contains(e.Node))
                {
                    if (justSelectedNode == e.Node)
                    {
                        justSelectedNode = null;
                        e.Cancel         = true;
                        return;
                    }
                    DeselectNode(e.Node);
                    SelectedNode = null;
                    e.Cancel     = true;
                    SelectedItemsChanged?.Invoke(this, EventArgs.Empty);
                }
            }

            base.OnBeforeSelect(e);
        }
Example #5
0
        private async Task UpdateSelected()
        {
            await OnItemSelected.InvokeAsync(SelectedItem);

            await SelectedItemsChanged.InvokeAsync(SelectedItems);

            await Update();
        }
 internal void UpdateSelection(T item, bool?selected)
 {
     if (selected == null)
     {
         return;
     }
     if (SelectedItems == null)
     {
         SelectedItems = new List <T>();
     }
     if (selected == false)
     {
         SelectedItems.Remove(item);
         InvokeAsync(async() =>
         {
             try
             {
                 await SelectedItemsChanged.InvokeAsync(SelectedItems);
             }
             catch
             {
             }
         });
     }
     else if (selected == true && !SelectedItems.Contains(item))
     {
         SelectedItems.Add(item);
         InvokeAsync(async() =>
         {
             try
             {
                 await SelectedItemsChanged.InvokeAsync(SelectedItems);
             }
             catch
             {
             }
         });
     }
 }
 internal void UpdateSelection(T item, bool selected, bool indeterminate)
 {
     if (SelectedItems == null)
     {
         SelectedItems = new List <T>();
     }
     if (!selected || indeterminate)
     {
         SelectedItems.Remove(item);
         InvokeAsync(async() =>
         {
             try
             {
                 await SelectedItemsChanged.InvokeAsync(SelectedItems);
             }
             catch
             {
             }
         });
     }
     else
     {
         if (!SelectedItems.Contains(item))
         {
             SelectedItems.Add(item);
             InvokeAsync(async() =>
             {
                 try
                 {
                     await SelectedItemsChanged.InvokeAsync(SelectedItems);
                 }
                 catch
                 {
                 }
             });
         }
     }
 }
Example #8
0
        protected override void RenderAttributes(AttributesBuilder builder)
        {
            base.RenderAttributes(builder);

            if (SelectedItems != null)
            {
                builder.AddAttribute(nameof(SelectedItems), AttributeHelper.ObjectToDelegate(SelectedItems));
            }

            if (SelectedItem != null)
            {
                builder.AddAttribute(nameof(SelectedItem), AttributeHelper.ObjectToDelegate(SelectedItem));
            }
            if (SelectionMode != null)
            {
                builder.AddAttribute(nameof(SelectionMode), (int)SelectionMode.Value);
            }

            builder.AddAttribute("onselectionchanged", OnSelectionChanged);
            builder.AddAttribute("onselecteditemchanged", EventCallback.Factory.Create <ChangeEventArgs>(this, e => SelectedItemChanged.InvokeAsync(e.Value)));
            builder.AddAttribute("onselecteditemschanged", EventCallback.Factory.Create <ChangeEventArgs>(this, e => SelectedItemsChanged.InvokeAsync((IList <object>)e.Value)));
        }
Example #9
0
 private void RaiseSelectedItemsChanged()
 {
     SelectedItemsChanged?.Invoke(this, EventArgs.Empty);
 }
 protected virtual void OnSelectedItemsChanged()
 {
     SelectedItemsChanged?.Invoke(this, SelectedItems);
 }
Example #11
0
 private void OnSelectedItemsChangedInternal(Object newValue)
 {
     OnSelectedItemsChanged(newValue);
     SelectedItemsChanged?.Invoke(this, EventArgs.Empty);
 }
Example #12
0
        private void Render()
        {
            try
            {
                if (ItemsSource == null || ItemsSource.Count() == 0)
                {
                    return;
                }

                stackContainer.Children.Clear();
                if (IsMultiSelect)
                {
                    SelectedItems = new ObservableCollection <object>();
                }
                foreach (var item in ItemsSource)
                {
                    var displayText = DisplayMemberPath == null?item.ToString() : item.GetType().GetProperty(DisplayMemberPath).GetValue(item, null).ToString();

                    var btn = new ToggleButton
                    {
                        Text            = displayText,
                        FontFamily      = FontFamily,
                        BackgroundColor = BackgroundColor,
                        SelectedColor   = SelectedColor,
                        UnselectedColor = UnselectedColor,
                    };
                    if (!string.IsNullOrEmpty(InitialValuePath))
                    {
                        var value = item.GetType().GetProperty(InitialValuePath).GetValue(item, null);
                        if (value.ToString().Equals(InitialValue))
                        {
                            btn.IsSelected = true;
                        }
                    }
                    else if (InitialIndex >= 0)
                    {
                        if (ItemsSource.IndexOf(item) == InitialIndex)
                        {
                            btn.IsSelected = true;
                        }
                    }
                    btn.SelectionChanged += (s, e) =>
                    {
                        if (IsMultiSelect)
                        {
                            if (btn.IsSelected)
                            {
                                (SelectedItems as ObservableCollection <object>).Add(item);
                            }
                            else
                            {
                                (SelectedItems as ObservableCollection <object>).Remove(item);
                            }
                        }
                        else
                        {
                            var allToggleButtons = stackContainer.Children.Where(x => x is ToggleButton);
                            allToggleButtons?.ForEach(x => ((ToggleButton)x).IsSelected = false);
                            btn.IsSelected = true;
                            SelectedItems  = item;
                        }
                        if (!IsMultiSelect && btn.IsSelected)
                        {
                            SelectedItemsChanged?.Invoke(this, new TogglesBarSelectionChangedEventArgs
                            {
                                SelectedItems   = SelectedItems,
                                SelectedIndices = ItemsSource.IndexOf(item)
                            });
                        }
                        else if (IsMultiSelect)
                        {
                            SelectedItemsChanged?.Invoke(this, new TogglesBarSelectionChangedEventArgs
                            {
                                SelectedItems   = SelectedItems,
                                SelectedIndices = (SelectedItems as ObservableCollection <object>).Select(x => ItemsSource.IndexOf(x))
                            });
                        }
                    };
                    stackContainer.Spacing = ItemsSpacing;
                    stackContainer.Children.Add(btn);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #13
0
 protected virtual void OnSelectedItemsChanged(object obj, IList e)
 {
     SelectedItemsChanged?.Invoke(this, e);
 }
Example #14
0
        private void Render()
        {
            try
            {
                if (ItemsSource == null || ItemsSource.Count() == 0)
                {
                    return;
                }

                object selectedItems = new ObservableCollection <object>();

                stackContainer.Children.Clear();

                foreach (var item in ItemsSource)
                {
                    var displayText = item.ToString();
                    if (DisplayMemberPath != null)
                    {
                        var property = item.GetType().GetProperty(DisplayMemberPath);
                        if (property == null)
                        {
                            throw new InvalidOperationException($"The property selected by DisplayMemberPath ({DisplayMemberPath}) did not resolve.");
                        }
                        displayText = property.GetValue(item, null).ToString();
                    }
                    var btn = new Xamlly.XamllyControls.ToggleButton
                    {
                        Text            = displayText,
                        FontFamily      = FontFamily,
                        BackgroundColor = BackgroundColor,
                        SelectedColor   = SelectedColor,
                        UnselectedColor = UnselectedColor,
                    };

                    btn.IsSelected = ShouldSelectItem(item, displayText);

                    btn.SelectionChanged += (s, e) =>
                    {
                        if (IsMultiSelect)
                        {
                            if (btn.IsSelected)
                            {
                                (selectedItems as ObservableCollection <object>).Add(item);
                            }
                            else
                            {
                                (selectedItems as ObservableCollection <object>).Remove(item);
                            }
                        }
                        else
                        {
                            var allToggleButtons = stackContainer.Children.Where(x => x is Xamlly.XamllyControls.ToggleButton);
                            allToggleButtons?.ForEach(x => ((Xamlly.XamllyControls.ToggleButton)x).IsSelected = false);
                            btn.IsSelected = true;
                            SelectedItems  = item;
                        }

                        if (!IsMultiSelect && btn.IsSelected)
                        {
                            SelectedItemsChanged?.Invoke(this, new TogglesBarSelectionChangedEventArgs
                            {
                                SelectedItems   = selectedItems,
                                SelectedIndices = ItemsSource.IndexOf(item)
                            });
                        }
                        else if (IsMultiSelect)
                        {
                            SelectedItemsChanged?.Invoke(this, new TogglesBarSelectionChangedEventArgs
                            {
                                SelectedItems   = selectedItems,
                                SelectedIndices = (selectedItems as ObservableCollection <object>).Select(x => ItemsSource.IndexOf(x))
                            });
                        }
                    };
                    stackContainer.Spacing = ItemsSpacing;
                    stackContainer.Children.Add(btn);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #15
0
        protected override void OnAfterSelect(TreeViewEventArgs e)
        {
            if (!MultiSelect)
            {
                base.OnAfterSelect(e);
                selectedNodes.Clear();
                selectedNodes.Add(e.Node);
                SelectedItemsChanged?.Invoke(this, EventArgs.Empty);
                return;
            }

            justSelectedNode = SelectedNode;
            SelectedNode     = null;
            if (ModifierKeys == Keys.Control && !selectedNodes.Contains(e.Node))
            {
                SelectNode(e.Node);
                lastSelectedNode = e.Node;
                base.OnAfterSelect(e);
                SelectedItemsChanged?.Invoke(this, EventArgs.Empty);
                justSelectedNode = null;
                return;
            }
            else if (!(ModifierKeys == Keys.Shift) || (ModifierKeys == Keys.Control && lastSelectedNode == null))
            {
                DeselectNodes(selectedNodes);
                SelectNode(e.Node);
                lastSelectedNode = e.Node;
                base.OnAfterSelect(e);
                SelectedItemsChanged?.Invoke(this, EventArgs.Empty);
                justSelectedNode = null;
                return;
            }

            if (lastSelectedNode != null)
            {
                //Shift pressed
                TreeNode lowerNode;
                TreeNode upperNode;
                TreeNode prevLowerNode; // why it's not used?

                //Set upper - lower nodes
                if (lastSelectedNode.Bounds.Y < e.Node.Bounds.Y)
                {
                    upperNode = lastSelectedNode as TreeNode;
                    lowerNode = e.Node as TreeNode;
                }
                else
                {
                    upperNode = e.Node as TreeNode;
                    lowerNode = lastSelectedNode as TreeNode;
                }
                prevLowerNode = lowerNode;

                while (lowerNode != null && lowerNode != upperNode)
                {
                    if (!(!SelectableGroups && lowerNode.NodeType == TreeNodeType.GroupItem))
                    {
                        SelectNode(lowerNode);
                    }
                    prevLowerNode = lowerNode;
                    lowerNode     = lowerNode.PrevVisibleNode as TreeNode;
                }
                if (lowerNode != null)
                {
                    SelectNode(lowerNode);
                }

                lastSelectedNode = e.Node as TreeNode;
            }
            lastSelectedNode = e.Node as TreeNode;
            base.OnAfterSelect(e);
            SelectedItemsChanged?.Invoke(this, EventArgs.Empty);
            justSelectedNode = null;
        }