Dev 56 add jvm args editor#109
Conversation
c84d0bf to
f38e236
Compare
|
|
||
| <!-- Content --> | ||
| <controls:AdvancedTextBox | ||
| <StackPanel |
There was a problem hiding this comment.
А в использование StackPanel есть какая-та секретная логика или можем просто удалить?
| { | ||
| get => RelayCommand.GetCommand(ref _bulkPasteCommand, obj => | ||
| { | ||
| if (string.IsNullOrWhiteSpace(BulkPasteText)) |
There was a problem hiding this comment.
Думаю все содержимое этой компанды лучше вынести в отдельный метод для читабельности
|
|
||
| namespace Lexplosion.UI.WPF.Core.Converters | ||
| { | ||
| public class EmptyValueToDashConverter : ConverterBase<EmptyValueToDashConverter> |
| private List<string> SplitArgs(string args) | ||
| { | ||
| var result = new List<string>(); | ||
| var regex = new Regex(@"[\""'].+?[\""']|[^\s]+"); |
There was a problem hiding this comment.
думаю стоит вынести за метод как поле класса в формате:
private static readonly Regex SplitArgsRegex = new(
@"[\""'].+?[\""']|[^\s]+",
RegexOptions.Compiled
);|
|
||
| if (token.StartsWith("-X")) | ||
| { | ||
| var match = Regex.Match(token, @"^(-X\w+?)(\d+[gGmMkKbB]?)$"); |
There was a problem hiding this comment.
Тоже самое для для всех regex, что и в методе SplitArgs выше.
|
|
||
| namespace Lexplosion.UI.WPF.Mvvm.ViewModels.Modal | ||
| { | ||
| public class JvmArgsEditorViewModel : ActionModalViewModelBase |
There was a problem hiding this comment.
думаю стоит все viewmodel запечатывать через sealed
|
|
||
| public event Action<JvmArgEntry> FocusNewEntryRequested; | ||
|
|
||
| public ObservableCollection<JvmArgEntry> Entries { get; } |
There was a problem hiding this comment.
Стоит подумать можно ли большую часть логики отсюда вынести в JvmArgsEditorModel. Во viewmodel останется только команды и ссылка на Model.
В качестве примера можно взять GeneralSettingsViewModel
| public string Rebuild(List<JvmArgEntry> entries) | ||
| { | ||
| if (entries == null || entries.Count == 0) | ||
| return ""; |
There was a problem hiding this comment.
думаю можно вернуть string.Empty заместо ""
| } | ||
|
|
||
| private void OnLoaded(object sender, RoutedEventArgs e) | ||
| { |
There was a problem hiding this comment.
думаю лучше вот так метод сделать
private void OnFocusNewEntryRequested(JvmArgEntry entry)
{
// Fail-fast guard clauses to prevent NullReference and ArgumentOutOfRange exceptions
if (entry == null || ArgsDataGrid == null || ArgsDataGrid.Columns.Count == 0)
return;
// 1. Instantly select and start the scroll action
ArgsDataGrid.SelectedItem = entry;
ArgsDataGrid.ScrollIntoView(entry);
// 2. Queue the remaining work until after the DataGrid finishes rendering the row
Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() =>
{
// Re-verify the item is still valid after the brief async delay
if (ArgsDataGrid.Columns.Count == 0) return;
var column = ArgsDataGrid.Columns[0];
ArgsDataGrid.CurrentCell = new DataGridCellInfo(entry, column);
// 3. Move keyboard focus to the grid and start editing the cell
ArgsDataGrid.Focus();
ArgsDataGrid.BeginEdit();
}));
}73f98be to
2cb905c
Compare
No description provided.