mirror of
https://github.com/Stone-Red-Code/ClipCMD.git
synced 2026-09-04 00:46:10 +02:00
Small UI improvments
This commit is contained in:
+11
-2
@@ -48,7 +48,7 @@
|
||||
<TextBox Text="{Binding Settings.AutoTypeDelay, UpdateSourceTrigger=PropertyChanged}" Width="50" Height="20" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<Button Content="Cancel AutoType" Click="CancelAutoType_Click" IsEnabled="{Binding RuntimeData.AutoTypeRunning}" />
|
||||
<Button Content="Cancel AutoType" Click="CancelAutoTypeButton_Click" IsEnabled="{Binding RuntimeData.AutoTypeRunning}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Grid DockPanel.Dock="Top" VerticalAlignment="Stretch">
|
||||
@@ -59,7 +59,16 @@
|
||||
|
||||
<DockPanel Grid.Column="0">
|
||||
<Label DockPanel.Dock="Top" Content="Commands:" />
|
||||
<TextBox DockPanel.Dock="Top" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" Text="{Binding RuntimeData.CommandsText, UpdateSourceTrigger=PropertyChanged}" Foreground="{Binding RuntimeData.CommandsTextColor}" TextChanged="StaticCommandsTextBox_TextChanged" AcceptsReturn="True" VerticalAlignment="Stretch" />
|
||||
|
||||
<Grid DockPanel.Dock="Bottom">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="100" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Margin="4,0,0,3" Text="{Binding RuntimeData.CommandsInfo}" />
|
||||
<Button Grid.Column="1" Background="AliceBlue" Content="Copy to clipboard" Click="CopyToClipboardButton_Click" />
|
||||
</Grid>
|
||||
<TextBox DockPanel.Dock="Top" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Text="{Binding RuntimeData.CommandsText, UpdateSourceTrigger=PropertyChanged}" Foreground="{Binding RuntimeData.CommandsTextColor}" TextChanged="StaticCommandsTextBox_TextChanged" AcceptsReturn="True" VerticalAlignment="Stretch" />
|
||||
</DockPanel>
|
||||
|
||||
<DockPanel Visibility="{Binding RuntimeData.LogPanelVisible}" Grid.Column="1">
|
||||
|
||||
@@ -83,7 +83,7 @@ public partial class MainWindow : Window
|
||||
RuntimeData.Errors.Add($"[{commandNames}]\n{error}");
|
||||
}
|
||||
|
||||
private void CancelAutoType_Click(object sender, RoutedEventArgs e)
|
||||
private void CancelAutoTypeButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
RuntimeData.AutoTypeRunning = false;
|
||||
}
|
||||
@@ -187,6 +187,12 @@ public partial class MainWindow : Window
|
||||
}
|
||||
}
|
||||
|
||||
private void CopyToClipboardButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Clipboard.SetText(RuntimeData.CommandsText);
|
||||
_ = MessageBox.Show($"Successfully copied {commands.Count - 1} command(s) to clipboard!", "Success!", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
|
||||
private void NotifyIcon_Click(object? sender, EventArgs e)
|
||||
{
|
||||
Show();
|
||||
@@ -221,6 +227,8 @@ public partial class MainWindow : Window
|
||||
RuntimeData.Errors.Clear();
|
||||
commands.Clear();
|
||||
|
||||
RuntimeData.CommandsInfo = $"Lines: {lines.Length} Commands: {commands.Count} Errors: {RuntimeData.Errors.Count}";
|
||||
|
||||
foreach (string l in lines)
|
||||
{
|
||||
string line = l.Trim('\n', '\r');
|
||||
@@ -243,11 +251,15 @@ public partial class MainWindow : Window
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(commandName))
|
||||
{
|
||||
AddError(commandNames, "Command \"{commandName}\" is empty!");
|
||||
AddError(commandNames, $"Command \"{commandName}\" is empty!");
|
||||
}
|
||||
else if (commandName.Any(char.IsWhiteSpace))
|
||||
{
|
||||
AddError(commandNames, $"Command \"{commandName}\" can't contain white spaces!");
|
||||
}
|
||||
else if (!commands.TryAdd(commandName.Trim(), script.ToString()))
|
||||
{
|
||||
AddError(commandNames, "Command \"{commandName}\" already exists!");
|
||||
AddError(commandNames, $"Command \"{commandName}\" already exists!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -269,6 +281,8 @@ public partial class MainWindow : Window
|
||||
}
|
||||
}
|
||||
|
||||
RuntimeData.CommandsInfo = $"Lines: {lines.Length} Commands: {commands.Count} Errors: {RuntimeData.Errors.Count}";
|
||||
|
||||
_ = commands.TryAdd("list", $"\"{string.Join(", ", commands.Keys)}\"");
|
||||
|
||||
File.WriteAllText(commandsPath, RuntimeData.CommandsText);
|
||||
|
||||
+13
-1
@@ -12,6 +12,7 @@ public class RuntimeData : INotifyPropertyChanged
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
private bool autoTypeRunning = false;
|
||||
private string commandsInfo = string.Empty;
|
||||
private string commandsText = string.Empty;
|
||||
private Visibility errorPanelVisible = Visibility.Collapsed;
|
||||
private Visibility logPanelVisible = Visibility.Visible;
|
||||
@@ -26,6 +27,16 @@ public class RuntimeData : INotifyPropertyChanged
|
||||
}
|
||||
}
|
||||
|
||||
public string CommandsInfo
|
||||
{
|
||||
get => commandsInfo;
|
||||
set
|
||||
{
|
||||
commandsInfo = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string CommandsText
|
||||
{
|
||||
get => commandsText;
|
||||
@@ -36,7 +47,7 @@ public class RuntimeData : INotifyPropertyChanged
|
||||
}
|
||||
}
|
||||
|
||||
public Color CommandsTextColor => Errors.Count > 0 ? Colors.Red : Colors.Black;
|
||||
public Brush CommandsTextColor => Errors.Count > 0 ? Brushes.Red : Brushes.Black;
|
||||
|
||||
public Visibility ErrorPanelVisible
|
||||
{
|
||||
@@ -68,6 +79,7 @@ public class RuntimeData : INotifyPropertyChanged
|
||||
{
|
||||
ErrorPanelVisible = Errors.Any() ? Visibility.Visible : Visibility.Collapsed;
|
||||
LogPanelVisible = Errors.Any() ? Visibility.Collapsed : Visibility.Visible;
|
||||
OnPropertyChanged(nameof(CommandsTextColor));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user