sc 12 months ago
parent
commit
e72bb097e2
  1. 7
      SunlightCentralizedControlManagement_SCCM_.csproj
  2. 77
      View/ProgramstepsView .xaml
  3. 143
      View/ProgramstepsView .xaml.cs
  4. 11
      WindowsView/ViewStep.xaml
  5. 4
      WindowsView/ViewStep.xaml.cs

7
SunlightCentralizedControlManagement_SCCM_.csproj

@ -128,6 +128,9 @@
<Compile Include="WindowsView\InputBox.xaml.cs">
<DependentUpon>InputBox.xaml</DependentUpon>
</Compile>
<Compile Include="WindowsView\ViewStep.xaml.cs">
<DependentUpon>ViewStep.xaml</DependentUpon>
</Compile>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -186,6 +189,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="WindowsView\ViewStep.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">

77
View/ProgramstepsView .xaml

@ -6,27 +6,20 @@
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.View"
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
xmlns:ConvertMoels="clr-namespace:SunlightCentralizedControlManagement_SCCM_.ConvertMoels"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d" Loaded="UserControl_Loaded"
d:DesignHeight="630" d:DesignWidth="1280">
<UserControl.Resources>
<ConvertMoels:RowToIndexConverter x:Key="RowToIndexConverter"/>
</UserControl.Resources>
<Grid>
<Rectangle Margin="0,0,0,0" Fill="#FFCCCCCC" VerticalAlignment="Top" Height="40"/>
<Button Content="{x:Static lang:Resources.edit}" x:Name="ProgramgroupView_edit" FontSize="20" HorizontalAlignment="Left" Height="40" Margin="0,0,0,0" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_edit_Click"/>
<Button Content="{x:Static lang:Resources.Quit}" x:Name="ProgramgroupView_Quit" FontSize="20" HorizontalAlignment="Left" Height="40" Margin="400,0,0,0" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_Quit_Click"/>
<Button Content="{x:Static lang:Resources.Delete}" x:Name="ProgramgroupView_del" FontSize="20" HorizontalAlignment="Left" Height="40" Margin="800,0,0,0" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_del_Click"/>
<Button Content="{x:Static lang:Resources.Insert}" x:Name="ProgramgroupView_Insert" FontSize="20" HorizontalAlignment="Left" Height="40" Margin="200,0,0,0" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_Insert_Click"/>
<Button Content="{x:Static lang:Resources.Save}" x:Name="ProgramgroupView_Save" FontSize="20" HorizontalAlignment="Left" Height="40" Margin="600,0,0,0" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_Save_Click"/>
<TextBlock x:Name="p_title" FontSize="20" VerticalAlignment="Top" Height="40" Margin="1000,0,0,0" />
<DataGrid x:Name="Grid" AlternationCount="2" IsReadOnly="True" SelectionChanged="Grid_SelectionChanged"
Margin="0,40,0,0" d:ItemsSource="{d:SampleData ItemCount=90}" AutoGenerateColumns="False" MinColumnWidth="30"
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="#CCCCCC"
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" Grid.ColumnSpan="2" AllowDrop="False"
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"
CanUserAddRows="True" CanUserDeleteRows="False" HeadersVisibility ="Column"
Background="White" SelectionMode="Single" FontSize="15">
<DataGrid x:Name="Grid" AlternationCount="2" IsReadOnly="True" d:ItemsSource="{d:SampleData ItemCount=90}"
PreviewMouseLeftButtonUp="Grid_PreviewMouseLeftButtonUp" MouseDoubleClick="Grid_MouseDoubleClick"
Background="White" HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9"
GridLinesVisibility="All" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" FontSize="15"
Grid.ColumnSpan="2" CanUserResizeRows="False" AutoGenerateColumns="False" MinColumnWidth="30"
CanUserAddRows="False" CanUserDeleteRows="False" HeadersVisibility ="Column" SelectionMode="Single"
Margin="0,0,0,60">
<DataGrid.RowStyle >
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Height" Value="30" />
@ -76,6 +69,58 @@
<DataGridTextColumn Binding="{Binding Parameter10}" Width="0" MinWidth="0" MaxWidth="0"/>
</DataGrid.Columns>
</DataGrid>
<StackPanel x:Name="scr" VerticalAlignment="Bottom" Height="60" Background="#FF00204E" Orientation="Horizontal" Margin="0,0,400,0">
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
<ListViewItem Width="150" MouseLeftButtonUp="ListViewItem_Quit" x:Name="Quit">
<StackPanel Orientation="Horizontal" >
<materialDesign:PackIcon Kind="PresenceExit" Width="40" Height="30" Margin="10" VerticalAlignment="Center" Foreground="#FF1368BD"/>
<TextBlock Text="{x:Static lang:Resources.Quit}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
</StackPanel>
</ListViewItem>
</ListView>
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
<ListViewItem Width="150" MouseLeftButtonUp="ListViewItem_edit" IsEnabled="False" x:Name="edit">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Edit" Width="40" Height="30" Margin="10" VerticalAlignment="Center" Foreground="#FF1368BD"/>
<TextBlock Text="{x:Static lang:Resources.edit}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
</StackPanel>
</ListViewItem>
</ListView>
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
<ListViewItem Width="150" MouseLeftButtonUp="ListViewItem_Insert" IsEnabled="False" x:Name="Insert">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="InsertComment" Width="40" Height="30" Margin="10" VerticalAlignment="Center" Foreground="#FF1368BD"/>
<TextBlock Text="{x:Static lang:Resources.Insert}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
</StackPanel>
</ListViewItem>
</ListView>
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
<ListViewItem Width="150" MouseLeftButtonUp="ListViewItem_Save" x:Name="Save">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Note" Width="40" Height="30" Margin="10" VerticalAlignment="Center" Foreground="#FF1368BD"/>
<TextBlock Text="{x:Static lang:Resources.Save}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
</StackPanel>
</ListViewItem>
</ListView>
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
<ListViewItem Width="150" MouseLeftButtonUp="ListViewItem_Delete" IsEnabled="False" x:Name="Delete">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Delete" Width="40" Height="30" Margin="10" VerticalAlignment="Center" Foreground="#FF1368BD"/>
<TextBlock Text="{x:Static lang:Resources.Delete}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
</StackPanel>
</ListViewItem>
</ListView>
</StackPanel>
<StackPanel VerticalAlignment="Bottom" Height="60" Background="#FF00204E" Orientation="Horizontal" Margin="0,0,0,0" Width="400" HorizontalAlignment="Right">
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
<ListViewItem>
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="ChatProcessing" Width="40" Height="30" Margin="10" VerticalAlignment="Center" Foreground="#FF1368BD"/>
<TextBlock Text="{x:Static lang:Resources.ProcessName}" FontSize="20" VerticalAlignment="Center" Margin="20 10" Foreground="White" />
<TextBlock x:Name="p_title" FontSize="20" VerticalAlignment="Center" Margin="20 10" Foreground="White" FontWeight="Bold" />
</StackPanel>
</ListViewItem>
</ListView>
</StackPanel>
</Grid>
</UserControl>

143
View/ProgramstepsView .xaml.cs

@ -1,4 +1,5 @@
using SunlightCentralizedControlManagement_SCCM_.UserClass;
using SunlightCentralizedControlManagement_SCCM_.WindowsView;
using System;
using System.Collections.Generic;
using System.Data;
@ -22,8 +23,10 @@ using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml.Linq;
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
//using static SunlightCentralizedControlManagement_SCCM_.Windows.ViewStep;
using static SunlightCentralizedControlManagement_SCCM_.WindowsView.ViewStep;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace SunlightCentralizedControlManagement_SCCM_.View
{
@ -49,7 +52,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
string ProgramID;
string ProgramNAME;
string Numder = null;
string ID = null;
string P1, P2, P3, P4, P5;
public void Programgroup_sql()
{
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
@ -67,9 +72,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
Dat();
if (sql != null) Grid.ItemsSource = sql.Tables[0].DefaultView; //转换显示计划表
SQLiteHelpers.Close(); //关闭连接
//sql.Clear(); //清除缓存
//System.GC.Collect();
}
public void Dat()//行号刷新
@ -84,24 +86,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
}
}
string Numder = null;
string ID = null;
string P1, P2, P3, P4, P5;
private void Grid_SelectionChanged(object sender, SelectionChangedEventArgs e)//表格选择事件
{
int rownum = Grid.SelectedIndex;//获取鼠标选中行并定义变量
if (rownum != -1)//判断鼠标定位是否有效
{
ID = (Grid.Columns[2].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第0列,
Numder = (Grid.Columns[3].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第1列,
P1 = (Grid.Columns[6].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第6列,
P2 = (Grid.Columns[7].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第7列,
P3 = (Grid.Columns[8].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第8列,
P4 = (Grid.Columns[9].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第9列,
P5 = (Grid.Columns[10].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第10列,
}
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)//打开页面时的操作
{
if (ID == null) ID = sql.Tables[0].Rows.Count.ToString();
@ -127,16 +111,67 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
return child;
}
private void ProgramgroupView_edit_Click(object sender, RoutedEventArgs e)//编辑
private void Grid_PreviewMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)//表格选择事件
{
edit.IsEnabled = true;
Insert.IsEnabled = true;
Delete.IsEnabled = true;
int rownum = Grid.SelectedIndex;//获取鼠标选中行并定义变量
if (rownum != -1)//判断鼠标定位是否有效
{
ID = (Grid.Columns[2].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第0列,
Numder = (Grid.Columns[3].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第1列,
P1 = (Grid.Columns[6].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第6列,
P2 = (Grid.Columns[7].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第7列,
P3 = (Grid.Columns[8].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第8列,
P4 = (Grid.Columns[9].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第9列,
P5 = (Grid.Columns[10].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第10列,
}
}
private void Grid_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)//双击表格编辑事件
{
edit.IsEnabled = true;
Insert.IsEnabled = true;
Delete.IsEnabled = true;
int rownum = Grid.SelectedIndex;//获取鼠标选中行并定义变量
if (rownum != -1)//判断鼠标定位是否有效
{
ID = (Grid.Columns[2].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第0列,
Numder = (Grid.Columns[3].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第1列,
P1 = (Grid.Columns[6].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第6列,
P2 = (Grid.Columns[7].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第7列,
P3 = (Grid.Columns[8].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第8列,
P4 = (Grid.Columns[9].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第9列,
P5 = (Grid.Columns[10].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第10列,
if (string.IsNullOrEmpty(Numder)) { Numder = null; P1 = "0"; P2 = "0"; P3 = "0"; P4 = "0"; P5 = "0"; }
if (ID == null) ID = sql.Tables[0].Rows.Count.ToString();
ViewStep viewstop = new ViewStep(Numder, P1, P2, P3, P4, P5);
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Address_ButtonClicked);
viewstop.data = ID;
viewstop.ShowDialog();
}
}
private void ListViewItem_Quit(object sender, System.Windows.Input.MouseButtonEventArgs e)//退出事件
{
/* if (string.IsNullOrEmpty(Numder)) { Numder = null; P1 = "0";P2 = "0";P3 = "0";P4 = "0";P5 = "0"; }
this.Visibility = Visibility.Collapsed;//隐藏控件
}
private void ListViewItem_edit(object sender, System.Windows.Input.MouseButtonEventArgs e)//编辑事件
{
edit.IsEnabled = false;
Insert.IsEnabled = false;
Delete.IsEnabled = false;
if (string.IsNullOrEmpty(Numder)) { Numder = null; P1 = "0"; P2 = "0"; P3 = "0"; P4 = "0"; P5 = "0"; }
if (ID == null) ID = sql.Tables[0].Rows.Count.ToString();
ViewStep viewstop = new ViewStep(Numder, P1, P2, P3, P4, P5);
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Address_ButtonClicked);
viewstop.data = ID;
viewstop.ShowDialog();*/
viewstop.ShowDialog();
}
/* private void Address_ButtonClicked(object sender, AddressUpdateEventArgs e)//编辑返回结果
private void Address_ButtonClicked(object sender, AddressUpdateEventArgs e)//编辑返回结果
{
int i = sql.Tables[0].Rows.Count;
int n = StrToInt.To16Convert10(ID);
@ -147,10 +182,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
dr_["Program"] = ProgramNAME;
sql.Tables[0].Rows.Add(dr_);
Dat();
ID = (n+1).ToString();
ID = (n + 1).ToString();
}
DataRow dr = sql.Tables[0].Rows[n-1];
DataRow dr = sql.Tables[0].Rows[n - 1];
dr.BeginEdit();
dr["StepID"] = e.StepID;
dr["StepName"] = e.StepNAME;
@ -164,30 +199,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
Grid.ItemsSource = sql.Tables[0].DefaultView;
}
*/
private void ProgramgroupView_Quit_Click(object sender, RoutedEventArgs e)//退出
{
this.Visibility = Visibility.Collapsed;//隐藏控件
}
private void ProgramgroupView_del_Click(object sender, RoutedEventArgs e)//删除行
private void ListViewItem_Insert(object sender, System.Windows.Input.MouseButtonEventArgs e)//插入事件
{
int d = 0;
int a = sql.Tables[0].Rows.Count;
if (ID != null) { d = Convert.ToInt32(ID); } else { return; }
if (a != d)//如果删除不是最后一行执行
{
sql.Tables[0].Rows.RemoveAt(d - 1);
Dat();
Grid.ItemsSource = sql.Tables[0].DefaultView; //转换显示计划表
}
}
private void ProgramgroupView_Insert_Click(object sender, RoutedEventArgs e)//插入行
{
int d = 0;
edit.IsEnabled = false;
Insert.IsEnabled = false;
Delete.IsEnabled = false; int d = 0;
if (ID != null) { d = Convert.ToInt32(ID); } else { return; }
DataRow dr = sql.Tables[0].NewRow();//添加表数据
dr["ProgramID"] = ProgramID;
@ -199,8 +216,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
Grid.ItemsSource = sql.Tables[0].DefaultView; //转换显示计划表
}
private void ProgramgroupView_Save_Click(object sender, RoutedEventArgs e)//保存
private void ListViewItem_Save(object sender, System.Windows.Input.MouseButtonEventArgs e)//保存事件
{
edit.IsEnabled = false;
Insert.IsEnabled = false;
Delete.IsEnabled = false;
int r = 0;
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
@ -224,7 +244,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
}
Dictionary<string, object> Program_Step = new Dictionary<string, object>();//缓存函数
Program_Step.Add("Step", a-1);
Program_Step.Add("Step", a - 1);
SQLiteHelpers.Update("ProgramName", Program_Step, "ProgramID='" + ProgramID + "'", null);
SQLiteHelpers.Close(); //关闭连接
@ -235,7 +255,24 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
}
}
private void ListViewItem_Delete(object sender, System.Windows.Input.MouseButtonEventArgs e)//删除事件
{
edit.IsEnabled = false;
Insert.IsEnabled = false;
Delete.IsEnabled = false;
int d = 0;
int a = sql.Tables[0].Rows.Count;
if (ID != null) { d = Convert.ToInt32(ID); } else { return; }
if (a != d)//如果删除不是最后一行执行
{
sql.Tables[0].Rows.RemoveAt(d - 1);
Dat();
Grid.ItemsSource = sql.Tables[0].DefaultView; //转换显示计划表
}
}
}
}

11
WindowsView/ViewStep.xaml

@ -1,17 +1,18 @@
<Window x:Class="DyeingComputer.Windows.ViewStep"
<Window x:Class="SunlightCentralizedControlManagement_SCCM_.WindowsView.ViewStep"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DyeingComputer.Windows"
xmlns:lang="clr-namespace:DyeingComputer.Properties"
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.WindowsView"
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
ResizeMode="NoResize"
Title="SUNLIGHT 800" Height="400" Width="400">
<Grid FocusManager.FocusedElement="{Binding ElementName=box}">
<TextBlock Text="{x:Static lang:Resources.Code}" HorizontalAlignment="Left" Height="30" Margin="10,20,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20" Background="#FFEFEEEE"/>
<TextBlock Text="{x:Static lang:Resources.Function}" HorizontalAlignment="Left" Height="30" Margin="10,60,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20" Background="#FFEFEEEE"/>
<TextBlock Text="{x:Static lang:Resources.Code}" HorizontalAlignment="Left" Height="30" Margin="10,20,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="130" FontSize="20" Background="#FFEFEEEE"/>
<TextBlock Text="{x:Static lang:Resources.Function}" HorizontalAlignment="Left" Height="30" Margin="10,60,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="130" FontSize="20" Background="#FFEFEEEE"/>
<ComboBox x:Name="boxID" HorizontalAlignment="Right" Height="30" Margin="0,60,10,0" VerticalAlignment="Top" Width="230" FontSize="20" Text="12345125" SelectionChanged="BoxID_SelectionChanged"/>
<TextBox x:Name="boxNAME" HorizontalAlignment="Right" Height="30" Margin="0,20,10,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
TextChanged="TextBox_TextChanged" PreviewTextInput="Tb_KeyPress" InputMethod.IsInputMethodEnabled="False" FontSize="20" HorizontalContentAlignment="Right" MaxLength="3"/>

4
WindowsView/ViewStep.xaml.cs

@ -1,4 +1,4 @@
using DyeingComputer.View;
using SunlightCentralizedControlManagement_SCCM_.WindowsView;
using ScottPlot.Palettes;
using System;
using System.Collections.Generic;
@ -18,7 +18,7 @@ using System.Windows.Shapes;
using System.Windows.Forms;
using System.Net.NetworkInformation;
namespace DyeingComputer.Windows
namespace SunlightCentralizedControlManagement_SCCM_.WindowsView
{
/// <summary>
/// ViewStep.xaml 的交互逻辑

Loading…
Cancel
Save