Commit 36919024 authored by LiGuohua's avatar LiGuohua

glee08@home 完成UC_SelectData,AlarmZone

parent 40c272a7
...@@ -113,6 +113,10 @@ ...@@ -113,6 +113,10 @@
<Compile Include="UIModule\UC_AirRingShift.xaml.cs"> <Compile Include="UIModule\UC_AirRingShift.xaml.cs">
<DependentUpon>UC_AirRingShift.xaml</DependentUpon> <DependentUpon>UC_AirRingShift.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="UIModule\UC_BrowseData\UC_BrowseData.xaml.cs">
<DependentUpon>UC_BrowseData.xaml</DependentUpon>
</Compile>
<Compile Include="UIModule\UC_BrowseData\ViewModel_UC_BrowseData.cs" />
<Compile Include="UIModule\UC_FrameDiff.xaml.cs"> <Compile Include="UIModule\UC_FrameDiff.xaml.cs">
<DependentUpon>UC_FrameDiff.xaml</DependentUpon> <DependentUpon>UC_FrameDiff.xaml</DependentUpon>
</Compile> </Compile>
...@@ -124,6 +128,7 @@ ...@@ -124,6 +128,7 @@
<DependentUpon>UC_HeatBoltAnalyst.xaml</DependentUpon> <DependentUpon>UC_HeatBoltAnalyst.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="UIModule\UC_HeatBoltAnalystViewModel.cs" /> <Compile Include="UIModule\UC_HeatBoltAnalystViewModel.cs" />
<Compile Include="UIModule\UC_SelectData\AlarmZone.cs" />
<Compile Include="UIModule\UC_SelectData\UC_SelectData.xaml.cs"> <Compile Include="UIModule\UC_SelectData\UC_SelectData.xaml.cs">
<DependentUpon>UC_SelectData.xaml</DependentUpon> <DependentUpon>UC_SelectData.xaml</DependentUpon>
</Compile> </Compile>
...@@ -152,6 +157,10 @@ ...@@ -152,6 +157,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="UIModule\UC_BrowseData\UC_BrowseData.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UIModule\UC_FrameDiff.xaml"> <Page Include="UIModule\UC_FrameDiff.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
...@@ -233,5 +242,6 @@ ...@@ -233,5 +242,6 @@
<Version>1.0.112</Version> <Version>1.0.112</Version>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>
\ No newline at end of file
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FLY.HeatingHelper.UI.UIModule" xmlns:local="clr-namespace:FLY.HeatingHelper.UI.UIModule"
xmlns:local1="clr-namespace:FLY.HeatingHelper.UI.UIModule.UC_SelectData"
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf" xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="900" d:DesignWidth="960" d:DesignHeight="900" d:DesignWidth="960"
...@@ -259,6 +260,9 @@ ...@@ -259,6 +260,9 @@
</Border> </Border>
</Grid> </Grid>
</TabItem> </TabItem>
<TabItem Header="数据选择new" Style="{DynamicResource TabItemStyle1}">
<local1:UC_SelectData/>
</TabItem>
<TabItem Header="风环偏转" Style="{DynamicResource TabItemStyle1}" x:Name="tabitem_ringShift"> <TabItem Header="风环偏转" Style="{DynamicResource TabItemStyle1}" x:Name="tabitem_ringShift">
<local:UC_AirRingShift x:Name="uc_airRingShift"> <local:UC_AirRingShift x:Name="uc_airRingShift">
......
<UserControl x:Class="FLY.HeatingHelper.UI.UIModule.UC_BrowseData.UC_BrowseData"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FLY.HeatingHelper.UI.UIModule.UC_BrowseData"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace FLY.HeatingHelper.UI.UIModule.UC_BrowseData
{
/// <summary>
/// UC_BrowseData.xaml 的交互逻辑
/// </summary>
public partial class UC_BrowseData : UserControl
{
public UC_BrowseData()
{
InitializeComponent();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FLY.HeatingHelper.UI.UIModule.UC_BrowseData
{
class ViewModel_UC_BrowseData : INotifyPropertyChanged
{
public IThickHeatData Dat { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Windows.Controls;
using C1.WPF.C1Chart;
using System.Windows;
namespace Chart_AlarmZones_WPF_CS
{
public class AlarmZone : XYDataSeries
{
#region "constructor"
public AlarmZone()
{
this.LayoutUpdated += new EventHandler(AlarmZone_LayoutUpdated);
this.ChartType = C1.WPF.C1Chart.ChartType.PolygonFilled;
this.XValues = new DoubleCollection();
this.Values = new DoubleCollection();
UpdateLegend();
Update();
}
#endregion
public static readonly DependencyProperty NearProperty = DependencyProperty.Register("Near", typeof(double?), typeof(AlarmZone), new FrameworkPropertyMetadata(null));
public static readonly DependencyProperty FarProperty = DependencyProperty.Register("Far", typeof(double?), typeof(AlarmZone), new FrameworkPropertyMetadata(null));
public static readonly DependencyProperty LowExtentProperty = DependencyProperty.Register("LowExtent", typeof(double?), typeof(AlarmZone), new FrameworkPropertyMetadata(null));
public static readonly DependencyProperty UpperExtentProperty = DependencyProperty.Register("UpperExtent", typeof(double?), typeof(AlarmZone), new FrameworkPropertyMetadata(null));
#region "members"
private C1Chart _chart;
public C1Chart Chart
{
get { return _chart; }
set { _chart = value; }
}
public double? Near
{
get { return (double?)this.GetValue(NearProperty); }
set
{
this.SetValue(NearProperty, value);
Update();
}
}
public double? Far
{
get { return (double?)this.GetValue(FarProperty); }
set
{
this.SetValue(FarProperty, value);
Update();
}
}
public double? LowExtent
{
get { return (double?)this.GetValue(LowExtentProperty); }
set
{
this.SetValue(LowExtentProperty, value);
Update();
}
}
public double? UpperExtent
{
get { return (double?)this.GetValue(UpperExtentProperty); }
set
{
this.SetValue(UpperExtentProperty, value);
Update();
}
}
private bool _showInLegend = false;
public bool ShowInLegend
{
get { return _showInLegend; }
set
{
_showInLegend = value;
UpdateLegend();
}
}
#endregion
#region "implementation"
public void Update()
{
double? _near = Near, _far = Far;
if (_near != null && _far != null)
{
this.XValues.Clear();
this.XValues.Add((double)_near);
this.XValues.Add((double)_far);
this.XValues.Add((double)_far);
this.XValues.Add((double)_near);
}
double? _lowExtent = LowExtent, _upperExtent = UpperExtent;
if (_lowExtent != null && _upperExtent != null)
{
this.Values.Clear();
this.Values.Add((double)_lowExtent);
this.Values.Add((double)_lowExtent);
this.Values.Add((double)_upperExtent);
this.Values.Add((double)_upperExtent);
}
}
public void UpdateLegend()
{
if (_showInLegend)
{
this.Display = SeriesDisplay.SkipNaN;
}
else
{
this.Display = SeriesDisplay.HideLegend;
}
}
private void chart_LayoutUpdated(object sender, EventArgs e)
{
if (this.Chart != null)
{
if (this.Chart.View != null)
{
if (Near == null)
{
Near = Chart.View.AxisX.ActualMin;
Update();
}
if (Far == null)
{
Far = Chart.View.AxisX.ActualMax;
Update();
}
if (LowExtent == null)
{
LowExtent = Chart.View.AxisY.ActualMin;
Update();
}
if (UpperExtent == null)
{
UpperExtent = Chart.View.AxisY.ActualMax;
Update();
}
}
}
}
// obtains the parent chart control so we can later get axis bounds
void AlarmZone_LayoutUpdated(object sender, EventArgs e)
{
if (this.Parent != null && this.Chart == null)
{
Canvas c = this.Parent as Canvas;
if (c != null)
{
Canvas cv = c.Parent as Canvas;
if (cv != null)
{
Border b = cv.Parent as Border;
if (b != null)
{
Grid g = b.Parent as Grid;
if (g != null)
{
C1Chart chart = g.Parent as C1Chart;
if (chart != null)
{
this.Chart = chart;
this.Chart.LayoutUpdated += chart_LayoutUpdated;
}
}
}
}
}
}
}
#endregion
}
}
...@@ -4,10 +4,12 @@ ...@@ -4,10 +4,12 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FLY.HeatingHelper.UI.UIModule.UC_SelectData" xmlns:local="clr-namespace:FLY.HeatingHelper.UI.UIModule.UC_SelectData"
xmlns:az="clr-namespace:Chart_AlarmZones_WPF_CS"
xmlns:c1c="clr-namespace:C1.WPF.C1Chart;assembly=C1.WPF.C1Chart.4.5.2"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors" xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"> d:DesignHeight="450" d:DesignWidth="800" Background="WhiteSmoke">
<UserControl.Resources> <UserControl.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
...@@ -27,22 +29,104 @@ ...@@ -27,22 +29,104 @@
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid Grid.Row="0"> <Grid Grid.Row="0">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/> <ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/> <ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical" Grid.Column="0" Margin="0,0,5,0">
<Controls:DateTimePicker Controls:TextBoxHelper.UseFloatingWatermark="True" Margin="0,0,0,1"> <Label Content="数据范围:" Margin="0,0,0,3"/>
<Controls:DateTimePicker Controls:TextBoxHelper.UseFloatingWatermark="True"
DisplayDate="{Binding Path=Dat.TotalDataFrom}"
Margin="0,0,0,1"
IsEnabled="False">
</Controls:DateTimePicker>
<Controls:DateTimePicker Controls:TextBoxHelper.UseFloatingWatermark="True"
DisplayDate="{Binding Path=Dat.TotalDataTo}"
Margin="0,1,0,0" IsEnabled="False">
</Controls:DateTimePicker>
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="1" Margin="0,0,5,0">
<Label Content="选定数据范围:" Margin="0,0,0,3"/>
<Controls:DateTimePicker Controls:TextBoxHelper.UseFloatingWatermark="True"
DisplayDate="{Binding Path=Dat.LoadDataFrom}"
Margin="0,0,0,1">
</Controls:DateTimePicker> </Controls:DateTimePicker>
<Controls:DateTimePicker Controls:TextBoxHelper.UseFloatingWatermark="True" Margin="0,1,0,0"> <Controls:DateTimePicker Controls:TextBoxHelper.UseFloatingWatermark="True"
DisplayDate="{Binding Path=Dat.LoadDataTo}"
Margin="0,1,0,0">
</Controls:DateTimePicker> </Controls:DateTimePicker>
</StackPanel> </StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="2" Margin="0,0,5,0">
<CheckBox Content="过滤加热重复项" Margin="0,5,0,5" IsChecked="{Binding Path=Dat.IsDataFilter}"/>
<Button Content="缺省数据范围" Style="{DynamicResource MahApps.Styles.Button.AccentedSquare}"
Command="{Binding DefaultLoadDataRange}"/>
<Button Content="加载数据" Style="{DynamicResource MahApps.Styles.Button.AccentedSquare}"
Command="{Binding ReloadData}"/>
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="3" Margin="0,0,5,0">
<Label Content="加载数据数量:"/>
<TextBox Margin="{StaticResource ControlMargin}"
Controls:TextBoxHelper.Watermark="Watermark"
Text="{Binding RecordCount}"
IsEnabled="False" />
</StackPanel>
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Grid.Column="0" Margin="0,0,5,0">
<Label Content="选择数据范围:"/>
<Controls:RangeSlider Minimum="0"
Maximum="{Binding RecordCount}"
LowerValue="{Binding Dat.AnalystIndexFrom}"
UpperValue="{Binding Dat.AnalystIndexTo}"
Style="{DynamicResource MahApps.Styles.RangeSlider.Win10}">
</Controls:RangeSlider>
</StackPanel>
<Button Content="前一项" Style="{DynamicResource MahApps.Styles.Button.AccentedSquare}"
Grid.Column="1" MinWidth="80" Margin="0,0,5,0"
Command="{Binding PreData}"/>
<Button Content="后一项" Style="{DynamicResource MahApps.Styles.Button.AccentedSquare}"
Grid.Column="2" MinWidth="80" Margin="0,0,5,0"
Command="{Binding NextData}"/>
<Button Content="缺省项" Style="{DynamicResource MahApps.Styles.Button.AccentedSquare}"
Grid.Column="3" MinWidth="80"
Command="{Binding DefaultAnalystData}"/>
</Grid> </Grid>
<Border Grid.Row="2" Margin="2,5,2,2">
<c1c:C1Chart ChartType="Line" Margin="5,0,0,0">
<c1c:C1Chart.Data>
<c1c:ChartData>
<az:AlarmZone Near="{Binding Dat.AnalystIndexFrom}" Far="{Binding Dat.AnalystIndexTo}"/>
<c1c:DataSeries ValuesSource="{Binding DS_thick}" AxisY="ay0" Label="厚度"/>
</c1c:ChartData>
</c1c:C1Chart.Data>
<c1c:C1Chart.View>
<c1c:ChartView>
<c1c:ChartView.AxisY>
<c1c:Axis Visible="False"/>
</c1c:ChartView.AxisY>
<c1c:Axis Name="ay0" AxisType="Y" Title="厚度" Position="Near"/>
</c1c:ChartView>
</c1c:C1Chart.View>
</c1c:C1Chart>
</Border>
</Grid> </Grid>
</UserControl> </UserControl>
using System; using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace FLY.HeatingHelper.UI.UIModule.UC_SelectData namespace FLY.HeatingHelper.UI.UIModule.UC_SelectData
{ {
class ViewModel_UC_SelectData class ViewModel_UC_SelectData : INotifyPropertyChanged
{ {
public ViewModel_UC_SelectData(IThickHeatData dat)
{
Dat = dat;
DefaultLoadDataRange = new RelayCommand(Command_DefaultLoadDataRange);
ReloadData = new RelayCommand(Command_ReloadData);
PreData = new RelayCommand(Command_PreData);
NextData = new RelayCommand(Command_NextData);
DefaultAnalystData = new RelayCommand(Command_DefaultAnalystData);
}
#region UI界面
IThickHeatData Dat { get; set; }
public int RecordCount
{
get
{
if (Dat is null) return 0;
return Dat.Dat_Times.Count();
}
}
public double[] DS_thick { get; set; }
#endregion
#region UI界面按钮功能(Command)
public RelayCommand DefaultLoadDataRange { get; internal set; } = null;
private void Command_DefaultLoadDataRange()
{
Dat.SetLoadDaTaDefault();
}
public RelayCommand ReloadData { get; internal set; } = null;
private void Command_ReloadData()
{
if (Dat is null) return;
Dat.LoadDataFromDB(1);
Dat.ResetCluster();
Dat.ClusterOnThickMean();
}
public RelayCommand PreData { get; internal set; } = null;
private void Command_PreData()
{
}
public RelayCommand NextData { get; internal set; } = null;
private void Command_NextData()
{
}
public RelayCommand DefaultAnalystData { get; internal set; } = null;
private void Command_DefaultAnalystData()
{
Dat.SetDefaultAnalystIndexs();
}
#endregion
public event PropertyChangedEventHandler PropertyChanged;
} }
} }
...@@ -124,6 +124,29 @@ namespace FLY.HeatingHelper ...@@ -124,6 +124,29 @@ namespace FLY.HeatingHelper
Tuple<int, double, double> SearchMaxSimilarity(int idxL, int idxB, double searchRange, bool SearchRotAngle); Tuple<int, double, double> SearchMaxSimilarity(int idxL, int idxB, double searchRange, bool SearchRotAngle);
#endregion #endregion
#region 数据处理-数据分类接口
/// <summary>
/// 初始化聚类数据,类清空。
/// </summary>
void ResetCluster();
/// <summary>
/// 依据厚度均值进行聚类
/// </summary>
void ClusterOnThickMean();
/// <summary>
/// 选择用于分析的数据项范围
/// </summary>
int AnalystIndexFrom { get; set; }
int AnalystIndexTo { get; set; }
/// <summary>
/// 设定缺省的分析数据范围
/// </summary>
/// <returns></returns>
int SetDefaultAnalystIndexs();
#endregion
#region 数据库数据变化后自动运行 #region 数据库数据变化后自动运行
List<ThickHeatEvent> AutoDetectEvents { get; } List<ThickHeatEvent> AutoDetectEvents { get; }
......
...@@ -301,7 +301,7 @@ namespace FLY.HeatingHelper ...@@ -301,7 +301,7 @@ namespace FLY.HeatingHelper
/// <summary> /// <summary>
/// 初始化聚类数据,类清空。 /// 初始化聚类数据,类清空。
/// </summary> /// </summary>
private void ResetCluster() public void ResetCluster()
{ {
_last_cluster_idx = -1; _last_cluster_idx = -1;
thickClasses.Clear(); thickClasses.Clear();
...@@ -310,7 +310,7 @@ namespace FLY.HeatingHelper ...@@ -310,7 +310,7 @@ namespace FLY.HeatingHelper
/// <summary> /// <summary>
/// 依据厚度均值进行聚类 /// 依据厚度均值进行聚类
/// </summary> /// </summary>
private void ClusterOnThickMean() public void ClusterOnThickMean()
{ {
int i; int i;
...@@ -404,6 +404,23 @@ namespace FLY.HeatingHelper ...@@ -404,6 +404,23 @@ namespace FLY.HeatingHelper
} }
} }
public int AnalystIndexFrom { get; set; }
public int AnalystIndexTo { get; set; }
/// <summary>
/// 设定缺省的分析数据范围
/// </summary>
/// <returns></returns>
public int SetDefaultAnalystIndexs()
{
int f = 0, t = 0;
int cls = CalculateFromToByClass(-99, ref f, ref t);
if (cls >= 0)
{
AnalystIndexFrom = _select_frame_idx1 = thickClasses[cls].from;
AnalystIndexTo = _select_frame_idx2 = thickClasses[cls].to;
}
return cls;
}
#endregion #endregion
public int _select_frame_idx1; public int _select_frame_idx1;
public int _select_frame_idx2; public int _select_frame_idx2;
......
...@@ -232,6 +232,7 @@ namespace FLY.HeatingHelper ...@@ -232,6 +232,7 @@ namespace FLY.HeatingHelper
{ {
return FetchNewData(); return FetchNewData();
} }
} }
catch catch
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment