Skip to content

Commit 50a43f6

Browse files
committed
WinControl: activate duplicated form
1 parent 9be25a3 commit 50a43f6

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

Src/WinControl/WinControl/WinControl.cs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,14 @@ public Form ActiveForm
8181
}
8282

8383
/// <summary>
84-
/// Gets the list of forms contained within the control.
85-
/// <para>Получить список форм, которые содержит элемент управления.</para>
84+
/// Gets the enumerator of forms contained within the control.
85+
/// <para>Получить перечисление форм, которые содержит элемент управления.</para>
8686
/// </summary>
87-
public List<Form> Forms
87+
public IEnumerable<Form> Forms
8888
{
8989
get
9090
{
91-
List<Form> forms = new(tabPageList.Count);
92-
93-
foreach (TabPage tabPage in tabPageList)
94-
{
95-
Form form = tabPage.ChildForm;
96-
if (form != null)
97-
forms.Add(form);
98-
}
99-
100-
return forms;
91+
return tabPageList.Where(t => t.ChildForm != null).Select(t => t.ChildForm);
10192
}
10293
}
10394

@@ -664,8 +655,13 @@ protected void OnChildFormModifiedChanged(ChildFormEventArgs e)
664655
/// </summary>
665656
public void AddForm(Form form, string hint, Image image, TreeNode treeNode)
666657
{
667-
// tests the form for duplicating
668-
// проверка дублирования формы
658+
// activate the form if it is already added
659+
if (FindTabPage(form) is TabPage existingTabPage)
660+
{
661+
SelectTabPage(existingTabPage);
662+
return;
663+
}
664+
669665
foreach (TabPage tab in tabPageList)
670666
{
671667
if (tab.ChildForm != null && tab.ChildForm == form)

Src/WinControl/WinControl/WinControl.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<ImplicitUsings>enable</ImplicitUsings>
99
<RootNamespace>WinControls</RootNamespace>
1010
<GenerateDocumentationFile>True</GenerateDocumentationFile>
11-
<Version>2.2.0</Version>
11+
<Version>2.2.1</Version>
1212
<Authors>Mikhail Shiryaev</Authors>
1313
<Company />
1414
<PackageProjectUrl></PackageProjectUrl>

0 commit comments

Comments
 (0)