示例#1
0
        /// <summary>
        /// The list's window procedure.
        /// </summary>
        /// <param name="m">A Windows Message Object.</param>
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == LB_ADDSTRING ||
                m.Msg == LB_INSERTSTRING ||
                m.Msg == LB_DELETESTRING ||
                m.Msg == LB_RESETCONTENT)
            {
                ItemsChanged?.Invoke(this, new EventArgs());
            }

            // if the message indicates that the TopIndex property of the list box might have changed, raise the VScrollChanged event..
            if (m.Msg == WM_VSCROLL || m.Msg == WM_MOUSEWHEEL || m.Msg == WM_KEYDOWN)
            {
                // ..if not denied and the TopIndex property was actually changed..
                if (lastTopIndex != this.TopIndex)
                {
                    lastTopIndex = TopIndex; // save the top index so it's changes can be monitored..

                    // if the VScrollChanged event is subscribed the raise the event with (FromControl = true)..
                    VScrollChanged?.Invoke(this, new VScrollChangedEventArgs()
                    {
                        Minimum = 0, Maximum = Items.Count, Value = VScrollPosition, FromControl = true
                    });
                }
            }

            base.WndProc(ref m);
        }
示例#2
0
        public new TValue this[TKey key]
        {
            get
            {
                return(base[key]);
            }
            set
            {
                Boolean succesfull = TryGetValue(key, out TValue val);

                if (succesfull && val?.Equals(value) == true)
                {
                    return;
                }

                base[key] = value;

                if (succesfull)
                {
                    OnChange?.Invoke(key, value);
                }
                else
                {
                    OnAdd?.Invoke(key, value);
                }

                OnSet?.Invoke(key, value);
                ItemsChanged?.Invoke();
            }
        }
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);

            switch (m.Msg)
            {
            case 0x1007:
                ItemsChanged?.Invoke();
                break;

            case 0x104D:
                ItemsChanged?.Invoke();
                break;

            case 0x1008:
                ItemsChanged?.Invoke();
                break;

            case 0x1009:
                ItemsChanged?.Invoke();
                break;

            default:
                break;
            }
        }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        protected virtual void OnItemsChanged()
        {
            OnPropertyChanged("Count");
            IsEmpty = Count == 0;

            ItemsChanged?.Invoke(this, new EventArgs());
        }
示例#5
0
 public new void Add(TKey key, TValue value)
 {
     base.Add(key, value);
     OnAdd?.Invoke(key, value);
     OnSet?.Invoke(key, value);
     ItemsChanged?.Invoke();
 }
 internal void FireContentChanged()
 {
     if (ItemsChanged != null)
     {
         ItemsChanged.Invoke(this, EventArgs.Empty);
     }
 }
示例#7
0
 public new void Insert(Int32 index, T item)
 {
     base.Insert(index, item);
     OnAdd?.Invoke(ref item);
     OnInsert?.Invoke(index, ref item);
     ItemsChanged?.Invoke();
 }
示例#8
0
        public MenuItem <T> Add(string text, T value = default(T))
        {
            MenuItem <T> menuItem = MenuItem <T> .Create(text, value);

            _menuItems.Add(menuItem);
            ItemsChanged?.Invoke(this, EventArgs.Empty);
            return(menuItem);
        }
示例#9
0
    public void RemoveItem(Item item)
    {
        _itemsInventory.Remove(item);

        _audioSource.PlayOneShot(_selectClip);

        ItemsChanged?.Invoke();
    }
示例#10
0
 private void Start()
 {
     if (_startItems)
     {
         Items = _startItems.GetItemDictionary();
     }
     ItemsChanged.Invoke();
 }
示例#11
0
 public MaterialsToStudentViewModel(IEnumerable <MaterialSelectorItem> materials)
 {
     Materials = new ObservableCollection <MaterialSelectorItem>(materials);
     Apply     = new DelegateCommand(() => {
         ItemsChanged?.Invoke(this, EventArgs.Empty);
         ViewService.Message("Материалы прикрепленны");
     });
 }
 public void Clear()
 {
     InvokeIfRequired(() =>
     {
         Control.Items.Clear();
         ItemsChanged?.Invoke(this, new GenericEventArgs <string[]>(Items));
     });
 }
示例#13
0
 protected override void OnItemsChanged(object e)
 {
     base.OnItemsChanged(e);
     ItemsChanged?.Invoke(this, new MessagesViewItemsChangedArgs()
     {
         Items = Items
     });
 }
示例#14
0
        public new void RemoveAt(Int32 index)
        {
            T item = this[index];

            base.RemoveAt(index);
            OnRemove?.Invoke(item);
            ItemsChanged?.Invoke();
        }
示例#15
0
        public async Task DeleteItemByKey(Guid ID)
        {
            var item = await this[ID];
            await _companyCollection.FindOneAndUpdateAsync(e => e.ID == item.CompanyID,
                                                           Builders <Company> .Update.Pull(e => e.Employees, item));

            ItemsChanged?.Invoke(this, new RepositoryChangeEventArgs <Employee>(OperationType.Delete, item));
        }
示例#16
0
    public bool Remove(Item item)
    {
        var success = items.Remove(item);

        ItemsChanged?.Invoke();

        return(success);
    }
示例#17
0
文件: ItemList.cs 项目: Daoting/dt
 /// <summary>
 /// 触发集合更改事件
 /// </summary>
 /// <param name="change"></param>
 /// <param name="index"></param>
 void RaiseVectorChanged(CollectionChange change, int index)
 {
     if (_updating <= 0 && ItemsChanged != null)
     {
         // 符合更新条件,触发基类事件,否则延迟更新
         ItemsChanged.Invoke(this, new ItemListChangedArgs(change, index));
     }
 }
 public void AddRange(string[] items)
 {
     InvokeIfRequired(() =>
     {
         Control.Items.AddRange(items);
         ItemsChanged?.Invoke(this, new GenericEventArgs <string[]>(Items));
     });
 }
 public void Remove(string item)
 {
     InvokeIfRequired(() =>
     {
         Control.Items.Remove(item);
         ItemsChanged?.Invoke(this, new GenericEventArgs <string[]>(Items));
     });
 }
示例#20
0
 private void button2_Click(object sender, EventArgs e)
 {
     while (listBox1.SelectedIndices.Count > 0)
     {
         listBox1.Items.RemoveAt(listBox1.SelectedIndices[0]);
     }
     ItemsChanged?.Invoke(this, EventArgs.Empty);
 }
示例#21
0
        public new int RemoveAll(Predicate <T> match)
        {
            int removedCount = base.RemoveAll(match);

            ItemRemoved?.Invoke();
            ItemsChanged?.Invoke();
            return(removedCount);
        }
        public void AddItem()
        {
            _items.Add(new Item {
                Title = $"Item {_items.Count}"
            });

            ItemsChanged?.Invoke(this, EventArgs.Empty);
        }
示例#23
0
        public void ReplaceItems(IEnumerable <MenuItemUserModel> userItems)
        {
            var newItems = userItems.ToList();

            _items.Clear();
            RegisterModel(newItems, _items);
            ItemsChanged?.Invoke(newItems);
        }
示例#24
0
 void Item_Interact(object sender, EventArgs e)
 {
     foreach (IItem item in Parent.Controls)
     {
         item.Snap();
     }
     ItemsChanged?.Invoke();
 }
示例#25
0
 public virtual async Task RemoveItemAsync(IItem item)
 {
     _items.Remove(item);
     if (ItemsChanged != null)
     {
         await ItemsChanged.Invoke(this, Items);
     }
 }
示例#26
0
        protected override void OnPreviewMouseMove(MouseEventArgs e)
        {
            base.OnPreviewMouseMove(e);
            e.Handled = true;
            if (!_mouseLeftButtonDown)
            {
                return;
            }

            Point cursorScreenPosition = OpenControls.Wpf.DockManager.Controls.Utilities.GetCursorPosition();
            int   selectedIndex        = GetListBoxItemIndex(cursorScreenPosition);

            if ((selectedIndex < 0) || (selectedIndex >= Items.Count) || (selectedIndex == _dragIndex))
            {
                Point topLeftPoint = PointToScreen(new Point(0, 0));
                if (
                    (cursorScreenPosition.Y < (topLeftPoint.Y - 30)) ||
                    (cursorScreenPosition.Y > (topLeftPoint.Y + ActualHeight + 15)) ||
                    (cursorScreenPosition.X < (topLeftPoint.X - 30)) ||
                    (cursorScreenPosition.X > (topLeftPoint.X + ActualWidth + 15))
                    )
                {
                    // Cancel further drag processing until we get the next mouse left button down
                    _mouseLeftButtonDown = false;
                    System.Windows.Input.Mouse.Capture(this, CaptureMode.None);
                    System.Diagnostics.Debug.WriteLine("FloatTabRequest: count = " + Items.Count);
                    FloatTabRequest?.Invoke(this, null);
                }
                return;
            }

            Rect rectSelectedItem = GetListBoxItemBounds(selectedIndex);
            Rect rectDragItem     = GetListBoxItemBounds(_dragIndex);

            double selectedWidth = rectSelectedItem.Width;
            double currentWidth  = rectDragItem.Width;

            if (_dragIndex > SelectedIndex)
            {
                selectedWidth = -selectedWidth;
            }

            rectDragItem.Offset(selectedWidth, 0);
            if (!rectDragItem.Contains(cursorScreenPosition))
            {
                return;
            }

            // Move the item along to the new index
            var item = Items[_dragIndex];

            Items.Remove(item);
            Items.Insert(selectedIndex, item);
            _dragIndex    = selectedIndex;
            SelectedIndex = selectedIndex;

            ItemsChanged?.Invoke(this, null);
        }
示例#27
0
 private void rebuildProxies()
 {
     proxyList.Clear();
     foreach (TOriginal original in originalList)
     {
         proxyList.Add(converterMethod(original));
     }
     ItemsChanged?.Invoke();
 }
示例#28
0
 public new void AddRange(IEnumerable <T> collection)
 {
     base.AddRange(collection);
     if (collection.Count() > 0)
     {
         ItemAdded?.Invoke();
         ItemsChanged?.Invoke();
     }
 }
示例#29
0
 public new void InsertRange(int index, IEnumerable <T> collection)
 {
     base.InsertRange(index, collection);
     if (collection.Count() > 0)
     {
         ItemAdded?.Invoke();
         ItemsChanged?.Invoke();
     }
 }
示例#30
0
 public void Clear()
 {
     if (listBox1.Items.Count > 0)
     {
         listBox1.Items.Clear();
         button2.Enabled = false;
         ItemsChanged?.Invoke(this, EventArgs.Empty);
     }
 }