Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KerlyJiang1 committed Dec 8, 2019
1 parent 718b2b3 commit 97f5273
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,23 @@ public Switch Switch

public Metric Metric
{
get => this.metric;
set => this.SetProperty(ref this.metric, value);
get => this.metric ?? new Metric();
set
{
this.SetProperty(ref this.metric, value);
this.RaisePropertyChanged("WaterPump");
this.RaisePropertyChanged("HeaterWaterTemperature");
}
}

public bool HeaterWaterTemperature
{
get => this.Metric.HeaterOutputWaterCelsiusDegree - this.Metric.InputWaterCelsiusDegree > 0 ? true : false;
}

public bool WaterPump
{
get => this.Metric.WaterPumpFlowRateCubicMeterPerHour > 0 ? true : false;
}

public async Task LoadMetricAsync()
Expand Down Expand Up @@ -78,7 +93,7 @@ public async Task UpdateSwitchAsync(Switch switchInfo, FieldMask mask)
new UpdateSwitchRequest()
{
DeviceId = this.ViewModelContext.SelectedDevice.Id,
Switch = this.Switch,
Switch = switchInfo,
UpdateMask = mask,
},
deadline: DateTime.Now.AddMilliseconds(500));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:GeothermalResearchInstitute.Wpf.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:prism="http://prismlibrary.com/"
d:DesignHeight="360"
xmlns:prism="http://prismlibrary.com/"
xmlns:c="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
d:DesignHeight="360"
d:DesignWidth="600"
prism:ViewModelLocator.AutoWireViewModel="True"
Loaded="DeviceControlView_LoadedAsync"
Expand Down Expand Up @@ -169,7 +170,7 @@
<Ellipse.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding Switch.HeaterPowerOn}" Value="true">
<DataTrigger Binding="{Binding HeaterWaterTemperature}" Value="true">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
Expand Down Expand Up @@ -200,7 +201,7 @@
<Ellipse.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding Switch.HeaterCompressorOn}" Value="true">
<DataTrigger Binding="{Binding WaterPump}" Value="true">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
Expand Down Expand Up @@ -262,13 +263,57 @@

</Image.Style>
</Image>
<StackPanel
Canvas.Left="150"
Canvas.Top="120"
Orientation="Horizontal">
<Label Content="设备状态:"
VerticalAlignment="Center"/>
<TextBlock Text="{Binding Switch.DevicePowerOn, Converter={local:SwitchStatusConverter}}"
VerticalAlignment="Center"
Padding="0,0,10,0"/>
<Button
Margin="5"
Padding="5"
Content=""
Command="{Binding SwitchOnClickCommand}"
CommandParameter="heater_auto_on"/>
<Button
Margin="5"
Padding="5"
Content=""
Command="{Binding SwitchOffClickCommand}"
CommandParameter="heater_auto_on"/>
</StackPanel>
<StackPanel
Canvas.Left="150"
Canvas.Top="150"
Orientation="Horizontal">
<Label Content="排气状态:"
VerticalAlignment="Center"/>
<TextBlock Text="{Binding Switch.ExhausterPowerOn , Converter={local:SwitchStatusConverter}}"
VerticalAlignment="Center"
Padding="0,0,10,0"/>
<Button
Margin="5"
Padding="5"
Content=""
Command="{Binding SwitchOnClickCommand}"
CommandParameter="heater_auto_on"/>
<Button
Margin="5"
Padding="5"
Content=""
Command="{Binding SwitchOffClickCommand}"
CommandParameter="heater_auto_on"/>
</StackPanel>
<StackPanel
Canvas.Left="335"
Canvas.Top="105"
Orientation="Horizontal">
<Label Content="电源状态"
<Label Content="热泵电源"
VerticalAlignment="Center"/>
<TextBlock Text="{Binding Switch.DevicePowerOn}"
<TextBlock Text="{Binding Switch.HeaterPowerOn, Converter={local:SwitchStatusConverter}}"
VerticalAlignment="Center"
Padding="0,0,10,0"/>
<Button
Expand Down Expand Up @@ -304,7 +349,7 @@
<StackPanel Canvas.Left="450"
Canvas.Top="200"
Orientation="Horizontal">
<TextBlock Width="30" Text="手动"/>
<TextBlock Width="30" Text="{Binding Switch.HeaterAutoOn, Converter={local:SwitchAutoManuConverter}}"/>
</StackPanel>
<StackPanel
Canvas.Left="335"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Data;
using System.Windows.Markup;

namespace GeothermalResearchInstitute.Wpf.Views
{
public class SwitchAutoManuConverter : MarkupExtension, IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool)value switch
{
true => "自动",
false => "手动",
};
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}

public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Data;
using System.Windows.Markup;

namespace GeothermalResearchInstitute.Wpf.Views
{
public class SwitchRunningStatusConverter : MarkupExtension, IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return float.Parse((string)value) > 0 ? "true" : "false";
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}

public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Text;
using System.Windows.Data;
using System.Windows.Markup;

namespace GeothermalResearchInstitute.Wpf.Views
{
public class SwitchStatusConverter : MarkupExtension, IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool)value switch
{
true => "开",
false => "关",
};

}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}

public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
}

0 comments on commit 97f5273

Please sign in to comment.