• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

KSP-CKAN / CKAN / 15834236157

23 Jun 2025 07:42PM UTC coverage: 42.232% (+0.1%) from 42.099%
15834236157

push

github

HebaruSan
Merge #4398 Exception handling revamp, parallel multi-host inflation

3880 of 9479 branches covered (40.93%)

Branch coverage included in aggregate %.

48 of 137 new or added lines in 30 files covered. (35.04%)

12 existing lines in 6 files now uncovered.

8334 of 19442 relevant lines covered (42.87%)

0.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/GUI/TabController.cs
1
using System.Collections.Generic;
2
using System.Windows.Forms;
3
using System.Threading.Tasks;
4
using System.Threading;
5
#if NET5_0_OR_GREATER
6
using System.Runtime.Versioning;
7
#endif
8

9
namespace CKAN.GUI
10
{
11

12
    #if NET5_0_OR_GREATER
13
    [SupportedOSPlatform("windows")]
14
    #endif
15
    public class TabController
16
    {
17

18
        public TabController(TabControl control)
×
19
        {
×
20
            m_TabControl = control;
×
21
            m_TabControl.Deselecting += OnDeselect;
×
22
            m_TabControl.Selecting += OnDeselect;
×
23

24
            foreach (TabPage page in m_TabControl.TabPages)
×
25
            {
×
26
                m_TabPages.Add(page.Name, page);
×
27
            }
×
28

29
            m_TabControl.TabPages.Clear();
×
30
        }
×
31

32
        public void ShowTab(string name, int index = 0, bool setActive = true)
33
        {
×
34
            Util.Invoke(m_TabControl, () =>
×
35
            {
×
36
                if (!m_TabControl.TabPages.Contains(m_TabPages[name]))
×
37
                {
×
38
                    if (index > m_TabControl.TabPages.Count)
×
39
                    {
×
40
                        index = m_TabControl.TabPages.Count;
×
41
                    }
×
42

43
                    m_TabControl.TabPages.Insert(index, m_TabPages[name]);
×
44
                }
×
45

46
                if (setActive)
×
47
                {
×
48
                    SetActiveTab(name);
×
49
                }
×
50
            });
×
51
        }
×
52

53
        public void HideTab(string name)
54
        {
×
55
            Util.Invoke(m_TabControl, () =>
×
56
            {
×
57
                // Unsafe to hide the active tab as of Mono 5.14
58
                if (m_TabControl.SelectedTab?.Name == name)
×
59
                {
×
60
                    m_TabControl.DeselectTab(name);
×
61
                }
×
62
                m_TabControl.TabPages.Remove(m_TabPages[name]);
×
63
            });
×
64
        }
×
65

66
        public void RenameTab(string name, string newDisplayName)
67
        {
×
68
            Util.Invoke(m_TabControl, () =>
×
69
            {
×
70
                m_TabPages[name].Text = newDisplayName;
×
71
            });
×
72
        }
×
73

74
        public void SetTabLock(bool state)
75
        {
×
76
            Util.Invoke(m_TabControl, () =>
×
77
            {
×
78
                m_TabLock = state;
×
79
            });
×
80
        }
×
81

82
        public void SetActiveTab(string name)
83
        {
×
84
            Util.Invoke(m_TabControl, () =>
×
85
            {
×
86
                var tabLock = m_TabLock;
×
87
                m_TabLock = false;
×
88
                m_TabControl.SelectTab(m_TabPages[name]);
×
89
                m_TabLock = tabLock;
×
90
            });
×
91
        }
×
92

93
        private void OnDeselect(object? sender, TabControlCancelEventArgs args)
94
        {
×
95
            if (m_TabLock)
×
96
            {
×
97
                args.Cancel = true;
×
98
            }
×
99
            else if (Platform.IsMac)
×
100
            {
×
101
                if (args.Action == TabControlAction.Deselecting && args.TabPage != null)
×
102
                {
×
103
                    // Have to set visibility to false on children controls on hidden tabs because they don't
104
                    // always heed parent visibility on Mac OS X https://bugzilla.xamarin.com/show_bug.cgi?id=3124
105
                    foreach (Control control in args.TabPage.Controls)
×
106
                    {
×
107
                        control.Visible = false;
×
108
                    }
×
109
                }
×
110
                else if (args.Action == TabControlAction.Selecting && args.TabPage != null)
×
111
                {
×
112
                    // Set children controls' visibility back to true
113
                    foreach (Control control in args.TabPage.Controls)
×
114
                    {
×
115
                        control.Visible = true;
×
116

117
                        // Have to specifically tell the mod list's panel to refresh
118
                        // after things settle out because otherwise it doesn't
119
                        // when coming back to the mods tab from updating the repo
120
                        if (control is SplitContainer splitter)
×
121
                        {
×
NEW
122
                            Task.Run(() =>
×
NEW
123
                            {
×
NEW
124
                                Thread.Sleep(500);
×
NEW
125
                                splitter.Panel1.Refresh();
×
NEW
126
                            });
×
127
                        }
×
128
                    }
×
129
                }
×
130
            }
×
131
        }
×
132

133
        private readonly TabControl m_TabControl;
134

135
        private bool m_TabLock;
136

137
        public Dictionary<string, TabPage> m_TabPages = new Dictionary<string, TabPage>();
×
138
    }
139
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc