Commit 3ed9d4ca authored by 潘栩锋's avatar 潘栩锋 🚴

1. 称重的流量图,可以选择看某个流量

2.IBC,与称重的图,当不是最新,10秒后会自动按 最新
parent e181b1fe
......@@ -162,6 +162,7 @@
<Compile Include="UIModule\Window_K123.xaml.cs">
<DependentUpon>Window_K123.xaml</DependentUpon>
</Compile>
<Compile Include="UnitTests\UnitTests_BufferWindow.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
......
......@@ -17,7 +17,10 @@
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Border Margin="5" CornerRadius="5" Background="#FF50B7F9" >
<Grid>
<Grid x:Name="grid_modelview" d:DataContext="{StaticResource unittests_flowgraphmv}"/>
<Grid x:Name="grid_bufferwindow" d:DataContext="{StaticResource unittests_bufferwindow}"/>
<Border Margin="5" CornerRadius="5" Background="#FF50B7F9" DataContext="{Binding ElementName=grid_modelview,Path=DataContext}">
<Border.Effect>
<DropShadowEffect BlurRadius="15" Direction="-90" RenderingBias="Quality" Opacity=".2" ShadowDepth="1"/>
</Border.Effect>
......@@ -42,7 +45,7 @@
<Run Text="{Binding BeginTime,StringFormat={}{0:HH:mm:ss}}"/><Run Text="-"/><Run Text="{Binding EndTime,StringFormat={}{0:HH:mm:ss}}"/>
</TextBlock>
</StackPanel>
<StackPanel x:Name="stackpanel_window" Orientation="Horizontal" Margin="5">
<StackPanel DataContext="{Binding ElementName=grid_bufferwindow,Path=DataContext}" Orientation="Horizontal" Margin="5">
<StackPanel.Resources>
<Style TargetType="Button" BasedOn="{StaticResource ButtonStyle_empty}">
<Setter Property="Width" Value="30"/>
......@@ -52,22 +55,75 @@
</Style>
</StackPanel.Resources>
<Button Click="button_pre_Click" >
<Path Data="{StaticResource Geometry_arrow-left}" Fill="{StaticResource Color_theme_static}" Stretch="Uniform"/>
<Path Data="{StaticResource Geometry_arrow-left}" Stretch="Uniform">
<Path.Style>
<Style TargetType="Path">
<Setter Property="Fill" Value="{StaticResource Color_theme_static}"/>
<Style.Triggers>
<!--已经是第1页-->
<DataTrigger Binding="{Binding IsFirstPage}" Value="True">
<Setter Property="Fill" Value="{StaticResource Color_theme_noact}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Path.Style>
</Path>
</Button>
<StackPanel Orientation="Horizontal" Margin="5">
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="第" Foreground="White"/>
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" Text="{Binding CurrentPage}" Foreground="White"/>
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="页" Foreground="White"/>
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm_interval}" Text="/" Foreground="White"/>
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="共" Foreground="White"/>
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" Text="{Binding TotalPages}" Foreground="White"/>
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="页" Foreground="White"/>
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="第" Foreground="#FF5B5B5B" />
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" Text="{Binding CurrentPage}" />
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="页" Foreground="#FF5B5B5B"/>
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm_interval}" Text="/" Foreground="#FF5B5B5B"/>
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="共" Foreground="#FF5B5B5B"/>
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" Text="{Binding TotalPages}" />
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="页" Foreground="#FF5B5B5B"/>
</StackPanel>
<Button Click="button_next_Click" >
<Path Data="{StaticResource Geometry_arrow-right}" Fill="{StaticResource Color_theme_static}" Stretch="Uniform"/>
<Path Data="{StaticResource Geometry_arrow-right}" Stretch="Uniform">
<Path.Style>
<Style TargetType="Path">
<Setter Property="Fill" Value="{StaticResource Color_theme_static}"/>
<Style.Triggers>
<!--已经是最后页-->
<DataTrigger Binding="{Binding IsLastPage}" Value="True">
<Setter Property="Fill" Value="{StaticResource Color_theme_noact}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Path.Style>
</Path>
</Button>
<Button Click="button_newest_Click" Height="35" Width="40">
<Path Data="{StaticResource Geometry_arrow-collapse-right}" Fill="{StaticResource Color_theme_static}" Stretch="Uniform"/>
<Grid>
<Path Data="{StaticResource Geometry_arrow-collapse-right}" Stretch="Uniform">
<Path.Style>
<Style TargetType="Path">
<Setter Property="Fill" Value="{StaticResource Color_theme_static}"/>
<Style.Triggers>
<!--已经是最新-->
<DataTrigger Binding="{Binding IsKeepNewest}" Value="True">
<Setter Property="Fill" Value="{StaticResource Color_theme_noact}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Path.Style>
</Path>
<!--当不是最新, 弹出 自动按[最新] 倒计时-->
<Grid Width="20" Height="20" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="0,0,-5,-5" >
<Grid.Style>
<Style TargetType="Grid">
<Style.Triggers>
<DataTrigger Binding="{Binding IsKeepNewest}" Value="True">
<Setter Property="Visibility" Value="Hidden"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<Ellipse Fill="#FF932020" />
<TextBlock Text="{Binding AutoKeepNewestTimeRemaining}" DataContext="{Binding ElementName=grid_modelview,Path=DataContext}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"/>
</Grid>
</Grid>
</Button>
</StackPanel>
</StackPanel>
......@@ -116,4 +172,5 @@
</lvc:CartesianChart>
</Grid>
</Border>
</Grid>
</UserControl>
......@@ -18,6 +18,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
namespace FLY.IBC.UI.Client.UIModule
{
......@@ -36,10 +37,8 @@ namespace FLY.IBC.UI.Client.UIModule
iBCCtrlGraphModelView = new IBCCtrlGraphModelView();
iBCCtrlGraphModelView.InitData();
this.DataContext = iBCCtrlGraphModelView;
stackpanel_window.DataContext = iBCCtrlGraphModelView.bufferWindow;
grid_modelview.DataContext = iBCCtrlGraphModelView;
grid_bufferwindow.DataContext = iBCCtrlGraphModelView.bufferWindow;
}
private void button_info_Click(object sender, RoutedEventArgs e)
{
......@@ -70,14 +69,31 @@ namespace FLY.IBC.UI.Client.UIModule
}
public class IBCCtrlGraphModelView : INotifyPropertyChanged
{
/// <summary>
/// 当前现在不是最新,而且没有移动动作,20秒自动按 Newest()
/// </summary>
DispatcherTimer timer;
public event PropertyChangedEventHandler PropertyChanged;
FLY.IBC.Client.IBCSystemClient iBCSystemClient;
public FLY.OBJComponents.Client.BufferWindow<FlyData_IBCCtrl> bufferWindow;
public IBCCtrlGraphParams graphParams;
/// <summary>
/// 画面只显示200个数据, 就算设置画面设置显示1000个数,也会整合为200个数据
/// </summary>
const int ValuesCap = 200;
/// <summary>
/// 自动按保持最新值,总时间
/// </summary>
const int AutoKeepNewestTimeCounter = 10;
#region property
/// <summary>
///自动按保持最新值,剩余时间
/// </summary>
public int AutoKeepNewestTimeRemaining { get; set; }
/// <summary>
/// 曲线, 是有 bufferWindow.Record 生成的
/// Values 最大数量只有 ValuesCap
......@@ -230,8 +246,38 @@ namespace FLY.IBC.UI.Client.UIModule
Update_d_y();
}
};
}
//当不是最新数据时,10秒内无操作,自动按 [最新]
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += Timer_Tick;
bufferWindow.PropertyChanged += BufferWindow_PropertyChanged;
}
private void Timer_Tick(object sender, EventArgs e)
{
AutoKeepNewestTimeRemaining--;
if (AutoKeepNewestTimeRemaining <= 0)
{
AutoKeepNewestTimeRemaining = AutoKeepNewestTimeCounter;
bufferWindow.MoveNewest();
}
}
private void BufferWindow_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "IsKeepNewest")
{
if (!bufferWindow.IsKeepNewest)
{
//当前不是最新,开始倒计时
AutoKeepNewestTimeRemaining = AutoKeepNewestTimeCounter;
timer.Start();
}
else
{
timer.Stop();
}
}
}
void Update_filmwidth_y()
{
......
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
namespace FLY.IBC.UI.Client.UnitTests
{
public class UnitTests_BufferWindow : INotifyPropertyChanged
{
public bool IsFirstPage { get; set; }
public bool IsLastPage { get; set; }
public bool IsKeepNewest { get; set; }
public int CurrentPage { get; set; }
public int TotalPages { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
}
public class UnitTests_FlowGraphModelView : INotifyPropertyChanged
{
/// <summary>
///自动按保持最新值,剩余时间
/// </summary>
public int AutoKeepNewestTimeRemaining { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
}
}
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:FLY.IBC.UI.Client.UnitTests"
xmlns:ibc_common="clr-namespace:FLY.IBC.Common;assembly=FLY.IBC">
<ibc_common:IBCData x:Key="unitests_ibc"
IsIBCAuto = "True"
......@@ -18,5 +19,14 @@
L="3002"
BubbleCorrA="23"
/>
<local:UnitTests_BufferWindow x:Key="unittests_bufferwindow"
IsFirstPage ="False"
IsLastPage="True"
IsKeepNewest="False"
CurrentPage="10"
TotalPages="10"
/>
<local:UnitTests_FlowGraphModelView x:Key="unittests_flowgraphmv"
AutoKeepNewestTimeRemaining ="10"
/>
</ResourceDictionary>
\ No newline at end of file
......@@ -132,14 +132,12 @@
<Compile Include="UIModule\Window_GraphSet.xaml.cs">
<DependentUpon>Window_GraphSet.xaml</DependentUpon>
</Compile>
<Compile Include="UnitTests\UnitTests_BufferWindow.cs" />
<Compile Include="UnitTests\WeighterCsService.cs" />
<Compile Include="WeighterColorDB.cs" />
<Compile Include="Window_Frequency.xaml.cs">
<DependentUpon>Window_Frequency.xaml</DependentUpon>
</Compile>
<Compile Include="Window_GraphSet.xaml.cs">
<DependentUpon>Window_GraphSet.xaml</DependentUpon>
</Compile>
<Compile Include="Window_Ingredient.xaml.cs">
<DependentUpon>Window_Ingredient.xaml</DependentUpon>
</Compile>
......@@ -253,10 +251,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Window_GraphSet.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Window_Ingredient.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......
......@@ -22,7 +22,10 @@
<conv:OpacityConverter x:Key="OpacityConverter"></conv:OpacityConverter>
</ResourceDictionary>
</UserControl.Resources>
<Border CornerRadius="5" Background="White">
<Grid>
<Grid x:Name="grid_modelview" d:DataContext="{StaticResource unittests_flowgraphmv}"/>
<Grid x:Name="grid_bufferwindow" d:DataContext="{StaticResource unittests_bufferwindow}"/>
<Border CornerRadius="5" Background="White" DataContext="{Binding ElementName=grid_modelview,Path=DataContext}">
<Border.Effect>
<DropShadowEffect BlurRadius="15" Direction="-90" RenderingBias="Quality" Opacity=".2" ShadowDepth="1"/>
</Border.Effect>
......@@ -54,7 +57,7 @@
<Run Text="{Binding BeginTime,StringFormat={}{0:HH:mm:ss}}"/><Run Text="-"/><Run Text="{Binding EndTime,StringFormat={}{0:HH:mm:ss}}"/>
</TextBlock>
</StackPanel>
<StackPanel x:Name="stackpanel_window" Orientation="Horizontal" Margin="5">
<StackPanel DataContext="{Binding ElementName=grid_bufferwindow,Path=DataContext}" Orientation="Horizontal" Margin="5">
<StackPanel.Resources>
<Style TargetType="Button" BasedOn="{StaticResource ButtonStyle_empty}">
<Setter Property="Width" Value="30"/>
......@@ -103,6 +106,7 @@
</Path>
</Button>
<Button Click="button_newest_Click" Height="35" Width="40">
<Grid>
<Path Data="{StaticResource Geometry_arrow-collapse-right}" Stretch="Uniform">
<Path.Style>
<Style TargetType="Path">
......@@ -116,6 +120,22 @@
</Style>
</Path.Style>
</Path>
<!--当不是最新, 弹出 自动按[最新] 倒计时-->
<Grid Width="20" Height="20" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="0,0,-5,-5" >
<Grid.Style>
<Style TargetType="Grid">
<Style.Triggers>
<DataTrigger Binding="{Binding IsKeepNewest}" Value="True">
<Setter Property="Visibility" Value="Hidden"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<Ellipse Fill="#FFFF3535" />
<TextBlock Text="{Binding AutoKeepNewestTimeRemaining}" DataContext="{Binding ElementName=grid_modelview,Path=DataContext}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"/>
</Grid>
</Grid>
</Button>
</StackPanel>
</StackPanel>
......@@ -129,7 +149,7 @@
</Grid>
<Grid Grid.Row="1" Name="Canvas" Margin="-4,0,0,0">
<Grid Grid.Row="1" Margin="-4,0,0,0">
<lvc:CartesianChart Series="{Binding Series}" Hoverable="False" DataTooltip="{x:Null}" >
<lvc:CartesianChart.Resources>
<Style x:Key="CleanSeparator" TargetType="lvc:Separator">
......@@ -139,8 +159,8 @@
<lvc:CartesianChart.AxisX>
<lvc:Axis
IsMerged="True"
FontSize="14"
Foreground="White"
FontSize="16"
Foreground="Black"
IsEnabled="True" ShowLabels="True" LabelFormatter="{Binding DateTimeFormatter}" >
<lvc:Axis.Separator>
<lvc:Separator Style="{StaticResource CleanSeparator}"></lvc:Separator>
......@@ -150,8 +170,8 @@
<lvc:CartesianChart.AxisY>
<lvc:Axis
IsMerged="True"
FontSize="14"
Foreground="White"
FontSize="16"
Foreground="Black"
MaxValue="{Binding MaxValue}"
MinValue="{Binding MinValue}"
LabelFormatter="{Binding YFormatter}"
......@@ -165,7 +185,60 @@
</Grid>
<StackPanel Orientation="Vertical" Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="60,-30,0,0">
<StackPanel.Resources>
<Style TargetType="Button" BasedOn="{StaticResource ButtonStyle_empty}">
<Setter Property="Margin" Value="2"/>
<Setter Property="Height" Value="35"/>
<Setter Property="Width" Value="40"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
</Style>
</StackPanel.Resources>
<Button Click="button_selectall_Click" >
<Grid >
<Border Background="{StaticResource Color_theme_static}" >
<TextBlock Text="All" FontSize="25" Foreground="White" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Border>
</Grid>
</Button>
<ItemsControl ItemsSource="{Binding Items}" Panel.ZIndex="2">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button Click="button_select_Click" Tag="{Binding .}" >
<Border x:Name="mainBorder" MinWidth="40" Height="35" Background="{Binding Fill}" BorderThickness="1" BorderBrush="White">
<TextBlock x:Name="tb" Text="{Binding Title}" FontSize="40" Foreground="White" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Border>
</Button>
<StackPanel Orientation="Horizontal" x:Name="sp_value" >
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Value,StringFormat={}{0:F1}}" FontSize="25" Foreground="Black" VerticalAlignment="Bottom" />
<TextBlock Text="kg/h" FontSize="15" Foreground="Black" VerticalAlignment="Bottom"/>
</StackPanel>
</StackPanel>
</StackPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Visibility}" Value="Hidden">
<Setter TargetName="mainBorder" Property="Background" Value="White"/>
<Setter TargetName="tb" Property="Foreground" Value="{Binding Fill}"/>
<Setter TargetName="mainBorder" Property="BorderBrush" Value="{StaticResource Color_theme_static}"/>
<Setter TargetName="sp_value" Property="Visibility" Value="Hidden"/>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</Grid>
</Border>
</Grid>
</UserControl>
......@@ -20,6 +20,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
namespace FLY.Weight.UI.Client.UIModule
{
......@@ -37,14 +38,18 @@ namespace FLY.Weight.UI.Client.UIModule
{
flowGraphModelView = new FlowGraphModelView();
flowGraphModelView.InitData();
this.DataContext = flowGraphModelView;
stackpanel_window.DataContext = flowGraphModelView.bufferWindow;
grid_modelview.DataContext = flowGraphModelView;
grid_bufferwindow.DataContext = flowGraphModelView.bufferWindow;
}
/// <summary>
/// 测试界面用
/// </summary>
public void Debug()
{
flowGraphModelView = new FlowGraphModelView();
flowGraphModelView.InitData_Debug();
this.DataContext = flowGraphModelView;
grid_modelview.DataContext = flowGraphModelView;
//TODO 有问题
//itemsControl.ItemsSource = flowGraphModelView.Series;
//stackpanel_window.DataContext = flowGraphModelView.bufferWindow;
......@@ -105,17 +110,44 @@ namespace FLY.Weight.UI.Client.UIModule
}
}
private void button_select_Click(object sender, RoutedEventArgs e)
{
flowGraphModelView.SelectABC(((Button)sender).Tag as FlowGraphModelView_Item);
}
private void button_selectall_Click(object sender, RoutedEventArgs e)
{
flowGraphModelView.SelectAll();
}
}
public class FlowGraphModelView : INotifyPropertyChanged
{
/// <summary>
/// 当前现在不是最新,而且没有移动动作,20秒自动按 Newest()
/// </summary>
DispatcherTimer timer;
public event PropertyChangedEventHandler PropertyChanged;
WeightSystemClient weightSystemClient;
public BufferWindow<FlyData_Flow> bufferWindow;
public FlowGraphParams graphParams;
/// <summary>
/// 画面只显示200个数据, 就算设置画面设置显示1000个数,也会整合为200个数据
/// </summary>
const int ValuesCap = 200;
/// <summary>
/// 自动按保持最新值,总时间
/// </summary>
const int AutoKeepNewestTimeCounter = 10;
#region property
/// <summary>
///自动按保持最新值,剩余时间
/// </summary>
public int AutoKeepNewestTimeRemaining { get; set; }
/// <summary>
/// 曲线, 是由 bufferWindow.Record 生成的
/// Values 最大数量只有 ValuesCap
......@@ -167,6 +199,8 @@ namespace FLY.Weight.UI.Client.UIModule
/// 曲线
/// </summary>
public SeriesCollection Series { get; set; } = new SeriesCollection();
public ObservableCollection<FlowGraphModelView_Item> Items { get; } = new ObservableCollection<FlowGraphModelView_Item>();
#endregion
public FlowGraphModelView()
......@@ -234,6 +268,39 @@ namespace FLY.Weight.UI.Client.UIModule
};
//当不是最新数据时,10秒内无操作,自动按 [最新]
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += Timer_Tick;
bufferWindow.PropertyChanged += BufferWindow_PropertyChanged;
}
private void Timer_Tick(object sender, EventArgs e)
{
AutoKeepNewestTimeRemaining--;
if (AutoKeepNewestTimeRemaining <= 0)
{
AutoKeepNewestTimeRemaining = AutoKeepNewestTimeCounter;
bufferWindow.MoveNewest();
}
}
private void BufferWindow_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "IsKeepNewest")
{
if (!bufferWindow.IsKeepNewest)
{
//当前不是最新,开始倒计时
AutoKeepNewestTimeRemaining = AutoKeepNewestTimeCounter;
timer.Start();
}
else
{
timer.Stop();
}
}
}
class GetMapperOfFlyData_Flow
......@@ -270,6 +337,8 @@ namespace FLY.Weight.UI.Client.UIModule
series.Configuration = new GetMapperOfFlyData_Flow(i).GetCartesianMapper();
Series.Add(series);
}
}
else if (Series.Count > weightSystemClient.Items.Count)
{
......@@ -279,6 +348,22 @@ namespace FLY.Weight.UI.Client.UIModule
Series.RemoveAt(Series.Count - 1);
}
}
if (Items.Count != Series.Count)
{
Items.Clear();
foreach (StackedAreaSeries series in Series)
{
FlowGraphModelView_Item item = new FlowGraphModelView_Item
{
Title = series.Title,
Fill = series.Fill,
Visibility = Visibility.Visible
};
series.SetBinding(StackedAreaSeries.VisibilityProperty, new Binding("Visibility") { Source = item });
Items.Add(item);
}
}
}
void ToValues()
{
......@@ -300,6 +385,8 @@ namespace FLY.Weight.UI.Client.UIModule
{
BeginTime = Values.First().Time;
EndTime = Values.Last().Time;
UpdateAxisYTarget();
}
else
{
......@@ -375,8 +462,6 @@ namespace FLY.Weight.UI.Client.UIModule
EndTime = DateTime.MinValue;
}
AxisYTarget = flows.Sum();
for (int i = 0; i < flows.Count(); i++)
{
......@@ -398,22 +483,88 @@ namespace FLY.Weight.UI.Client.UIModule
MaxValue = AxisYTarget + graphParams.AxisYRange;
MinValue = AxisYTarget - graphParams.AxisYRange;
}
UpdateAxisYTarget();
}
void UpdateAxisYTarget()
{
FlyData_Flow flows = Values.Last();
double target = 0;
for (int i = 0; i < flows.Items.Count(); i++)
{
if (Items[i].Visibility == Visibility.Visible)
target += flows.Items[i].Flow;
Items[i].Value = flows.Items[i].Flow;
}
AxisYTarget = (int)target;
}
public void Newest()
{
AutoKeepNewestTimeRemaining = AutoKeepNewestTimeCounter;
bufferWindow.MoveNewest();
}
public void Next()
{
AutoKeepNewestTimeRemaining = AutoKeepNewestTimeCounter;
bufferWindow.MoveNextPage();
}
public void Pre()
{
AutoKeepNewestTimeRemaining = AutoKeepNewestTimeCounter;
bufferWindow.MovePrePage();
}
public void SelectAll()
{
foreach (FlowGraphModelView_Item i in Items)
{
i.Visibility = Visibility.Visible;
}
UpdateAxisYTarget();
}
public void SelectABC(FlowGraphModelView_Item item)
{
foreach (FlowGraphModelView_Item i in Items)
{
if (i != item )
{
i.Visibility = Visibility.Hidden;
}
else
{
i.Visibility = Visibility.Visible;
}
}
UpdateAxisYTarget();
}
}
public class FlowGraphModelView_Item : INotifyPropertyChanged
{
public string Title { get; set; }
/// <summary>
/// 颜色
/// </summary>
public Brush Fill { get; set; }
/// <summary>
/// 显示
/// </summary>
public Visibility Visibility { get; set; }
/// <summary>
/// 值
/// </summary>
public double Value { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
}
public class FlowGraphParams : INotifyPropertyChanged, Misc.ISaveToXml
{
public event PropertyChangedEventHandler PropertyChanged;
......
......@@ -29,7 +29,11 @@
<sys:Double x:Key="FontSize_unit">12</sys:Double>
<sys:Double x:Key="FontSize_context_min">32</sys:Double>
<sys:Double x:Key="FontSize_context_max">48</sys:Double>
<sys:Double x:Key="MaxHeight_viewer1">130</sys:Double>
<Style TargetType="Viewbox" x:Key="ViewerStyle">
<Setter Property="MaxHeight" Value="130"/>
<Setter Property="MaxWidth" Value="240"/>
</Style>
</ResourceDictionary>
</Page.Resources>
<Viewbox Stretch="Uniform" VerticalAlignment="Top" HorizontalAlignment="Left">
......@@ -41,7 +45,7 @@
<Border Margin="5" CornerRadius="5" Background="{StaticResource Color_theme_background}">
<StackPanel Orientation="Horizontal">
<Viewbox Margin="15,5" MaxHeight="{StaticResource MaxHeight_viewer1}">
<Viewbox Margin="15,5">
<Button Style="{StaticResource ButtonStyle_empty}" Background="Transparent" Click="button_ratio_Click" Margin="30,5">
<StackPanel Orientation="Horizontal">
......@@ -70,7 +74,7 @@
</StackPanel>
</Button>
</Viewbox>
<Viewbox Margin="15,5" MaxHeight="90">
<Viewbox Margin="15,5" MaxHeight="90" Style="{StaticResource ViewerStyle}">
<StackPanel Orientation="Horizontal" >
<control:PieChart Width="60" Height="60" Margin="10"
ItemValueBinding="CumulativeProduction" ItemColorBinding="Color"
......@@ -109,7 +113,7 @@
</Grid>
</StackPanel>
</Viewbox>
<Viewbox Margin="15,5" MaxHeight="{StaticResource MaxHeight_viewer1}">
<Viewbox Margin="15,5" Style="{StaticResource ViewerStyle}">
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
......@@ -162,7 +166,7 @@
</Grid>
</Viewbox>
<Viewbox Margin="15,5" MaxHeight="{StaticResource MaxHeight_viewer1}">
<Viewbox Margin="15,5" Style="{StaticResource ViewerStyle}">
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
......
......@@ -55,7 +55,7 @@
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" Text="±" />
<TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding AxisYRange}"/>
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" Text="um" />
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" Text="kg/h" />
</StackPanel>
</StackPanel>
</StackPanel>
......
using FLY.Weight.UI.Client.UIModule;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Media;
namespace FLY.Weight.UI.Client.UnitTests
{
public class UnitTests_BufferWindow : INotifyPropertyChanged
{
public bool IsFirstPage { get; set; }
public bool IsLastPage { get; set; }
public bool IsKeepNewest { get; set; }
public int CurrentPage { get; set; }
public int TotalPages { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
}
public class UnitTests_FlowGraphModelView : INotifyPropertyChanged
{
/// <summary>
///自动按保持最新值,剩余时间
/// </summary>
public int AutoKeepNewestTimeRemaining { get; set; } = 10;
public List<FlowGraphModelView_Item> Items { get; set; }
public UnitTests_FlowGraphModelView()
{
Items = new List<FlowGraphModelView_Item>();
Items.Add(new FlowGraphModelView_Item() { Title = "A", Value=103.1, Visibility = Visibility.Hidden });
Items.Add(new FlowGraphModelView_Item() { Title = "B", Value = 10, Visibility = Visibility.Visible });
Items.Add(new FlowGraphModelView_Item() { Title = "C", Value = 23, Visibility = Visibility.Hidden });
Items.Add(new FlowGraphModelView_Item() { Title = "D", Value = 46.7, Visibility = Visibility.Hidden });
Items.Add(new FlowGraphModelView_Item() { Title = "E", Value = 80, Visibility = Visibility.Hidden });
foreach (FlowGraphModelView_Item s in Items)
{
s.Fill = WeighterColorDB.GetSelf(s.Title);
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
}
......@@ -6,5 +6,13 @@
</ResourceDictionary.MergedDictionaries>
<local:UnitTests_Weights x:Key="unittests_weighters" />
<local:UnitTests_BufferWindow x:Key="unittests_bufferwindow"
IsFirstPage ="False"
IsLastPage="True"
IsKeepNewest="False"
CurrentPage="10"
TotalPages="10"
/>
<local:UnitTests_FlowGraphModelView x:Key="unittests_flowgraphmv"/>
</ResourceDictionary>
\ No newline at end of file
<flyctrllib:WindowBigClose x:Class="FLY.Weight.UI.Client.Window_GraphSet"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:flyctrllib="clr-namespace:FLY.ControlLibrary;assembly=FLY.ControlLibrary"
xmlns:local="clr-namespace:FLY.Weight.UI.Client"
mc:Ignorable="d"
Title="Window_GraphSet" WindowStartupLocation="CenterScreen" Height="410.994" Width="405.484" >
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.Weight.UI.Client;component/Themes/LightSkin.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Weight.UI.Client;component/Themes/Dictionary_MainSingleWeight.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<StackPanel Orientation="Vertical" Margin="5,20">
<StackPanel Orientation="Vertical" Margin="5">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeader}" Text="流量数据" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="44" />
</StackPanel>
<StackPanel x:Name="stackpanel_sys" Orientation="Horizontal" >
<StackPanel Orientation="Vertical" Margin="5">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="时间间隔" />
<StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding FlowInterval}"/>
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" Text="s" />
</StackPanel>
</StackPanel>
<StackPanel Orientation="Vertical" Margin="5">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="总数量" />
<StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding FlowListSize}"/>
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" Text="个" />
</StackPanel>
</StackPanel>
</StackPanel>
<StackPanel x:Name="stackpanel_show" Orientation="Horizontal">
<StackPanel Orientation="Vertical" Margin="5">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="显示个数" />
<StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding XRange}"/>
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" Text="个" />
</StackPanel>
</StackPanel>
</StackPanel>
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
</Grid>
<Button Style="{StaticResource ButtonStyle2}" Content="确定" Width="auto" Margin="5" Click="button_ok_Click" />
</StackPanel>
</flyctrllib:WindowBigClose>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
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.Shapes;
namespace FLY.Weight.UI.Client
{
/// <summary>
/// Window_GraphSet.xaml 的交互逻辑
/// </summary>
public partial class Window_GraphSet : FLY.ControlLibrary.WindowBigClose, INotifyPropertyChanged
{
private int flowinterval = 2;
/// <summary>
/// 流量记录周期,单位min
/// </summary>
public int FlowInterval
{
get
{
return flowinterval;
}
set
{
if (value < 1)
value = 1;
if (flowinterval != value)
{
flowinterval = value;
NotifyPropertyChanged("FlowInterval");
}
}
}
private int flowlistsize = 400;
/// <summary>
/// 流量列表长度,单位个
/// </summary>
public int FlowListSize
{
get
{
return flowlistsize;
}
set
{
if (flowlistsize != value)
{
flowlistsize = value;
NotifyPropertyChanged("FlowListSize");
}
}
}
private int flowsaverows = 200;
/// <summary>
/// 流量保存周期,单位个
/// </summary>
public int FlowSaveRows
{
get
{
return flowsaverows;
}
set
{
if (flowsaverows != value)
{
flowsaverows = value;
NotifyPropertyChanged("FlowSaveRows");
}
}
}
private int xrange;
public int XRange
{
get { return xrange; }
set
{
if (xrange != value)
{
xrange = value;
NotifyPropertyChanged("XRange");
}
}
}
public Window_GraphSet()
{
InitializeComponent();
this.DataContext = this;
}
private void button_ok_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = true;
this.Close();
}
protected void NotifyPropertyChanged(string propertyname)
{
if (PropertyChanged != null)
{
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyname));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
}
......@@ -43,9 +43,10 @@ namespace WpfApplication1
//FLY.IBC.UI.Client.UIModule.Page_Main p = new FLY.IBC.UI.Client.UIModule.Page_Main();
//FLY.Winder.UI.Client.UIModule.Page_Main p = new FLY.Winder.UI.Client.UIModule.Page_Main();
FLY.Weight.UI.Client.UIModule.Page_Main p = new FLY.Weight.UI.Client.UIModule.Page_Main();
//FLY.Weight.UI.Client.UIModule.Page_Main p = new FLY.Weight.UI.Client.UIModule.Page_Main();
FLY.Weight.UI.Client.UIModule.FlowGraph p = new FLY.Weight.UI.Client.UIModule.FlowGraph();
p.Init(0);
//FLY.Weight.UI.Client.UIModule.FlowGraph p= new FLY.Weight.UI.Client.UIModule.FlowGraph();
//graph.Init(0);
Frame f1 = new Frame();
f1.Content = p;
......
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