예제 #1
0
        private void RaiseEventBeforeItemSelected(object item)
        {
            EventHandler <CollectionListBoxEventArgs> handler = BeforeItemSelected;

            if (handler != null)
            {
                CollectionListBoxEventArgs ea = new CollectionListBoxEventArgs(item);
                handler(this, ea);
            }
        }
예제 #2
0
        private void RaiseEventItemSelected(object item)
        {
            EventHandler <CollectionListBoxEventArgs> handler = ItemSelected;

            if (handler != null)
            {
                CollectionListBoxEventArgs ea = new CollectionListBoxEventArgs(item);

                _lastCategory = GetCategory(item, CategoryProperty);
                handler(this, ea);
            }
        }
예제 #3
0
        private void ButtonCopy_Click(object sender, EventArgs e)
        {
            if (listViewSelected.SelectedItems.Count == 0)
            {
                return;
            }

            if (Copy != null)
            {
                var args = new CollectionListBoxEventArgs(listViewSelected.SelectedItems[0].Tag);
                Copy(this, args);
            }
        }
예제 #4
0
        private void Add(Type addtype)
        {
            RaiseEventBeforeItemSelected(_selectedObject);

            var _obj = Activator.CreateInstance(addtype);

            if (CategoryProperty != null)
            {
                var _prop = _obj.GetType().GetProperty(CategoryProperty);

                if (_prop.CanWrite && _prop.PropertyType == typeof(string))
                {
                    _prop.SetValue(_obj, _lastCategory);
                }
            }

            CollectionListBoxEventArgs ea = new CollectionListBoxEventArgs(_obj);


            OnAdd?.Invoke(this, ea);
            if (ea.Canceled)
            {
                return;
            }

            _collection.Add(ea.Item);

            OnCollectionChanged?.Invoke(this, new EventArgs());

            BuildCollectionList();
            foreach (ListViewItem lvi in listViewSelected.Items)
            {
                if (lvi.Tag == ea.Item)
                {
                    lvi.Selected = true;
                    lvi.EnsureVisible();
                    ListViewClick();
                }
            }
            listViewSelected.Focus();
        }
예제 #5
0
        private void ButtonPaste_Click(object sender, EventArgs e)
        {
            if (Paste != null)
            {
                var args = new CollectionListBoxEventArgs(listViewSelected.SelectedItems[0].Tag);
                Paste(this, args);

                _collection.Add(args.Item);

                BuildCollectionList();
                foreach (ListViewItem lvi in this.listViewSelected.Items)
                {
                    if (lvi.Tag == args.Item)
                    {
                        lvi.Selected = true;
                        lvi.EnsureVisible();
                        ListViewClick();
                    }
                }
                listViewSelected.Focus();
            }
        }
예제 #6
0
        private void ToolStripButton1_Click(object sender, EventArgs e)
        {
            if (listViewSelected.SelectedItems.Count == 0)
            {
                return;
            }

            if (Copy != null)
            {
                CollectionListBoxEventArgs args = new CollectionListBoxEventArgs(listViewSelected.SelectedItems[0].Tag);
                Copy(this, args);

                _selectedObject = null;
                foreach (ListViewItem lvi in listViewSelected.SelectedItems)
                {
                    Object o = (Object)lvi.Tag;
                    _collection.Remove(o);
                    lvi.Remove();
                    OnCollectionChanged?.Invoke(this, new EventArgs());
                }
                RaiseEventItemSelected(null);
                BuildCollectionList();
            }
        }