Example #1
0
        /* ----------------------------------------------------------------- */
        ///
        /// Replace
        ///
        /// <summary>
        /// 指定されたインデックスの内容を置換します。
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        public void Replace <T>(int index, T item)
        {
            if (index < 0 || index >= Count)
            {
                return;
            }
            var args = new ValueCancelEventArgs <int>(index);

            OnReplacing(args);
            if (args.Cancel || VirtualMode)
            {
                return;
            }

            var focused  = Items[index].Focused;
            var selected = Items[index].Selected;

            Items[index] = Converter?.Convert(item) ??
                           new System.Windows.Forms.ListViewItem(item.ToString());

            HackAlignmentBug();
            Items[index].Focused  = focused;
            Items[index].Selected = selected;
            OnReplaced(new ValueEventArgs <int>(index));
        }
Example #2
0
        /* ----------------------------------------------------------------- */
        ///
        /// WhenLocked
        ///
        /// <summary>
        /// ファイルがロックされている時に実行されるハンドラです。
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        private void WhenLocked(object sender, ValueCancelEventArgs <string> e)
        {
            var result = SyncWait(() => Views.ShowMessage(
                                      string.Format(
                                          Properties.Resources.MessageLock,
                                          System.IO.Path.GetFileName(e.Value)
                                          ), MessageBoxButtons.RetryCancel));

            e.Cancel = (result == DialogResult.Cancel);
        }
Example #3
0
 /* ----------------------------------------------------------------- */
 ///
 /// OnLocked
 ///
 /// <summary>
 /// Locked イベントを発生させます。
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 protected virtual void OnLocked(ValueCancelEventArgs <string> e)
 {
     if (Locked != null)
     {
         Locked(this, e);
     }
     else
     {
         e.Cancel = true;
     }
 }
Example #4
0
        /* ----------------------------------------------------------------- */
        ///
        /// Insert
        ///
        /// <summary>
        /// 指定されたインデックスに項目を追加します。
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        public void Insert <T>(int index, T item)
        {
            var args = new ValueCancelEventArgs <int>(index);

            OnAdding(args);
            if (args.Cancel || VirtualMode)
            {
                return;
            }

            Items.Insert(index,
                         Converter?.Convert(item) ??
                         new System.Windows.Forms.ListViewItem(item.ToString())
                         );

            HackAlignmentBug();
            OnAdded(new ValueEventArgs <int>(index));
        }
Example #5
0
        /* ----------------------------------------------------------------- */
        ///
        /// RemoveItems
        ///
        /// <summary>
        /// 項目を削除します。
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        public void RemoveItems(IEnumerable <int> indices)
        {
            var args = new ValueCancelEventArgs <int[]>(indices.ToArray());

            OnRemoving(args);
            if (args.Cancel || VirtualMode)
            {
                return;
            }

            foreach (var index in indices.OrderByDescending(x => x))
            {
                if (index < 0 || index >= Count)
                {
                    continue;
                }
                Items.RemoveAt(index);
            }

            OnRemoved(new ValueEventArgs <int[]>(indices.ToArray()));
        }
Example #6
0
 /* ----------------------------------------------------------------- */
 ///
 /// OnRemoving
 ///
 /// <summary>
 /// Removing イベントを発生させます。
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 protected virtual void OnRemoving(ValueCancelEventArgs <int[]> e)
 => Removing?.Invoke(this, e);
Example #7
0
 /* ----------------------------------------------------------------- */
 ///
 /// OnAdding
 ///
 /// <summary>
 /// Adding イベントを発生させます。
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 protected virtual void OnAdding(ValueCancelEventArgs <int> e)
 => Adding?.Invoke(this, e);
Example #8
0
        public void ValueCancelEventArgs_Cancel()
        {
            var src = new ValueCancelEventArgs <int>(1);

            Assert.That(src.Cancel, Is.False);
        }