Skip to content

Feature/maintenance #161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sample/Atc.Wpf.Sample/Atc.Wpf.Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.552" />
<PackageReference Include="Atc.XamlToolkit" Version="1.5.34" />
<PackageReference Include="Atc.XamlToolkit.Wpf" Version="1.5.34" />
<PackageReference Include="Atc.XamlToolkit" Version="1.5.36" />
<PackageReference Include="Atc.XamlToolkit.Wpf" Version="1.5.36" />
<PackageReference Include="ControlzEx" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.4" />
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="9.0.4" />
Expand Down
1 change: 1 addition & 0 deletions sample/Atc.Wpf.Sample/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
global using Atc.Helpers;
global using Atc.Serialization.JsonConverters;
global using Atc.Wpf.Collections;
global using Atc.Wpf.Controls;
global using Atc.Wpf.Controls.Dialogs;
global using Atc.Wpf.Controls.LabelControls;
global using Atc.Wpf.Controls.LabelControls.Abstractions;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<UserControl
x:Class="Atc.Wpf.Sample.SamplesWpfControls.Viewers.TerminalViewerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:atc="https://github.com/atc-net/atc-wpf/tree/main/schemas"
xmlns:atcValueConverters="https://github.com/atc-net/atc-wpf/tree/main/schemas/value-converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">

<atc:AutoGrid Columns="*" Rows="Auto,*">

<GroupBox
Margin="0,0,0,10"
Padding="10"
Header="Features">

<atc:UniformSpacingPanel Orientation="Horizontal" Spacing="10">
<atc:UniformSpacingPanel Orientation="Vertical" Spacing="10">
<Button Click="SendLineOnClick" Content="Send Line" />
<Button Click="SendLineWithErrorOnClick" Content="Send Line of with Error" />
<Button Click="SendLineWithSuccessfulOnClick" Content="Send Line of with Successful" />
</atc:UniformSpacingPanel>
<atc:UniformSpacingPanel Orientation="Vertical" Spacing="10">
<Button Click="SendLineWithOneOfTerms1OnClick" Content="Send Line of with Terms1" />
<Button Click="SendLineWithOneOfTerms2OnClick" Content="Send Line of with Terms2" />
<Button Click="SendLineWithOneOfTerms3OnClick" Content="Send Line of with Terms3" />
</atc:UniformSpacingPanel>
</atc:UniformSpacingPanel>

</GroupBox>

<GroupBox Header="Usage">
<ScrollViewer>

<atc:TerminalViewer
x:Name="UcTerminalViewer"
DefaultTextColor="Teal"
ErrorTextColor="Red"
SuccessfulTextColor="LimeGreen"
Terms1="{Binding Source='+', Converter={x:Static atcValueConverters:StringToSplitStringListValueConverter.Instance}}"
Terms1TextColor="Chocolate"
Terms2="{Binding Source='[sudo]', Converter={x:Static atcValueConverters:StringToSplitStringListValueConverter.Instance}}"
Terms2TextColor="DarkOrange"
Terms3="{Binding Source='upgraded;installed;connected;disconnected', Converter={x:Static atcValueConverters:StringToSplitStringListValueConverter.Instance}}"
Terms3TextColor="CornflowerBlue"
TermsError="{Binding Source='error', Converter={x:Static atcValueConverters:StringToSplitStringListValueConverter.Instance}}"
TermsSuccessful="{Binding Source='Done;100%', Converter={x:Static atcValueConverters:StringToSplitStringListValueConverter.Instance}}" />

</ScrollViewer>
</GroupBox>
</atc:AutoGrid>

</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
namespace Atc.Wpf.Sample.SamplesWpfControls.Viewers;

public partial class TerminalViewerView
{
public TerminalViewerView()
{
InitializeComponent();

DataContext = this;
}

private void SendLineOnClick(
object sender,
RoutedEventArgs e)
{
Messenger.Default.Send(
new TerminalReceivedDataEventArgs(["hello world"]));
}

private void SendLineWithErrorOnClick(
object sender,
RoutedEventArgs e)
{
Messenger.Default.Send(
new TerminalReceivedDataEventArgs(["error"]));
}

private void SendLineWithSuccessfulOnClick(
object sender,
RoutedEventArgs e)
{
Messenger.Default.Send(
new TerminalReceivedDataEventArgs(["100%"]));
}

private void SendLineWithOneOfTerms1OnClick(
object sender,
RoutedEventArgs e)
{
Messenger.Default.Send(
new TerminalReceivedDataEventArgs(["+ xxx"]));
}

private void SendLineWithOneOfTerms2OnClick(
object sender,
RoutedEventArgs e)
{
Messenger.Default.Send(
new TerminalReceivedDataEventArgs(["[sudo] xxx"]));
}

private void SendLineWithOneOfTerms3OnClick(
object sender,
RoutedEventArgs e)
{
Messenger.Default.Send(
new TerminalReceivedDataEventArgs(["installed"]));
}
}
4 changes: 4 additions & 0 deletions sample/Atc.Wpf.Sample/SamplesWpfControlsTreeView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@
Header="JsonViewer"
IsExpanded="True"
SamplePath="Viewers.JsonViewerView" />
<sample:SampleTreeViewItem
Header="TerminalViewer"
IsExpanded="True"
SamplePath="Viewers.TerminalViewerView" />
</TreeViewItem>

</TreeView>
5 changes: 3 additions & 2 deletions src/Atc.Wpf.Controls/Atc.Wpf.Controls.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.552" />
<PackageReference Include="Atc.XamlToolkit" Version="1.5.34" />
<PackageReference Include="Atc.XamlToolkit.Wpf" Version="1.5.34" />
<PackageReference Include="Atc.XamlToolkit" Version="1.5.36" />
<PackageReference Include="Atc.XamlToolkit.Wpf" Version="1.5.36" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Atc.Wpf.FontIcons\Atc.Wpf.FontIcons.csproj" />
<ProjectReference Include="..\Atc.Wpf.Theming\Atc.Wpf.Theming.csproj" />
<ProjectReference Include="..\Atc.Wpf\Atc.Wpf.csproj" />
</ItemGroup>
Expand Down
40 changes: 9 additions & 31 deletions src/Atc.Wpf.Controls/BaseControls/ColorPicker.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,15 @@ public partial class ColorPicker
[DependencyProperty(DefaultValue = RenderColorIndicatorType.Square)]
private RenderColorIndicatorType renderColorIndicatorType;

// Note: DependencyProperty-SourceGenerator don't support "typeof(Color) as null" for now
public static readonly DependencyProperty ColorValueProperty = DependencyProperty.Register(
nameof(ColorValue),
typeof(Color),
typeof(LabelColorPicker),
new PropertyMetadata(
Colors.Black,
OnColorValueChanged));

// Note: DependencyProperty-SourceGenerator don't support "typeof(Color) as null" for now
public Color? ColorValue
{
get => (Color?)GetValue(ColorValueProperty);
set => SetValue(ColorValueProperty, value);
}

// Note: DependencyProperty-SourceGenerator don't support "typeof(SolidColorBrush) as null" for now
public static readonly DependencyProperty BrushValueProperty = DependencyProperty.Register(
nameof(BrushValue),
typeof(SolidColorBrush),
typeof(ColorPicker),
new PropertyMetadata(
Brushes.Black,
OnBrushValueChanged));

// Note: DependencyProperty-SourceGenerator don't support "typeof(SolidColorBrush) as null" for now
public SolidColorBrush? BrushValue
{
get => (SolidColorBrush?)GetValue(BrushValueProperty);
set => SetValue(BrushValueProperty, value);
}
[DependencyProperty(
DefaultValue = "Black",
PropertyChangedCallback = nameof(OnColorValueChanged))]
private Color? colorValue;

[DependencyProperty(
DefaultValue = "Black",
PropertyChangedCallback = nameof(OnBrushValueChanged))]
private SolidColorBrush? brushValue;

public static readonly DependencyProperty DisplayHexCodeProperty = DependencyProperty.Register(
nameof(DisplayHexCode),
Expand Down
15 changes: 2 additions & 13 deletions src/Atc.Wpf.Controls/ColorControls/WellKnownColorPicker.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,8 @@ public partial class WellKnownColorPicker
[DependencyProperty(DefaultValue = false, PropertyChangedCallback = nameof(OnShowOnlyStandardChanged))]
private bool showOnlyBasicColors;

// Note: DependencyProperty-SourceGenerator don't support "List<ColorItem>" for now
public static readonly DependencyProperty PaletteProperty = DependencyProperty.Register(
nameof(Palette),
typeof(List<ColorItem>),
typeof(WellKnownColorPicker),
new PropertyMetadata(default(List<ColorItem>)));

// Note: DependencyProperty-SourceGenerator don't support "List<ColorItem>" for now
public List<ColorItem> Palette
{
get => (List<ColorItem>)GetValue(PaletteProperty);
set => SetValue(PaletteProperty, value);
}
[DependencyProperty]
private List<ColorItem> palette;

[DependencyProperty(DefaultValue = "Transparent")]
private Brush colorBrush;
Expand Down
5 changes: 5 additions & 0 deletions src/Atc.Wpf.Controls/Data/Models/TerminalLineItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace Atc.Wpf.Controls.Data.Models;

public record TerminalLineItem(
string Text,
Brush Foreground);
4 changes: 4 additions & 0 deletions src/Atc.Wpf.Controls/EventArgs/TerminalClearEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// ReSharper disable CheckNamespace
namespace Atc.Wpf.Controls;

public sealed class TerminalClearEventArgs : EventArgs;
10 changes: 10 additions & 0 deletions src/Atc.Wpf.Controls/EventArgs/TerminalReceivedDataEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// ReSharper disable CheckNamespace
namespace Atc.Wpf.Controls;

public sealed class TerminalReceivedDataEventArgs(string[] lines) : EventArgs
{
public IReadOnlyList<string> Lines { get; } = lines;

public override string ToString()
=> $"{nameof(Lines)}.Count: {Lines.Count}";
}
2 changes: 2 additions & 0 deletions src/Atc.Wpf.Controls/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
global using System.Text;
global using System.Text.Json;
global using System.Text.RegularExpressions;
global using System.Threading.Channels;
global using System.Windows;
global using System.Windows.Automation;
global using System.Windows.Automation.Peers;
Expand All @@ -41,6 +42,7 @@
global using Atc.Wpf.Controls.BaseControls;
global using Atc.Wpf.Controls.BaseControls.Internal;
global using Atc.Wpf.Controls.ColorControls.Internal;
global using Atc.Wpf.Controls.Data.Models;
global using Atc.Wpf.Controls.Dialogs;
global using Atc.Wpf.Controls.Documents.ColorSchemas;
global using Atc.Wpf.Controls.Documents.TextFormatters;
Expand Down
40 changes: 9 additions & 31 deletions src/Atc.Wpf.Controls/LabelControls/LabelColorPicker.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,15 @@ public partial class LabelColorPicker : ILabelColorPicker
[DependencyProperty(DefaultValue = RenderColorIndicatorType.Square)]
private RenderColorIndicatorType renderColorIndicatorType;

// Note: DependencyProperty-SourceGenerator don't support "typeof(Color) as null" for now
public static readonly DependencyProperty ColorValueProperty = DependencyProperty.Register(
nameof(ColorValue),
typeof(Color),
typeof(LabelColorPicker),
new PropertyMetadata(
Colors.Black,
OnColorValueChanged));

// Note: DependencyProperty-SourceGenerator don't support "typeof(Color) as null" for now
public Color? ColorValue
{
get => (Color?)GetValue(ColorValueProperty);
set => SetValue(ColorValueProperty, value);
}

// Note: DependencyProperty-SourceGenerator don't support "typeof(SolidColorBrush) as null" for now
public static readonly DependencyProperty BrushValueProperty = DependencyProperty.Register(
nameof(BrushValue),
typeof(SolidColorBrush),
typeof(LabelColorPicker),
new PropertyMetadata(
Brushes.Black,
OnBrushValueChanged));

// Note: DependencyProperty-SourceGenerator don't support "typeof(SolidColorBrush) as null" for now
public SolidColorBrush? BrushValue
{
get => (SolidColorBrush?)GetValue(BrushValueProperty);
set => SetValue(BrushValueProperty, value);
}
[DependencyProperty(
DefaultValue = "Black",
PropertyChangedCallback = nameof(OnColorValueChanged))]
private Color? colorValue;

[DependencyProperty(
DefaultValue = "Black",
PropertyChangedCallback = nameof(OnBrushValueChanged))]
private SolidColorBrush? brushValue;

public event EventHandler<ValueChangedEventArgs<Color>>? ColorChanged;

Expand Down
43 changes: 10 additions & 33 deletions src/Atc.Wpf.Controls/LabelControls/LabelComboBox.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,16 @@ namespace Atc.Wpf.Controls.LabelControls;

public partial class LabelComboBox : ILabelComboBox
{
// Note: DependencyProperty-SourceGenerator don't support "Dictionary<string, string>" for now
public static readonly DependencyProperty ItemsProperty = DependencyProperty.Register(
nameof(Items),
typeof(Dictionary<string, string>),
typeof(LabelComboBox),
new PropertyMetadata(default(Dictionary<string, string>)));

// Note: DependencyProperty-SourceGenerator don't support "Dictionary<string, string>" for now
public Dictionary<string, string> Items
{
get => (Dictionary<string, string>)GetValue(ItemsProperty);
set => SetValue(ItemsProperty, value);
}

// Note: DependencyProperty-SourceGenerator don't support "coerceValueCallback / isAnimationProhibited" correctly for now
public static readonly DependencyProperty SelectedKeyProperty = DependencyProperty.Register(
nameof(SelectedKey),
typeof(string),
typeof(LabelComboBox),
new FrameworkPropertyMetadata(
defaultValue: null,
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal,
OnSelectedKeyLostFocus,
coerceValueCallback: null,
isAnimationProhibited: true,
UpdateSourceTrigger.LostFocus));

// Note: DependencyProperty-SourceGenerator don't support "coerceValueCallback / isAnimationProhibited" correctly for now
public string SelectedKey
{
get => (string)GetValue(SelectedKeyProperty);
set => SetValue(SelectedKeyProperty, value);
}
[DependencyProperty]
private Dictionary<string, string> items;

[DependencyProperty(
DefaultValue = "",
Flags = FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal,
PropertyChangedCallback = nameof(OnSelectedKeyLostFocus),
IsAnimationProhibited = true,
DefaultUpdateSourceTrigger = UpdateSourceTrigger.LostFocus)]
private string selectedKey;

public event EventHandler<ValueChangedEventArgs<string?>>? SelectorChanged;

Expand Down
Loading
Loading