Skip to content

Commit b9f3ae8

Browse files
authored
Merge pull request #570 from emoacht/develop
Develop
2 parents c436a7e + e90c61c commit b9f3ae8

File tree

8 files changed

+112
-75
lines changed

8 files changed

+112
-75
lines changed

Source/Installer/Product.wxs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
3-
<Product Id="*" Name="Monitorian" Manufacturer="emoacht" Version="4.6.10"
3+
<Product Id="*" Name="Monitorian" Manufacturer="emoacht" Version="4.6.11"
44
Language="1033" Codepage="1252" UpgradeCode="{81A4D148-75D3-462E-938D-8C208FB48E3C}">
55
<Package Id="*" InstallerVersion="500" Compressed="yes"
66
InstallScope="perMachine" InstallPrivileges="elevated"

Source/Monitorian.Core/Monitorian.Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
<Compile Include="Views\Behaviors\ItemSliderBehavior.cs" />
123123
<Compile Include="Views\Behaviors\MouseDownParentAction.cs" />
124124
<Compile Include="Views\Behaviors\MouseHorizontalWheelBehavior.cs" />
125+
<Compile Include="Views\Behaviors\UpdateSourceAction.cs" />
125126
<Compile Include="Views\Controls\Sliders\CompoundSlider.cs" />
126127
<Compile Include="Views\Controls\Sliders\EnhancedSlider.cs" />
127128
<Compile Include="Views\Controls\Sliders\RangeConverter.cs" />

Source/Monitorian.Core/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
// You can specify all the values or you can default the Build and Revision Numbers
3434
// by using the '*' as shown below:
3535
// [assembly: AssemblyVersion("1.0.*")]
36-
[assembly: AssemblyVersion("4.6.10.0")]
37-
[assembly: AssemblyFileVersion("4.6.10.0")]
36+
[assembly: AssemblyVersion("4.6.11.0")]
37+
[assembly: AssemblyFileVersion("4.6.11.0")]
3838
[assembly: NeutralResourcesLanguage("en-US")]
3939

4040
// For unit test

Source/Monitorian.Core/Views/Behaviors/FocusElementAction.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace Monitorian.Core.Views.Behaviors;
55

6-
public class FocusElementAction : TriggerAction<DependencyObject>
6+
public class FocusElementAction : TriggerAction<UIElement>
77
{
88
public UIElement TargetElement
99
{
@@ -19,7 +19,8 @@ public UIElement TargetElement
1919

2020
protected override void Invoke(object parameter)
2121
{
22-
if (TargetElement is { Focusable: true, IsFocused: false })
23-
TargetElement.Focus();
22+
var target = TargetElement ?? AssociatedObject;
23+
if (target is { Focusable: true, IsFocused: false })
24+
target.Focus();
2425
}
2526
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Windows.Controls;
2+
using System.Windows.Data;
3+
using Microsoft.Xaml.Behaviors;
4+
5+
namespace Monitorian.Core.Views.Behaviors;
6+
7+
public class UpdateSourceAction : TriggerAction<TextBox>
8+
{
9+
protected override void Invoke(object parameter)
10+
{
11+
var textPropertyExpression = BindingOperations.GetBindingExpression(AssociatedObject, TextBox.TextProperty);
12+
if (!string.IsNullOrEmpty(textPropertyExpression?.ParentBinding?.Path.Path))
13+
textPropertyExpression.UpdateSource();
14+
}
15+
}

Source/Monitorian.Core/Views/DevSection.xaml

Lines changed: 78 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,74 +2,91 @@
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
xmlns:behaviors="clr-namespace:Monitorian.Core.Views.Behaviors"
58
xmlns:controls="clr-namespace:Monitorian.Core.Views.Controls"
6-
xmlns:properties="clr-namespace:Monitorian.Core.Properties">
9+
xmlns:properties="clr-namespace:Monitorian.Core.Properties"
10+
mc:Ignorable="d">
711
<UserControl.Resources>
8-
<StackPanel x:Key="Content">
9-
<ContentControl Style="{StaticResource MenuItemStyle}">
10-
<Button Padding="8,4"
11-
Style="{StaticResource PlainButtonItemStyle}"
12-
Content="{x:Static properties:Resources.Probe}"
13-
IsEnabled="{Binding CanProbe, Mode=OneWay}">
14-
<i:Interaction.Triggers>
15-
<i:EventTrigger EventName="Click">
16-
<i:CallMethodAction TargetObject="{Binding}"
17-
MethodName="PerformProbe"/>
18-
</i:EventTrigger>
19-
</i:Interaction.Triggers>
20-
</Button>
21-
</ContentControl>
12+
<ControlTemplate x:Key="Content" TargetType="{x:Type UserControl}">
13+
<StackPanel Initialized="ContentPanel_Initialized"
14+
d:Background="DarkGreen">
15+
<ContentControl Style="{StaticResource MenuItemStyle}">
16+
<Button Padding="8,4"
17+
Style="{StaticResource PlainButtonItemStyle}"
18+
Content="{x:Static properties:Resources.Probe}"
19+
IsEnabled="{Binding CanProbe, Mode=OneWay}">
20+
<i:Interaction.Triggers>
21+
<i:EventTrigger EventName="Click">
22+
<i:CallMethodAction TargetObject="{Binding}"
23+
MethodName="PerformProbe"/>
24+
</i:EventTrigger>
25+
</i:Interaction.Triggers>
26+
</Button>
27+
</ContentControl>
2228

23-
<ContentControl Style="{StaticResource MenuItemStyle}">
24-
<Button Padding="8,4"
25-
Style="{StaticResource PlainButtonItemStyle}"
26-
Content="{x:Static properties:Resources.Rescan}">
27-
<i:Interaction.Triggers>
28-
<i:EventTrigger EventName="Click">
29-
<i:CallMethodAction TargetObject="{Binding}"
30-
MethodName="PerformRescan"/>
31-
</i:EventTrigger>
32-
</i:Interaction.Triggers>
33-
</Button>
34-
</ContentControl>
29+
<ContentControl Style="{StaticResource MenuItemStyle}">
30+
<Button Padding="8,4"
31+
Style="{StaticResource PlainButtonItemStyle}"
32+
Content="{x:Static properties:Resources.Rescan}">
33+
<i:Interaction.Triggers>
34+
<i:EventTrigger EventName="Click">
35+
<i:CallMethodAction TargetObject="{Binding}"
36+
MethodName="PerformRescan"/>
37+
</i:EventTrigger>
38+
</i:Interaction.Triggers>
39+
</Button>
40+
</ContentControl>
3541

36-
<ContentControl Style="{StaticResource MenuItemStyle}">
37-
<ToggleButton Padding="8,4"
38-
Style="{StaticResource CheckButtonItemStyle}"
39-
Content="{x:Static properties:Resources.MakeOperation}"
40-
IsChecked="{Binding Settings.MakesOperationLog}"/>
41-
</ContentControl>
42+
<ContentControl Style="{StaticResource MenuItemStyle}">
43+
<ToggleButton Padding="8,4"
44+
Style="{StaticResource CheckButtonItemStyle}"
45+
Content="{x:Static properties:Resources.MakeOperation}"
46+
IsChecked="{Binding Settings.MakesOperationLog}"/>
47+
</ContentControl>
4248

43-
<ContentControl Style="{StaticResource MenuItemStyle}">
44-
<Button Padding="8,4"
45-
Style="{StaticResource PlainButtonItemStyle}"
46-
Content="{x:Static properties:Resources.CopyOperation}">
47-
<i:Interaction.Triggers>
48-
<i:EventTrigger EventName="Click">
49-
<i:CallMethodAction TargetObject="{Binding}"
50-
MethodName="PerformCopy"/>
51-
</i:EventTrigger>
52-
</i:Interaction.Triggers>
53-
</Button>
54-
</ContentControl>
49+
<ContentControl Style="{StaticResource MenuItemStyle}">
50+
<Button Padding="8,4"
51+
Style="{StaticResource PlainButtonItemStyle}"
52+
Content="{x:Static properties:Resources.CopyOperation}">
53+
<i:Interaction.Triggers>
54+
<i:EventTrigger EventName="Click">
55+
<i:CallMethodAction TargetObject="{Binding}"
56+
MethodName="PerformCopy"/>
57+
</i:EventTrigger>
58+
</i:Interaction.Triggers>
59+
</Button>
60+
</ContentControl>
5561

56-
<ContentControl Style="{StaticResource MenuItemStyle}">
57-
<controls:MultiToggleButton Padding="8,4"
58-
Style="{StaticResource MultiButtonItemStyle}"
59-
Content="{x:Static properties:Resources.Arguments}"
60-
IsCheckable="False">
61-
<controls:MultiToggleButton.SubContent>
62-
<TextBox Style="{StaticResource PlainTextBoxStyle}"
63-
FlowDirection="LeftToRight"
64-
TextWrapping="Wrap" AcceptsReturn="True"
65-
MaxLength="256" MaxLines="5"
66-
Text="{Binding Arguments, Mode=TwoWay}"/>
67-
</controls:MultiToggleButton.SubContent>
68-
</controls:MultiToggleButton>
69-
</ContentControl>
62+
<ContentControl Style="{StaticResource MenuItemStyle}">
63+
<controls:MultiToggleButton Padding="8,4"
64+
Style="{StaticResource MultiButtonItemStyle}"
65+
Content="{x:Static properties:Resources.Arguments}"
66+
IsCheckable="False">
67+
<controls:MultiToggleButton.SubContent>
68+
<TextBox Style="{StaticResource PlainTextBoxStyle}"
69+
FlowDirection="LeftToRight"
70+
TextWrapping="Wrap" AcceptsReturn="True"
71+
MaxLength="256" MaxLines="5"
72+
Text="{Binding Arguments, Mode=TwoWay}">
73+
<i:Interaction.Triggers>
74+
<i:EventTrigger SourceObject="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}}" EventName="Closed">
75+
<behaviors:UpdateSourceAction/>
76+
</i:EventTrigger>
77+
</i:Interaction.Triggers>
78+
</TextBox>
79+
</controls:MultiToggleButton.SubContent>
80+
</controls:MultiToggleButton>
81+
</ContentControl>
7082

71-
<Separator Style="{StaticResource MenuSeparatorStyle}"/>
72-
</StackPanel>
83+
<Separator Style="{StaticResource MenuSeparatorStyle}"/>
84+
</StackPanel>
85+
</ControlTemplate>
7386
</UserControl.Resources>
7487

88+
<d:UserControl.Template>
89+
<StaticResource ResourceKey="Content"/>
90+
</d:UserControl.Template>
91+
7592
</UserControl>

Source/Monitorian.Core/Views/DevSection.xaml.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,22 @@ public void Open()
3939
if (++_count != CountThreshold)
4040
return;
4141

42-
if (this.Resources["Content"] is not StackPanel content)
43-
return;
42+
if (this.Resources["Content"] is ControlTemplate template)
43+
this.Template = template;
44+
}
4445

45-
if (_additionalItems is { Length: > 0 })
46+
private void ContentPanel_Initialized(object sender, EventArgs e)
47+
{
48+
if ((sender is StackPanel panel) &&
49+
(_additionalItems is { Length: > 0 }))
4650
{
4751
foreach (var (item, index) in _additionalItems)
4852
{
49-
int i = index ?? Math.Max(0, content.Children.Count - 1);
50-
content.Children.Insert(i, item);
53+
int i = index ?? Math.Max(0, panel.Children.Count - 1);
54+
panel.Children.Insert(i, item);
5155
}
5256
}
5357

54-
this.Content = content;
5558
MenuWindow.EnsureFlowDirection(this);
5659
}
5760
}

Source/Monitorian/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("4.6.10.0")]
55-
[assembly: AssemblyFileVersion("4.6.10.0")]
54+
[assembly: AssemblyVersion("4.6.11.0")]
55+
[assembly: AssemblyFileVersion("4.6.11.0")]
5656
[assembly: Guid("a4cc5362-9b08-465b-ad64-5cfabc72a4c7")]
5757
[assembly: NeutralResourcesLanguage("en-US")]

0 commit comments

Comments
 (0)