yangyin
2024-10-22 90573e299e2eea301a0ad8585a7e6b95d7a798bb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// *********************************
// Message from Original Author:
//
// 2008 Jose Menendez Poo
// Please give me credit if you use this code. It's all I ask.
// Contact me for more info: menendezpoo@gmail.com
// *********************************
//
// Original project from http://ribbon.codeplex.com/
// Continue to support and maintain by http://officeribbon.codeplex.com/
 
 
using System.Windows.Forms.Classes.Collections;
 
namespace System.Windows.Forms
{
    /// <summary>
    /// Represents a collection of RibbonTabContext
    /// </summary>
    public sealed class RibbonContextCollection
        : RibbonCollectionBase<RibbonContext>
    {
 
        /// <summary>
        /// Creates a new RibbonTabContext Collection
        /// </summary>
        /// <param name="owner">Ribbon that owns this collection</param>
        /// <exception cref="ArgumentNullException">owner is null</exception>
        internal RibbonContextCollection(Ribbon owner)
            : base(owner)
        {
            if (owner == null) throw new ArgumentNullException(nameof(owner));
        }
 
        public new void Remove(RibbonContext context)
        {
 
            foreach (RibbonTab tab in context.ContextualTabs)
            {
                tab.Context = null;
            }
 
            base.Remove(context);
        }
 
        public new int RemoveAll(Predicate<RibbonContext> predicate)
        {
            throw new NotSupportedException("RibbonContextCollectin.RemoveAll function is not supported");
        }
 
        public new void RemoveAt(int index)
        {
            RibbonContext context = this[index];
 
            foreach (RibbonTab tab in context.ContextualTabs)
            {
                tab.Context = null;
            }
 
            base.RemoveAt(index);
        }
 
        public new void RemoveRange(int index, int count)
        {
            throw new NotSupportedException("RibbonContextCollection.RemoveRange function is not supported");
        }
 
        internal override void SetOwner(RibbonContext item)
        {
            item.SetOwner(Owner);
        }
 
        internal override void ClearOwner(RibbonContext item)
        {
            item.ClearOwner();
        }
 
        internal override void UpdateRegions()
        {
            try
            {
                Owner.OnRegionsChanged();
            }
            catch
            {
                // ignored
            }
        }
    }
}