Skip to content

Commit

Permalink
WinControl: activate duplicated form
Browse files Browse the repository at this point in the history
  • Loading branch information
2mik committed Jul 23, 2024
1 parent 9be25a3 commit 50a43f6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
26 changes: 11 additions & 15 deletions Src/WinControl/WinControl/WinControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,14 @@ public Form ActiveForm
}

/// <summary>
/// Gets the list of forms contained within the control.
/// <para>Получить список форм, которые содержит элемент управления.</para>
/// Gets the enumerator of forms contained within the control.
/// <para>Получить перечисление форм, которые содержит элемент управления.</para>
/// </summary>
public List<Form> Forms
public IEnumerable<Form> Forms
{
get
{
List<Form> forms = new(tabPageList.Count);

foreach (TabPage tabPage in tabPageList)
{
Form form = tabPage.ChildForm;
if (form != null)
forms.Add(form);
}

return forms;
return tabPageList.Where(t => t.ChildForm != null).Select(t => t.ChildForm);
}
}

Expand Down Expand Up @@ -664,8 +655,13 @@ protected void OnChildFormModifiedChanged(ChildFormEventArgs e)
/// </summary>
public void AddForm(Form form, string hint, Image image, TreeNode treeNode)
{
// tests the form for duplicating
// проверка дублирования формы
// activate the form if it is already added
if (FindTabPage(form) is TabPage existingTabPage)
{
SelectTabPage(existingTabPage);
return;
}

foreach (TabPage tab in tabPageList)
{
if (tab.ChildForm != null && tab.ChildForm == form)
Expand Down
2 changes: 1 addition & 1 deletion Src/WinControl/WinControl/WinControl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>WinControls</RootNamespace>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Version>2.2.0</Version>
<Version>2.2.1</Version>
<Authors>Mikhail Shiryaev</Authors>
<Company />
<PackageProjectUrl></PackageProjectUrl>
Expand Down

0 comments on commit 50a43f6

Please sign in to comment.