Commit 1568434a authored by 潘栩锋's avatar 潘栩锋 :bicyclist:

合并称重单组分

parents 5803b2ba 73e1b8c4
......@@ -128,6 +128,14 @@
<Project>{973f0eed-3181-4fb9-abd6-196a9e816b77}</Project>
<Name>FLY.HeatingHelper</Name>
</ProjectReference>
<ProjectReference Include="..\..\Project.FLY.Weight2\FLY.Weight2.UI.Client\FLY.Weight2.UI.Client.csproj">
<Project>{75e96277-7745-4680-90d7-0d9c34ceca06}</Project>
<Name>FLY.Weight2.UI.Client</Name>
</ProjectReference>
<ProjectReference Include="..\..\Project.FLY.Weight2\FLY.Weight2\FLY.Weight2.csproj">
<Project>{b47f09de-9a6e-421f-b7c0-2ea87cc09570}</Project>
<Name>FLY.Weight2</Name>
</ProjectReference>
<ProjectReference Include="..\..\Project.FLY.Weight\FLY.Weight.UI.Client\FLY.Weight.UI.Client.csproj">
<Project>{654515f2-caae-450b-a344-547321836e8f}</Project>
<Name>FLY.Weight.UI.Client</Name>
......
<Application x:Class="FLY.Weight2.UI.Client.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="GroupBox" />
</ResourceDictionary>
</Application.Resources>
</Application>
using System.Windows;
namespace FLY.Weight2.UI.Client
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
}
}
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:FLY.Weight2.UI.Client.Converter">
<local:RatioConverter x:Key="rconv" />
</ResourceDictionary>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;
namespace FLY.Weight2.UI.Client.Converter
{
public class OpacityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (Visibility)value == Visibility.Visible
? 1d
: .2d;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
namespace FLY.Weight2.UI.Client.Converter
{
public class RatioConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
UInt16 v = (UInt16)value;
string ratio_s = (string)parameter;
double ratio;
if (!double.TryParse(ratio_s, out ratio))
return (double)v;
else
return (double)v * ratio;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string s_v = (string)value;
double v;
if (!double.TryParse(s_v, out v))
return null;
string ratio_s = parameter as string;
double ratio;
if (!double.TryParse(ratio_s, out ratio))
return (UInt16) v;
else
return (UInt16)(v / ratio);
}
#endregion
}
}
using LiveCharts;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Data;
namespace FLY.Weight2.UI.Client.Converter
{
public class ReverseConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return ((SeriesCollection)value).Reverse();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<PropertyChanged />
</Weavers>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="PropertyChanged" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="InjectOnPropertyNameChanged" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the On_PropertyName_Changed feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="EventInvokerNames" type="xs:string">
<xs:annotation>
<xs:documentation>Used to change the name of the method that fires the notify event. This is a string that accepts multiple values in a comma separated form.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="CheckForEquality" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should be inserted. If false, equality checking will be disabled for the project.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="CheckForEqualityUsingBaseEquals" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should use the Equals method resolved from the base class.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UseStaticEqualsFromBase" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should use the static Equals method resolved from the base class.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
\ No newline at end of file
<Page x:Class="FLY.Weight2.UI.Client.PgFlowTable"
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.Weight2.UI.Client"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
mc:Ignorable="d"
d:DesignHeight="900" d:DesignWidth="960" Background="White"
Title="Page_Ingredient">
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Weight2.UI.Client;component/Themes/ABCTab.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Weight2.UI.Client;component/UnitTests/UnitTests_Weights.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="DataGridCell" >
<Setter Property="FontSize" Value="16"/>
</Style>
</ResourceDictionary>
</Page.Resources>
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="496*" />
</Grid.RowDefinitions>
<Grid x:Name="stackpanel_weight" Background="{StaticResource Background_Title}" d:DataContext="{StaticResource unittests_weighters}">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" >
<Button Style="{StaticResource ButtonStyle_back2}" Click="button_back_Click" />
<TextBlock Style="{StaticResource TextBlockStyle_Title}" Text="流量记录"/>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center" >
<Button Style="{StaticResource ButtonStyle_largeIcon}" Click="button_clear_click" Foreground="White" Margin="20,0">
<StackPanel>
<Grid Style="{StaticResource GridStyle_ButtonShadow}">
<Ellipse Fill="#FFEE3232" Margin="1"/>
<iconPacks:PackIconMaterial Kind="CloseCircle" />
</Grid>
<TextBlock Text="清空" Foreground="White"/>
</StackPanel>
</Button>
</StackPanel>
</Grid>
<Grid Grid.Row="1" x:Name="grid_window">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Margin="{StaticResource ControlMargin}">
<Button Style="{StaticResource ButtonStyle_icon}" Background="Transparent" Click="button_prepage_Click" >
<iconPacks:PackIconMaterial Kind="ArrowLeft"/>
</Button>
<StackPanel Orientation="Horizontal" Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="第"/>
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" Text="{Binding CurrentPage}"/>
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="页"/>
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm_interval}" Text="/"/>
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="共"/>
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" Text="{Binding TotalPages}"/>
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="页"/>
</StackPanel>
<Button Style="{StaticResource ButtonStyle_icon}" Click="button_nextpage_Click" >
<iconPacks:PackIconMaterial Kind="ArrowRight"/>
</Button>
<Button Style="{StaticResource ButtonStyle_icon}" Click="button_newest_Click" >
<iconPacks:PackIconMaterial Kind="ArrowCollapseRight"/>
</Button>
<StackPanel Orientation="Horizontal" Margin="20,5">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="显示"/>
<TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding Size}" MinWidth="40"/>
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="行"/>
</StackPanel>
</StackPanel>
</Grid>
<DataGrid Grid.Row="1" x:Name="gridFlows" ItemsSource="{Binding Record}" AutoGenerateColumns="False" IsReadOnly="True"
AlternationCount="5" AlternatingRowBackground="LightGray">
</DataGrid>
</Grid>
</Grid>
</Page>
using FLY.OBJComponents.Client;
using FLY.OBJComponents.IService;
using FLY.Thick.Base.UI;
using FLY.Weight2.Common;
using FLY.Weight2.IService;
using FLY.Weight2.Server.Model;
using Misc;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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.Navigation;
using System.Windows.Shapes;
using Unity;
namespace FLY.Weight2.UI.Client
{
/// <summary>
/// Page_Flow.xaml 的交互逻辑
/// </summary>
public partial class PgFlowTable : Page
{
IUnityContainer container;
IWeightSystemService weightSystemService;
IBuffer<Lc_Flow> flowList;
ParamDictionary paramDictionary;
BufferWindow<Lc_Flow> mWindow;
public PgFlowTable()
{
InitializeComponent();
}
[InjectionMethod]
public void Init(
IUnityContainer container,
IWeightSystemService weightSystemService,
IBuffer<Lc_Flow> flowList,
ParamDictionary paramDictionary)
{
this.container = container;
this.weightSystemService = weightSystemService;
this.flowList = flowList;
this.paramDictionary = paramDictionary;
//itemsControl.DataContext = this.weightSystemService;
//窗口显示数据条数
int windowSize = this.paramDictionary.GetValue<int>(ParamDistItemKeys.WindowSize, 30);
mWindow = new BufferWindow<Lc_Flow>(flowList, windowSize);
mWindow.PropertyChanged += (s, e) =>
{
if (e.PropertyName == "Size")
{
this.paramDictionary.SetValue(ParamDistItemKeys.WindowSize, mWindow.Size);
this.paramDictionary.Save();
}
};
//界面........................................
InitDataGrid();
grid_window.DataContext = mWindow;
stackpanel_weight.DataContext = this.weightSystemService;
}
void InitDataGrid()
{
DataGridTextColumn c = new DataGridTextColumn()
{
CanUserSort = false,
CanUserReorder = false,
Header = "时间",
Binding = new Binding("Time") { StringFormat = "{0:MM/dd HH:mm}" }
};
gridFlows.Columns.Add(c);
c = new DataGridTextColumn()
{
CanUserSort = false,
CanUserReorder = false,
Header = "总流量 kg/h",
Binding = new Binding("Total") { StringFormat = "{0:F1}" }
};
gridFlows.Columns.Add(c);
for (int i = 0; i < weightSystemService.ItemsCnt; i++)
{
string name = (char)('A' + i) + "层";
c = new DataGridTextColumn()
{
CanUserSort = false,
CanUserReorder = false,
Header = name + "流量 kg/h",
Binding = new Binding($"Items[{i}].Flow") { StringFormat = "{0:F1}" }
};
gridFlows.Columns.Add(c);
c = new DataGridTextColumn()
{
CanUserSort = false,
CanUserReorder = false,
Header = name + "比例 %",
Binding = new Binding($"Items[{i}].ScrewPDisp") { StringFormat = "{0:F1}" }
};
gridFlows.Columns.Add(c);
c = new DataGridTextColumn()
{
CanUserSort = false,
CanUserReorder = false,
Header = name + "频率 Hz",
Binding = new Binding($"Items[{i}].ScrewMotorFreq") { StringFormat = "{0:F1}" }
};
gridFlows.Columns.Add(c);
}
}
private void button_back_Click(object sender, RoutedEventArgs e)
{
NavigationService.GoBack();
mWindow.Dispose();
}
private void button_clear_click(object sender, RoutedEventArgs e)
{
if (FLY.ControlLibrary.MyMessageBox.Show("确定是否清空全部历史数据?") == true)
{
mWindow.Buffer.Reset();
FLY.ControlLibrary.Window_Tip.Show("成功", "清除完毕!", TimeSpan.FromSeconds(2));
}
}
private void button_prepage_Click(object sender, RoutedEventArgs e)
{
mWindow.MovePrePage();
}
private void button_nextpage_Click(object sender, RoutedEventArgs e)
{
mWindow.MoveNextPage();
}
private void button_newest_Click(object sender, RoutedEventArgs e)
{
mWindow.MoveNewest();
}
}
}
<Page x:Class="FLY.Weight2.UI.Client.PgMenu"
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.Weight2.UI.Client"
xmlns:misc="clr-namespace:Misc;assembly=MISC"
mc:Ignorable="d"
d:DesignHeight="768" d:DesignWidth="1388"
Background="White"
Title="Page_Menu">
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Weight2.UI.Client;component/Converter/Dictionary_MyConv.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Weight2.UI.Client;component/UnitTests/UnitTests_Weights.xaml"/>
</ResourceDictionary.MergedDictionaries>
<misc:Ver x:Key="version" SrcType="{x:Type local:PgMenu}"/>
</ResourceDictionary>
</Page.Resources>
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="540*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource ButtonStyle_back}" Command="BrowseBack"/>
</StackPanel>
<StackPanel Orientation="Horizontal" FlowDirection="RightToLeft">
<StackPanel Orientation="Vertical" DataContext="{StaticResource version}">
<Button Style="{StaticResource ButtonStyle_empty}" Background="{x:Null}" Click="button_version_Click" VerticalAlignment="Center">
<TextBlock Text="{Binding .}" FontSize="24" FontWeight="Bold" Margin="15" />
</Button>
</StackPanel>
</StackPanel>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Auto">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<WrapPanel x:Name="wrappanel_root" Orientation="Vertical" Grid.Column="1" d:DataContext="{StaticResource unittests_weighters}">
<WrapPanel.Resources>
<Style TargetType="Button" BasedOn="{StaticResource ResourceKey=ButtonStyle_empty}">
<Setter Property="Background" Value="#FF0083D7"/>
<Setter Property="Width" Value="225"/>
<Setter Property="Height" Value="140"/>
<Setter Property="Margin" Value="5"/>
</Style>
</WrapPanel.Resources>
<Button Click="button_screw_Click" >
<TextBlock FontWeight="Bold" FontFamily="YouYuan" VerticalAlignment="Center">
<Run Foreground="White" FontSize="40" Text="称重参数"/>
</TextBlock>
</Button>
<Button Click="button_thickness_Click" >
<TextBlock FontWeight="Bold" FontFamily="YouYuan" VerticalAlignment="Center">
<Run Foreground="White" FontSize="40" Text="厚度参数"/>
</TextBlock>
</Button>
<Button Click="button_error_Click" Background="Red" >
<Grid>
<TextBlock FontWeight="Bold" FontFamily="YouYuan" VerticalAlignment="Center" Foreground="White" FontSize="40" Text="报警管理" Padding="10"/>
</Grid>
</Button>
<Button Click="button_flow_Click" >
<TextBlock FontWeight="Bold" FontFamily="YouYuan" VerticalAlignment="Center">
<Run Foreground="White" FontSize="40" Text="流量记录"/>
</TextBlock>
</Button>
</WrapPanel>
</Grid>
</ScrollViewer>
</Grid>
</Page>
using FLY.OBJComponents.IService;
using FLY.Thick.Base.UI;
using FLY.Weight2.Common;
using FLY.Weight2.IService;
using FLY.Weight2.Server.Model;
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;
using Unity;
namespace FLY.Weight2.UI.Client
{
/// <summary>
/// Page_Menu.xaml 的交互逻辑
/// </summary>
public partial class PgMenu : Page
{
IUnityContainer container;
IWeightSystemService weightSystemService;
public PgMenu()
{
InitializeComponent();
}
[InjectionMethod]
public void Init(IUnityContainer container,
IWeightSystemService weightSystemService)
{
this.container = container;
this.weightSystemService = weightSystemService;
wrappanel_root.DataContext = weightSystemService;
}
private void button_ingredient_Click(object sender, RoutedEventArgs e)
{
if (!WdPassword.Authorize("Weighter"))
return;
//PgIngredient p = new PgIngredient();
//container.BuildUp(p);
//NavigationService.Navigate(p);
}
private void button_screw_Click(object sender, RoutedEventArgs e)
{
if (!WdPassword.Authorize("Weighter"))
return;
PgScrew p = new PgScrew();
container.BuildUp(p);
NavigationService.Navigate(p);
}
private void button_error_Click(object sender, RoutedEventArgs e)
{
PgErrorTable2 p = new PgErrorTable2();
var warningReasonWindow = container.Resolve<WarningReasonWindow>("weighterWarningReasonWindow");
var warningService = container.Resolve<IWarningService>("weighterWarningService");
p.Init(container, warningService, warningReasonWindow);
NavigationService.Navigate(p);
}
private void button_thickness_Click(object sender, RoutedEventArgs e)
{
if (!WdPassword.Authorize("Weighter"))
return;
PgThickness p = new PgThickness();
container.BuildUp(p);
NavigationService.Navigate(p);
}
private void button_version_Click(object sender, RoutedEventArgs e)
{
}
private void button_flow_Click(object sender, RoutedEventArgs e)
{
PgFlowTable p = new PgFlowTable();
container.BuildUp(p);
NavigationService.Navigate(p);
}
}
}
This diff is collapsed.
using FLY.OBJComponents.Client;
using FLY.Weight2.Client;
using FLY.Weight2.IService;
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;
using Unity;
namespace FLY.Weight2.UI.Client
{
/// <summary>
/// Page_Screw.xaml 的交互逻辑
/// </summary>
public partial class PgScrew : Page
{
IWeightSystemService weightSystemService;
List<SetPLCUpdatePlan> setPlan_items = new List<SetPLCUpdatePlan>();
public PgScrew()
{
InitializeComponent();
}
[InjectionMethod]
public void Init(
IWeightSystemService weightSystemService)
{
this.weightSystemService = weightSystemService;
root_grid.DataContext = this.weightSystemService;
RebuildPlans();
if (weightSystemService is WeightSystemServiceClient)
{
(weightSystemService as WeightSystemServiceClient).ResetItemsEvent += MWeighterCsService_ResetItemsEvent;
}
}
private void MWeighterCsService_ResetItemsEvent()
{
RebuildPlans();
}
/// <summary>
/// 由于数量改变,重新构造更新计划
/// </summary>
void RebuildPlans()
{
foreach (SetPLCUpdatePlan plan in setPlan_items)
plan.Dispose();
setPlan_items.Clear();
for (int i = 0; i < weightSystemService.Items.Count(); i++)
{
setPlan_items.Add(new SetPLCUpdatePlan(
weightSystemService.PLCos,
weightSystemService.Items[i],
new string[] {
"FlowDisp",
"FlowSetting",
"FilterParam",
"SwitchLv",
"UpDownGain",
"PGain",
"ITime",
"AdjustFactor",
"AdjustUpper",
"AdjustLower",
"StableLvSwitch",
"PIDLimit",
"SampleTime",
"PIDResult",
"PIDAdjust",
"ScrewCurrentSpeed",
"ScrewMotorFreq",
"PGainDisp"
}));
}
}
private void button_back_Click(object sender, RoutedEventArgs e)
{
NavigationService.GoBack();
}
private void Page_Unloaded(object sender, RoutedEventArgs e)
{
foreach (var setPlan in setPlan_items)
{
setPlan.Dispose();
}
}
}
}
<Page x:Class="FLY.Weight2.UI.Client.PgThickness"
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.Weight2.UI.Client"
mc:Ignorable="d"
d:DesignHeight="900" d:DesignWidth="960" Background="White"
Title="Page_Hopper">
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Weight2.UI.Client;component/Themes/ABCTab.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Weight2.UI.Client;component/UnitTests/UnitTests_Weights.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Weight2.UI.Client;component/Converter/Dictionary_MyConv.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Page.Resources>
<Grid Name="root_grid" d:DataContext="{StaticResource unittests_weighters}">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="496*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Background="{StaticResource Background_Title}">
<Button Style="{StaticResource ButtonStyle_back2}" Click="button_back_Click" />
<TextBlock Style="{StaticResource TextBlockStyle_Title}" Text="厚度参数设置"/>
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Row="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Border Width="150" Background="{StaticResource Color_theme_activity}" Margin="0,5,5,5" >
<TextBlock Style="{StaticResource TextBlockStyle_ItemHeader}" Text="参数" />
</Border>
<StackPanel Orientation="Vertical" Grid.Column="1">
<StackPanel 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 Accessory.WheelPerimeter,StringFormat={}{0:F0}}"/>
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" Text="mm" />
</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 Accessory.WheelPulse,StringFormat={}{0:F0}}"/>
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" Text="脉冲/转" />
</StackPanel>
</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 Accessory.Density,StringFormat={}{0:F3}}"/>
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" Text="kg/m³" />
</StackPanel>
</StackPanel>
</StackPanel>
</Grid>
</StackPanel>
</Grid>
</Page>
using FLY.OBJComponents.Client;
using FLY.Weight2.Client;
using FLY.Weight2.IService;
using System;
using System.Collections.Generic;
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.Navigation;
using System.Windows.Shapes;
using Unity;
namespace FLY.Weight2.UI.Client
{
/// <summary>
/// Page_Thickness.xaml 的交互逻辑
/// </summary>
public partial class PgThickness : Page
{
IWeightSystemService weightSystemService;
SetPLCUpdatePlan setPlan_accessory;
public PgThickness()
{
InitializeComponent();
}
[InjectionMethod]
public void Init(IWeightSystemService weightSystemService)
{
this.weightSystemService = weightSystemService;
root_grid.DataContext = this.weightSystemService;
RebuildPlans();
}
/// <summary>
/// 由于数量改变,重新构造更新计划
/// </summary>
void RebuildPlans()
{
setPlan_accessory = new SetPLCUpdatePlan(
weightSystemService.PLCos,
weightSystemService.Accessory,
new string[] {
"WheelPerimeter",
"WheelPulse",
"Density"
});
}
private void button_back_Click(object sender, RoutedEventArgs e)
{
setPlan_accessory.Dispose();
NavigationService.GoBack();
}
}
}
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("FLY.Weight2.UI.Client")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("佛山市枫莱尔自动化技术有限公司")]
[assembly: AssemblyProduct("自动上料(称重单组分) 客户端")]
[assembly: AssemblyCopyright("Copyright © 2020 FlyAutomation")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//将 ComVisible 设置为 false 将使此程序集中的类型
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
//若要开始生成可本地化的应用程序,请
//<PropertyGroup> 中的 .csproj 文件中
//例如,如果您在源文件中使用的是美国英语,
//使用的是美国英语,请将 <UICulture> 设置为 en-US。 然后取消
//对以下 NeutralResourceLanguage 特性的注释。 更新
//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //主题特定资源词典所处位置
//(当资源未在页面
//或应用程序资源字典中找到时使用)
ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
//(当资源未在页面
//、应用程序或任何主题专用资源字典中找到时使用)
)]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("6.0.0.0")]
[assembly: AssemblyFileVersion("6.0.0.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace FLY.Weight2.UI.Client.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FLY.Weight2.UI.Client.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性
/// 重写当前线程的 CurrentUICulture 属性。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace FLY.Weight2.UI.Client.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.5.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
\ No newline at end of file
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:FLY.Weight2.UI.Client.Themes">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style x:Key="TabItemStyle_ABC" TargetType="{x:Type TabItem}">
<Setter Property="Foreground" Value="Black"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="6,2,6,2"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}" >
<Grid x:Name="templateRoot" SnapsToDevicePixels="true" >
<Border x:Name="mainBorder" MinWidth="113" Height="96" Background="{Binding Color}" Margin="0" />
<TextBlock Text="{Binding Number}" FontSize="100" FontWeight="Bold" Margin="-15,0,0,-30" VerticalAlignment="Bottom" HorizontalAlignment="Left"/>
</Grid>
<ControlTemplate.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
</MultiDataTrigger.Conditions>
<Setter Property="Panel.ZIndex" Value="2"/>
<Setter Property="Margin" Value="-2,-2,-2,-2"/>
<Setter Property="Margin" TargetName="mainBorder" Value="-1"/>
</MultiDataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="TabControlStyle_ABC" TargetType="{x:Type TabControl}">
<Setter Property="Padding" Value="2"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabControl}">
<Grid x:Name="templateRoot" ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="ColumnDefinition0"/>
<ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition x:Name="RowDefinition0" Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition x:Name="RowDefinition1" Height="*"/>
</Grid.RowDefinitions>
<TabPanel x:Name="headerPanel" Background="Transparent" Grid.Column="0" IsItemsHost="true" Margin="2,2,2,0" Grid.Row="0" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1"/>
<Grid Panel.ZIndex="1" Grid.Row="1" >
<Border Background="{Binding Path='SelectedItem.Color',RelativeSource={RelativeSource Mode=TemplatedParent}}" Height="10" />
<Border Background="Black" Height="2" VerticalAlignment="Bottom" />
</Grid>
<Border x:Name="contentPanel" Background="{TemplateBinding Background}" Grid.Column="0" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="2" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="TabStripPlacement" Value="Bottom">
<Setter Property="Grid.Row" TargetName="headerPanel" Value="1"/>
<Setter Property="Grid.Row" TargetName="contentPanel" Value="0"/>
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
<Setter Property="Height" TargetName="RowDefinition1" Value="Auto"/>
<Setter Property="Margin" TargetName="headerPanel" Value="2,0,2,2"/>
</Trigger>
<Trigger Property="TabStripPlacement" Value="Left">
<Setter Property="Grid.Row" TargetName="headerPanel" Value="0"/>
<Setter Property="Grid.Row" TargetName="contentPanel" Value="0"/>
<Setter Property="Grid.Column" TargetName="headerPanel" Value="0"/>
<Setter Property="Grid.Column" TargetName="contentPanel" Value="1"/>
<Setter Property="Width" TargetName="ColumnDefinition0" Value="Auto"/>
<Setter Property="Width" TargetName="ColumnDefinition1" Value="*"/>
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
<Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
<Setter Property="Margin" TargetName="headerPanel" Value="2,2,0,2"/>
</Trigger>
<Trigger Property="TabStripPlacement" Value="Right">
<Setter Property="Grid.Row" TargetName="headerPanel" Value="0"/>
<Setter Property="Grid.Row" TargetName="contentPanel" Value="0"/>
<Setter Property="Grid.Column" TargetName="headerPanel" Value="1"/>
<Setter Property="Grid.Column" TargetName="contentPanel" Value="0"/>
<Setter Property="Width" TargetName="ColumnDefinition0" Value="*"/>
<Setter Property="Width" TargetName="ColumnDefinition1" Value="Auto"/>
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
<Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
<Setter Property="Margin" TargetName="headerPanel" Value="0,2,2,2"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="TextElement.Foreground" TargetName="templateRoot" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
\ No newline at end of file
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="Color_title" Color="#A0FFFFFF"/>
<SolidColorBrush x:Key="Color_unit" Color="#80FFFFFF"/>
<SolidColorBrush x:Key="Color_text" Color="#FFFFFFFF"/>
<SolidColorBrush x:Key="Color_title_activity" Color="#FF008BE5"/>
<SolidColorBrush x:Key="Color_text_activity" Color="#FFa8ddff"/>
<SolidColorBrush x:Key="Color_background" Color="#FF384064"/>
<SolidColorBrush x:Key="Color_background2" Color="#50587c"/>
</ResourceDictionary>
\ No newline at end of file
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="DataGrid" x:Key="DataGridStyle01">
<!--网格线颜色-->
<Setter Property="Background" Value="#E6DBBB" />
<Setter Property="BorderBrush" Value="#d6c79b" />
<Setter Property="HorizontalGridLinesBrush">
<Setter.Value>
<SolidColorBrush Color="#d6c79b"/>
</Setter.Value>
</Setter>
<Setter Property="VerticalGridLinesBrush">
<Setter.Value>
<SolidColorBrush Color="#d6c79b"/>
</Setter.Value>
</Setter>
</Style>
<!--标题栏样式-->
<!--<Style TargetType="DataGridColumnHeader" >
<Setter Property="Width" Value="50"/>
<Setter Property="Height" Value="30"/>
<Setter Property="FontSize" Value="14" />
<Setter Property="Background" Value="White" />
<Setter Property="FontWeight" Value="Bold"/>
</Style>-->
<Style TargetType="DataGridColumnHeader">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="MinWidth" Value="0" />
<Setter Property="MinHeight" Value="28" />
<Setter Property="Foreground" Value="#323433" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridColumnHeader">
<Border x:Name="BackgroundBorder" BorderThickness="0,1,0,1"
BorderBrush="#e6dbba"
Width="Auto">
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ContentPresenter Margin="0,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Path x:Name="SortArrow" Visibility="Collapsed" Data="M0,0 L1,0 0.5,1 z" Stretch="Fill" Grid.Column="2" Width="8" Height="6" Fill="White" Margin="0,0,50,0"
VerticalAlignment="Center" RenderTransformOrigin="1,1" />
<Rectangle Width="1" Fill="#d6c79b" HorizontalAlignment="Right" Grid.ColumnSpan="1" />
<!--<TextBlock Background="Red">
<ContentPresenter></ContentPresenter></TextBlock>-->
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Height" Value="25"/>
</Style>
<!--行样式触发-->
<!--背景色改变必须先设置cellStyle 因为cellStyle会覆盖rowStyle样式-->
<Style TargetType="DataGridRow">
<Setter Property="Background" Value="#F2F2F2" />
<Setter Property="Height" Value="25"/>
<Setter Property="Foreground" Value="Black" />
<Style.Triggers>
<!--隔行换色-->
<Trigger Property="AlternationIndex" Value="0" >
<Setter Property="Background" Value="#e7e7e7" />
</Trigger>
<Trigger Property="AlternationIndex" Value="1" >
<Setter Property="Background" Value="#f2f2f2" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="LightGray"/>
<!--<Setter Property="Foreground" Value="White"/>-->
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Foreground" Value="Black"/>
</Trigger>
</Style.Triggers>
</Style>
<!--单元格样式触发-->
<Style TargetType="DataGridCell">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridCell">
<TextBlock TextAlignment="Center" VerticalAlignment="Center" >
<ContentPresenter />
</TextBlock>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<!--<Setter Property="Background" Value="White"/>
<Setter Property="BorderThickness" Value="0"/>-->
<Setter Property="Foreground" Value="Black"/>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:FLY.Weight2.UI.Client">
<SolidColorBrush x:Key="Color_g1#0" Color="#FF3269ac" />
<SolidColorBrush x:Key="Color_g2#0" Color="#FF4cc5f4"/>
<SolidColorBrush x:Key="Color_g3#0" Color="#FFe44c63"/>
<SolidColorBrush x:Key="Color_g4#0" Color="#FF12a7ad"/>
<SolidColorBrush x:Key="Color_g5#0" Color="#FFf9b14d"/>
</ResourceDictionary>
\ No newline at end of file
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="Color_title" Color="#FF464646"/>
<SolidColorBrush x:Key="Color_unit" Color="#FF464646"/>
<SolidColorBrush x:Key="Color_text" Color="#FF0b0b0b"/>
<SolidColorBrush x:Key="Color_title_activity" Color="#FF008BE5"/>
<SolidColorBrush x:Key="Color_text_activity" Color="#FF005083"/>
</ResourceDictionary>
\ No newline at end of file
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Converter/Dictionary_MyConv.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Weight2.UI.Client;component/Themes/DarkSkin.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Weight2.UI.Client;component/UnitTests/UnitTests_Weights.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Weight2.UI.Client;component/Converter/Dictionary_MyConv.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Converter/Dictionary_MyConv.xaml"/>
</ResourceDictionary.MergedDictionaries>
<sys:Double x:Key="d100">100</sys:Double>
<sys:Double x:Key="FontSize_title">18</sys:Double>
<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>
<Style TargetType="Viewbox" x:Key="ViewerStyle">
<Setter Property="MaxHeight" Value="130"/>
<Setter Property="MaxWidth" Value="240"/>
</Style>
<SolidColorBrush x:Key="Color_button1_b" Color="#FF008BE5"/>
<SolidColorBrush x:Key="Color_button2_b" Color="#FF919191"/>
<SolidColorBrush x:Key="Color_button_f" Color="#FFf1f1f1"/>
</ResourceDictionary>
\ No newline at end of file
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib" >
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.Weight2.UI.Client;component/Themes/Styles.xaml"/>
</ResourceDictionary.MergedDictionaries>
<sys:Double x:Key="FontSize_title">18</sys:Double>
<sys:Double x:Key="FontSize_unit">18</sys:Double>
<sys:Double x:Key="FontSize_text">48</sys:Double>
<Style x:Key="TextBlockStyle_title" TargetType="TextBlock">
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="FontSize" Value="{StaticResource FontSize_title}"/>
<Setter Property="Foreground" Value="{DynamicResource Color_title}"/>
</Style>
<Style x:Key="RunStyle_unit" TargetType="Run">
<Setter Property="FontSize" Value="{StaticResource FontSize_unit}"/>
<Setter Property="Foreground" Value="{DynamicResource Color_unit}"/>
</Style>
<Style x:Key="RunStyle_text" TargetType="Run">
<Setter Property="FontSize" Value="{StaticResource FontSize_text}"/>
<Setter Property="Foreground" Value="{DynamicResource Color_text}"/>
</Style>
<Style x:Key="TextBlockStyle_title_activity" TargetType="TextBlock">
<Setter Property="FontSize" Value="{StaticResource FontSize_title}"/>
<Setter Property="Foreground" Value="{DynamicResource Color_title_activity}"/>
</Style>
<Style x:Key="RunStyle_text_activity" TargetType="Run">
<Setter Property="FontSize" Value="{StaticResource FontSize_text}"/>
<Setter Property="Foreground" Value="{DynamicResource Color_text_activity}"/>
</Style>
<Style TargetType="Border" x:Key="BorderStyle_block">
<Setter Property="CornerRadius" Value="5"/>
<Setter Property="Background" Value="{StaticResource Color_background}"/>
</Style>
</ResourceDictionary>
\ No newline at end of file
<UserControl x:Class="FLY.Weight2.UI.Client.UiModule.DynAreaWeight"
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.Weight2.UI.Client.UiModule"
xmlns:flyctrl="clr-namespace:FLY.ControlLibrary;assembly=FLY.ControlLibrary"
mc:Ignorable="d"
d:DesignWidth="292" >
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.Weight2.UI.Client;component/Themes/UcWeighterItemStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="{x:Type Path}" x:Key="PathStyle_icon">
<Setter Property="Fill" Value="White"/>
<Setter Property="Stretch" Value="Uniform"/>
<Setter Property="Width" Value="30"/>
<Setter Property="Height" Value="30"/>
<Setter Property="SnapsToDevicePixels" Value="True"/>
</Style>
<local:DynAreaViewModelParams x:Key="unitests_props" IsError="False" Error="报警MSG"/>
</ResourceDictionary>
</UserControl.Resources>
<Button Style="{StaticResource ButtonStyle_empty}" Background="Transparent" Click="Button_Click">
<Grid>
<Grid x:Name="grid_weighter" d:DataContext="{StaticResource unittests_weighters}"/>
<Grid x:Name="grid_error" d:DataContext="{StaticResource unitests_props}"/>
<Border Style="{StaticResource BorderStyle_module}"
DataContext="{Binding DataContext,ElementName=grid_weighter}" Background="{StaticResource Color_background}">
<StackPanel Orientation="Vertical">
<Grid Name="grid_flow">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<flyctrl:PieChart Grid.RowSpan="2" Width="60" Height="60" Margin="10"
ItemValueBinding="CurrentFlow" ItemColorBinding="Color"
ItemsSource="{Binding Items}"
/>
<StackPanel Grid.Column="1">
<TextBlock Text="总流量" Style="{StaticResource TextBlockStyle_title}" />
<Viewbox MaxHeight="70" HorizontalAlignment="Left">
<StackPanel Orientation="Horizontal">
<TextBlock Margin="4" >
<Run Text="{Binding Accessory.TotalFlow,StringFormat={}{0:F1}}" Style="{StaticResource RunStyle_text}" FontSize="50" />
<Run Text="kg/h" Style="{StaticResource RunStyle_unit}"/>
</TextBlock>
</StackPanel>
</Viewbox>
</StackPanel>
</Grid>
<Grid Margin="2">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Margin="2">
<TextBlock Style="{StaticResource TextBlockStyle_title}" Text="平均厚度" FontSize="12" />
<TextBlock Margin="5,0">
<Run Text="{Binding Accessory.Thickness,StringFormat={}{0:F1}}" Style="{StaticResource RunStyle_text}" FontSize="24" />
<Run Text="um" Style="{StaticResource RunStyle_unit}" FontSize="12"/>
</TextBlock>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal" Margin="2" >
<TextBlock Style="{StaticResource TextBlockStyle_title}" Text="边料" FontSize="12" />
<TextBlock Margin="5,0">
<Run Text="{Binding Accessory.RimCharge,StringFormat={}{0:F1}}" Style="{StaticResource RunStyle_text}" FontSize="24" />
<Run Text="kg/h" Style="{StaticResource RunStyle_unit}" FontSize="12"/>
</TextBlock>
</StackPanel>
</Grid>
</StackPanel>
</Border>
<Border Style="{StaticResource BorderStyle_module}" Background="Red"
DataContext="{Binding DataContext,ElementName=grid_error}"
Visibility="{Binding IsError,Converter={StaticResource visbilityconv}}">
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Path Margin="5" Fill="White" Stretch="Uniform" Width="60" Height="60" SnapsToDevicePixels="True" Data="{StaticResource Geometry_alert-circle-outline}" >
<Path.Style>
<Style TargetType="Path">
<Style.Triggers>
<DataTrigger Binding="{Binding IsError}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard RepeatBehavior="Forever" >
<DoubleAnimation BeginTime="0:0:0" Storyboard.TargetProperty="Opacity" From="1" To="0" Duration="00:00:01" />
<DoubleAnimation BeginTime="0:0:1" Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="00:00:01" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Path.Style>
</Path>
<TextBlock Grid.Column="1" Margin="5" VerticalAlignment="Center" TextWrapping="Wrap" FontSize="30" Foreground="White" Text="{Binding Error}"/>
</Grid>
</Border>
</Grid>
</Button>
</UserControl>
using FLY.OBJComponents.Client;
using FLY.OBJComponents.Common;
using FLY.OBJComponents.IService;
using FLY.Thick.Base.UI;
using FLY.Weight2.Client;
using FLY.Weight2.IService;
using FObjBase;
using MultiLayout;
using MultiLayout.UiModule;
using System;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using System.Windows.Threading;
using Unity;
namespace FLY.Weight2.UI.Client.UiModule
{
/// <summary>
/// DynAreaWeight.xaml 的交互逻辑
/// </summary>
public partial class DynAreaWeight : UserControl
{
#region 延时推送 MARKNO
const int MARKNO_UPDATEERROR = 1;
#endregion
IUnityContainer container;
IWeightSystemService weightSystemService;
WarningReasonWindow warningReasonWindow;
IWarningService warningService;
DispatcherTimer timer_error;
DynAreaViewModelParams props = new DynAreaViewModelParams();
SetPLCUpdatePlan setPlan;
public DynAreaWeight()
{
InitializeComponent();
}
[InjectionMethod]
public void Init(
IUnityContainer container,
[Dependency("weighterWarningReasonWindow")] WarningReasonWindow warningReasonWindow,
[Dependency("weighterWarningService")]IWarningService warningService,
IWeightSystemService weightSystemService
)
{
this.container = container;
this.weightSystemService = weightSystemService;
//创建窗口观察 报警原因列表
this.warningReasonWindow = warningReasonWindow;
this.warningService = warningService;
//报警原因轮流显示
timer_error = new DispatcherTimer();
timer_error.Interval = TimeSpan.FromSeconds(3);
timer_error.Tick += (s, e) =>
{
reason_list_index--;
if (reason_list_index < 0)
reason_list_index = this.warningReasonWindow.Record.Count();
updateError();
};
this.warningReasonWindow.Record.CollectionChanged += Record_CollectionChanged;
grid_weighter.DataContext = this.weightSystemService;
grid_error.DataContext = props;
//注册属性更新计划
setPlan = new SetPLCUpdatePlan(
this.weightSystemService.PLCos,
this.weightSystemService.Accessory,
new string[] {
"Thickness",
"RimCharge"});
this.weightSystemService.PropertyChanged += (s, e) =>
{
if (e.PropertyName == "IsConnected")
{
updateError();
}
};
updateError();
}
private void Record_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
FObjBase.PollModule.Current.Poll_JustOnce(
new FObjBase.PollModule.PollHandler(delegate ()
{
reason_list_index = warningReasonWindow.Record.Count() - 1;
updateError();
}), this, MARKNO_UPDATEERROR);
}
void updateError()
{
if (weightSystemService is FObjServiceClient)
{
var objClient = weightSystemService as FObjServiceClient;
if (!objClient.IsConnected) {
props.Error = "称重服务器连接断开";
props.IsError = true;
reason_list_index = -1;
timer_error.Stop();
return;
}
}
if (warningReasonWindow.Record.Count == 0) {
props.IsError = false;
props.Error = "";
reason_list_index = -1;
timer_error.Stop();
return;
}
if (reason_list_index >= warningReasonWindow.Record.Count)
reason_list_index = warningReasonWindow.Record.Count - 1;
else if (reason_list_index < 0)
reason_list_index = 0;
props.Error = warningReasonWindow.Record[reason_list_index].Description;
props.IsError = true;
timer_error.Start();
}
private int reason_list_index = -1;
private void Button_Click(object sender, RoutedEventArgs e)
{
PgErrorTable2 p = new PgErrorTable2();
p.Init(container, warningService, warningReasonWindow);
FlyLayoutManager.NavigationService.Navigate(p);
}
}
public class DynAreaViewModelParams : INotifyPropertyChanged
{
/// <summary>
/// 有异常
/// </summary>
public bool IsError { get; set; }
/// <summary>
/// 异常消息
/// </summary>
public string Error { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
}
public class UiModule2_DynAreaWeight : MultiLayout.UiModule.IUiModule2
{
/// <summary>
/// 控件标题
/// 它的值取决于culture
/// </summary>
public string Title=> "单组份称重状态";
public ComponentType Type => ComponentType.DynArea;
public bool IsUnique => true;
/// <summary>
/// 控件
/// 创建时,需要给它唯一ID,让加载自己的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public FrameworkElement GetComponent(int id, IUnityContainer container)
{
DynAreaWeight graph = new DynAreaWeight();
container.BuildUp(graph);
return graph;
}
/// <summary>
/// 控件缩略图,用于编辑界面时,大致看看
/// 创建时,需要给它唯一ID,让加载自己的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public FrameworkElement GetThumbnail()
{
return new System.Windows.Controls.Grid();
}
/// <summary>
/// 给出全部控件ID, 控件自行删除没有的参数
/// </summary>
/// <param name="IDs"></param>
public void MatchParam(int[] IDs)
{
}
}
}
<UserControl x:Class="FLY.Weight2.UI.Client.UiModule.MainGraph"
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.Weight2.UI.Client.UiModule"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d" >
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.Weight2.UI.Client;component/Themes/UcWeighterItemStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Viewbox Stretch="Uniform" VerticalAlignment="Top" HorizontalAlignment="Left">
<Grid Name="root_grid" d:DataContext="{StaticResource unittests_weighters}">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition />
</Grid.RowDefinitions>
<local:UcTotalFlow x:Name="ucTotalFlow" Margin="5" />
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<local:UcThickness x:Name="ucThickness" Margin="5"/>
<ItemsControl x:Name="itemsControl" Grid.Column="1" ItemsSource="{Binding Items}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<local:UcWeighterItem Margin="5" WeightSystemService="{Binding DataContext,ElementName=root_grid}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</Grid>
</Viewbox>
</UserControl>
using FLY.OBJComponents.Client;
using FLY.Weight2.Client;
using FLY.Weight2.Common;
using FLY.Weight2.IService;
using MultiLayout;
using MultiLayout.UiModule;
using System;
using System.Collections.Generic;
using System.Globalization;
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;
using Unity;
namespace FLY.Weight2.UI.Client.UiModule
{
/// <summary>
/// Page_Main.xaml 的交互逻辑
/// </summary>
public partial class MainGraph : UserControl
{
IWeightSystemService weightSystemService;
List<SetPLCUpdatePlan> setPlan_items = new List<SetPLCUpdatePlan>();
public MainGraph()
{
InitializeComponent();
}
[InjectionMethod]
public void Init(
IUnityContainer container,
IWeightSystemService weightSystemService)
{
ucTotalFlow.Init(weightSystemService);
ucThickness.Init(weightSystemService);
this.weightSystemService = weightSystemService;
root_grid.DataContext = this.weightSystemService;
for (int i = 0; i < this.weightSystemService.Items.Count(); i++)
{
SetPLCUpdatePlan plan = new SetPLCUpdatePlan(
this.weightSystemService.PLCos,
this.weightSystemService.Items[i],
UcWeighterItem.item_update_propertynames);
setPlan_items.Add(plan);
}
if (weightSystemService is WeightSystemServiceClient) {
(weightSystemService as WeightSystemServiceClient).ResetItemsEvent += MWeighterCsService_ResetItemsEvent;
}
}
private void MWeighterCsService_ResetItemsEvent()
{
//把多出来的删除
int remove_cnt = setPlan_items.Count() - weightSystemService.Items.Count();
if (remove_cnt > 0)
{
for (int i = 0; i < remove_cnt; i++)
{
SetPLCUpdatePlan plan = setPlan_items[setPlan_items.Count() - 1 - i];
plan.Dispose();
}
setPlan_items.RemoveRange(setPlan_items.Count() - remove_cnt, remove_cnt);
}
else
{
int start_idx = setPlan_items.Count();
int add_cnt = -remove_cnt;
for (int i = 0; i < add_cnt; i++)
{
SetPLCUpdatePlan plan = new SetPLCUpdatePlan(
weightSystemService.PLCos,
weightSystemService.Items[start_idx+i],
UcWeighterItem.item_update_propertynames);
setPlan_items.Add(plan);
}
}
}
}
public class UiModule2_MainGraph : IUiModule2
{
/// <summary>
/// 控件标题
/// 它的值取决于culture
/// </summary>
public string Title => "称重单组分主界面";
public ComponentType Type => ComponentType.Graph;
public bool IsUnique => true;
/// <summary>
/// 控件
/// 创建时,需要给它唯一ID,让加载自己的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public FrameworkElement GetComponent(int id, IUnityContainer container)
{
MainGraph graph = new MainGraph();
container.BuildUp(graph);
return graph;
}
/// <summary>
/// 控件缩略图,用于编辑界面时,大致看看
/// 创建时,需要给它唯一ID,让加载自己的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public FrameworkElement GetThumbnail()
{
return new System.Windows.Controls.Grid();
}
/// <summary>
/// 给出全部控件ID, 控件自行删除没有的参数
/// </summary>
/// <param name="IDs"></param>
public void MatchParam(int[] IDs)
{
}
}
}
<UserControl x:Class="FLY.Weight2.UI.Client.UiModule.MenuSetting"
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.Weight2.UI.Client.UiModule"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
mc:Ignorable="d" >
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Button Style="{StaticResource ButtonStyle_icon}" Foreground="White"
Click="btnMenuClick">
<StackPanel >
<iconPacks:PackIconMaterial Kind="FilterOutline" />
<TextBlock Text="称重" Foreground="White"/>
</StackPanel>
</Button>
</Grid>
</UserControl>
using MultiLayout;
using MultiLayout.UiModule;
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;
using Unity;
namespace FLY.Weight2.UI.Client.UiModule
{
/// <summary>
/// MenuSelect.xaml 的交互逻辑
/// </summary>
public partial class MenuSetting : UserControl
{
IUnityContainer container;
public MenuSetting()
{
InitializeComponent();
}
[InjectionMethod]
public void Init(IUnityContainer container)
{
this.container = container;
}
private void btnMenuClick(object sender, RoutedEventArgs e)
{
PgMenu p = new PgMenu();
container.BuildUp(p);
FlyLayoutManager.NavigationService.Navigate(p);
}
}
public class UiModule2_MenuSetting : IUiModule2
{
/// <summary>
/// 控件标题
/// 它的值取决于culture
/// </summary>
public string Title => "称重单组分菜单";
public ComponentType Type => ComponentType.Menu;
public bool IsUnique => true;
/// <summary>
/// 控件
/// 创建时,需要给它唯一ID,让加载自己的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public FrameworkElement GetComponent(int id, IUnityContainer container)
{
var uc = container.Resolve<MenuSetting>();
return uc;
}
/// <summary>
/// 控件缩略图,用于编辑界面时,大致看看
/// 创建时,需要给它唯一ID,让加载自己的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public FrameworkElement GetThumbnail()
{
return new System.Windows.Controls.Grid();
}
/// <summary>
/// 给出全部控件ID, 控件自行删除没有的参数
/// </summary>
/// <param name="IDs"></param>
public void MatchParam(int[] IDs)
{
}
}
}
<UserControl x:Class="FLY.Weight2.UI.Client.UiModule.UcThickness"
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.Weight2.UI.Client.UiModule"
xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:flyctrl="clr-namespace:FLY.ControlLibrary;assembly=FLY.ControlLibrary"
d:DesignWidth="300"
mc:Ignorable="d" >
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.Weight2.UI.Client;component/Themes/UcWeighterItemStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Border Style="{StaticResource BorderStyle_block}" d:DataContext="{StaticResource unittests_weighters}">
<Button Style="{StaticResource ButtonStyle_empty}" Background="Transparent" Click="button_thickness_Click" >
<Viewbox Margin="{StaticResource ControlMargin}" HorizontalAlignment="Left" VerticalAlignment="Top">
<StackPanel Width="180">
<StackPanel Margin="3" >
<TextBlock Text="吹膜宽度" Style="{StaticResource TextBlockStyle_title_activity}"/>
<TextBlock >
<Run Text="{Binding Accessory.TotalFilmWidth,StringFormat={}{0:F0}}" Style="{StaticResource RunStyle_text_activity}" />
<Run Text="mm" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</StackPanel>
<StackPanel Margin="3" >
<TextBlock Text="边料不回收" Style="{StaticResource TextBlockStyle_title_activity}"/>
<flyctrl:ToggleButtonOnOff IsEnabled="False"
IsChecked="{Binding Accessory.IsRimNoRecycle}"
OffLabel="否" OffBrush="#e44c65"
OnLabel="是" OnBrush="#10a8a9"/>
</StackPanel>
<StackPanel Margin="3" >
<TextBlock Text="切边" Style="{StaticResource TextBlockStyle_title_activity}"/>
<TextBlock >
<Run Text="{Binding Accessory.RimWidth,StringFormat={}{0:F0}}" Style="{StaticResource RunStyle_text_activity}" />
<Run Text="mm" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</StackPanel>
<StackPanel Margin="3" Background="{StaticResource Color_background2}" >
<TextBlock Text="收卷宽度" Style="{StaticResource TextBlockStyle_title}" Foreground="White"/>
<TextBlock >
<Run Text="{Binding Accessory.ActFilmWidth,StringFormat={}{0:F0}}" Style="{StaticResource RunStyle_text}" Foreground="White"/>
<Run Text="mm" Style="{StaticResource RunStyle_unit}" Foreground="White"/>
</TextBlock>
</StackPanel>
<StackPanel Margin="3" >
<TextBlock Text="设置厚度" Style="{StaticResource TextBlockStyle_title_activity}"/>
<TextBlock >
<Run Text="{Binding Accessory.SetThickness,StringFormat={}{0:F0}}" Style="{StaticResource RunStyle_text_activity}" />
<Run Text="um" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</StackPanel>
<StackPanel Margin="3" Background="{StaticResource Color_background2}">
<TextBlock Text="理论线速度" Style="{StaticResource TextBlockStyle_title}" Foreground="White"/>
<TextBlock >
<Run Text="{Binding Accessory.TargetVelocity,StringFormat={}{0:F1}}" Style="{StaticResource RunStyle_text}" Foreground="White"/>
<Run Text="m/min" Style="{StaticResource RunStyle_unit}" Foreground="White"/>
</TextBlock>
</StackPanel>
<StackPanel Margin="3" >
<TextBlock Text="当前线速度" Style="{StaticResource TextBlockStyle_title}" />
<TextBlock >
<Run Text="{Binding Accessory.CurrentVelocity,StringFormat={}{0:F1}}" Style="{StaticResource RunStyle_text}" />
<Run Text="m/min" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</StackPanel>
</StackPanel>
</Viewbox>
</Button>
</Border>
</UserControl>
using FLY.OBJComponents.Client;
using FLY.Weight2.IService;
using MultiLayout.UiModule;
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;
using Unity;
namespace FLY.Weight2.UI.Client.UiModule
{
/// <summary>
/// UcThickness.xaml 的交互逻辑
/// </summary>
public partial class UcThickness : UserControl
{
IWeightSystemService weightSystemService;
SetPLCUpdatePlan setPlan_accessory;
public UcThickness()
{
InitializeComponent();
}
public void Init(IWeightSystemService weightSystemService)
{
this.weightSystemService = weightSystemService;
this.DataContext = this.weightSystemService;
setPlan_accessory = new SetPLCUpdatePlan(
this.weightSystemService.PLCos,
this.weightSystemService.Accessory,
new string[] {
"TotalFilmWidth",
"IsRimNoRecycle",
"RimWidth",
"ActFilmWidth",
"SetThickness",
"TargetVelocity",
"CurrentVelocity"
});
}
private void button_thickness_Click(object sender, RoutedEventArgs e)
{
WdThickness w = new WdThickness();
if (weightSystemService.Items.Count() < 1)
return;
w.SetThickness = (int)weightSystemService.Accessory.SetThickness;
w.FilmWidth = (int)weightSystemService.Accessory.TotalFilmWidth;
w.RimWidth = (int)weightSystemService.Accessory.RimWidth;
w.IsRimNoRecycle = weightSystemService.Accessory.IsRimNoRecycle;
w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
if (w.ShowDialog() == true)
{
weightSystemService.Accessory.SetThickness = w.SetThickness;
weightSystemService.Accessory.TotalFilmWidth = w.FilmWidth;
weightSystemService.Accessory.RimWidth = w.RimWidth;
weightSystemService.Accessory.IsRimNoRecycle = w.IsRimNoRecycle;
FLY.ControlLibrary.Window_Tip.Show("", "厚度参数设置成功", TimeSpan.FromSeconds(2));
}
}
}
public class UiModule2_UcThickness : IUiModule2
{
/// <summary>
/// 控件标题
/// 它的值取决于culture
/// </summary>
public string Title => "称重单组分厚度";
public ComponentType Type => ComponentType.Graph;
public bool IsUnique => true;
/// <summary>
/// 控件
/// 创建时,需要给它唯一ID,让加载自己的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public FrameworkElement GetComponent(int id, IUnityContainer container)
{
UcThickness graph = new UcThickness();
container.BuildUp(graph);
return graph;
}
/// <summary>
/// 控件缩略图,用于编辑界面时,大致看看
/// 创建时,需要给它唯一ID,让加载自己的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public FrameworkElement GetThumbnail()
{
return new System.Windows.Controls.Grid();
}
/// <summary>
/// 给出全部控件ID, 控件自行删除没有的参数
/// </summary>
/// <param name="IDs"></param>
public void MatchParam(int[] IDs)
{
}
}
}
using FLY.OBJComponents.Client;
using FLY.Weight2.Client;
using FLY.Weight2.IService;
using MultiLayout.UiModule;
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;
using Unity;
namespace FLY.Weight2.UI.Client.UiModule
{
/// <summary>
/// UcTotalFlow.xaml 的交互逻辑
/// </summary>
public partial class UcTotalFlow : UserControl
{
IWeightSystemService weightSystemService;
SetPLCUpdatePlan setPlan_accessory;
List<SetPLCUpdatePlan> setPlan_items = new List<SetPLCUpdatePlan>();
public UcTotalFlow()
{
InitializeComponent();
}
[InjectionMethod]
public void Init(IWeightSystemService weightSystemService)
{
this.weightSystemService = weightSystemService;
this.DataContext = weightSystemService;
setPlan_accessory = new SetPLCUpdatePlan(
weightSystemService.PLCos,
weightSystemService.Accessory,
new string[] {
"TotalFlowSetOut",
"TotalFlowSetIn",
"TotalFlowSetInIsSet",
"TotalFlow",
"ALast",
"ACurrent",
"ACurrentLen",
"AClear",
"BLast",
"BCurrent",
"BCurrentLen",
"BClear"
});
for (int i = 0; i < weightSystemService.Items.Count(); i++)
{
SetPLCUpdatePlan plan = new SetPLCUpdatePlan(
weightSystemService.PLCos,
weightSystemService.Items[i],
item_update_propertynames);
setPlan_items.Add(plan);
}
if (weightSystemService is WeightSystemServiceClient)
(weightSystemService as WeightSystemServiceClient).ResetItemsEvent += MWeighterCsService_ResetItemsEvent;
}
private void MWeighterCsService_ResetItemsEvent()
{
//把多出来的删除
int remove_cnt = setPlan_items.Count() - weightSystemService.Items.Count();
if (remove_cnt > 0)
{
for (int i = 0; i < remove_cnt; i++)
{
SetPLCUpdatePlan plan = setPlan_items[setPlan_items.Count() - 1 - i];
plan.Dispose();
}
setPlan_items.RemoveRange(setPlan_items.Count() - remove_cnt, remove_cnt);
}
else
{
int start_idx = setPlan_items.Count();
int add_cnt = -remove_cnt;
for (int i = 0; i < add_cnt; i++)
{
SetPLCUpdatePlan plan = new SetPLCUpdatePlan(
weightSystemService.PLCos,
weightSystemService.Items[start_idx + i],
item_update_propertynames);
setPlan_items.Add(plan);
}
}
}
string[] item_update_propertynames = new string[] {
"CurrentFlow",
};
private void button_ratio_Click(object sender, RoutedEventArgs e)
{
WdRatioSet w = new WdRatioSet();
w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
w.Init(weightSystemService);
w.ShowDialog();
}
private void button_aclear_Click(object sender, RoutedEventArgs e)
{
if (weightSystemService.ItemsCnt > 0)
{
weightSystemService.Accessory.AClear = true;
FLY.ControlLibrary.Window_Tip.Show("", "清空成功", TimeSpan.FromSeconds(2));
}
}
private void button_bclear_Click(object sender, RoutedEventArgs e)
{
if (weightSystemService.ItemsCnt > 0)
{
weightSystemService.Accessory.BClear = true;
FLY.ControlLibrary.Window_Tip.Show("", "清空成功", TimeSpan.FromSeconds(2));
}
}
}
public class UiModule2_UcTotalFlow : IUiModule2
{
/// <summary>
/// 控件标题
/// 它的值取决于culture
/// </summary>
public string Title => "单组分称重总流量";
public ComponentType Type => ComponentType.Graph;
public bool IsUnique => true;
/// <summary>
/// 控件
/// 创建时,需要给它唯一ID,让加载自己的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public FrameworkElement GetComponent(int id, IUnityContainer container)
{
UcTotalFlow graph = new UcTotalFlow();
container.BuildUp(graph);
return graph;
}
/// <summary>
/// 控件缩略图,用于编辑界面时,大致看看
/// 创建时,需要给它唯一ID,让加载自己的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public FrameworkElement GetThumbnail()
{
return new System.Windows.Controls.Grid();
}
/// <summary>
/// 给出全部控件ID, 控件自行删除没有的参数
/// </summary>
/// <param name="IDs"></param>
public void MatchParam(int[] IDs)
{
}
}
}
<UserControl x:Class="FLY.Weight2.UI.Client.UiModule.UcWeighterItem"
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.Weight2.UI.Client.UiModule"
xmlns:flyctrl="clr-namespace:FLY.ControlLibrary;assembly=FLY.ControlLibrary"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
d:DesignHeight="400" >
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.Weight2.UI.Client;component/Themes/UcWeighterItemStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Border Style="{StaticResource BorderStyle_block}" d:DataContext="{StaticResource unittests_weighters}">
<Viewbox Margin="{StaticResource ControlMargin}" d:DataContext="{Binding Items[4]}" HorizontalAlignment="Left" VerticalAlignment="Top">
<StackPanel >
<Border Background="{Binding Color}" Margin="2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid Width="50" >
<TextBlock Text="{Binding Number}" FontSize="100" FontWeight="Bold" Foreground="{StaticResource Color_background}" VerticalAlignment="Top" HorizontalAlignment="Right" FontFamily="Arial" Margin="0,-20,0,0"/>
</Grid>
<StackPanel Margin="3" Grid.Column="1" >
<StackPanel Orientation="Horizontal">
<TextBlock Text="当前产量" Style="{StaticResource TextBlockStyle_title}" Margin="3,0" />
<TextBlock >
<Run Text="{Binding CurrentFlowAuto,StringFormat={}{0:F0}}" Style="{StaticResource RunStyle_text}" FontSize="30" />
<Run Text="kg" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</StackPanel>
<Viewbox Width="200" Height="80" HorizontalAlignment="Left">
<TextBlock >
<Run Text="{Binding CurrentFlow,StringFormat={}{0:F1}}" Style="{StaticResource RunStyle_text}" FontSize="60" />
<Run Text="kg/h" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</Viewbox>
</StackPanel>
</Grid>
</Border>
<Border x:Name="border_p" Background="{StaticResource Color_background2}" Height="30" Margin="2">
<Rectangle HorizontalAlignment="Left" Fill="{Binding Color}">
<Rectangle.Width>
<MultiBinding Converter="{StaticResource ratioconv}" Mode="OneWay">
<Binding Path="ScrewPDisp" />
<Binding Source="{StaticResource d100}" />
<Binding Path="ActualWidth" ElementName="border_p"/>
</MultiBinding>
</Rectangle.Width>
</Rectangle>
</Border>
<Button Grid.Row="1" Grid.Column="1" Margin="3" Style="{StaticResource ButtonStyle_empty}" Click="button_ratio_Click" Tag="{Binding .}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<StackPanel Margin="3">
<TextBlock Text="当前比例" Style="{StaticResource TextBlockStyle_title}"/>
<TextBlock>
<Run Text="{Binding ScrewPDisp,StringFormat={}{0:F1}}" Style="{StaticResource RunStyle_text}" FontSize="60" />
<Run Text="%" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</StackPanel>
<StackPanel Grid.Column="1" Margin="3">
<TextBlock Text="设置比例" Style="{StaticResource TextBlockStyle_title_activity}"/>
<TextBlock >
<Run Text="{Binding ScrewPDispAuto,StringFormat={}{0:F1}}" Style="{StaticResource RunStyle_text_activity}"/>
<Run Text="%" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</StackPanel>
</Grid>
</Button>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<StackPanel Margin="3" Grid.Row="2" >
<TextBlock Text="当前重量" Style="{StaticResource TextBlockStyle_title}"/>
<TextBlock >
<Run Text="{Binding BinWeight,StringFormat={}{0:F3}}" Style="{StaticResource RunStyle_text}" />
<Run Text="kg" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</StackPanel>
<StackPanel Grid.Row="3" >
<Button Style="{StaticResource ButtonStyle_empty}" Background="Transparent" Click="button_frequency_Click"
Tag="{Binding .}"
>
<StackPanel Margin="3" >
<TextBlock Text="电机频率" Style="{StaticResource TextBlockStyle_title_activity}"/>
<TextBlock >
<Run Text="{Binding ScrewMotorFreq,StringFormat={}{0:F1}}" Style="{StaticResource RunStyle_text_activity}" />
<Run Text="Hz" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</StackPanel>
</Button>
</StackPanel>
<StackPanel Grid.Row="3" Grid.Column="1" >
<StackPanel Margin="3" Grid.Row="4" VerticalAlignment="Center" >
<TextBlock Text="螺杆操作" Style="{StaticResource TextBlockStyle_title_activity}"/>
<flyctrl:NoToggleButton
IsChecked="{Binding ScrewMotorIsOn}"
OffLabel="关闭" OffBrush="#e44c65"
OnLabel="启动" OnBrush="#10a8a9"
>
<i:Interaction.Behaviors>
<flyctrl:ResetBehavior Binding="{Binding ScrewMotorOnSet}"/>
</i:Interaction.Behaviors>
</flyctrl:NoToggleButton>
</StackPanel>
<StackPanel Margin="3" Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" Visibility="{Binding IsChecked,Converter={StaticResource ResourceKey=visbilityconv},ConverterParameter=Hidden, ElementName=togglebutton_screw}">
<TextBlock Text="螺杆模式" Style="{StaticResource TextBlockStyle_title_activity}"/>
<flyctrl:ToggleButtonOnOff
IsChecked="{Binding ScrewIsAutoMode}"
OffLabel="手动" OffBrush="#e44c65"
OnLabel="自动" OnBrush="#10a8a9"/>
</StackPanel>
</StackPanel>
</Grid>
</StackPanel>
</Viewbox>
</Border>
</UserControl>
using FLY.OBJComponents.Client;
using FLY.Weight2.Client;
using FLY.Weight2.IService;
using MultiLayout.UiModule;
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;
using Unity;
namespace FLY.Weight2.UI.Client.UiModule
{
/// <summary>
/// UcWeighterItem.xaml 的交互逻辑
/// </summary>
public partial class UcWeighterItem : UserControl
{
public IWeightSystemService WeightSystemService
{
get { return (IWeightSystemService)GetValue(WeightSystemServiceProperty); }
set { SetValue(WeightSystemServiceProperty, value); }
}
// Using a DependencyProperty as the backing store for WeightSystemService. This enables animation, styling, binding, etc...
public static readonly DependencyProperty WeightSystemServiceProperty =
DependencyProperty.Register("WeightSystemService", typeof(IWeightSystemService), typeof(UcWeighterItem), new PropertyMetadata(null));
List<SetPLCUpdatePlan> setPlan_items = new List<SetPLCUpdatePlan>();
int Index = 0;
public UcWeighterItem()
{
InitializeComponent();
}
[InjectionMethod]
public void Init(
int id,
IWeightSystemService weightSystemService)
{
this.WeightSystemService = weightSystemService;
//查找参数
if (WeighterItemParams.Current.Indexs.ContainsKey(id))
{
Index = WeighterItemParams.Current.Indexs[id];
}
else
{
for (int i = 0; i < this.WeightSystemService.Items.Count(); i++)
{
if (!WeighterItemParams.Current.Indexs.ContainsValue(i))
{
WeighterItemParams.Current.Indexs.Add(id, i);
Index = i;
break;
}
}
}
int idx = Index;
if (idx >= this.WeightSystemService.Items.Count())
idx = this.WeightSystemService.Items.Count() - 1;
else if (idx < 0)
idx = 0;
this.DataContext = this.WeightSystemService.Items[idx];
for (int i = 0; i < this.WeightSystemService.Items.Count(); i++)
{
SetPLCUpdatePlan plan = new SetPLCUpdatePlan(
this.WeightSystemService.PLCos,
this.WeightSystemService.Items[i],
item_update_propertynames);
setPlan_items.Add(plan);
}
if (weightSystemService is WeightSystemServiceClient)
(weightSystemService as WeightSystemServiceClient).ResetItemsEvent += MWeighterCsService_ResetItemsEvent;
}
private void MWeighterCsService_ResetItemsEvent()
{
//把多出来的删除
int remove_cnt = setPlan_items.Count() - WeightSystemService.Items.Count();
if (remove_cnt > 0)
{
for (int i = 0; i < remove_cnt; i++)
{
SetPLCUpdatePlan plan = setPlan_items[setPlan_items.Count() - 1 - i];
plan.Dispose();
}
setPlan_items.RemoveRange(setPlan_items.Count() - remove_cnt, remove_cnt);
}
else
{
int start_idx = setPlan_items.Count();
int add_cnt = -remove_cnt;
for (int i = 0; i < add_cnt; i++)
{
SetPLCUpdatePlan plan = new SetPLCUpdatePlan(
WeightSystemService.PLCos,
WeightSystemService.Items[start_idx + i],
item_update_propertynames);
setPlan_items.Add(plan);
}
}
}
public static string[] item_update_propertynames = new string[] {
"CurrentFlow",
"ScrewPDisp",
"CurrentFlowAuto",
"ScrewPDispAuto",
"BinWeight",
"ScrewMotorFreq",
"ScrewManualFreq",
"ScrewManualFreqIsSet",
"ScrewIsAutoMode",
"ScrewMotorIsOn",
"ScrewMotorOnSet"
};
private async void button_frequency_Click(object sender, RoutedEventArgs e)
{
WdFrequency w = new WdFrequency();
var weight = ((Button)sender).Tag as FLY.Weight2.Common.WeighterC;
w.FrequencySet = weight.ScrewManualFreq;
w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
if (w.ShowDialog() == true)
{
//TODO
weight.ScrewManualFreq = (float)w.FrequencySet;
weight.ScrewManualFreqIsSet = true;
//不用写下降沿!!!!!
}
}
private void button_ratio_Click(object sender, RoutedEventArgs e)
{
WdRatioSet w = new WdRatioSet();
w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
w.Init(WeightSystemService);
w.ShowDialog();
}
}
/// <summary>
/// 全部扫描图的参数
/// </summary>
public class WeighterItemParams
{
public Dictionary<int, int> Indexs = new Dictionary<int, int>();
public WeighterItemParams()
{
}
public static WeighterItemParams Current { get; } = new WeighterItemParams();
}
public class UiModule2_UcWeighterItem : MultiLayout.UiModule.IUiModule2
{
/// <summary>
/// 控件标题
/// 它的值取决于culture
/// </summary>
public string Title => "单组份称重层控制";
public ComponentType Type => ComponentType.Graph;
public bool IsUnique => false;
/// <summary>
/// 控件
/// 创建时,需要给它唯一ID,让加载自己的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public FrameworkElement GetComponent(int id, IUnityContainer container)
{
UcWeighterItem graph = new UcWeighterItem();
container.BuildUp(graph);
return graph;
}
/// <summary>
/// 控件缩略图,用于编辑界面时,大致看看
/// 创建时,需要给它唯一ID,让加载自己的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public FrameworkElement GetThumbnail()
{
return new System.Windows.Controls.Grid();
}
/// <summary>
/// 给出全部控件ID, 控件自行删除没有的参数
/// </summary>
/// <param name="IDs"></param>
public void MatchParam(int[] IDs)
{
}
}
}
<flyctrllib:WindowBigClose x:Class="FLY.Weight2.UI.Client.UiModule.WdGraphSet"
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.Weight2.UI.Client.UiModule"
mc:Ignorable="d"
Title="Window_GraphSet" WindowStartupLocation="CenterScreen" SizeToContent="WidthAndHeight" >
<flyctrllib:WindowBigClose.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Converter/Dictionary_MyConv.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</flyctrllib:WindowBigClose.Resources>
<StackPanel Orientation="Vertical" Margin="5">
<StackPanel x:Name="stackpanel_sys" Orientation="Horizontal" >
<StackPanel Orientation="Vertical" Margin="5,20">
<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>
<StackPanel x:Name="stackpanel_show" Orientation="Vertical">
<StackPanel 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 WindowSize}"/>
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" Text="个" />
</StackPanel>
</StackPanel>
<StackPanel Orientation="Vertical" Margin="5">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="自动Y轴" />
<ToggleButton x:Name="togglebutton_autoy" Style="{StaticResource ToggleButtonStyle1}" IsChecked="{Binding IsAxisYRangeAuto}"/>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" Visibility="{Binding IsChecked,ElementName=togglebutton_autoy,Converter={StaticResource visbilityconv}, ConverterParameter=CollapsedWhenTrue}">
<StackPanel Orientation="Vertical" Margin="5" >
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="Y轴范围" />
<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="kg/h" />
</StackPanel>
</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 FLY.ControlLibrary;
using FLY.Weight2.IService;
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;
using Unity;
namespace FLY.Weight2.UI.Client.UiModule
{
/// <summary>
/// Window_GraphSet.xaml 的交互逻辑
/// </summary>
public partial class WdGraphSet : WindowBigClose
{
IWeightSystemService weightSystemService;
public WdGraphSet()
{
InitializeComponent();
}
[InjectionMethod]
public void Init(IWeightSystemService weightSystemService)
{
this.weightSystemService = weightSystemService;
stackpanel_show.DataContext = FlowGraphParams.Current;
stackpanel_sys.DataContext = weightSystemService;
}
private void button_ok_Click(object sender, RoutedEventArgs e)
{
FlowGraphParams.Current.Save();
this.DialogResult = true;
this.Close();
}
}
}
using FLY.Weight2.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.Weight2.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<FlowGraphVm_Item> Items { get; set; }
public UnitTests_FlowGraphModelView()
{
Items = new List<FlowGraphVm_Item>();
Items.Add(new FlowGraphVm_Item() { Title = "A", Value=103.1, Visibility = Visibility.Hidden });
Items.Add(new FlowGraphVm_Item() { Title = "B", Value = 10, Visibility = Visibility.Visible });
Items.Add(new FlowGraphVm_Item() { Title = "C", Value = 23, Visibility = Visibility.Hidden });
Items.Add(new FlowGraphVm_Item() { Title = "D", Value = 46.7, Visibility = Visibility.Hidden });
Items.Add(new FlowGraphVm_Item() { Title = "E", Value = 80, Visibility = Visibility.Hidden });
foreach (FlowGraphVm_Item s in Items)
{
s.Fill = WeighterColorDB.GetSelf(s.Title);
}
}
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.Weight2.UI.Client.UnitTests">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.Weight2.UI.Client;component/Themes/Dictionary_CellColor.xaml"/>
</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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using FLY.Weight2.Common;
using System.Collections.ObjectModel;
namespace FLY.Weight2.UI.Client.UnitTests
{
public class WeighterCsService
{
/// <summary>
/// 称重其它附件
/// </summary>
public WeighterAccessory Accessory { get; } = new WeighterAccessory();
/// <summary>
/// 各层称重
/// </summary>
public ObservableCollection<WeighterC> Items { get; } = new ObservableCollection<WeighterC>();
}
public class UnitTests_Weights : WeighterCsService
{
public UnitTests_Weights()
{
Items.Add(new FLY.Weight2.Common.WeighterC("A")
{
CurrentFlow = 150,
BinWeight = 5,
});
Items.Add(new FLY.Weight2.Common.WeighterC("B")
{
CurrentFlow = 100,
BinWeight = 4.3f,
});
Items.Add(new FLY.Weight2.Common.WeighterC("C")
{
CurrentFlow = 50,
BinWeight = 5.1f,
});
Items.Add(new FLY.Weight2.Common.WeighterC("D")
{
CurrentFlow = 10,
BinWeight = 1.23f,
});
Items.Add(new FLY.Weight2.Common.WeighterC("E")
{
CurrentFlow = 10,
BinWeight = 1.42f,
});
foreach (FLY.Weight2.Common.WeighterC w in Items) {
w.Color = WeighterColorDB.GetSelf(w.Number);
}
Accessory.TotalFlow = (UInt16)Items.Sum((w) => { return w.CurrentFlow; });
Accessory.TotalFlowSetIn = Accessory.TotalFlow;
Accessory.TotalFlowSetOut = Accessory.TotalFlow;
foreach (FLY.Weight2.Common.WeighterC w in Items) {
w.ScrewPDisp = (UInt16)(w.CurrentFlow * 100 / Accessory.TotalFlow);
}
Accessory.WheelPerimeter = 378;
Accessory.WheelPulse = 3000;
Accessory.Density = 1;
Accessory.RimCharge = 30;
Accessory.Thickness = 80;
Accessory.CurrentVelocity = 50.3f;
Accessory.TotalFilmWidth = 2134;
Accessory.RimWidth = 20;
Accessory.ActFilmWidth = Accessory.TotalFilmWidth - Accessory.RimWidth * 2;
Accessory.SetThickness = 79;
Accessory.TargetVelocity = 50.1f;
Accessory.ACurrentLen = 200;
Accessory.ACurrent = 200;
Accessory.ALast = 230;
Accessory.BCurrentLen = 300;
Accessory.BLast = 290;
}
}
}
<flyctrllib:WindowBigClose x:Class="FLY.Weight2.UI.Client.WdFrequency"
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.Weight2.UI.Client"
mc:Ignorable="d"
Title="Window_Frequency" WindowStartupLocation="CenterScreen" d:DesignWidth="334.492" d:DesignHeight="318.246" >
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.Weight2.UI.Client;component/Themes/UcWeighterItemStyle.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>
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Column="1">
<StackPanel Orientation="Vertical" Margin="5">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="手动频率" />
<StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding FrequencySet, StringFormat={}{0:F1}}"/>
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" Text="Hz" />
</StackPanel>
</StackPanel>
<Button Style="{StaticResource ButtonStyle_empty}" Background="Transparent" Click="button_minus_Click" Margin="5">
<Path Data="{StaticResource Geometry_minus-circle}" Fill="{StaticResource Color_theme_activity}" Stretch="Fill" Height="80" Width="80" />
</Button>
<Button Style="{StaticResource ButtonStyle_empty}" Background="Transparent" Click="button_plus_Click" Margin="5">
<Path Data="{StaticResource Geometry_plus-circle}" Fill="{StaticResource Color_theme_activity}" Stretch="Fill" Height="80" Width="80" />
</Button>
</StackPanel>
</Grid>
<Button Style="{StaticResource ButtonStyle2}" Content="确定" Width="auto" Margin="5" Click="button_ok_Click" />
</StackPanel>
</flyctrllib:WindowBigClose>
using System;
using System.Collections.Generic;
using System.ComponentModel;
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.Shapes;
namespace FLY.Weight2.UI.Client
{
/// <summary>
/// Window_Frequency.xaml 的交互逻辑
/// </summary>
public partial class WdFrequency : FLY.ControlLibrary.WindowBigClose,INotifyPropertyChanged
{
public double FrequencySet { get; set; } = 0;
public WdFrequency()
{
InitializeComponent();
this.DataContext = this;
}
private void button_minus_Click(object sender, RoutedEventArgs e)
{
if (FrequencySet >= 0.1)
{
FrequencySet -= 0.1;
}
}
private void button_plus_Click(object sender, RoutedEventArgs e)
{
if(FrequencySet<100)
FrequencySet += 0.1;
}
private void button_ok_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = true;
this.Close();
}
public event PropertyChangedEventHandler PropertyChanged;
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
using FLY.Weight2.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FLY.Weight2.UI.Client
{
public class WeightSystemServiceClientWithColor : WeightSystemServiceClient
{
public WeightSystemServiceClientWithColor(UInt32 serviceId, string connName) : base(serviceId, connName) {
//-------------------------------------------------------
//添加颜色
this.ResetItemsEvent += WeightSystemServiceClientWithColor_ResetItemsEvent;
WeightSystemServiceClientWithColor_ResetItemsEvent();
}
private void WeightSystemServiceClientWithColor_ResetItemsEvent()
{
foreach (FLY.Weight2.Common.WeighterC w in Items)
{
w.Color = WeighterColorDB.GetSelf(w.Number);
}
}
}
}
This diff is collapsed.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
\ No newline at end of file
<Application x:Class="FLY.Weight2.UI.Server.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:FLY.Weight2.UI.Server"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Project.FLY.Weight2/FLY.Weight2.UI.Server/hourglass.ico

66.1 KB

This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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