示例#1
0
        public void ItemAddRange(IEnumerable <object> items)
        {
            ItemAddBase(items);

            /* === 更新イベント === */
            UpdatedList?.Invoke(this, EventArgs.Empty);
        }
示例#2
0
        public void ItemRemoveAt(IEnumerable <int> indices)
        {
            ItemRemoveAtBase(indices);

            /* === 更新イベント === */
            UpdatedList?.Invoke(this, EventArgs.Empty);
        }
示例#3
0
        public void ItemRemoveAt(int index)
        {
            ItemRemoveAtBase(new [] { index });

            /* === 更新イベント === */
            UpdatedList?.Invoke(this, EventArgs.Empty);
        }
示例#4
0
 public void Update(RealData item)
 {
     if (item.Name.Equals("error"))
     {
         throw new Exception("error happened");
     }
     UpdatedList.Add(item);
 }
示例#5
0
        public void ItemClear()
        {
            items_ = new List <object>();

            /* すぐにメモリに反映させるためにGCを手動リセット */
            GC.Collect();

            VirtualListSize = items_.Count;

            /* === 更新イベント === */
            UpdatedList?.Invoke(this, EventArgs.Empty);
        }
        public async Task <ActionResult> UpdateList(UpdatedList list)
        {
            // Get the customer id from the access token
            string customerId = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            // Make sure this customer is the owner of this list
            if (!await unitOfWork.Collaborators.Any(x => x.ListId == list.Id && x.CustomerId == customerId && x.IsOwner))
            {
                return(Unauthorized());
            }


            // Get the list from the database
            List updatedList = await unitOfWork.Lists.Get(list.Id);

            // Update the list with the new data
            if (updatedList != null)
            {
                string previousName = updatedList.Name;

                updatedList.Name        = list.Name;
                updatedList.Description = list.Description;

                // Update and save
                unitOfWork.Lists.Update(updatedList);
                await unitOfWork.Save();



                // Setup the email
                if (previousName != list.Name)
                {
                    emailService.SetupEmail(SetupChangedListName, new EmailSetupParams
                    {
                        Host       = GetHost(),
                        CustomerId = User.FindFirst(ClaimTypes.NameIdentifier).Value,
                        ListId1    = updatedList.Id,
                        Var1       = previousName,
                        Var2       = list.Name
                    });
                }



                return(Ok(new
                {
                    name = list.Name,
                    description = list.Description
                }));
            }

            return(BadRequest());
        }
示例#7
0
        protected override void OnDragDrop(DragEventArgs e)
        {
            if (ReadOnly)
            {
                return;
            }

            var item_drag = (int[])e.Data.GetData(typeof(int[]));

            if (item_drag == null)
            {
                return;
            }

            /* === 移動するアイテムを抽出する === */
            /* 削除するとインデックスがずれてしまうため降順で検索する */
            var move_items = new Stack <object>();

            foreach (var value in item_drag.OrderByDescending(item => item))
            {
                move_items.Push(items_[value]);
                ItemRemoveAtBase(new [] { value });
            }

            /* === 挿入位置(アイテム)を取得する === */
            var insert_pos   = PointToClient(new Point(e.X, e.Y));
            var insert_obj   = GetItemAt(insert_pos.X, insert_pos.Y);
            var insert_index = 0;

            if (insert_obj != null)
            {
                insert_index = insert_obj.Index;
            }
            else if (insert_pos.Y > 0)
            {
                insert_index = (int)items_.Count;
            }

            /* === 挿入する === */
            ItemInsertBase(insert_index, move_items);

            /* === 更新イベント === */
            UpdatedList?.Invoke(this, EventArgs.Empty);
        }
示例#8
0
        protected override void OnListChanged(System.ComponentModel.ListChangedEventArgs e)
        {
            switch (e.ListChangedType)
            {
            case System.ComponentModel.ListChangedType.ItemAdded:

                AddedList.Add(this[e.NewIndex]);

                break;

            case System.ComponentModel.ListChangedType.ItemChanged:
                UpdatedList.Add(this[e.NewIndex]);
                break;

            case System.ComponentModel.ListChangedType.ItemDeleted:
                //   DeleteList.Add(this[e.NewIndex]);
                break;

            default:
                break;
            }
            base.OnListChanged(e);
        }