Imports Inventor Imports System.IO Imports System.Windows.Forms Imports System.Text.RegularExpressions Imports System.Net Sub Main() Dim doc As Document = ThisApplication.ActiveDocument Dim allParams As Parameters Try allParams = doc.ComponentDefinition.Parameters Catch ex As Exception MessageBox.Show("Документ не содержит параметров.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error) Return End Try ' Определение пути к файлу настроек в уникальной папке Dim appDataPath As String = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData), "Autodesk", "Inventor", "iLogic") Dim settingsDir As String = System.IO.Path.Combine(appDataPath, "Parwindow") ' Уникальная папка для настроек Dim settingsFilePath As String = System.IO.Path.Combine(settingsDir, "Settings.txt") ' Файл настроек в уникальной папке ' Инициализация настроек Dim settings As New Dictionary(Of String, String)() ' Чтение настроек из файла If System.IO.File.Exists(settingsFilePath) Then Try Dim lines() As String = System.IO.File.ReadAllLines(settingsFilePath) For Each line As String In lines If Not String.IsNullOrWhiteSpace(Line) AndAlso Line.Contains("=") Then Dim parts() As String = Line.Split(New Char() {"="c}, 2) Dim key As String = parts(0).Trim() Dim value As String = parts(1).Trim() settings(key) = value End If Next Catch ex As Exception ' Если возникла ошибка при чтении файла, используем стандартные настройки End Try End If ' Получение настроек из словаря или установка значений по умолчанию Dim isDarkTheme As Boolean = If(settings.ContainsKey("Theme") AndAlso settings("Theme").ToLower() = "dark", True, False) Dim currentLanguage As String = If(settings.ContainsKey("Language"), settings("Language").ToLower(), "en") ' Чтение настроек сортировки Dim currentSortColumn As String = "" If settings.ContainsKey("SortColumn") Then currentSortColumn = settings("SortColumn") End If Dim sortAscending As Boolean = True If settings.ContainsKey("SortAscending") Then Boolean.TryParse(settings("SortAscending"), sortAscending) End If ' Настройки положения и размера окна Dim windowLeft As Integer = 0 Dim windowTop As Integer = 0 Dim windowWidth As Integer = 475 Dim windowHeight As Integer = 420 If settings.ContainsKey("WindowLeft") Then Integer.TryParse(settings("WindowLeft"), windowLeft) If settings.ContainsKey("WindowTop") Then Integer.TryParse(settings("WindowTop"), windowTop) If settings.ContainsKey("WindowWidth") Then Integer.TryParse(settings("WindowWidth"), windowWidth) If settings.ContainsKey("WindowHeight") Then Integer.TryParse(settings("WindowHeight"), windowHeight) ' Создание формы Dim resultForm As New Form() resultForm.Text = If(currentLanguage = "en", "Parameters", "Параметры") resultForm.Width = windowWidth resultForm.Height = windowHeight resultForm.StartPosition = FormStartPosition.CenterScreen resultForm.FormBorderStyle = FormBorderStyle.Sizable resultForm.MaximizeBox = False resultForm.MinimizeBox = False ' Установка положения окна, если настройки существуют If windowLeft <> 0 OrElse windowTop <> 0 Then resultForm.StartPosition = FormStartPosition.Manual resultForm.Left = windowLeft resultForm.Top = windowTop End If ' Обработчик для ограничения минимальных размеров окна AddHandler resultForm.SizeChanged, Sub(sender As Object, E As EventArgs) ' Проверяем ширину и высоту, и если они меньше минимальных значений, восстанавливаем их If resultForm.Width < 475 Then resultForm.Width = 475 If resultForm.Height < 420 Then resultForm.Height = 420 End Sub Dim webBrowser As New WebBrowser() webBrowser.Dock = DockStyle.Fill webBrowser.IsWebBrowserContextMenuEnabled = False webBrowser.AllowWebBrowserDrop = False webBrowser.ScrollBarsEnabled = False webBrowser.ScriptErrorsSuppressed = True resultForm.Controls.Add(webBrowser) ' Создание экземпляра ScriptInterface с передачей настроек сортировки Dim scriptInterface As New ScriptInterface(doc, allParams, resultForm, webBrowser, isDarkTheme, currentLanguage, settingsFilePath, settings, currentSortColumn, sortAscending) AddHandler webBrowser.DocumentCompleted, AddressOf scriptInterface.WebBrowser_DocumentCompleted webBrowser.DocumentText = scriptInterface.GenerateHtml() AddHandler resultForm.KeyDown, Sub(sender As Object, e As KeyEventArgs) If e.KeyCode = Keys.Escape OrElse e.KeyCode = Keys.Oem3 Then resultForm.Close() End If End Sub resultForm.KeyPreview = True AddHandler webBrowser.PreviewKeyDown, Sub(sender As Object, e As PreviewKeyDownEventArgs) If e.KeyCode = Keys.Escape OrElse e.KeyCode = Keys.Oem3 Then resultForm.Close() End If End Sub ' Обработчик события закрытия окна для сохранения положения AddHandler resultForm.FormClosing, AddressOf scriptInterface.SaveWindowPosition resultForm.ShowDialog() End Sub Public Class ScriptInterface Private doc As Document Private allParams As Parameters Private resultForm As Form Private webBrowser As webBrowser Private isDarkTheme As Boolean Private currentLanguage As String Private settingsFilePath As String Private settings As Dictionary(Of String, String) Private translations As Dictionary(Of String, Dictionary(Of String, String)) ' Хранение текущего состояния сортировки Private currentSortColumn As String = "" Private sortAscending As Boolean = True Public Sub New(doc As Document, params As Parameters, Form As Form, browser As webBrowser, isDarkTheme As Boolean, currentLanguage As String, settingsFilePath As String, settings As Dictionary(Of String, String), currentSortColumn As String, sortAscending As Boolean) Me.doc = doc Me.allParams = params Me.resultForm = Form Me.webBrowser = browser Me.isDarkTheme = isDarkTheme Me.currentLanguage = currentLanguage Me.settingsFilePath = settingsFilePath Me.settings = settings Me.currentSortColumn = currentSortColumn Me.sortAscending = sortAscending InitializeTranslations() End Sub Private Function SplitName(name As String) As Tuple(Of String, Integer) Dim match As Match = Regex.Match(name, "^(.*?)(\d+)$") If match.Success Then Dim prefix As String = match.Groups(1).Value Dim number As Integer = Integer.Parse(match.Groups(2).Value) Return Tuple.Create(prefix, number) Else ' Если нет числовой части, считаем префикс равным всему имени, а число 0 Return Tuple.Create(name, 0) End If End Function Private Sub InitializeTranslations() translations = New Dictionary(Of String, Dictionary(Of String, String))() Dim ru As New Dictionary(Of String, String) From { {"Parameters", "Параметры"}, {"Error", "Ошибка"}, {"AddParameter", "Добавить параметр"}, {"ParameterName", "Обозначение"}, {"Value", "Значение"}, {"Description", "Описание"}, {"Save", "Сохранить"}, {"Theme", "Тема"}, {"Language", "Язык"}, {"StandardParameters", "Переименованные стандартные параметры"}, {"UserParameters", "Пользовательские параметры"}, {"NoStandardParams", "Нет переименованных стандартных параметров."}, {"NoUserParams", "Нет пользовательских параметров."}, {"AddParamPlaceholderName", "Имя"}, {"AddParamPlaceholderValue", "Значение"}, {"AddParamPlaceholderDescription", "Описание"}, {"AddParamTitle", "Добавить параметр"}, {"SaveSuccess", "Свойства успешно сохранены."}, {"SaveThemeError", "Не удалось сохранить настройки темы: "}, {"SaveLanguageError", "Не удалось сохранить настройки языка: "}, {"CopySuccess", "Скопировано!"}, {"ToggleThemeTitle", "Переключить тему"}, {"ToggleLanguageTitle", "Сменить язык"}, {"CopyButtonTitle", "Скопировать имя параметра"}, {"AddButtonTitle", "Добавить параметр"}, {"SaveButtonTitle", "Сохранить"} } Dim en As New Dictionary(Of String, String) From { {"Parameters", "Parameters"}, {"Error", "Error"}, {"AddParameter", "Add Parameter"}, {"ParameterName", "Part Number"}, {"Value", "Value"}, {"Description", "Description"}, {"Save", "Save"}, {"Theme", "Theme"}, {"Language", "Language"}, {"StandardParameters", "Renamed Standard Parameters"}, {"UserParameters", "User Parameters"}, {"NoStandardParams", "No renamed standard parameters."}, {"NoUserParams", "No user parameters."}, {"AddParamPlaceholderName", "Name"}, {"AddParamPlaceholderValue", "Value"}, {"AddParamPlaceholderDescription", "Description"}, {"AddParamTitle", "Add Parameter"}, {"SaveSuccess", "Properties saved successfully."}, {"SaveThemeError", "Failed to save theme settings: "}, {"SaveLanguageError", "Failed to save language settings: "}, {"CopySuccess", "Copied!"}, {"ToggleThemeTitle", "Toggle Theme"}, {"ToggleLanguageTitle", "Change Language"}, {"CopyButtonTitle", "Copy Parameter Name"}, {"AddButtonTitle", "Add Parameter"}, {"SaveButtonTitle", "Save"} } translations.Add("ru", ru) translations.Add("en", en) End Sub Private Function Translate(key As String) As String Dim lang As String = If(currentLanguage = "en", "en", "ru") If translations.ContainsKey(lang) AndAlso translations(lang).ContainsKey(key) Then Return translations(lang)(key) Else Return key End If End Function Private Function ExtractNumber(name As String) As Integer Dim match As Match = Regex.Match(name, "\d+") If match.Success Then Return Integer.Parse(match.Value) Else Return 0 End If End Function Public Sub AddParameter() Dim docHtml As HtmlDocument = webBrowser.Document Dim paramName As String = docHtml.GetElementById("paramName").GetAttribute("value").Trim() Dim paramFormula As String = docHtml.GetElementById("paramFormula").GetAttribute("value").Trim() Dim paramDescription As String = docHtml.GetElementById("paramDescription").GetAttribute("value").Trim() Dim paramExists As Boolean = False Try Dim existingParam = allParams.Item(paramName) paramExists = True Catch ex As Exception paramExists = False End Try If paramExists Then MessageBox.Show(Translate("Error") & ": " & Translate("ParameterName") & " '" & paramName & "' " & If(currentLanguage = "en", "already exists.", "уже существует."), Translate("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error) Return End If Try Dim newParam As UserParameter = allParams.UserParameters.AddByExpression(paramName, paramFormula, UnitsTypeEnum.kDefaultDisplayLengthUnits) newParam.Comment = paramDescription Clipboard.SetText(paramName) UpdateParameterList() Catch ex As Exception MessageBox.Show(Translate("Error") & ": " & Translate("AddParameter") & " - " & ex.Message, Translate("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub Public Sub UpdateParameterList() allParams = doc.ComponentDefinition.Parameters webBrowser.DocumentText = GenerateHtml() webBrowser.ObjectForScripting = Me End Sub Public Sub ToggleTheme() isDarkTheme = Not isDarkTheme UpdateParameterList() SaveThemeSetting() End Sub Public Sub ToggleLanguage() currentLanguage = If(currentLanguage = "en", "ru", "en") UpdateParameterList() SaveLanguageSetting() End Sub Private Sub SaveThemeSetting() Try settings("Theme") = If(isDarkTheme, "Dark", "Light") SaveSettingsToFile() Catch ex As Exception MessageBox.Show(Translate("SaveThemeError") & ex.Message, Translate("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub ' Обновленный метод сохранения настроек языка Private Sub SaveLanguageSetting() Try settings("Language") = currentLanguage SaveSettingsToFile() Catch ex As Exception MessageBox.Show(Translate("SaveLanguageError") & ex.Message, Translate("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub ' Обновленный метод сохранения положения окна Public Sub SaveWindowPosition(sender As Object, e As FormClosingEventArgs) Try settings("WindowLeft") = resultForm.Left.ToString() settings("WindowTop") = resultForm.Top.ToString() settings("WindowWidth") = resultForm.Width.ToString() settings("WindowHeight") = resultForm.Height.ToString() SaveSettingsToFile() Catch ex As Exception MessageBox.Show("Не удалось сохранить положение окна: " & ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub ' Метод для сохранения всех настроек в файл Private Sub SaveSettingsToFile() Try Dim settingsDir As String = System.IO.Path.GetDirectoryName(settingsFilePath) If Not System.IO.Directory.Exists(settingsDir) Then System.IO.Directory.CreateDirectory(settingsDir) End If Dim lines As New List(Of String)() For Each kvp As KeyValuePair(Of String, String) In settings lines.Add(kvp.Key & "=" & kvp.Value) Next System.IO.File.WriteAllLines(settingsFilePath, lines) Catch ex As Exception MessageBox.Show("Ошибка при сохранении настроек: " & ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub Public Sub SaveDocumentProperties(partNumber As String, description As String) Try Dim designTrackingProps As PropertySet = doc.PropertySets.Item("Design Tracking Properties") Dim partNumberProp As [Property] = Nothing Try partNumberProp = designTrackingProps.Item("Part Number") Catch ex As Exception MessageBox.Show(Translate("Error") & ": 'Part Number' " & If(currentLanguage = "en", "not found.", "не найдено."), Translate("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error) Return End Try Dim descriptionProp As [Property] = Nothing Try descriptionProp = designTrackingProps.Item("Description") Catch ex As Exception MessageBox.Show(Translate("Error") & ": 'Description' " & If(currentLanguage = "en", "not found.", "не найдено."), Translate("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error) Return End Try If String.IsNullOrWhiteSpace(partNumber) Then partNumberProp.Value = "" Else partNumberProp.Value = partNumber End If If String.IsNullOrWhiteSpace(description) Then descriptionProp.Value = "" Else descriptionProp.Value = description End If doc.Save() UpdateParameterList() MessageBox.Show(Translate("SaveSuccess"), If(currentLanguage = "en", "Success", "Успех"), MessageBoxButtons.OK, MessageBoxIcon.Information) Catch ex As Exception MessageBox.Show(Translate("Error") & ": " & ex.Message, Translate("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub Public Sub UpdateParameter(paramName As String, newValue As String) Try Dim param As Parameter = allParams.Item(paramName) If TypeOf param Is UserParameter Then Dim userParam As UserParameter = CType(param, UserParameter) userParam.Expression = newValue ElseIf TypeOf param Is ModelParameter Then Dim modelParam As ModelParameter = CType(param, ModelParameter) modelParam.Expression = newValue End If doc.Save() UpdateParameterList() Catch ex As Exception MessageBox.Show(Translate("Error") & ": " & ex.Message, Translate("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub Public Sub UpdateParameterName(oldName As String, newName As String) Try Try Dim existingParam = allParams.Item(newName) MessageBox.Show(Translate("Error") & ": " & Translate("ParameterName") & " '" & newName & "' " & If(currentLanguage = "en", "already exists.", "уже существует."), Translate("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error) Return Catch ex As Exception End Try Dim param As Parameter = allParams.Item(oldName) param.Name = newName doc.Save() UpdateParameterList() Catch ex As Exception MessageBox.Show(Translate("Error") & ": " & ex.Message, Translate("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub Public Function GenerateHtml() As String Dim partNumber As String = "" Dim description As String = "" Try Dim designTrackingProps As PropertySet = doc.PropertySets.Item("Design Tracking Properties") Dim partNumberProp As [Property] = designTrackingProps.Item("Part Number") Dim descriptionProp As [Property] = designTrackingProps.Item("Description") partNumber = partNumberProp.Value.ToString() description = descriptionProp.Value.ToString() Catch ex As Exception partNumber = "" description = "" End Try Dim partNumberEncoded As String = WebUtility.HtmlEncode(partNumber) Dim descriptionEncoded As String = WebUtility.HtmlEncode(description) Dim standardParams As New List(Of Parameter)() Dim userParams As New List(Of Parameter)() For Each param As Parameter In allParams.UserParameters userParams.Add(param) Next Dim defaultParamPattern As New Regex("^d\d+$", RegexOptions.IgnoreCase) For Each param As ModelParameter In allParams.ModelParameters If Not defaultParamPattern.IsMatch(param.Name) Then standardParams.Add(param) End If Next ' Сортировка параметров standardParams = SortParameters(standardParams) userParams = SortParameters(userParams) Dim htmlOutput As New System.Text.StringBuilder() htmlOutput.AppendLine("") htmlOutput.AppendLine("") htmlOutput.AppendLine("") htmlOutput.AppendLine("") htmlOutput.AppendLine("") htmlOutput.AppendLine("") htmlOutput.AppendLine("") htmlOutput.AppendLine("") htmlOutput.AppendLine("") ' Шапка формы htmlOutput.AppendLine("
") htmlOutput.AppendLine("
") htmlOutput.AppendLine("
") htmlOutput.AppendLine(" ") htmlOutput.AppendLine(" ") htmlOutput.AppendLine("
") htmlOutput.AppendLine("
") htmlOutput.AppendLine(" ") htmlOutput.AppendLine(" ") htmlOutput.AppendLine("
") htmlOutput.AppendLine(" ") htmlOutput.AppendLine("
") htmlOutput.AppendLine("
") htmlOutput.AppendLine(" ") htmlOutput.AppendLine(" ") htmlOutput.AppendLine("
") htmlOutput.AppendLine("
") ' Основное содержимое таблицы htmlOutput.AppendLine("
") htmlOutput.AppendLine("") htmlOutput.AppendLine("") htmlOutput.AppendLine(" ") htmlOutput.AppendLine(" ") htmlOutput.AppendLine(" ") htmlOutput.AppendLine("") htmlOutput.AppendLine("") If standardParams.Count > 0 Then For Each param As Parameter In standardParams Try Dim numericValue As Double = param.Value Dim valueInMM As String = (numericValue * 10).ToString("F2", System.Globalization.CultureInfo.InvariantCulture) Dim paramNameEncoded As String = WebUtility.HtmlEncode(param.Name) Dim descriptionParam As String = If(String.IsNullOrEmpty(param.Comment), "-", WebUtility.HtmlEncode(param.Comment)) htmlOutput.AppendLine("") ' Вставка кнопки копирования внутри ячейки имени параметра htmlOutput.AppendLine(" ") htmlOutput.AppendLine(" ") htmlOutput.AppendLine(" ") htmlOutput.AppendLine("") Catch ex As Exception htmlOutput.AppendLine("") htmlOutput.AppendLine(" ") htmlOutput.AppendLine(" ") htmlOutput.AppendLine(" ") htmlOutput.AppendLine("") End Try Next Else htmlOutput.AppendLine("") End If htmlOutput.AppendLine("") htmlOutput.AppendLine("") If userParams.Count > 0 Then For Each param As Parameter In userParams Try Dim numericValue As Double = param.Value Dim valueInMM As String = (numericValue * 10).ToString("F2", System.Globalization.CultureInfo.InvariantCulture) Dim paramNameEncoded As String = WebUtility.HtmlEncode(param.Name) Dim descriptionParam As String = If(String.IsNullOrEmpty(param.Comment), "-", WebUtility.HtmlEncode(param.Comment)) htmlOutput.AppendLine("") ' Вставка кнопки копирования внутри ячейки имени параметра htmlOutput.AppendLine(" ") htmlOutput.AppendLine(" ") htmlOutput.AppendLine(" ") htmlOutput.AppendLine("") Catch ex As Exception htmlOutput.AppendLine("") htmlOutput.AppendLine(" ") htmlOutput.AppendLine(" ") htmlOutput.AppendLine(" ") htmlOutput.AppendLine("") End Try Next Else htmlOutput.AppendLine("") End If htmlOutput.AppendLine("
" & Translate("ParameterName") & " " & Translate("Value") & " (mm) " & Translate("Description") & "

" & Translate("StandardParameters") & "

" & paramNameEncoded & "" & valueInMM & " mm" & descriptionParam & "
" & param.Name & "" & Translate("Error") & ": " & ex.Message & "-
" & Translate("NoStandardParams") & "
 

" & Translate("UserParameters") & "

" & paramNameEncoded & "" & valueInMM & " mm" & descriptionParam & "
" & param.Name & "" & Translate("Error") & ": " & ex.Message & "-
" & Translate("NoUserParams") & "
") htmlOutput.AppendLine("
") ' Футер формы с добавлением параметра htmlOutput.AppendLine("") htmlOutput.AppendLine("") Return htmlOutput.ToString() End Function ' Метод для получения класса стрелки сортировки Private Function GetSortArrowClass(column As String) As String If column = currentSortColumn Then Return If(sortAscending, "asc", "desc") Else Return "" End If End Function ' Метод для сортировки параметров с учетом числовых частей в имени Private Function NaturalSort(x As String, y As String) As Integer ' Используем регулярное выражение для разделения строки на части (буквы и цифры) Dim regex As New Regex("(\d+|\D+)") ' Разделяем обе строки на части Dim xParts As MatchCollection = regex.Matches(x) Dim yParts As MatchCollection = regex.Matches(y) ' Определяем минимальное количество частей для сравнения Dim minParts As Integer = Math.Min(xParts.Count, yParts.Count) ' Сравниваем части строк поочередно For i As Integer = 0 To minParts - 1 Dim xPart As String = xParts(i).Value Dim yPart As String = yParts(i).Value ' Попробуем сначала сравнить числовые части, если они присутствуют Dim xNum, yNum As Integer If Integer.TryParse(xPart, xNum) AndAlso Integer.TryParse(yPart, yNum) Then ' Если обе части числовые, сравниваем их как числа Dim comparison As Integer = xNum.CompareTo(yNum) If comparison <> 0 Then Return comparison End If Else ' Если это не числа, сравниваем как строки Dim comparison As Integer = String.Compare(xPart, yPart) If comparison <> 0 Then Return comparison End If End If Next ' Если все части совпадают, сравниваем по количеству частей Return xParts.Count.CompareTo(yParts.Count) End Function ' Метод для извлечения числового значения из строки, например "10 mm" -> 10 Private Function ExtractNumericValue(value As String) As Double Dim regex As New Regex("(\d+(\.\d+)?)") Dim match As Match = regex.Match(value) ' Если число найдено, возвращаем его, иначе возвращаем 0 If match.Success Then Return Double.Parse(match.Value, System.Globalization.CultureInfo.InvariantCulture) Else Return 0 End If End Function ' Метод для сортировки параметров с учетом числовых частей в имени и значении Private Function SortParameters(paramsList As List(Of Parameter)) As List(Of Parameter) If String.IsNullOrEmpty(currentSortColumn) Then Return paramsList End If Select Case currentSortColumn Case "name" If sortAscending Then paramsList.Sort(Function(x, y) NaturalSort(x.Name, y.Name)) Else paramsList.Sort(Function(x, y) NaturalSort(y.Name, x.Name)) End If Case "value" If sortAscending Then paramsList.Sort(Function(x, y) x.Value.CompareTo(y.Value)) Else paramsList.Sort(Function(x, y) y.Value.CompareTo(x.Value)) End If Case "description" If sortAscending Then paramsList.Sort(Function(x, y) ' Сравниваем описания Dim comparison As Integer = String.Compare(x.Comment, y.Comment) ' Если описания одинаковые, сортируем по значению If comparison = 0 Then Return x.Value.CompareTo(y.Value) Else Return comparison End If End Function) Else paramsList.Sort(Function(x, y) Dim comparison As Integer = String.Compare(y.Comment, x.Comment) If comparison = 0 Then Return y.Value.CompareTo(x.Value) Else Return comparison End If End Function) End If End Select Return paramsList End Function Public Sub WebBrowser_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Try webBrowser.ObjectForScripting = Me Catch ex As Exception End Try End Sub Public Sub UpdateParameterDescription(paramName As String, newDescription As String) Try Dim param As Parameter = allParams.Item(paramName) param.Comment = newDescription doc.Save() UpdateParameterList() Catch ex As Exception MessageBox.Show(Translate("Error") & ": " & ex.Message, Translate("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub ' Метод для сортировки параметров из JavaScript Public Sub SortParameters(Column As String, Ascending As Boolean) currentSortColumn = Column sortAscending = Ascending UpdateParameterList() ' Сохранение настроек сортировки settings("SortColumn") = currentSortColumn settings("SortAscending") = sortAscending.ToString() SaveSettingsToFile() End Sub End Class