Skip to content

Commit

Permalink
Use predefined dialog button texts (1/n).
Browse files Browse the repository at this point in the history
  • Loading branch information
hamster620 committed Oct 9, 2024
1 parent 592e9c6 commit 2272612
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 67 deletions.
21 changes: 11 additions & 10 deletions ULogViewer/Controls/KeyLogAnalysisRuleSetEditorDialog.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
xmlns:asControls="using:CarinaStudio.AppSuite.Controls"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="CarinaStudio.ULogViewer.Controls.KeyLogAnalysisRuleSetEditorDialog"
Name="dialog"
CanResize="True"
Classes="Dialog"
Height="{StaticResource Double/KeyLogAnalysisRuleSetEditorDialog.Height}"
Expand All @@ -23,10 +24,10 @@
<!-- Control buttons -->
<Border Classes="Dialog_ControlButtonsPanel">
<StackPanel Classes="Dialog_ControlButtonsPanel">
<Button Classes="Dialog_ControlButton" Command="{Binding $parent[Window].OpenDocumentation}" Content="{DynamicResource String/Common.Help}"/>
<Button Classes="Dialog_ControlButton" Command="{Binding #dialog.OpenDocumentation}" Content="{DynamicResource String/Common.Help}"/>
<Separator Classes="Dialog_Separator_Small"/>
<Button Classes="Dialog_ControlButton" Command="{Binding $parent[Window].CompleteEditing}" Content="{DynamicResource String/Common.OK}" IsEnabled="{Binding $parent[Window].AreValidParameters}"/>
<Button Classes="Dialog_ControlButton" Command="{Binding $parent[Window].Close}" Content="{DynamicResource String/Common.Cancel}"/>
<Button Classes="Dialog_ControlButton" Command="{Binding #dialog.CompleteEditing}" Content="{Binding #dialog.OKButtonText}" IsEnabled="{Binding #dialog.AreValidParameters}"/>
<Button Classes="Dialog_ControlButton" Command="{Binding #dialog.Close}" Content="{DynamicResource String/Common.Cancel}"/>
</StackPanel>
</Border>

Expand Down Expand Up @@ -70,33 +71,33 @@
<TextBlock Classes="Dialog_TextBlock" HorizontalAlignment="Right" IsVisible="{Binding !#ruleListBox.IsVisible}" Text="{DynamicResource String/Common.None}"/>
</asControls:DialogItem>
<Line Classes="Dialog_Item_Separator_Inner"/>
<asControls:ListBox Name="ruleListBox" Classes="Dialog_Item_ListBox" IsVisible="{Binding $parent[Window].Rules.Count}" ItemsPanel="{StaticResource ItemsPanelTemplate/StackPanel}" ItemsSource="{Binding $parent[Window].Rules}">
<asControls:ListBox Name="ruleListBox" Classes="Dialog_Item_ListBox" IsVisible="{Binding #dialog.Rules.Count}" ItemsPanel="{StaticResource ItemsPanelTemplate/StackPanel}" ItemsSource="{Binding #dialog.Rules}">
<asControls:ListBox.ItemTemplate>
<DataTemplate>
<Grid Name="itemRoot" ColumnDefinitions="Auto,*,Auto" RowDefinitions="Auto,Auto">
<Panel Classes="ListBoxItem_Icon">
<Image Classes="Icon" IsVisible="{Binding $parent[ListBoxItem].IsSelected}" Source="{Binding ResultType, Converter={x:Static appConverters:DisplayableLogAnalysisResultIconConverter.Default}, ConverterParameter=Light}"/>
<Image Classes="Icon" IsVisible="{Binding !$parent[ListBoxItem].IsSelected}" Source="{Binding ResultType, Converter={x:Static appConverters:DisplayableLogAnalysisResultIconConverter.Default}}"/>
</Panel>
<asControls:SyntaxHighlightingTextBlock DefinitionSet="{Binding $parent[Window].RegexSyntaxHighlightingDefinitionSet}" FontFamily="{Binding PatternFontFamily, Source={x:Static appControls:ControlFonts.Default}}" Grid.Column="1" Text="{Binding Pattern}" TextTrimming="None"/>
<asControls:SyntaxHighlightingTextBlock DefinitionSet="{Binding $parent[Window].MessageSyntaxHighlightingDefinitionSet}" FontFamily="{Binding PatternFontFamily, Source={x:Static appControls:ControlFonts.Default}}" FontSize="{StaticResource Double/KeyLogAnalysisRuleSetEditorDialog.RuleListBox.Item.Message.FontSize}" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="1" Margin="{StaticResource Thickness/KeyLogAnalysisRuleSetEditorDialog.RuleListBox.Message.Margin}" Opacity="{StaticResource Double/KeyLogAnalysisRuleSetEditorDialog.RuleListBox.Item.Message.Opacity}" Text="{Binding Message}" TextTrimming="None"/>
<asControls:SyntaxHighlightingTextBlock DefinitionSet="{Binding #dialog.RegexSyntaxHighlightingDefinitionSet}" FontFamily="{Binding PatternFontFamily, Source={x:Static appControls:ControlFonts.Default}}" Grid.Column="1" Text="{Binding Pattern}" TextTrimming="None"/>
<asControls:SyntaxHighlightingTextBlock DefinitionSet="{Binding #dialog.MessageSyntaxHighlightingDefinitionSet}" FontFamily="{Binding PatternFontFamily, Source={x:Static appControls:ControlFonts.Default}}" FontSize="{StaticResource Double/KeyLogAnalysisRuleSetEditorDialog.RuleListBox.Item.Message.FontSize}" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="1" Margin="{StaticResource Thickness/KeyLogAnalysisRuleSetEditorDialog.RuleListBox.Message.Margin}" Opacity="{StaticResource Double/KeyLogAnalysisRuleSetEditorDialog.RuleListBox.Item.Message.Opacity}" Text="{Binding Message}" TextTrimming="None"/>
<Border Classes="InPlaceAction_Reserved"/>
<StackPanel Grid.Column="2" IsVisible="{Binding $parent[ListBoxItem].IsPointerOver}" Orientation="Horizontal">
<Button Classes="InPlaceAction_Button" Command="{Binding $parent[Window].RemoveRuleCommand}" CommandParameter="{Binding $parent[ListBoxItem]}" ToolTip.Tip="{DynamicResource String/Common.Delete}">
<Button Classes="InPlaceAction_Button" Command="{Binding #dialog.RemoveRuleCommand}" CommandParameter="{Binding $parent[ListBoxItem]}" ToolTip.Tip="{DynamicResource String/Common.Delete}">
<asControls:Image Classes="InPlaceAction_Icon">
<DrawingImage>
<GeometryDrawing Brush="{Binding #itemRoot.(TextElement.Foreground)}" Geometry="{StaticResource Geometry/Icon.Delete.Outline}"/>
</DrawingImage>
</asControls:Image>
</Button>
<Button Classes="InPlaceAction_Button" Command="{Binding $parent[Window].CopyRuleCommand}" CommandParameter="{Binding $parent[ListBoxItem]}" ToolTip.Tip="{DynamicResource String/Common.Copy}">
<Button Classes="InPlaceAction_Button" Command="{Binding #dialog.CopyRuleCommand}" CommandParameter="{Binding $parent[ListBoxItem]}" ToolTip.Tip="{DynamicResource String/Common.Copy}">
<asControls:Image Classes="InPlaceAction_Icon">
<DrawingImage>
<GeometryDrawing Brush="{Binding #itemRoot.(TextElement.Foreground)}" Geometry="{StaticResource Geometry/Icon.Copy.Outline}"/>
</DrawingImage>
</asControls:Image>
</Button>
<Button Classes="InPlaceAction_Button" Command="{Binding $parent[Window].EditRuleCommand}" CommandParameter="{Binding $parent[ListBoxItem]}" ToolTip.Tip="{DynamicResource String/Common.Edit}">
<Button Classes="InPlaceAction_Button" Command="{Binding #dialog.EditRuleCommand}" CommandParameter="{Binding $parent[ListBoxItem]}" ToolTip.Tip="{DynamicResource String/Common.Edit}">
<asControls:Image Classes="InPlaceAction_Icon">
<DrawingImage>
<GeometryDrawing Brush="{Binding #itemRoot.(TextElement.Foreground)}" Geometry="{StaticResource Geometry/Icon.Edit.Outline}"/>
Expand All @@ -109,7 +110,7 @@
</asControls:ListBox.ItemTemplate>
</asControls:ListBox>
<Separator Classes="Dialog_Separator_Small" IsVisible="{Binding #ruleListBox.IsVisible}"/>
<Button Classes="Dialog_Item_Button" Command="{Binding $parent[Window].AddRule}" Content="{DynamicResource String/Common.Add.WithDialog}"/>
<Button Classes="Dialog_Item_Button" Command="{Binding #dialog.AddRule}" Content="{DynamicResource String/Common.Add.WithDialog}"/>

</StackPanel>
</Border>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace CarinaStudio.ULogViewer.Controls;
/// <summary>
/// Dialog to edit <see cref="KeyLogAnalysisRuleSet"/>.
/// </summary>
class KeyLogAnalysisRuleSetEditorDialog : Window<IULogViewerApplication>
class KeyLogAnalysisRuleSetEditorDialog : Dialog<IULogViewerApplication>
{
// Static fields.
static readonly StyledProperty<bool> AreValidParametersProperty = AvaloniaProperty.Register<KeyLogAnalysisRuleSetEditorDialog, bool>("AreValidParameters");
Expand Down Expand Up @@ -277,11 +277,6 @@ protected override void OnOpening(EventArgs e)
}
this.validateParametersAction.Execute();
}


/// <inheritdoc/>
protected override WindowTransparencyLevel OnSelectTransparentLevelHint() =>
WindowTransparencyLevel.None;


/// <summary>
Expand Down
14 changes: 7 additions & 7 deletions ULogViewer/Controls/LogAnalysisScriptSetEditorDialog.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
<!-- Control buttons -->
<Border Classes="Dialog_ControlButtonsPanel">
<StackPanel Classes="Dialog_ControlButtonsPanel">
<Button Classes="Dialog_ControlButton" Command="{Binding $parent[Window].OpenDocumentation}" Content="{DynamicResource String/Common.Help}"/>
<Button Classes="Dialog_ControlButton" Command="{Binding #window.OpenDocumentation}" Content="{DynamicResource String/Common.Help}"/>
<Separator Classes="Dialog_Separator_Small"/>
<Button Classes="Dialog_ControlButton" Command="{Binding $parent[Window].ApplyCommand}" Content="{DynamicResource String/Common.Apply}" IsVisible="{Binding !#window.IsNewScriptSet}"/>
<Button Classes="Dialog_ControlButton" Command="{Binding $parent[Window].CompleteEditingCommand}" Content="{DynamicResource String/Common.OK}"/>
<Button Classes="Dialog_ControlButton" Command="{Binding $parent[Window].Close}" Content="{DynamicResource String/Common.Cancel}"/>
<Button Classes="Dialog_ControlButton" Command="{Binding #window.ApplyCommand}" Content="{DynamicResource String/Common.Apply}" IsVisible="{Binding !#window.IsNewScriptSet}"/>
<Button Classes="Dialog_ControlButton" Command="{Binding #window.CompleteEditingCommand}" Content="{Binding #window.OKButtonText}"/>
<Button Classes="Dialog_ControlButton" Command="{Binding #window.Close}" Content="{DynamicResource String/Common.Cancel}"/>
</StackPanel>
</Border>

Expand All @@ -42,7 +42,7 @@
<StackPanel>

<!-- Name and Icon -->
<StackPanel IsVisible="{Binding !$parent[Window].IsEmbeddedScriptSet}">
<StackPanel IsVisible="{Binding !#window.IsEmbeddedScriptSet}">

<!-- Name -->
<asControls:DialogItem>
Expand Down Expand Up @@ -88,7 +88,7 @@
<asControls:DialogItem>
<WrapPanel VerticalAlignment="Center">
<TextBlock Classes="Dialog_TextBlock_Label" Text="{DynamicResource String/LogAnalysisScriptSetEditorDialog.SetupScript}"/>
<Button Classes="Dialog_Info_Button" Command="{x:Static app:Utility.OpenLinkCommand}" CommandParameter="{Binding $parent[Window].SetupScriptDocumentUri}" ToolTip.Tip="{DynamicResource String/Common.Help}">
<Button Classes="Dialog_Info_Button" Command="{x:Static app:Utility.OpenLinkCommand}" CommandParameter="{Binding #window.SetupScriptDocumentUri}" ToolTip.Tip="{DynamicResource String/Common.Help}">
<Image Classes="Icon" Source="{DynamicResource Image/Icon.Question.Outline}"/>
</Button>
</WrapPanel>
Expand All @@ -102,7 +102,7 @@
<asControls:DialogItem>
<WrapPanel VerticalAlignment="Center">
<TextBlock Classes="Dialog_TextBlock_Label" Text="{DynamicResource String/LogAnalysisScriptSetEditorDialog.AnalysisScript}"/>
<Button Classes="Dialog_Info_Button" Command="{x:Static app:Utility.OpenLinkCommand}" CommandParameter="{Binding $parent[Window].AnalysisScriptDocumentUri}" ToolTip.Tip="{DynamicResource String/Common.Help}">
<Button Classes="Dialog_Info_Button" Command="{x:Static app:Utility.OpenLinkCommand}" CommandParameter="{Binding #window.AnalysisScriptDocumentUri}" ToolTip.Tip="{DynamicResource String/Common.Help}">
<Image Classes="Icon" Source="{DynamicResource Image/Icon.Question.Outline}"/>
</Button>
</WrapPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace CarinaStudio.ULogViewer.Controls;
/// <summary>
/// Dialog to edit log analysis script set.
/// </summary>
class LogAnalysisScriptSetEditorDialog : CarinaStudio.Controls.ApplicationWindow<IULogViewerApplication>
class LogAnalysisScriptSetEditorDialog : Dialog<IULogViewerApplication>
{
// Static fields.
static readonly DirectProperty<LogAnalysisScriptSetEditorDialog, Uri?> AnalysisScriptDocumentUriProperty = AvaloniaProperty.RegisterDirect<LogAnalysisScriptSetEditorDialog, Uri?>(nameof(AnalysisScriptDocumentUri), d => d.analysisScriptDocumentUri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
xmlns:asControls="using:CarinaStudio.AppSuite.Controls"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="CarinaStudio.ULogViewer.Controls.OperationCountingAnalysisRuleSetEditorDialog"
Name="dialog"
CanResize="True"
Classes="Dialog"
Height="{StaticResource Double/OperationCountingAnalysisRuleSetEditorDialog.Height}"
Expand All @@ -23,10 +24,10 @@
<!-- Control buttons -->
<Border Classes="Dialog_ControlButtonsPanel">
<StackPanel Classes="Dialog_ControlButtonsPanel">
<Button Classes="Dialog_ControlButton" Command="{Binding $parent[Window].OpenDocumentation}" Content="{DynamicResource String/Common.Help}"/>
<Button Classes="Dialog_ControlButton" Command="{Binding #dialog.OpenDocumentation}" Content="{DynamicResource String/Common.Help}"/>
<Separator Classes="Dialog_Separator_Small"/>
<Button Classes="Dialog_ControlButton" Command="{Binding $parent[Window].CompleteEditing}" Content="{DynamicResource String/Common.OK}" IsEnabled="{Binding $parent[Window].AreValidParameters}"/>
<Button Classes="Dialog_ControlButton" Command="{Binding $parent[Window].Close}" Content="{DynamicResource String/Common.Cancel}"/>
<Button Classes="Dialog_ControlButton" Command="{Binding #dialog.CompleteEditing}" Content="{Binding #dialog.OKButtonText}" IsEnabled="{Binding #dialog.AreValidParameters}"/>
<Button Classes="Dialog_ControlButton" Command="{Binding #dialog.Close}" Content="{DynamicResource String/Common.Cancel}"/>
</StackPanel>
</Border>

Expand Down Expand Up @@ -70,7 +71,7 @@
<TextBlock Classes="Dialog_TextBlock" HorizontalAlignment="Right" IsVisible="{Binding !#ruleListBox.IsVisible}" Text="{DynamicResource String/Common.None}"/>
</asControls:DialogItem>
<Line Classes="Dialog_Item_Separator_Inner"/>
<asControls:ListBox Name="ruleListBox" Classes="Dialog_Item_ListBox" IsVisible="{Binding $parent[Window].Rules.Count}" ItemsPanel="{StaticResource ItemsPanelTemplate/StackPanel}" ItemsSource="{Binding $parent[Window].Rules}">
<asControls:ListBox Name="ruleListBox" Classes="Dialog_Item_ListBox" IsVisible="{Binding #dialog.Rules.Count}" ItemsPanel="{StaticResource ItemsPanelTemplate/StackPanel}" ItemsSource="{Binding #dialog.Rules}">
<asControls:ListBox.ItemTemplate>
<DataTemplate>
<Grid Name="itemRoot" ColumnDefinitions="Auto,*,Auto" RowDefinitions="Auto,*">
Expand All @@ -90,21 +91,21 @@
TextTrimming="None"/>
<Border Classes="InPlaceAction_Reserved" Grid.Column="1"/>
<StackPanel Grid.Column="2" IsVisible="{Binding $parent[ListBoxItem].IsPointerOver}" Orientation="Horizontal">
<Button Classes="InPlaceAction_Button" Command="{Binding $parent[Window].RemoveRuleCommand}" CommandParameter="{Binding $parent[ListBoxItem].DataContext}" ToolTip.Tip="{DynamicResource String/Common.Delete}">
<Button Classes="InPlaceAction_Button" Command="{Binding #dialog.RemoveRuleCommand}" CommandParameter="{Binding $parent[ListBoxItem].DataContext}" ToolTip.Tip="{DynamicResource String/Common.Delete}">
<asControls:Image Classes="InPlaceAction_Icon">
<DrawingImage>
<GeometryDrawing Brush="{Binding #itemRoot.(TextElement.Foreground)}" Geometry="{StaticResource Geometry/Icon.Delete.Outline}"/>
</DrawingImage>
</asControls:Image>
</Button>
<Button Classes="InPlaceAction_Button" Command="{Binding $parent[Window].CopyRuleCommand}" CommandParameter="{Binding $parent[ListBoxItem].DataContext}" ToolTip.Tip="{DynamicResource String/Common.Copy}">
<Button Classes="InPlaceAction_Button" Command="{Binding #dialog.CopyRuleCommand}" CommandParameter="{Binding $parent[ListBoxItem].DataContext}" ToolTip.Tip="{DynamicResource String/Common.Copy}">
<asControls:Image Classes="InPlaceAction_Icon">
<DrawingImage>
<GeometryDrawing Brush="{Binding #itemRoot.(TextElement.Foreground)}" Geometry="{StaticResource Geometry/Icon.Copy.Outline}"/>
</DrawingImage>
</asControls:Image>
</Button>
<Button Classes="InPlaceAction_Button" Command="{Binding $parent[Window].EditRuleCommand}" CommandParameter="{Binding $parent[ListBoxItem].DataContext}" ToolTip.Tip="{DynamicResource String/Common.Edit}">
<Button Classes="InPlaceAction_Button" Command="{Binding #dialog.EditRuleCommand}" CommandParameter="{Binding $parent[ListBoxItem].DataContext}" ToolTip.Tip="{DynamicResource String/Common.Edit}">
<asControls:Image Classes="InPlaceAction_Icon">
<DrawingImage>
<GeometryDrawing Brush="{Binding #itemRoot.(TextElement.Foreground)}" Geometry="{StaticResource Geometry/Icon.Edit.Outline}"/>
Expand All @@ -117,7 +118,7 @@
</asControls:ListBox.ItemTemplate>
</asControls:ListBox>
<Separator Classes="Dialog_Separator_Small" IsVisible="{Binding #ruleListBox.IsVisible}"/>
<Button Classes="Dialog_Item_Button" Command="{Binding $parent[Window].AddRule}" Content="{DynamicResource String/Common.Add.WithDialog}"/>
<Button Classes="Dialog_Item_Button" Command="{Binding #dialog.AddRule}" Content="{DynamicResource String/Common.Add.WithDialog}"/>

</StackPanel>
</Border>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace CarinaStudio.ULogViewer.Controls
/// <summary>
/// Dialog to edit <see cref="OperationCountingAnalysisRuleSet"/>.
/// </summary>
class OperationCountingAnalysisRuleSetEditorDialog : Window<IULogViewerApplication>
class OperationCountingAnalysisRuleSetEditorDialog : Dialog<IULogViewerApplication>
{
/// <summary>
/// Definition set of patterns of rule.
Expand Down Expand Up @@ -252,11 +252,6 @@ protected override void OnOpening(EventArgs e)
}
this.validateParametersAction.Schedule();
}


/// <inheritdoc/>
protected override WindowTransparencyLevel OnSelectTransparentLevelHint() =>
WindowTransparencyLevel.None;


/// <summary>
Expand Down Expand Up @@ -285,7 +280,7 @@ void RemoveRule(OperationCountingAnalysisRuleSet.Rule rule)
/// <summary>
/// Rules.
/// </summary>
public IList<OperationCountingAnalysisRuleSet.Rule> Rules { get => this.rules; }
public IList<OperationCountingAnalysisRuleSet.Rule> Rules => this.rules;


/// <summary>
Expand All @@ -298,7 +293,7 @@ public static void Show(Avalonia.Controls.Window parent, OperationCountingAnalys
// show existing dialog
if (ruleSet != null && DialogWithEditingRuleSets.TryGetValue(ruleSet, out var dialog))
{
dialog?.ActivateAndBringToFront();
dialog.ActivateAndBringToFront();
return;
}

Expand Down
Loading

0 comments on commit 2272612

Please sign in to comment.