ソースを参照

报表功能修改

样式分支
pry 2年前
コミット
1d1e054a0c
18個のファイルの変更545行の追加117行の削除
  1. +2
    -0
      BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
  2. バイナリ
     
  3. +84
    -0
      BPASmartClient.CustomResource/Pages/Model/ProductionDataHelper.cs
  4. +5
    -5
      BPASmartClient.CustomResource/Pages/View/AlarmView.xaml
  5. +42
    -0
      BPASmartClient.CustomResource/Pages/View/ProductionDataView.xaml
  6. +28
    -0
      BPASmartClient.CustomResource/Pages/View/ProductionDataView.xaml.cs
  7. +4
    -5
      BPASmartClient.CustomResource/Pages/View/RunLogView.xaml
  8. +9
    -9
      BPASmartClient.CustomResource/Pages/View/UserLogView.xaml
  9. +19
    -0
      BPASmartClient.CustomResource/Pages/ViewModel/ProductionDataViewModel.cs
  10. +13
    -0
      BPASmartClient.Helper/DataRecord.cs
  11. +4
    -1
      BPASmartClient/Control/LogView.xaml
  12. +188
    -96
      DosingSystem/View/NewMaterialView.xaml
  13. +1
    -1
      WPFDemo/App.xaml
  14. +34
    -0
      WPFDemo/Class1.cs
  15. +19
    -0
      WPFDemo/DataTest.cs
  16. +44
    -0
      WPFDemo/TestData.xaml
  17. +45
    -0
      WPFDemo/TestData.xaml.cs
  18. +4
    -0
      WPFDemo/WPFDemo.csproj

+ 2
- 0
BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj ファイルの表示

@@ -115,6 +115,7 @@
<None Remove="Image\圆角矩形 4.png" />
<None Remove="Image\圆角矩形.png" />
<None Remove="Image\外边框1.png" />
<None Remove="Image\容器边框.png" />
<None Remove="Image\容器边框2.png" />
<None Remove="Image\工艺流程.jpg" />
<None Remove="Image\工艺流程.png" />
@@ -309,6 +310,7 @@
<Resource Include="Image\告警\无告警1.png" />
<Resource Include="Image\告警\轻微告警.png" />
<Resource Include="Image\外边框1.png" />
<Resource Include="Image\容器边框.png" />
<Resource Include="Image\容器边框2.png" />
<Resource Include="Image\工艺流程.jpg" />
<Resource Include="Image\工艺流程.png" />


バイナリ
ファイルの表示


+ 84
- 0
BPASmartClient.CustomResource/Pages/Model/ProductionDataHelper.cs ファイルの表示

@@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using System.Windows;
using System.IO;
using BPASmartClient.Helper;

namespace BPASmartClient.CustomResource.Pages.Model
{
public class ProductionDataHelper<TProductionData> where TProductionData : class, new()
{








public static string SavePath { get; set; }
private static string FileName = string.Empty;
private static string FilePath = string.Empty;
public static string Alias { get; set; } = string.Empty;
private static string _path
{
get
{
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\ProductionData\\{FilePath}"));
return $"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\ProductionData\\{ FilePath}";
}
}
public static ObservableCollection<TProductionData> productionDatas { get; set; } = new ObservableCollection<TProductionData>();
//public static TProductionData Data { get; set; } = new TProductionData();
public static void Add(TProductionData production)
{
if (FilePath.Length <= 0)
{
if (Alias.Length <= 0)
FilePath = $"{DateTime.Now.ToString("yyy-MM-dd")}";
else
FilePath = $"{DateTime.Now.ToString("yyy-MM-dd")}\\{Alias}";
}
if (FileName.Length <= 0) FileName = $"{DateTime.Now.ToString("HH-mm-ss")}.pry";
Application.Current.Dispatcher.Invoke(new Action(() =>
{
productionDatas.Add(production);
}));
}

public static bool Save(string path = "")
{
DataRecord dr = new DataRecord();
if (File.Exists(path))
{
dr.Save(productionDatas, FileName);
return true;
}
if (SavePath != null && File.Exists(SavePath))
{
dr.Save(productionDatas, FileName);
return true;
}

dr.Save(productionDatas, FileName);
return true;


}

public static void End()
{
FileName = string.Empty;
FilePath = string.Empty;
Alias = string.Empty;
}


}


}

+ 5
- 5
BPASmartClient.CustomResource/Pages/View/AlarmView.xaml ファイルの表示

@@ -23,11 +23,11 @@
<convert:AnalogAlarmConvert x:Key="analogAlarmConvert" />
<convert:DiscreteAlarmConvert x:Key="discreteAlarmConvert" />
<convert:AlarmTypeTextConvert x:Key="alarmTypeTextConvert" />-->
<SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" />
<SolidColorBrush x:Key="BorderSolid" Color="#332AB2E7" />
<SolidColorBrush x:Key="FontColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="TitleFontColor" Color="White" />
<SolidColorBrush x:Key="TitleFontColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="CursorColor" Color="Aqua" />
<SolidColorBrush x:Key="TitleBorderColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="TitleBorderColor" Color="#332AB2E7" />

<Style x:Key="TextBlockStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="楷体" />
@@ -51,7 +51,7 @@
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="Red" />
<Setter Property="Foreground" Value="#FFF53F62" />
<Setter Property="FontSize" Value="14" />
</Style>

@@ -157,7 +157,7 @@
</StackPanel>

<!--#region 表格标题栏设置-->
<Grid Grid.Row="1" Background="#FF19B7EC">
<Grid Grid.Row="1" Background="#ff0C255F">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.3*" />
<ColumnDefinition Width="0.7*" />


+ 42
- 0
BPASmartClient.CustomResource/Pages/View/ProductionDataView.xaml ファイルの表示

@@ -0,0 +1,42 @@
<UserControl
x:Class="BPASmartClient.CustomResource.Pages.View.ProductionDataView"
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:local="clr-namespace:BPASmartClient.CustomResource.Pages.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmartClient.CustomResource.Pages.ViewModel"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition />
</Grid.RowDefinitions>



<Grid>
<StackPanel Orientation="Horizontal">
<TextBlock
VerticalAlignment="Center"
Foreground="White"
Text="请输入开始时间:" />
<DatePicker VerticalAlignment="Center" />
<TextBlock
VerticalAlignment="Center"
Foreground="White"
Text="请输入结束时间:" />
<DatePicker VerticalAlignment="Center" />
<Button Margin="5,0,5,0" Content="查询" />
<Button Content="导入数据文件" />
</StackPanel>
</Grid>

<Grid Grid.Row="1">
<DataGrid ItemsSource="{Binding}" />
</Grid>

</Grid>
</UserControl>

+ 28
- 0
BPASmartClient.CustomResource/Pages/View/ProductionDataView.xaml.cs ファイルの表示

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BPASmartClient.CustomResource.Pages.View
{
/// <summary>
/// ProductionDataView.xaml 的交互逻辑
/// </summary>
public partial class ProductionDataView : UserControl
{
public ProductionDataView()
{
InitializeComponent();
}
}
}

+ 4
- 5
BPASmartClient.CustomResource/Pages/View/RunLogView.xaml ファイルの表示

@@ -25,9 +25,9 @@
<convert:AlarmTypeTextConvert x:Key="alarmTypeTextConvert" />-->
<SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" />
<SolidColorBrush x:Key="FontColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="TitleFontColor" Color="White" />
<SolidColorBrush x:Key="TitleFontColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="CursorColor" Color="Aqua" />
<SolidColorBrush x:Key="TitleBorderColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="TitleBorderColor" Color="#332AB2E7" />

<Style x:Key="TextBlockStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="楷体" />
@@ -158,7 +158,7 @@
</StackPanel>

<!--#region 表格标题栏设置-->
<Grid Grid.Row="1" Background="#FF19B7EC">
<Grid Grid.Row="1" Background="#ff0C255F">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.7*" />
<ColumnDefinition Width="0.7*" />
@@ -261,8 +261,7 @@
<TextBlock
Grid.Column="2"
Style="{StaticResource DataTextBlockStyle}"
Text="{Binding RunLogInfo}"
/>
Text="{Binding RunLogInfo}" />

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


+ 9
- 9
BPASmartClient.CustomResource/Pages/View/UserLogView.xaml ファイルの表示

@@ -24,11 +24,11 @@
<convert:AnalogAlarmConvert x:Key="analogAlarmConvert" />
<convert:DiscreteAlarmConvert x:Key="discreteAlarmConvert" />
<convert:AlarmTypeTextConvert x:Key="alarmTypeTextConvert" />-->
<SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" />
<SolidColorBrush x:Key="BorderSolid" Color="#332AB2E7" />
<SolidColorBrush x:Key="FontColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="TitleFontColor" Color="White" />
<SolidColorBrush x:Key="TitleFontColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="CursorColor" Color="Aqua" />
<SolidColorBrush x:Key="TitleBorderColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="TitleBorderColor" Color="#332AB2E7" />

<Style x:Key="TextBlockStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="楷体" />
@@ -240,7 +240,7 @@
</StackPanel>

<!--#region 表格标题栏设置-->
<Grid Grid.Row="1" Background="#FF19B7EC">
<Grid Grid.Row="1" Background="#ff0C255F">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.3*" />
<ColumnDefinition Width="0.3*" />
@@ -256,7 +256,7 @@
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="日期" />
<Grid Grid.Column="1">
<TextBlock
HorizontalAlignment="Center"
@@ -264,13 +264,13 @@
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="时间" />
<Border
BorderBrush="{StaticResource TitleBorderColor}"
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>

<TextBlock
Grid.Column="2"
@@ -279,7 +279,7 @@
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="操作权限" />

<Grid Grid.Column="3">
<TextBlock
@@ -288,7 +288,7 @@
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="用户名" />
<Border
BorderBrush="{StaticResource TitleBorderColor}"
BorderThickness="1,0,1,0"


+ 19
- 0
BPASmartClient.CustomResource/Pages/ViewModel/ProductionDataViewModel.cs ファイルの表示

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

namespace BPASmartClient.CustomResource.Pages.ViewModel
{
public class ProductionDataViewModel : ObservableObject
{
public ProductionDataViewModel()
{

}


}
}

+ 13
- 0
BPASmartClient.Helper/DataRecord.cs ファイルの表示

@@ -30,6 +30,19 @@ namespace BPASmartClient.Helper
return default;
}

public object Read(string filepath)
{
if (File.Exists(filepath))
{
FileStream fs = new FileStream(filepath, FileMode.Open);
BinaryFormatter bf = new BinaryFormatter();
var res = bf.Deserialize(fs);
fs.Close();
return res;
}
return default;
}

/// <summary>
/// 保存序列化文件
/// </summary>


+ 4
- 1
BPASmartClient/Control/LogView.xaml ファイルの表示

@@ -40,7 +40,10 @@
<!--表格栏-->
<Grid Grid.Row="1">
<DataGrid Margin="10" ItemsSource="{Binding LogDataGrid, UpdateSourceTrigger=PropertyChanged}" Grid.Row="2">
<DataGrid.Columns>
<DataGrid.Columns >



<DataGridTemplateColumn Header="日志时间" Width="300">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>


+ 188
- 96
DosingSystem/View/NewMaterialView.xaml ファイルの表示

@@ -8,7 +8,7 @@
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel"
Title="NewMateritalView"
Width="600"
Height="600"
Height="350"
AllowsTransparency="True"
Background="{x:Null}"
Topmost="True"
@@ -26,6 +26,58 @@

<ResourceDictionary>

<SolidColorBrush x:Key="tabColor" Color="#FF2AB2E7" />
<!--<SolidColorBrush x:Key="bordColor" Color="#33ffffff" />-->
<SolidColorBrush x:Key="bordColor" Color="#332AB2E7" />

<Style x:Key="ControlButtonStyle" TargetType="Button">
<Setter Property="Margin" Value="0" />
<Setter Property="FontSize" Value="18" />
<Setter Property="Foreground" Value="#FFF53F62" />
<Setter Property="FontWeight" Value="SemiBold" />
<Setter Property="FontFamily" Value="楷体" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border
Name="TitleBarBr"
BorderBrush="#00c2f4"
BorderThickness="0"
CornerRadius="0"
Opacity="0.8">

<ContentPresenter
Margin="{TemplateBinding Margin}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
<Border.Background>
<ImageBrush
ImageSource="/BPASmartClient.CustomResource;component/Image/组合边框1.1.png"
Opacity="0.8"
Stretch="Fill" />
</Border.Background>

</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="TitleBarBr" Property="Opacity" Value="1" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style x:Key="TitleTextblockStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="16" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Foreground" Value="{StaticResource tabColor}" />
<Setter Property="FontFamily" Value="楷体" />
<Setter Property="FontWeight" Value="SemiBold" />
</Style>

<!--#region ListBox样式-->
<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}">
<Setter Property="OverridesDefaultStyle" Value="True" />
@@ -53,120 +105,160 @@

<Border Name="br" BorderThickness="1">
<Border.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/bg.png" />
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/容器边框.png" />
</Border.Background>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="5" />
<RowDefinition Height="*" />
<RowDefinition Height="55" />
<RowDefinition Height="20" />
<RowDefinition Height="40" />
<RowDefinition Height="5" />
<RowDefinition Height="5*" />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel
Grid.Row="1"
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBlock
Margin="10,0,0,0"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="请输入原料名称:" />



<TextBox
Grid.Column="1"
Width="200"
Height="30"
Margin="10"
FontSize="16"
Text="{Binding MaterialName}" />

<Button
Width="80"
Height="30"
Margin="10"
Command="{Binding SaveCommand}"
Content="保存"
Cursor="Hand" />
<Button
Name="btClose"
Width="80"
Height="30"
Margin="10"
Click="btClose_Click"
Content="取消" />

</StackPanel>
FontSize="25"
Foreground="#FF2AB2E7"
Text="本地原料创建" />

<Grid Grid.Row="2" Margin="10,0">

<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="150" />
</Grid.ColumnDefinitions>

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<TextBlock
HorizontalAlignment="Left"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="请输入原料名称:" />

<TextBox
Grid.Column="1"
Height="30"
FontSize="16"
Text="{Binding MaterialName}" />

</Grid>

<StackPanel Grid.Column="1" Orientation="Horizontal">
<Button
Width="80"
Height="30"
Margin="5,0"
Command="{Binding SaveCommand}"
Content="添加"
Cursor="Hand" />

<Button
Name="btClose"
Width="70"
Height="30"
Click="btClose_Click"
Content="取消" />
</StackPanel>


</Grid>
<TextBlock
Grid.Row="2"
Margin="0,0,5,0"
Grid.Row="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Transparent"
FontSize="16"
Foreground="Red"
Text="{Binding ErrorInfo}" />
<Grid Grid.Row="4">

<Grid Grid.Row="4" Margin="10,0">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock
HorizontalAlignment="Center"
FontSize="25"
Foreground="#FF2AB2E7"
Text="本地原料" />
<Border

<Grid Margin="0,10,0,0" Background="#ff0C255F">

<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="150" />
</Grid.ColumnDefinitions>

<TextBlock
Grid.Column="0"
Style="{StaticResource TitleTextblockStyle}"
Text="原料名称" />

<Grid Grid.Column="1">
<TextBlock Style="{StaticResource TitleTextblockStyle}" Text="功能操作" />
<Border
BorderBrush="{StaticResource bordColor}"
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>

<Border
Grid.ColumnSpan="2"
BorderBrush="{StaticResource bordColor}"
BorderThickness="1,0,1,0" />

</Grid>

<ScrollViewer
Grid.Row="1"
Margin="100,10"
BorderBrush="#FF2AB2E7"
BorderThickness="1">
<ScrollViewer
Grid.Row="1"
BorderBrush="#FF2AB2E7"
BorderThickness="1">
<ItemsControl Margin="10" ItemsSource="{Binding Materials}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<RadioButton GroupName="all">
<RadioButton.Template>
<ControlTemplate TargetType="RadioButton">
<Grid Name="gr" Height="40">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock
Name="tb"
Grid.Column="0"
Width="150"
Height="29"
Margin="3,1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="20"
Text="{Binding RawMaterialName}" />

<Button
Grid.Column="1"
Margin="10,0,10,0"
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
CommandParameter="{Binding RawMaterialId}"
Content="删除" />
</Grid>


</ControlTemplate>
</RadioButton.Template>
</RadioButton>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Border>
BorderThickness="1"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding Materials}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Name="gr" Height="30">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="150" />
</Grid.ColumnDefinitions>

<TextBlock
Grid.Column="0"
Margin="10,0,0,0"
VerticalAlignment="Center"
Foreground="{StaticResource TitleBorderColor}"
Text="{Binding RawMaterialName}" />

<Grid Grid.Column="1">
<Button
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
CommandParameter="{Binding RawMaterialId}"
Content="删除"
FontSize="16"
Style="{StaticResource ControlButtonStyle}" />
<Border BorderBrush="{StaticResource bordColor}" BorderThickness="1,0,1,0" />
</Grid>

<Border
Grid.ColumnSpan="2"
BorderBrush="{StaticResource bordColor}"
BorderThickness="1,0,1,1" />

</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="gr" Property="Background" Value="#112AB2E7" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
<!--</Border>-->
</Grid>

</Grid>


+ 1
- 1
WPFDemo/App.xaml ファイルの表示

@@ -3,6 +3,6 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WPFDemo"
StartupUri="MainWindow.xaml">
StartupUri="TestData.xaml">
<Application.Resources />
</Application>

+ 34
- 0
WPFDemo/Class1.cs ファイルの表示

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;
using Microsoft.Toolkit.Mvvm.Input;

namespace WPFDemo
{
public class Class1 : ObservableObject
{
public Class1()
{
AddCommand = new RelayCommand(() =>
{
dataTests.Add(new DataTest()
{
data1 = new Random().Next(0, 100),
data2 = new Random().Next(200, 300),
data3 = new Random().Next(400, 500).ToString(),
data4 = Convert.ToBoolean(new Random().Next(0, 1)),
data5 = new Random().Next(600, 700)
});
});
}
public ObservableCollection<DataTest> dataTests { get; set; } = new ObservableCollection<DataTest>();

public RelayCommand AddCommand { get; set; }

}
}

+ 19
- 0
WPFDemo/DataTest.cs ファイルの表示

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

namespace WPFDemo
{
[Serializable]
public class DataTest
{
public int data1 { get; set; }
public int data2 { get; set; }
public string data3 { get; set; }
public bool data4 { get; set; }
public float data5 { get; set; }

}
}

+ 44
- 0
WPFDemo/TestData.xaml ファイルの表示

@@ -0,0 +1,44 @@
<Window
x:Class="WPFDemo.TestData"
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:local="clr-namespace:WPFDemo"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="TestData"
Width="800"
Height="450"
mc:Ignorable="d">

<Window.DataContext>
<local:Class1/>
</Window.DataContext>

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition />
</Grid.RowDefinitions>

<Grid>
<StackPanel Orientation="Horizontal">
<Button Margin="5,0" Content="添加数据记录" Command="{Binding AddCommand}"/>
<Button Margin="5,0" Content="保存数据记录" Click="Button_Click_1"/>
</StackPanel>
</Grid>

<DataGrid Grid.Row="1" AutoGenerateColumns="True" ItemsSource="{Binding dataTests}" >
<DataGrid.Columns>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>

</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>

</Grid>
</Window>

+ 45
- 0
WPFDemo/TestData.xaml.cs ファイルの表示

@@ -0,0 +1,45 @@
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.Shapes;
using BPASmartClient.CustomResource.Pages.Model;

namespace WPFDemo
{
/// <summary>
/// TestData.xaml 的交互逻辑
/// </summary>
public partial class TestData : Window
{
public TestData()
{
InitializeComponent();
}

private void Button_Click(object sender, RoutedEventArgs e)
{
ProductionDataHelper<DataTest>.Add(new DataTest()
{
data1 = new Random().Next(0, 100),
data2 = new Random().Next(200, 300),
data3 = new Random().Next(400, 500).ToString(),
data4 = Convert.ToBoolean(new Random().Next(0, 1)),
data5 = new Random().Next(600, 700)
});
}

private void Button_Click_1(object sender, RoutedEventArgs e)
{
ProductionDataHelper<DataTest>.Save();
}
}
}

+ 4
- 0
WPFDemo/WPFDemo.csproj ファイルの表示

@@ -18,6 +18,10 @@
<PackageReference Include="Vlc.DotNet.Wpf" Version="3.1.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" />
</ItemGroup>

<ItemGroup>
<Resource Include="device.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>


読み込み中…
キャンセル
保存