Browse Source

冲突解决

样式分支
taoye 2 years ago
parent
commit
89729ab572
33 changed files with 1465 additions and 210 deletions
  1. +1
    -0
      BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
  2. +76
    -0
      BPASmartClient.CustomResource/Converters/ToastIconConverter.cs
  3. BIN
     
  4. +27
    -0
      BPASmartClient.CustomResource/Pages/Model/TextToImage.cs
  5. +2
    -1
      BPASmartClient.CustomResource/Pages/View/LoginView.xaml.cs
  6. +0
    -20
      BPASmartClient.CustomResource/Pages/View/MainView.xaml.cs
  7. +1
    -1
      BPASmartClient.CustomResource/Themes/Generic.xaml
  8. +116
    -79
      BPASmartClient.CustomResource/Themes/MyStyle.xaml
  9. +18
    -32
      BPASmartClient.CustomResource/UserControls/Bottle.xaml
  10. +39
    -1
      BPASmartClient.CustomResource/UserControls/Bottle.xaml.cs
  11. +1
    -1
      BPASmartClient.CustomResource/UserControls/DosingSystem.xaml
  12. +17
    -0
      BPASmartClient.CustomResource/UserControls/Enum/ToastIcons.cs
  13. +31
    -0
      BPASmartClient.CustomResource/UserControls/Enum/ToastLocation.cs
  14. +27
    -27
      BPASmartClient.CustomResource/UserControls/IcoButton.cs
  15. +39
    -0
      BPASmartClient.CustomResource/UserControls/Model/ToastOptions.cs
  16. +47
    -7
      BPASmartClient.CustomResource/UserControls/MotorBottle.xaml
  17. +41
    -0
      BPASmartClient.CustomResource/UserControls/MotorBottle.xaml.cs
  18. +68
    -0
      BPASmartClient.CustomResource/UserControls/Toast.xaml
  19. +480
    -0
      BPASmartClient.CustomResource/UserControls/Toast.xaml.cs
  20. +4
    -4
      BPASmartClient/App.config
  21. +3
    -2
      DosingSystem/App.xaml.cs
  22. +27
    -0
      DosingSystem/Model/DeviceCurrentStatus.cs
  23. +8
    -0
      DosingSystem/View/DeviceListView.xaml
  24. +86
    -6
      DosingSystem/View/HardwareStatusView.xaml
  25. +4
    -2
      DosingSystem/View/NewRecipeView.xaml
  26. +78
    -5
      DosingSystem/View/RecipeControlView.xaml
  27. +158
    -4
      DosingSystem/View/RecipeSettingsView.xaml
  28. +20
    -0
      DosingSystem/View/RecipeSettingsView.xaml.cs
  29. +16
    -0
      DosingSystem/ViewModel/HardwareStatusViewModel.cs
  30. +13
    -13
      DosingSystem/ViewModel/NewRecipeViewModel.cs
  31. +3
    -1
      DosingSystem/ViewModel/RecipeControlViewModel.cs
  32. +13
    -4
      DosingSystem/ViewModel/RecipeSettingsViewModel.cs
  33. +1
    -0
      SmartClient.sln

+ 1
- 0
BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj View File

@@ -292,6 +292,7 @@

<ItemGroup>
<PackageReference Include="BPA.Message" Version="1.0.46" />
<PackageReference Include="MahApps.Metro.IconPacks.FontAwesome" Version="4.11.0" />
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" />
</ItemGroup>



+ 76
- 0
BPASmartClient.CustomResource/Converters/ToastIconConverter.cs View File

@@ -0,0 +1,76 @@
using BPASmartClient.CustomResource.UserControls.Enum;
using MahApps.Metro.IconPacks;
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;

namespace BPASmartClient.CustomResource.Converters
{
public class ToastIconConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
object value = values[0];
object grid = values[1];
object txt = values[2];
Grid _grid = grid as Grid;
TextBlock _txt = txt as TextBlock;

void WithoutIcon()
{
if (_grid != null)
{
_grid.ColumnDefinitions.RemoveAt(0);
}

if (_txt != null)
{
_txt.HorizontalAlignment = HorizontalAlignment.Center;
}
}

if (value == null)
{
WithoutIcon();
return PackIconFontAwesomeKind.None;
}

ToastIcons _value;
try
{
_value = (ToastIcons)value;
}
catch
{
WithoutIcon();
return PackIconFontAwesomeKind.None;
}

switch (_value)
{
case ToastIcons.Information:
return PackIconFontAwesomeKind.CheckCircleSolid;
case ToastIcons.Error:
return PackIconFontAwesomeKind.TimesSolid;
case ToastIcons.Warning:
return PackIconFontAwesomeKind.ExclamationSolid;
case ToastIcons.Busy:
return PackIconFontAwesomeKind.ClockSolid;
}

WithoutIcon();
return PackIconFontAwesomeKind.None;
}

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

BIN
View File


+ 27
- 0
BPASmartClient.CustomResource/Pages/Model/TextToImage.cs View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.CustomResource.Pages.Model
{
internal class TextToImage
{
public Image CreateTextImage(string text, Font font, Color backgroundColor, Color foreColor, int margin = 5, RotateFlipType rotate = RotateFlipType.RotateNoneFlipNone)
{
SizeF sizeF = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(text, font);
Bitmap bitmap = new Bitmap((int)sizeF.Width + margin * 2, (int)sizeF.Height + margin * 2);
Graphics g = Graphics.FromImage(bitmap);
g = Graphics.FromImage(bitmap);
g.SmoothingMode = SmoothingMode.HighQuality;
g.FillRegion(new SolidBrush(backgroundColor), g.Clip);
g.DrawString(text, font, new SolidBrush(foreColor), margin, margin);
g.Dispose();
bitmap.RotateFlip(rotate);
return bitmap;
}
}
}

+ 2
- 1
BPASmartClient.CustomResource/Pages/View/LoginView.xaml.cs View File

@@ -27,7 +27,7 @@ namespace BPASmartClient.CustomResource.Pages.View
{
InitializeComponent();
grid.Visibility = Visibility.Collapsed;
Username.Focus();
Username.SelectionStart = Username.Text.Trim().Length;
this.Loaded += LoginView_Loaded;
ActionManage.GetInstance.Register(new Action(() => { this.DialogResult = true; this.Close(); }), "LoginOk", true);
@@ -52,6 +52,7 @@ namespace BPASmartClient.CustomResource.Pages.View
private void Player_MediaOpened(object sender, RoutedEventArgs e)
{
grid.Visibility = Visibility.Visible;
Username.Focus();
}

private void media_Loaded(object sender, RoutedEventArgs e)


+ 0
- 20
BPASmartClient.CustomResource/Pages/View/MainView.xaml.cs View File

@@ -40,25 +40,5 @@ namespace BPASmartClient.CustomResource.Pages.View
};
}

private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
double num = Math.Abs((int)(e.Delta / 2));
double offset = 0.0;
if (e.Delta < 0)
{
offset = Math.Max((double)0.0, (double)(this.scroll.VerticalOffset - num));
}
else
{
offset = Math.Min(this.scroll.ScrollableHeight, this.scroll.VerticalOffset + num);
}
if (offset != this.scroll.VerticalOffset)
{
this.scroll.ScrollToVerticalOffset(offset);
e.Handled = true;
}

}
}
}

+ 1
- 1
BPASmartClient.CustomResource/Themes/Generic.xaml View File

@@ -8,7 +8,7 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:IcoButton}">
<Grid Name="PART_gr">
<Grid Name="PART_gr" Background="{TemplateBinding Background}">
<Border
Name="PART_br"
Background="{TemplateBinding Background}"


+ 116
- 79
BPASmartClient.CustomResource/Themes/MyStyle.xaml View File

@@ -176,7 +176,7 @@
<Style.Setters>
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Source" Value="/BPASmartClient.CustomResource;component/Image/Cb_Checked.png" />
<Setter Property="Source" Value="/BPASmartClient.CustomResource;component/Image/Cb_Checked.png" />
</Style.Setters>
</Style>

@@ -184,10 +184,10 @@
<Style.Setters>
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Source" Value="/BPASmartClient.CustomResource;component/Image/AGV/墙.png" />
<Setter Property="Source" Value="/BPASmartClient.CustomResource;component/Image/AGV/墙.png" />
</Style.Setters>
</Style>
<Style TargetType="Image">
<Style.Setters>
<Setter Property="UseLayoutRounding" Value="True" />
@@ -373,17 +373,17 @@
<!--#region Border-->
<Style x:Key="border车" TargetType="Border">
<Style.Setters>
<Setter Property="Height" Value="80"/>
<Setter Property="Width" Value="80"/>
<Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
<Setter Property="RenderTransform" >
<Setter Property="Height" Value="80" />
<Setter Property="Width" Value="80" />
<Setter Property="RenderTransformOrigin" Value="0.5,0.5" />
<Setter Property="RenderTransform">
<Setter.Value>
<TransformGroup>
<ScaleTransform ScaleY="-0.6" ScaleX="0.8"/>
<SkewTransform AngleY="0"/>
<RotateTransform Angle="180"/>
<TranslateTransform X="1" Y="0.5"/>
</TransformGroup>
<ScaleTransform ScaleX="0.8" ScaleY="-0.6" />
<SkewTransform AngleY="0" />
<RotateTransform Angle="180" />
<TranslateTransform X="1" Y="0.5" />
</TransformGroup>
</Setter.Value>
</Setter>
<Setter Property="Background">
@@ -396,16 +396,16 @@

<Style x:Key="border停车位" TargetType="Border">
<Style.Setters>
<Setter Property="Height" Value="80"/>
<Setter Property="Width" Value="80"/>
<Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
<Setter Property="RenderTransform" >
<Setter Property="Height" Value="80" />
<Setter Property="Width" Value="80" />
<Setter Property="RenderTransformOrigin" Value="0.5,0.5" />
<Setter Property="RenderTransform">
<Setter.Value>
<TransformGroup>
<ScaleTransform/>
<SkewTransform AngleY="20"/>
<RotateTransform/>
<TranslateTransform/>
<ScaleTransform />
<SkewTransform AngleY="20" />
<RotateTransform />
<TranslateTransform />
</TransformGroup>
</Setter.Value>
</Setter>
@@ -419,23 +419,23 @@

<Style x:Key="border充电桩" TargetType="Border">
<Style.Setters>
<Setter Property="Height" Value="60"/>
<Setter Property="Width" Value="60"/>
<Setter Property="Margin" Value="0,20,0,0"/>
<Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
<Setter Property="RenderTransform" >
<Setter Property="Height" Value="60" />
<Setter Property="Width" Value="60" />
<Setter Property="Margin" Value="0,20,0,0" />
<Setter Property="RenderTransformOrigin" Value="0.5,0.5" />
<Setter Property="RenderTransform">
<Setter.Value>
<TransformGroup>
<ScaleTransform/>
<SkewTransform AngleY="20"/>
<RotateTransform/>
<TranslateTransform/>
<ScaleTransform />
<SkewTransform AngleY="20" />
<RotateTransform />
<TranslateTransform />
</TransformGroup>
</Setter.Value>
</Setter>
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/AGV/充电桩.png" />
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/AGV/充电桩.png" />
</Setter.Value>
</Setter>
</Style.Setters>
@@ -444,13 +444,13 @@

<Style x:Key="border炒锅" TargetType="Border">
<Style.Setters>
<Setter Property="Margin" Value="60,0,0,20"/>
<Setter Property="Height" Value="80"/>
<Setter Property="Width" Value="80"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Margin" Value="60,0,0,20" />
<Setter Property="Height" Value="80" />
<Setter Property="Width" Value="80" />
<Setter Property="VerticalAlignment" Value="Bottom" />
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/AGV/炒锅.png" />
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/AGV/炒锅.png" />
</Setter.Value>
</Setter>
</Style.Setters>
@@ -458,12 +458,12 @@

<Style x:Key="border炒锅2" TargetType="Border">
<Style.Setters>
<Setter Property="Height" Value="100"/>
<Setter Property="Width" Value="100"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Height" Value="100" />
<Setter Property="Width" Value="100" />
<Setter Property="VerticalAlignment" Value="Bottom" />
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/AGV/炒锅2.png" />
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/AGV/炒锅2.png" />
</Setter.Value>
</Setter>
</Style.Setters>
@@ -471,13 +471,13 @@

<Style x:Key="border碗" TargetType="Border">
<Style.Setters>
<Setter Property="Height" Value="80"/>
<Setter Property="Width" Value="40"/>
<Setter Property="Margin" Value="0,-20,0,-20"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Height" Value="80" />
<Setter Property="Width" Value="40" />
<Setter Property="Margin" Value="0,-20,0,-20" />
<Setter Property="VerticalAlignment" Value="Bottom" />
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/AGV/汤碗.png" />
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/AGV/汤碗.png" />
</Setter.Value>
</Setter>
</Style.Setters>
@@ -485,13 +485,13 @@

<Style x:Key="border菜" TargetType="Border">
<Style.Setters>
<Setter Property="Margin" Value="0,-17,0,0"/>
<Setter Property="Height" Value="30"/>
<Setter Property="Width" Value="35"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="Margin" Value="0,-17,0,0" />
<Setter Property="Height" Value="30" />
<Setter Property="Width" Value="35" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/AGV/蔬菜.png" />
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/AGV/蔬菜.png" />
</Setter.Value>
</Setter>
</Style.Setters>
@@ -501,7 +501,12 @@
<Style.Setters>
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/AGV/砖块.png" Viewport="0, 0, 1, 0.03" TileMode="FlipY" Stretch="UniformToFill" ViewportUnits="RelativeToBoundingBox" />
<ImageBrush
ImageSource="/BPASmartClient.CustomResource;component/Image/AGV/砖块.png"
Stretch="UniformToFill"
TileMode="FlipY"
Viewport="0, 0, 1, 0.03"
ViewportUnits="RelativeToBoundingBox" />
</Setter.Value>
</Setter>
</Style.Setters>
@@ -511,27 +516,42 @@
<Style.Setters>
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/AGV/砖块.png" Viewport="0, 0, 0.02, 1" TileMode="FlipY" Stretch="UniformToFill" ViewportUnits="RelativeToBoundingBox" />
<ImageBrush
ImageSource="/BPASmartClient.CustomResource;component/Image/AGV/砖块.png"
Stretch="UniformToFill"
TileMode="FlipY"
Viewport="0, 0, 0.02, 1"
ViewportUnits="RelativeToBoundingBox" />
</Setter.Value>
</Setter>
</Style.Setters>
</Style>
<Style x:Key="border垂直墙1" TargetType="Border">
<Style.Setters>
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/AGV/砖块.png" Viewport="0, 0, 1, 0.1" TileMode="FlipY" Stretch="UniformToFill" ViewportUnits="RelativeToBoundingBox" />
<ImageBrush
ImageSource="/BPASmartClient.CustomResource;component/Image/AGV/砖块.png"
Stretch="UniformToFill"
TileMode="FlipY"
Viewport="0, 0, 1, 0.1"
ViewportUnits="RelativeToBoundingBox" />
</Setter.Value>
</Setter>
</Style.Setters>
</Style>
<Style x:Key="border水平墙1" TargetType="Border">
<Style.Setters>
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/AGV/砖块.png" Viewport="0, 0, 0.1, 1" TileMode="FlipY" Stretch="UniformToFill" ViewportUnits="RelativeToBoundingBox" />
<ImageBrush
ImageSource="/BPASmartClient.CustomResource;component/Image/AGV/砖块.png"
Stretch="UniformToFill"
TileMode="FlipY"
Viewport="0, 0, 0.1, 1"
ViewportUnits="RelativeToBoundingBox" />
</Setter.Value>
</Setter>
</Style.Setters>
@@ -968,7 +988,7 @@
</Style.Setters>
</Style>
<!--#endregion-->
<!--#region Button-->
<Style x:Key="TitleBarStyle" TargetType="Button">
<Setter Property="Foreground" Value="White" />
@@ -1846,11 +1866,11 @@
<Style x:Key="80号字体样式" TargetType="TextBlock">
<Setter Property="FontSize" Value="16" />
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="FontFamily" Value="/BPASmartClient.CustomResource;Component/Fonts/#zihun80hao-mengquxiaoyuti"/>
<Setter Property="FontFamily" Value="/BPASmartClient.CustomResource;Component/Fonts/#zihun80hao-mengquxiaoyuti" />
<Setter Property="Foreground" Value="#FFFCD5B5" />
</Style>

<Style TargetType="TextBlock">
<Style.Setters>
@@ -1959,10 +1979,10 @@
</Setter>
</Style>
<!--#endregion-->
<!--#region dataGrid-->
<Style TargetType="DataGrid" x:Key="dataGrid_Style">
<!--网格线颜色-->
<Style x:Key="dataGrid_Style" TargetType="DataGrid">
<!-- 网格线颜色 -->
<Setter Property="CanUserResizeColumns" Value="false" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="#a2c2e8" />
@@ -1982,7 +2002,7 @@
<Style x:Key="DatagridRow_Style" TargetType="DataGridRow">
<Setter Property="Background" Value="#3afdff" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Height" Value="20"/>
<Setter Property="Height" Value="20" />
<Style.Triggers>
<!-- 隔行换色 -->
<Trigger Property="AlternationIndex" Value="0">
@@ -2003,9 +2023,9 @@
</Style.Triggers>
</Style>
<!--#endregion-->
<!--#region dataGridHeader-->
<Style TargetType="DataGridColumnHeader" x:Key="dataGridHeader_Style">
<!--#region dataGridHeader-->
<Style x:Key="dataGridHeader_Style" TargetType="DataGridColumnHeader">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="MinWidth" Value="0" />
<Setter Property="MinHeight" Value="30" />
@@ -2015,19 +2035,36 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridColumnHeader">
<Border x:Name="BackgroundBorder" BorderThickness="0,1,0,1"
BorderBrush="#e6dbba"
Width="Auto">
<Border
x:Name="BackgroundBorder"
Width="Auto"
BorderBrush="#e6dbba"
BorderThickness="0,1,0,1">
<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="0" 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" />
<ContentPresenter
Margin="0,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
<Path
x:Name="SortArrow"
Grid.Column="0"
Width="8"
Height="6"
Margin="0,0,50,0"
VerticalAlignment="Center"
Data="M0,0 L1,0 0.5,1 z"
Fill="White"
RenderTransformOrigin="1,1"
Stretch="Fill"
Visibility="Collapsed" />
<Rectangle
Grid.ColumnSpan="1"
Width="1"
HorizontalAlignment="Right"
Fill="#d6c79b" />
</Grid>
</Border>
</ControlTemplate>
@@ -2037,10 +2074,10 @@
</Style>
<!--#endregion-->
<!--#region dataGridCell-->
<Style TargetType="DataGridCell" x:Key="dataGridCell_Style">
<Setter Property="Height" Value="20"/>
<Setter Property="FontSize" Value="14"/>
<Style x:Key="dataGridCell_Style" TargetType="DataGridCell">
<Setter Property="Height" Value="20" />
<Setter Property="FontSize" Value="14" />
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="White" />


+ 18
- 32
BPASmartClient.CustomResource/UserControls/Bottle.xaml View File

@@ -8,21 +8,14 @@
d:DesignHeight="200"
d:DesignWidth="70"
mc:Ignorable="d">
<Border BorderThickness="0">
<Viewbox>
<Canvas Width="70" Height="200">

<Ellipse
Width="70"
Height="18"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Fill="#97e8f4"
StrokeThickness="0" />
<Border Name="mainBr" BorderThickness="0">
<Viewbox Width="auto" Height="auto">
<Canvas
Name="cv"
Width="{Binding ElementName=mainBr, Path=ActualWidth}"
Height="{Binding ElementName=mainBr, Path=ActualHeight}">
<Rectangle
Canvas.Top="10"
Width="70"
Height="160"
Name="r1"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Stroke="Black"
@@ -37,30 +30,20 @@
</Rectangle.Fill>
</Rectangle>
<Border
Canvas.Left="14"
Canvas.Top="188"
Width="42"
Height="12"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Name="bd"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
Background="DimGray"
BorderThickness="0" />
<Path
Canvas.Left="0.5"
Canvas.Top="172.334"
Width="69"
Height="15"
Name="pa"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Data="M0,167 L13.833,187.83301 56.201249,187.83301 70,167"
Fill="#FFD8D35B"
Stretch="Fill"
StrokeThickness="0" />
<Ellipse
Canvas.Left="-0.5"
Canvas.Top="161"
Width="71"
Height="18"
Name="e2"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Fill="#FFD8D35B"
@@ -68,14 +51,17 @@
StrokeThickness="0.5" />
<Rectangle
Name="refile"
Canvas.Bottom="30"
Width="70"
Height="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Fill="#FFD8D35B"
Stroke="Black"
StrokeThickness="0" />
<Ellipse
x:Name="e1"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Fill="#97e8f4"
StrokeThickness="0" />

</Canvas>
</Viewbox>


+ 39
- 1
BPASmartClient.CustomResource/UserControls/Bottle.xaml.cs View File

@@ -23,6 +23,44 @@ namespace BPASmartClient.CustomResource.UserControls
public Bottle()
{
InitializeComponent();
this.SizeChanged += Bottle_SizeChanged;
}

private void Bottle_SizeChanged(object sender, SizeChangedEventArgs e)
{
e1.Width = this.Width;
e1.Height = this.Height * 0.09;

r1.Width = this.Width;
r1.Height = this.Height * 0.8;
Canvas.SetTop(r1, e1.Height / 2);

bd.Width = this.Width * 0.6;
bd.Height = this.Height * 0.06;
Canvas.SetLeft(bd, (this.Width - bd.Width) / 2);
Canvas.SetBottom(bd, 0);

e2.Width = this.Width;
e2.Height = this.Height * 0.09;
Canvas.SetTop(e2, r1.Height);
Canvas.SetLeft(e2, 0);


PathGeometry geometry = new PathGeometry();
PathFigure pathFigure = new PathFigure();
pathFigure.StartPoint = new Point(0, r1.Height + (e1.Height / 2));
pathFigure.Segments.Add(new LineSegment(new Point(Canvas.GetLeft(bd), this.Height - bd.Height), true));
pathFigure.Segments.Add(new LineSegment(new Point(Canvas.GetLeft(bd) + bd.Width, this.Height - bd.Height), true));
pathFigure.Segments.Add(new LineSegment(new Point(this.Width, r1.Height + (e1.Height / 2)), true));
pathFigure.Segments.Add(new LineSegment(new Point(0, r1.Height + (e1.Height / 2)), true));
geometry.Figures.Add(pathFigure);
this.pa.Data = geometry;
Canvas.SetTop(this.pa, r1.Height + (e1.Height / 2));
Canvas.SetLeft(this.pa, 0);

refile.Width = this.Width;
Canvas.SetBottom(refile, this.Height - r1.Height - (e1.Height / 2));
Refresh();
}

private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
@@ -32,7 +70,7 @@ namespace BPASmartClient.CustomResource.UserControls

private void Refresh()
{
double height = LinearConvert(CurrentValue, 160F, 0F, 100F, 0F);
double height = LinearConvert(CurrentValue, r1.Height, 0F, 100F, 0F);
refile.Height = height;
}



+ 1
- 1
BPASmartClient.CustomResource/UserControls/DosingSystem.xaml View File

@@ -9,7 +9,7 @@
d:DesignWidth="500"
mc:Ignorable="d">

<Grid>
<Grid x:Name="gr">
<Viewbox>
<Canvas
Width="500"


+ 17
- 0
BPASmartClient.CustomResource/UserControls/Enum/ToastIcons.cs View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.CustomResource.UserControls.Enum
{
public enum ToastIcons
{
None,
Information,//CheckSolid
Error,//TimesSolid
Warning,//ExclamationSolid
Busy//ClockSolid
}
}

+ 31
- 0
BPASmartClient.CustomResource/UserControls/Enum/ToastLocation.cs View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.CustomResource.UserControls.Enum
{
public enum ToastLocation
{
OwnerCenter,
OwnerLeft,
OwnerRight,
OwnerTopLeft,
OwnerTopCenter,
OwnerTopRight,
OwnerBottomLeft,
OwnerBottomCenter,
OwnerBottomRight,
ScreenCenter,
ScreenLeft,
ScreenRight,
ScreenTopLeft,
ScreenTopCenter,
ScreenTopRight,
ScreenBottomLeft,
ScreenBottomCenter,
ScreenBottomRight,
Default//OwnerCenter
}
}

+ 27
- 27
BPASmartClient.CustomResource/UserControls/IcoButton.cs View File

@@ -44,7 +44,7 @@ namespace BPASmartClient.CustomResource.UserControls
/// <MyNamespace:IcoButton/>
///
/// </summary>
public class IcoButton : Control
public class IcoButton : Button
{
static IcoButton()
{
@@ -63,24 +63,24 @@ namespace BPASmartClient.CustomResource.UserControls
tempBackground = this.Background;
}

public Action Command
{
get { return (Action)GetValue(CommandProperty); }
set { SetValue(CommandProperty, value); }
}
public static readonly DependencyProperty CommandProperty =
DependencyProperty.Register("Command", typeof(Action), typeof(IcoButton),
new PropertyMetadata(default, new PropertyChangedCallback(OnPropertyChanged)));
//public Action Command
//{
// get { return (Action)GetValue(CommandProperty); }
// set { SetValue(CommandProperty, value); }
//}
//public static readonly DependencyProperty CommandProperty =
// DependencyProperty.Register("Command", typeof(Action), typeof(IcoButton),
// new PropertyMetadata(default, new PropertyChangedCallback(OnPropertyChanged)));


public Action<object> CommandObj
{
get { return (Action<object>)GetValue(CommandObjProperty); }
set { SetValue(CommandObjProperty, value); }
}
public static readonly DependencyProperty CommandObjProperty =
DependencyProperty.Register("CommandObj", typeof(Action<object>), typeof(IcoButton),
new PropertyMetadata(default, new PropertyChangedCallback(OnPropertyChanged)));
//public Action<object> CommandObj
//{
// get { return (Action<object>)GetValue(CommandObjProperty); }
// set { SetValue(CommandObjProperty, value); }
//}
//public static readonly DependencyProperty CommandObjProperty =
// DependencyProperty.Register("CommandObj", typeof(Action<object>), typeof(IcoButton),
// new PropertyMetadata(default, new PropertyChangedCallback(OnPropertyChanged)));


//public object CommandPar
@@ -94,14 +94,14 @@ namespace BPASmartClient.CustomResource.UserControls



public string Content
{
get { return (string)GetValue(ContentProperty); }
set { SetValue(ContentProperty, value); }
}
public static readonly DependencyProperty ContentProperty =
DependencyProperty.Register("Content", typeof(string), typeof(IcoButton),
new PropertyMetadata(string.Empty, new PropertyChangedCallback(OnPropertyChanged)));
//public string Content
//{
// get { return (string)GetValue(ContentProperty); }
// set { SetValue(ContentProperty, value); }
//}
//public static readonly DependencyProperty ContentProperty =
// DependencyProperty.Register("Content", typeof(string), typeof(IcoButton),
// new PropertyMetadata(string.Empty, new PropertyChangedCallback(OnPropertyChanged)));

public string IcoText
{
@@ -212,8 +212,8 @@ namespace BPASmartClient.CustomResource.UserControls

private void Gr_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (Command != null) Command();
this.Background = PressedBackground;
//Command?.Invoke();
//this.Background = PressedBackground;
}

}


+ 39
- 0
BPASmartClient.CustomResource/UserControls/Model/ToastOptions.cs View File

@@ -0,0 +1,39 @@
using BPASmartClient.CustomResource.UserControls.Enum;
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Threading;

namespace BPASmartClient.CustomResource.UserControls.Model
{
public class ToastOptions
{
public double ToastWidth { get; set; }
public double ToastHeight { get; set; }
public double TextWidth { get; set; }
public int Time { get; set; } = 2000;
public ToastIcons Icon { get; set; } = ToastIcons.None;
public ToastLocation Location { get; set; } = ToastLocation.Default;
public Brush Foreground { get; set; } = (Brush)new BrushConverter().ConvertFromString("#031D38");
public Brush IconForeground { get; set; } = (Brush)new BrushConverter().ConvertFromString("#00D91A");
public FontStyle FontStyle { get; set; } = SystemFonts.MessageFontStyle;
public FontStretch FontStretch { get; set; } = FontStretches.Normal;
public double FontSize { get; set; } = SystemFonts.MessageFontSize;
public FontFamily FontFamily { get; set; } = SystemFonts.MessageFontFamily;
public FontWeight FontWeight { get; set; } = SystemFonts.MenuFontWeight;
public double IconSize { get; set; } = 26;
public CornerRadius CornerRadius { get; set; } = new CornerRadius(5);
public Brush BorderBrush { get; set; } = (Brush)new BrushConverter().ConvertFromString("#CECECE");
public Thickness BorderThickness { get; set; } = new Thickness(0);
public Brush Background { get; set; } = (Brush)new BrushConverter().ConvertFromString("#FFFFFF");
public HorizontalAlignment HorizontalContentAlignment { get; set; } = HorizontalAlignment.Center;
public VerticalAlignment VerticalContentAlignment { get; set; } = VerticalAlignment.Center;
public EventHandler<EventArgs> Closed { get; internal set; }
public EventHandler<EventArgs> Click { get; internal set; }
public Thickness ToastMargin { get; set; } = new Thickness(2);
}
}

+ 47
- 7
BPASmartClient.CustomResource/UserControls/MotorBottle.xaml View File

@@ -8,20 +8,60 @@
d:DesignHeight="500"
d:DesignWidth="700"
mc:Ignorable="d">
<Grid>
<Viewbox>
<Grid Name="gr">
<Viewbox >
<Canvas Width="700" Height="500">
<local:Bottle
x:Name="bottle"
Canvas.Left="608"
Canvas.Top="-11"
Width="84"
Height="298" />
Height="257" HorizontalAlignment="Center" VerticalAlignment="Top" Canvas.Top="10" />
<local:DosingSystem
Height="336"
Margin="-75,202,-75,0"
VerticalAlignment="Top" />
Height="386"
Width="827"
VerticalAlignment="Center" Canvas.Left="-66" Canvas.Top="186" HorizontalAlignment="Left" />

<Ellipse
Name="ep"
Canvas.Left="630"
Canvas.Top="339"
Width="40"
Height="40"
Fill="Red" HorizontalAlignment="Center" VerticalAlignment="Top" />

</Canvas>
</Viewbox>

<VisualStateManager.VisualStateGroups>
<VisualStateGroup>

<VisualState Name="Start">
<Storyboard AutoReverse="True" x:Name="sb" RepeatBehavior="Forever">
<DoubleAnimation
Storyboard.TargetName="ep"
Storyboard.TargetProperty="Opacity"
From="0"
To="1"
Duration="0:0:1" />

<ColorAnimation Storyboard.TargetName="ep" Storyboard.TargetProperty="(Ellipse.Fill).(SolidColorBrush.Color)" From="Green" To="Green"/>
</Storyboard>
</VisualState>

<VisualState Name="Stop">
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="ep"
Storyboard.TargetProperty="Opacity"
To="1"
Duration="0:0:1" />
<ColorAnimation Storyboard.TargetName="ep" Storyboard.TargetProperty="(Ellipse.Fill).(SolidColorBrush.Color)" To="Red" From="Red"/>
</Storyboard>
</VisualState>



</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</UserControl>

+ 41
- 0
BPASmartClient.CustomResource/UserControls/MotorBottle.xaml.cs View File

@@ -24,5 +24,46 @@ namespace BPASmartClient.CustomResource.UserControls
{
InitializeComponent();
}

private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
(d as MotorBottle)?.Refresh();
}

private void Refresh()
{
bottle.CurrentValue = this.CurrentValue;
VisualStateManager.GoToState(this, IsRun ? "Start" : "Stop", false);
}


public bool IsRun
{
get { return (bool)GetValue(IsRunProperty); }
set { SetValue(IsRunProperty, value); }
}
public static readonly DependencyProperty IsRunProperty =
DependencyProperty.Register("IsRun", typeof(bool), typeof(MotorBottle),
new PropertyMetadata(false, new PropertyChangedCallback(OnPropertyChanged)));

//public bool IsRun
//{
// get { return (bool)GetValue(IsRunProperty); }
// set { SetValue(IsRunProperty, value); }
//}
//public static readonly DependencyProperty IsRunProperty =
// DependencyProperty.Register("IsRun", typeof(bool), typeof(MotorBottle),
// new PropertyMetadata(0, new PropertyChangedCallback(OnPropertyChanged)));


public double CurrentValue
{
get { return (double)GetValue(CurrentValueProperty); }
set { SetValue(CurrentValueProperty, value); }
}
public static readonly DependencyProperty CurrentValueProperty =
DependencyProperty.Register("CurrentValue", typeof(double), typeof(MotorBottle),
new PropertyMetadata(0.0, new PropertyChangedCallback(OnPropertyChanged)));

}
}

+ 68
- 0
BPASmartClient.CustomResource/UserControls/Toast.xaml View File

@@ -0,0 +1,68 @@
<UserControl
x:Class="BPASmartClient.CustomResource.UserControls.Toast"
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:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:local="clr-namespace:BPASmartClient.CustomResource.UserControls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:con="clr-namespace:BPASmartClient.CustomResource.Converters"
Width="Auto"
Height="Auto"
MinWidth="100"
MinHeight="50"
MaxWidth="1500"
MaxHeight="500"
d:DesignHeight="48"
d:DesignWidth="200"
Focusable="False"
MouseLeftButtonDown="UserControl_MouseLeftButtonDown"
mc:Ignorable="d">

<UserControl.Resources>
<con:ToastIconConverter x:Key="IconConverter"></con:ToastIconConverter>
</UserControl.Resources>

<Border CornerRadius="{Binding CornerRadius}"
BorderThickness="{Binding BorderThickness}"
Background="{Binding Background}"
BorderBrush="{Binding BorderBrush}"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="1">
<Border.Effect>
<DropShadowEffect Color="#D1D1D1" BlurRadius="10" ShadowDepth="0" Opacity="0.5" />
</Border.Effect>

<Grid x:Name="grid" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>

<iconPacks:PackIconFontAwesome x:Name="icon_toast" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10 0 0 0"
Foreground="{Binding IconForeground}"
Width="{Binding IconSize}"
Height="{Binding IconSize}">
<iconPacks:PackIconFontAwesome.Kind>
<MultiBinding Converter="{StaticResource IconConverter}">
<Binding Path="Icon"/>
<Binding ElementName="grid"/>
<Binding ElementName="txt_toast"/>
</MultiBinding>
</iconPacks:PackIconFontAwesome.Kind>
</iconPacks:PackIconFontAwesome>

<TextBlock x:Name="txt_toast" Grid.Column="2" Text="{Binding Message}"
MaxWidth="{Binding TextWidth}" Height="Auto" TextWrapping="Wrap"
Foreground="{Binding Foreground}"
FontStyle="{Binding FontStyle}"
FontStretch="{Binding FontStretch}"
FontSize="{Binding FontSize}"
FontFamily="{Binding FontFamily}"
FontWeight="{Binding FontWeight}"
VerticalAlignment="{Binding VerticalContentAlignment}"
HorizontalAlignment="{Binding HorizontalContentAlignment}" Padding="0 5 10 5">
</TextBlock>
</Grid>
</Border>
</UserControl>

+ 480
- 0
BPASmartClient.CustomResource/UserControls/Toast.xaml.cs View File

@@ -0,0 +1,480 @@
using BPASmartClient.CustomResource.UserControls.Enum;
using BPASmartClient.CustomResource.UserControls.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.Controls.Primitives;
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 System.Windows.Threading;

namespace BPASmartClient.CustomResource.UserControls
{
/// <summary>
/// Toast.xaml 的交互逻辑
/// </summary>
public partial class Toast : UserControl
{
private Window owner = null;
private Popup popup = null;
private DispatcherTimer timer = null;

private Toast()
{
InitializeComponent();
this.DataContext = this;
}

private Toast(Window owner, string message, ToastOptions options = null)
{
Message = message;
InitializeComponent();
if (options != null)
{
if (options.ToastWidth != 0) ToastWidth = options.ToastWidth;
if (options.ToastHeight != 0) ToastHeight = options.ToastHeight;
if (options.TextWidth != 0) TextWidth = options.TextWidth;

Icon = options.Icon;
Location = options.Location;
Time = options.Time;
Closed += options.Closed;
Click += options.Click;
Background = options.Background;
Foreground = options.Foreground;
FontStyle = options.FontStyle;
FontStretch = options.FontStretch;
FontSize = options.FontSize;
FontFamily = options.FontFamily;
FontWeight = options.FontWeight;
IconSize = options.IconSize;
BorderBrush = options.BorderBrush;
BorderThickness = options.BorderThickness;
HorizontalContentAlignment = options.HorizontalContentAlignment;
VerticalContentAlignment = options.VerticalContentAlignment;
CornerRadius = options.CornerRadius;
ToastMargin = options.ToastMargin;
IconForeground = options.IconForeground;
}
this.DataContext = this;
if (owner == null)
{
this.owner = Application.Current.MainWindow;
}
else
{
this.owner = owner;
}
this.owner.Closed += Owner_Closed;
}

private void Owner_Closed(object sender, EventArgs e)
{
this.Close();
}

public static void Show(string msg, ToastOptions options = null)
{
var toast = new Toast(null, msg, options);
int time = toast.Time;
ShowToast(toast, time);
}

public static void Show(Window owner, string msg, ToastOptions options = null)
{
var toast = new Toast(owner, msg, options);
int time = toast.Time;
ShowToast(toast, time);
}

private static void ShowToast(Toast toast, int time)
{
toast.popup = null;
Application.Current.Dispatcher.Invoke(new Action(() =>
{
toast.popup = new Popup
{
PopupAnimation = PopupAnimation.Fade,
AllowsTransparency = true,
StaysOpen = true,
Placement = PlacementMode.Left,
IsOpen = false,
Child = toast,
MinWidth = toast.MinWidth,
MaxWidth = toast.MaxWidth,
MinHeight = toast.MinHeight,
MaxHeight = toast.MaxHeight,
};

if (toast.ToastWidth != 0)
{
toast.popup.Width = toast.ToastWidth;
}

if (toast.ToastHeight != 0)
{
toast.popup.Height = toast.ToastHeight;
}

toast.popup.PlacementTarget = GetPopupPlacementTarget(toast); //为 null 则 Popup 定位相对于屏幕的左上角;
toast.owner.LocationChanged += toast.UpdatePosition;
toast.owner.SizeChanged += toast.UpdatePosition;
toast.popup.Closed += Popup_Closed;

//SetPopupOffset(toast.popup, toast);
//toast.UpdatePosition(toast, null);
toast.popup.IsOpen = true; //先显示出来以确定宽高;
SetPopupOffset(toast.popup, toast);
//toast.UpdatePosition(toast, null);
toast.popup.IsOpen = false; //先关闭再打开来刷新定位;
toast.popup.IsOpen = true;
}));
toast.timer = new DispatcherTimer();
toast.timer.Tick += (sender, e) =>
{
toast.popup.IsOpen = false;
toast.owner.LocationChanged -= toast.UpdatePosition;
toast.owner.SizeChanged -= toast.UpdatePosition;
};
toast.timer.Interval = new TimeSpan(0, 0, 0, 0, time);
toast.timer.Start();
}

private void UpdatePosition(object sender, EventArgs e)
{
var up = typeof(Popup).GetMethod("UpdatePosition", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
if (up == null || popup == null)
{
return;
}
SetPopupOffset(popup, this);
up.Invoke(popup, null);
}

private static void Popup_Closed(object sender, EventArgs e)
{
Popup popup = sender as Popup;
if (popup == null)
{
return;
}
Toast toast = popup.Child as Toast;
if (toast == null)
{
return;
}
toast.RaiseClosed(e);
}

private void UserControl_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (e.ClickCount == 1)
{
RaiseClick(e);
}
}

/// <summary>
/// 获取定位目标
/// </summary>
/// <param name="toast">Toast 对象</param>
/// <returns>容器或null</returns>
private static UIElement GetPopupPlacementTarget(Toast toast)
{
switch (toast.Location)
{
case ToastLocation.ScreenCenter:
case ToastLocation.ScreenLeft:
case ToastLocation.ScreenRight:
case ToastLocation.ScreenTopLeft:
case ToastLocation.ScreenTopCenter:
case ToastLocation.ScreenTopRight:
case ToastLocation.ScreenBottomLeft:
case ToastLocation.ScreenBottomCenter:
case ToastLocation.ScreenBottomRight:
return null;
}
return toast.owner;
}

private static void SetPopupOffset(Popup popup, Toast toast)
{
double winTitleHeight = SystemParameters.CaptionHeight; //标题高度为22;
double owner_width = toast.owner.ActualWidth;
double owner_height = toast.owner.ActualHeight - winTitleHeight;
if (popup.PlacementTarget == null)
{
owner_width = SystemParameters.WorkArea.Size.Width;
owner_height = SystemParameters.WorkArea.Size.Height;
}

double popupWidth = (popup.Child as FrameworkElement)?.ActualWidth ?? 0; //Popup 宽高为其 Child 的宽高;
double popupHeight = (popup.Child as FrameworkElement)?.ActualHeight ?? 0;
double x = SystemParameters.WorkArea.X;
double y = SystemParameters.WorkArea.Y;
Thickness margin = toast.ToastMargin;

/*[dlgcy] 38 和 16 两个数字的猜测:
* PlacementTarget 为 Window 时,当 Placement 为 Bottom 时,Popup 上边缘与 Window 的下边缘的距离为 38;
* 当 Placement 为 Right 时,Popup 左边缘与 Window 的右边缘的距离为 16。
*/
double bottomDistance = 38;
double rightDistance = 16;

//上面创建时 Popup 的 Placement 为 PlacementMode.Left;
switch (toast.Location)
{
case ToastLocation.OwnerLeft: //容器左中间
popup.HorizontalOffset = popupWidth + margin.Left;
popup.VerticalOffset = (owner_height - popupHeight - winTitleHeight) / 2;
break;
case ToastLocation.ScreenLeft: //屏幕左中间
popup.HorizontalOffset = popupWidth + x + margin.Left;
popup.VerticalOffset = (owner_height - popupHeight) / 2 + y;
break;
case ToastLocation.OwnerRight: //容器右中间
popup.HorizontalOffset = owner_width - rightDistance - margin.Right;
popup.VerticalOffset = (owner_height - popupHeight - winTitleHeight) / 2;
break;
case ToastLocation.ScreenRight: //屏幕右中间
popup.HorizontalOffset = owner_width + x - margin.Right;
popup.VerticalOffset = (owner_height - popupHeight) / 2 + y;
break;
case ToastLocation.OwnerTopLeft: //容器左上角
popup.HorizontalOffset = popupWidth + margin.Left;
popup.VerticalOffset = margin.Top;
break;
case ToastLocation.ScreenTopLeft: //屏幕左上角
popup.HorizontalOffset = popupWidth + x + margin.Left;
popup.VerticalOffset = margin.Top;
break;
case ToastLocation.OwnerTopCenter: //容器上中间
popup.HorizontalOffset = popupWidth + (owner_width - popupWidth - rightDistance) / 2;
popup.VerticalOffset = margin.Top;
break;
case ToastLocation.ScreenTopCenter: //屏幕上中间
popup.HorizontalOffset = popupWidth + (owner_width - popupWidth) / 2 + x;
popup.VerticalOffset = y + margin.Top;
break;
case ToastLocation.OwnerTopRight: //容器右上角
popup.HorizontalOffset = owner_width - rightDistance - margin.Right;
popup.VerticalOffset = margin.Top;
break;
case ToastLocation.ScreenTopRight: //屏幕右上角
popup.HorizontalOffset = owner_width + x - margin.Right;
popup.VerticalOffset = y + margin.Top;
break;
case ToastLocation.OwnerBottomLeft: //容器左下角
//popup.HorizontalOffset = popupWidth;
//popup.VerticalOffset = owner_height - popupHeight - winTitleHeight;
popup.Placement = PlacementMode.Bottom;
popup.HorizontalOffset = margin.Left;
popup.VerticalOffset = -(bottomDistance + popupHeight + margin.Bottom);
break;
case ToastLocation.ScreenBottomLeft: //屏幕左下角
popup.HorizontalOffset = popupWidth + x + margin.Left;
popup.VerticalOffset = owner_height - popupHeight + y - margin.Bottom;
break;
case ToastLocation.OwnerBottomCenter: //容器下中间
//popup.HorizontalOffset = popupWidth + (owner_width - popupWidth - rightDistance) / 2;
//popup.VerticalOffset = owner_height - popupHeight - winTitleHeight;
popup.Placement = PlacementMode.Bottom;
popup.HorizontalOffset = (owner_width - popupWidth - rightDistance) / 2;
popup.VerticalOffset = -(bottomDistance + popupHeight + margin.Bottom);
break;
case ToastLocation.ScreenBottomCenter: //屏幕下中间
popup.HorizontalOffset = popupWidth + (owner_width - popupWidth) / 2 + x;
popup.VerticalOffset = owner_height - popupHeight + y - margin.Bottom;
break;
case ToastLocation.OwnerBottomRight: //容器右下角
//popup.HorizontalOffset = popupWidth + (owner_width - popupWidth - rightDistance);
//popup.VerticalOffset = owner_height - popupHeight - winTitleHeight;
popup.Placement = PlacementMode.Bottom;
popup.HorizontalOffset = owner_width - popupWidth - rightDistance - margin.Right;
popup.VerticalOffset = -(bottomDistance + popupHeight + margin.Bottom);
break;
case ToastLocation.ScreenBottomRight: //屏幕右下角
popup.HorizontalOffset = owner_width + x - margin.Right;
popup.VerticalOffset = owner_height - popupHeight + y - margin.Bottom;
break;
case ToastLocation.ScreenCenter: //屏幕正中间
popup.HorizontalOffset = popupWidth + (owner_width - popupWidth) / 2 + x;
popup.VerticalOffset = (owner_height - popupHeight) / 2 + y;
break;
case ToastLocation.OwnerCenter: //容器正中间
case ToastLocation.Default:
//popup.HorizontalOffset = popupWidth + (owner_width - popupWidth - rightDistance) / 2;
//popup.VerticalOffset = (owner_height - popupHeight - winTitleHeight) / 2;
popup.Placement = PlacementMode.Center;
popup.HorizontalOffset = -rightDistance / 2;
popup.VerticalOffset = -bottomDistance / 2;
break;
}
}

public void Close()
{
if (timer != null)
{
timer.Stop();
timer = null;
}
popup.IsOpen = false;
owner.LocationChanged -= UpdatePosition;
owner.SizeChanged -= UpdatePosition;
}

private event EventHandler<EventArgs> Closed;
private void RaiseClosed(EventArgs e)
{
Closed?.Invoke(this, e);
}

private event EventHandler<EventArgs> Click;
private void RaiseClick(EventArgs e)
{
Click?.Invoke(this, e);
}

#region 依赖属性

private string Message
{
get { return (string)GetValue(MessageProperty); }
set { SetValue(MessageProperty, value); }
}
private static readonly DependencyProperty MessageProperty =
DependencyProperty.Register("Message", typeof(string), typeof(Toast), new PropertyMetadata(string.Empty));

private CornerRadius CornerRadius
{
get { return (CornerRadius)GetValue(CornerRadiusProperty); }
set { SetValue(CornerRadiusProperty, value); }
}
private static readonly DependencyProperty CornerRadiusProperty =
DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(Toast), new PropertyMetadata(new CornerRadius(5)));

private double IconSize
{
get { return (double)GetValue(IconSizeProperty); }
set { SetValue(IconSizeProperty, value); }
}
private static readonly DependencyProperty IconSizeProperty =
DependencyProperty.Register("IconSize", typeof(double), typeof(Toast), new PropertyMetadata(26.0));

private new Brush BorderBrush
{
get { return (Brush)GetValue(BorderBrushProperty); }
set { SetValue(BorderBrushProperty, value); }
}
private static new readonly DependencyProperty BorderBrushProperty =
DependencyProperty.Register("BorderBrush", typeof(Brush), typeof(Toast), new PropertyMetadata((Brush)new BrushConverter().ConvertFromString("#FFFFFF")));

private new Thickness BorderThickness
{
get { return (Thickness)GetValue(BorderThicknessProperty); }
set { SetValue(BorderThicknessProperty, value); }
}
private static new readonly DependencyProperty BorderThicknessProperty =
DependencyProperty.Register("BorderThickness", typeof(Thickness), typeof(Toast), new PropertyMetadata(new Thickness(0)));

private new Brush Background
{
get { return (Brush)GetValue(BackgroundProperty); }
set { SetValue(BackgroundProperty, value); }
}
private static new readonly DependencyProperty BackgroundProperty =
DependencyProperty.Register("Background", typeof(Brush), typeof(Toast), new PropertyMetadata((Brush)new BrushConverter().ConvertFromString("#2E2929")));

private new HorizontalAlignment HorizontalContentAlignment
{
get { return (HorizontalAlignment)GetValue(HorizontalContentAlignmentProperty); }
set { SetValue(HorizontalContentAlignmentProperty, value); }
}
private static new readonly DependencyProperty HorizontalContentAlignmentProperty =
DependencyProperty.Register("HorizontalContentAlignment", typeof(HorizontalAlignment), typeof(Toast), new PropertyMetadata(HorizontalAlignment.Left));

private new VerticalAlignment VerticalContentAlignment
{
get { return (VerticalAlignment)GetValue(VerticalContentAlignmentProperty); }
set { SetValue(VerticalContentAlignmentProperty, value); }
}
private static new readonly DependencyProperty VerticalContentAlignmentProperty =
DependencyProperty.Register("VerticalContentAlignment", typeof(VerticalAlignment), typeof(Toast), new PropertyMetadata(VerticalAlignment.Center));

private double ToastWidth
{
get { return (double)GetValue(ToastWidthProperty); }
set { SetValue(ToastWidthProperty, value); }
}
private static readonly DependencyProperty ToastWidthProperty =
DependencyProperty.Register("ToastWidth", typeof(double), typeof(Toast), new PropertyMetadata(0.0));

private double ToastHeight
{
get { return (double)GetValue(ToastHeightProperty); }
set { SetValue(ToastHeightProperty, value); }
}
private static readonly DependencyProperty ToastHeightProperty =
DependencyProperty.Register("ToastHeight", typeof(double), typeof(Toast), new PropertyMetadata(0.0));

private ToastIcons Icon
{
get { return (ToastIcons)GetValue(IconProperty); }
set { SetValue(IconProperty, value); }
}
private static readonly DependencyProperty IconProperty =
DependencyProperty.Register("Icon", typeof(ToastIcons), typeof(Toast), new PropertyMetadata(ToastIcons.None));

private int Time
{
get { return (int)GetValue(TimeProperty); }
set { SetValue(TimeProperty, value); }
}
private static readonly DependencyProperty TimeProperty =
DependencyProperty.Register("Time", typeof(int), typeof(Toast), new PropertyMetadata(2000));

private ToastLocation Location
{
get { return (ToastLocation)GetValue(LocationProperty); }
set { SetValue(LocationProperty, value); }
}
private static readonly DependencyProperty LocationProperty =
DependencyProperty.Register("Location", typeof(ToastLocation), typeof(Toast), new PropertyMetadata(ToastLocation.Default));

public double TextWidth
{
get { return (double)GetValue(TextWidthProperty); }
set { SetValue(TextWidthProperty, value); }
}
public static readonly DependencyProperty TextWidthProperty =
DependencyProperty.Register("TextWidth", typeof(double), typeof(Toast), new PropertyMetadata(double.NaN));

public Thickness ToastMargin
{
get { return (Thickness)GetValue(ToastMarginProperty); }
set { SetValue(ToastMarginProperty, value); }
}
public static readonly DependencyProperty ToastMarginProperty =
DependencyProperty.Register("ToastMargin", typeof(Thickness), typeof(Toast), new PropertyMetadata(new Thickness(0)));

private Brush IconForeground
{
get { return (Brush)GetValue(IconForegroundProperty); }
set { SetValue(IconForegroundProperty, value); }
}
private static readonly DependencyProperty IconForegroundProperty =
DependencyProperty.Register("IconForeground", typeof(Brush), typeof(Toast), new PropertyMetadata((Brush)new BrushConverter().ConvertFromString("#00D91A")));

#endregion
}
}

+ 4
- 4
BPASmartClient/App.config View File

@@ -7,14 +7,14 @@
<add key="IsEnableTest" value="false"/>

<!--测试环境-->
<!--<add key="apollouri" value="http://10.2.1.21:28080/"/>
<add key="apollouri" value="http://10.2.1.21:28080/"/>
<add key="AppId" value="test1_HostComputer"/>
<add key ="Namespaces" value="DEV.test1.Config"/>-->
<add key ="Namespaces" value="DEV.test1.Config"/>

<!--开发环境-->
<add key="apollouri" value="http://10.2.1.21:28080/"/>
<!--<add key="apollouri" value="http://10.2.1.21:28080/"/>
<add key="AppId" value="dev1_common"/>
<add key ="Namespaces" value="DEV.Config"/>
<add key ="Namespaces" value="DEV.Config"/>-->

<!--正式环境-->
<!--<add key="apollouri" value="http://47.108.65.220:28080/"/>


+ 3
- 2
DosingSystem/App.xaml.cs View File

@@ -20,6 +20,7 @@ namespace BPASmartClient.DosingSystem
/// </summary>
public partial class App : Application
{
public static Window MainWindow;
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
@@ -34,7 +35,7 @@ namespace BPASmartClient.DosingSystem
// mv.Show();
//else
// mv.Close();
MainWindow = mv;
}

protected override void OnExit(ExitEventArgs e)
@@ -60,7 +61,7 @@ namespace BPASmartClient.DosingSystem
RecipeManage.Add(new SubMenumodel()
{
SubMenuName = "配方下发",
SubMenuPermission = new Permission[] { Permission.操作员 },
SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员 },
AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.RecipeControlView"
});


+ 27
- 0
DosingSystem/Model/DeviceCurrentStatus.cs View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;

namespace BPASmartClient.DosingSystem.Model
{
public class DeviceCurrentStatus : ObservableObject
{

public double Weight { get { return _mWeight; } set { _mWeight = value; OnPropertyChanged(); } }
private double _mWeight;


public bool RunStatus { get { return _mRunStatus; } set { _mRunStatus = value; OnPropertyChanged(); } }
private bool _mRunStatus;


public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } }
private string _mDeviceName;



}
}

+ 8
- 0
DosingSystem/View/DeviceListView.xaml View File

@@ -46,6 +46,14 @@

<Grid>

<!--<pry:Bottle
Width="80"
Height="500"
CurrentValue="50" />-->

<pry:MotorBottle IsRun="True" CurrentValue="100"/>


<Grid>
<ListView
Grid.Column="1"


+ 86
- 6
DosingSystem/View/HardwareStatusView.xaml View File

@@ -18,11 +18,61 @@

<Grid>

<UniformGrid Columns="10">


<!--#region 测试-->
<ListView
Height="150"
VerticalAlignment="Center"
Background="Transparent"
BorderThickness="0"
ItemsSource="{Binding TopDeviceCurrentStatuses}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid
HorizontalAlignment="Center"
VerticalAlignment="Center"
Columns="10" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>

<ListView.ItemTemplate>
<DataTemplate>
<Border Background="Transparent">
<Grid Height="100">
<pry:MotorBottle
Height="100"
CurrentValue="{Binding Weight}"
IsRun="{Binding RunStatus}"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
<RotateTransform Angle="90" />
</TransformGroup>
</pry:MotorBottle.RenderTransform>
</pry:MotorBottle>
</Grid>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<!--#endregion-->








<UniformGrid Columns="10" Visibility="Collapsed">

<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="66"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
@@ -34,6 +84,8 @@
<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="40"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
@@ -45,6 +97,8 @@
<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="88"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
@@ -56,6 +110,8 @@
<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="25"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
@@ -67,6 +123,8 @@
<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="97"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
@@ -78,6 +136,8 @@
<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="10"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
@@ -89,6 +149,8 @@
<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="60"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
@@ -100,6 +162,8 @@
<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="96"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
@@ -115,10 +179,10 @@
<pry:ConveyorBelt
Grid.Row="1"
Width="{Binding ElementName=gr, Path=ActualWidth}"
Height="{Binding ElementName=gr,Path=ActualHeight}"
Margin="0 0 400 0"
Height="{Binding ElementName=gr, Path=ActualHeight}"
Margin="0,0,400,0"
ConveyorBeltWidth="70"
Direction="1"
Direction="0"
StrokeBrush="Red"
StrokeDashArray="1.5 1.5"
StrokeFillBrush="Red"
@@ -130,6 +194,8 @@
<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="89"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
@@ -142,6 +208,8 @@
<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="13"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
@@ -154,6 +222,8 @@
<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="31"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
@@ -166,6 +236,8 @@
<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="96"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
@@ -178,6 +250,8 @@
<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="80"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
@@ -190,6 +264,8 @@
<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="26"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
@@ -202,6 +278,8 @@
<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="20"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
@@ -214,6 +292,8 @@
<pry:MotorBottle
Width="150"
Height="100"
CurrentValue="100"
IsRun="True"
RenderTransformOrigin="0.5,0.5">
<pry:MotorBottle.RenderTransform>
<TransformGroup>
@@ -226,9 +306,9 @@
</UniformGrid>

<Grid.RowDefinitions>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*" />
<RowDefinition />
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*" />
</Grid.RowDefinitions>
</Grid>
</UserControl>

+ 4
- 2
DosingSystem/View/NewRecipeView.xaml View File

@@ -116,7 +116,8 @@
Height="30"
Margin="0,0,7,0"
Command="{Binding AddCommand}"
Content="添加原料" Cursor="Hand" />
Content="添加原料"
Cursor="Hand" />

<Button
Width="80"
@@ -193,7 +194,8 @@
Margin="0,0,8,4"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Text="mg" />
FontSize="20"
Text="g" />

</StackPanel>



+ 78
- 5
DosingSystem/View/RecipeControlView.xaml View File

@@ -46,11 +46,84 @@

<Grid Margin="20">

<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding Recipes}">
<ScrollViewer >

<ListView
Margin="5"
VerticalAlignment="Top"
Background="Transparent"
BorderThickness="0"
ItemsSource="{Binding Recipes}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid
HorizontalAlignment="Left"
VerticalAlignment="Top"
Columns="8" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>

<ListView.ItemTemplate>
<DataTemplate>
<Border Margin="5" Background="LightSkyBlue">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="0.25*" />
<RowDefinition Height="0.2*" />
</Grid.RowDefinitions>

<Image Source="/BPASmartClient.CustomResource;component/Image/AGV/炒锅.png" />

<TextBlock
Grid.Row="1"
Margin="2,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="#dd000000"
Text="{Binding RecipeName}" />

<Grid
Name="gr"
Grid.Row="2"
Background="#00BEFA"
Height="30">

<pry:IcoButton
Width="{Binding ElementName=gr, Path=ActualWidth}"
Height="{Binding ElementName=gr, Path=ActualHeight}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
BorderThickness="0"
Command="{Binding DataContext.StartCommand, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding RecipCode}"
Content="订单下发"
EnterBackground="Red"
FontStyle="Normal"
Foreground="#dd000000"
IcoText="&#xe6cf;"
IsEnabled="{Binding IsEnable}"
Style="{StaticResource IcoButtonStyle}" />


</Grid>

</Grid>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>



<!--<ItemsControl ItemsSource="{Binding Recipes}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="0 0 0 50" Height="150" VerticalAlignment="Top">
<Grid
Height="150"
Margin="0,0,0,50"
VerticalAlignment="Top">
<Border
Name="ShadowElement"
Height="150"
@@ -86,8 +159,8 @@
Grid.Row="1"
Width="80"
Height="30"
Background="#00BEFA"
HorizontalAlignment="Left"
Background="#00BEFA"
Command="{Binding DataContext.StartCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
CommandParameter="{Binding RecipeName}"
Content="配方下发"
@@ -183,7 +256,7 @@
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ItemsControl>-->
</ScrollViewer>
</Grid>
</UserControl>

+ 158
- 4
DosingSystem/View/RecipeSettingsView.xaml View File

@@ -71,7 +71,6 @@
HorizontalAlignment="Left"
Command="{Binding SaveRecipe}"
Content="保存配方"
EnableColor="#FFB7B7B7"
FontSize="17"
Foreground="Aqua"
IcoText="&#xe936;"
@@ -149,9 +148,162 @@
</Grid>-->
<!--#endregion-->

<ScrollViewer Grid.Row="2">
<ListView
Margin="5"
VerticalAlignment="Top"
Background="Transparent"
BorderThickness="0"
ItemsSource="{Binding Recipes}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid
HorizontalAlignment="Left"
VerticalAlignment="Top"
Columns="8" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>

<ListView.ItemTemplate>
<DataTemplate>
<Border Margin="5" Background="LightSkyBlue">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="0.25*" />
<RowDefinition Height="0.2*" />
</Grid.RowDefinitions>

<Image Source="/BPASmartClient.CustomResource;component/Image/AGV/炒锅.png" />

<TextBlock
Grid.Row="1"
Margin="2,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="#dd000000"
Text="{Binding RecipeName}" />

<Grid
Name="gr"
Grid.Row="2"
Height="30">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<pry:IcoButton
Width="{Binding ElementName=gr, Path=ActualWidth}"
Height="{Binding ElementName=gr, Path=ActualHeight}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
BorderThickness="0"
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding RecipCode}"
Content="删除"
EnterBackground="Red"
FontStyle="Normal"
Foreground="#dd000000"
IcoText="&#xe68e;"
Style="{StaticResource IcoButtonStyle}" />

<pry:IcoButton
Grid.Column="1"
Width="{Binding ElementName=gr, Path=ActualWidth}"
Height="{Binding ElementName=gr, Path=ActualHeight}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
BorderThickness="0"
Command="{Binding DataContext.DetailsCommand, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding RecipCode}"
Content="编辑"
EnterBackground="#FF2AB2E7"
Foreground="#dd000000"
IcoText="&#xe636;"
Style="{StaticResource IcoButtonStyle}" />

</Grid>

</Grid>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ScrollViewer>



<!--<UniformGrid
Grid.Row="2"
Height="200"
VerticalAlignment="Top"
Columns="10">
<Border
Margin="10"
Background="LightSkyBlue"
BorderThickness="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="0.25*" />
<RowDefinition Height="0.2*" />
</Grid.RowDefinitions>

<Image Source="/BPASmartClient.CustomResource;component/Image/AGV/炒锅.png" />

<TextBlock
Grid.Row="1"
Margin="2,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="#dd000000"
Text="配方名称" />

<Grid Name="gr" Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<pry:IcoButton
Width="{Binding ElementName=gr, Path=ActualWidth}"
Height="{Binding ElementName=gr, Path=ActualHeight}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
BorderThickness="0"
Content="删除"
EnterBackground="Red"
FontStyle="Normal"
Foreground="#dd000000"
IcoText="&#xe68e;"
Style="{StaticResource IcoButtonStyle}" />

<pry:IcoButton
Grid.Column="1"
Width="{Binding ElementName=gr, Path=ActualWidth}"
Height="{Binding ElementName=gr, Path=ActualHeight}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
BorderThickness="0"
Content="编辑"
EnterBackground="#FF2AB2E7"
Foreground="#dd000000"
IcoText="&#xe68e;"
Style="{StaticResource IcoButtonStyle}" />

</Grid>

</Grid>
</Border>
</UniformGrid>-->


<!--#region 表格数据显示-->
<ScrollViewer
<!--<ScrollViewer
Grid.Row="2"
Visibility="Collapsed"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding Recipes}">
@@ -194,7 +346,8 @@
Style="{StaticResource TextBlockStyle}"
Text="{Binding RecipCode}" />

<!--<Grid Grid.Column="3">
-->
<!--<Grid Grid.Column="3">

<Button
Command="{Binding DataContext.EditCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
@@ -202,6 +355,7 @@
Content="编辑"
Style="{StaticResource buttonStyle}" />
</Grid>-->
<!--


<Grid Grid.Column="5">
@@ -240,7 +394,7 @@
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</ScrollViewer>-->
<!--#endregion-->
</Grid>
</UserControl>

+ 20
- 0
DosingSystem/View/RecipeSettingsView.xaml.cs View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
@@ -23,6 +24,25 @@ namespace BPASmartClient.DosingSystem.View
public RecipeSettingsView()
{
InitializeComponent();
//SetAlignment();
}

//public static void SetAlignment()
//{
// //获取系统是以Left-handed(true)还是Right-handed(false)
// var ifLeft = SystemParameters.MenuDropAlignment;

// if (ifLeft)
// {
// Console.WriteLine($"系统为左撇子,转换为右撇子。");

// // change to false
// var t = typeof(SystemParameters);
// var field = t.GetField("_menuDropAlignment", BindingFlags.NonPublic | BindingFlags.Static);
// field.SetValue(null, false);

// ifLeft = SystemParameters.MenuDropAlignment;
// }
//}
}
}

+ 16
- 0
DosingSystem/ViewModel/HardwareStatusViewModel.cs View File

@@ -9,10 +9,26 @@ using System.Collections.ObjectModel;
using System.Windows;
using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.Input;
using BPASmartClient.DosingSystem.Model;

namespace BPASmartClient.DosingSystem.ViewModel
{
public class HardwareStatusViewModel : ObservableObject
{
public HardwareStatusViewModel()
{
for (int i = 0; i < 8; i++)
{
TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus()
{
DeviceName = i.ToString(),
RunStatus = false,
Weight = new Random().Next(0, 100)
});
}
}

public ObservableCollection<DeviceCurrentStatus> TopDeviceCurrentStatuses { get; set; } = new ObservableCollection<DeviceCurrentStatus>();
public ObservableCollection<DeviceCurrentStatus> BottomDeviceCurrentStatuses { get; set; } = new ObservableCollection<DeviceCurrentStatus>();
}
}

+ 13
- 13
DosingSystem/ViewModel/NewRecipeViewModel.cs View File

@@ -108,22 +108,22 @@ namespace BPASmartClient.DosingSystem.ViewModel
static NewRecipeViewModel()
{
RawMaterialNames.Clear();
RawMaterialNames.Add("乳化剂");
RawMaterialNames.Add("酶制剂");
RawMaterialNames.Add("增味剂");
//RawMaterialNames.Add("乳化剂");
//RawMaterialNames.Add("酶制剂");
//RawMaterialNames.Add("增味剂");
RawMaterialNames.Add("营养强化剂");
RawMaterialNames.Add("抗结剂");
RawMaterialNames.Add("消泡剂");
RawMaterialNames.Add("膨松剂");
RawMaterialNames.Add("防腐剂");
RawMaterialNames.Add("着色剂");
//RawMaterialNames.Add("抗结剂");
//RawMaterialNames.Add("消泡剂");
//RawMaterialNames.Add("膨松剂");
//RawMaterialNames.Add("防腐剂");
//RawMaterialNames.Add("着色剂");
RawMaterialNames.Add("甜味剂");
RawMaterialNames.Add("酸味剂");
RawMaterialNames.Add("增白剂");
RawMaterialNames.Add("香料");
//RawMaterialNames.Add("酸味剂");
//RawMaterialNames.Add("增白剂");
//RawMaterialNames.Add("香料");
RawMaterialNames.Add("抗氧化剂");
RawMaterialNames.Add("使用香料");
RawMaterialNames.Add("增稠剂");
RawMaterialNames.Add("用香料");
//RawMaterialNames.Add("增稠剂");
}

private string RecipCode = string.Empty;


+ 3
- 1
DosingSystem/ViewModel/RecipeControlViewModel.cs View File

@@ -12,6 +12,8 @@ using Microsoft.Toolkit.Mvvm.Input;
using BPASmartClient.DosingSystem.Model;
using System.Threading;
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.CustomResource.UserControls;

namespace BPASmartClient.DosingSystem.ViewModel
{
@@ -34,7 +36,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
// MessageLog.GetInstance.ShowUserLog($"下发工单 { Recipes.ElementAt(index).RecipeName}");
// devices.Enqueue(deviceName);
//}
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!");
MessageLog.GetInstance.ShowUserLog($"下发工单 { Guid.NewGuid().ToString()}");
});



+ 13
- 4
DosingSystem/ViewModel/RecipeSettingsViewModel.cs View File

@@ -11,6 +11,11 @@ using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.Input;
using BPASmartClient.DosingSystem.Model;
using BPASmartClient.DosingSystem.View;
using BPASmartClient.CustomResource.UserControls;
using BPASmartClient.CustomResource.UserControls.Model;
using BPASmartClient.CustomResource.UserControls.Enum;
using System.Windows.Media;
using BPASmartClient.CustomResource.UserControls.MessageShow;

namespace BPASmartClient.DosingSystem.ViewModel
{
@@ -20,12 +25,16 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
//Json<LocaPar>.Read();
Recipes = Json<LocaPar>.Data.Recipes;
NewRecipe = new Action(() =>
NewRecipe = new RelayCommand(() =>
{
NewRecipeView nrv = new NewRecipeView();
nrv.ShowDialog();
});
SaveRecipe = new Action(() => { Json<LocaPar>.Save(); });
SaveRecipe = new RelayCommand(() =>
{
Json<LocaPar>.Save();
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方保存成功!");
});
RemoveCommand = new RelayCommand<object>((o) =>
{
if (o is string str)
@@ -48,9 +57,9 @@ namespace BPASmartClient.DosingSystem.ViewModel
});
}

public Action NewRecipe { get; set; }
public RelayCommand NewRecipe { get; set; }

public Action SaveRecipe { get; set; }
public RelayCommand SaveRecipe { get; set; }

public RelayCommand<object> EditCommand { get; set; }



+ 1
- 0
SmartClient.sln View File

@@ -1165,6 +1165,7 @@ Global
{E7168B03-68E5-4285-BB95-5660F877577A} = {8712125E-14CD-4E1B-A1CE-4BDE03805942}
{A49E1C5A-9489-451C-9CE6-CEA586234B84} = {8712125E-14CD-4E1B-A1CE-4BDE03805942}
{099E047C-F40E-47A3-A5BA-81FC1500D5E8} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625}
{76B6B333-0109-4EE8-A9B2-3E53A7421D92} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9AEC9B81-0222-4DE9-B642-D915C29222AC}


Loading…
Cancel
Save