diff --git a/Src/WinControl/WinControl/WinControl.cs b/Src/WinControl/WinControl/WinControl.cs index dabc0f2..84f5526 100644 --- a/Src/WinControl/WinControl/WinControl.cs +++ b/Src/WinControl/WinControl/WinControl.cs @@ -81,23 +81,14 @@ public Form ActiveForm } /// - /// Gets the list of forms contained within the control. - /// Получить список форм, которые содержит элемент управления. + /// Gets the enumerator of forms contained within the control. + /// Получить перечисление форм, которые содержит элемент управления. /// - public List
Forms + public IEnumerable Forms { get { - List 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); } } @@ -664,8 +655,13 @@ protected void OnChildFormModifiedChanged(ChildFormEventArgs e) /// 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) diff --git a/Src/WinControl/WinControl/WinControl.csproj b/Src/WinControl/WinControl/WinControl.csproj index c9c6020..e746e02 100644 --- a/Src/WinControl/WinControl/WinControl.csproj +++ b/Src/WinControl/WinControl/WinControl.csproj @@ -8,7 +8,7 @@ enable WinControls True - 2.2.0 + 2.2.1 Mikhail Shiryaev