This commit is contained in:
sc committed 2024-11-10 22:49:29 +08:00
commit 388afd4fea
10 files changed
+277 -34

No files matched your search

+54 -11
View File
@@ -4,24 +4,23 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.View"
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="630" d:DesignWidth="1280">
<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="200,0,0,0" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_edit_Click"/>
<Button Content="{x:Static lang:Resources.New}" x:Name="ProgramgroupView_new" FontSize="20" HorizontalAlignment="Left" Height="40" Margin="0,0,0,0" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_new_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.Rename}" x:Name="ProgramgroupView_Rename" FontSize="20" HorizontalAlignment="Left" Height="40" Margin="400,0,0,0" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_Rename_Click"/>
<Button Content="{x:Static lang:Resources.Rename}" x:Name="ProgramgroupView_Rename" FontSize="20" HorizontalAlignment="Left" Height="40" Margin="400,0,0,0" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_Rename_Click"/>
<Button Content="{x:Static lang:Resources.Remark}" x:Name="ProgramgroupView_Remark" FontSize="20" HorizontalAlignment="Left" Height="40" Margin="600,0,0,0" VerticalAlignment="Top" Width="200" Background="White" Click="ProgramgroupView_Remark_Click"/>
<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="False" CanUserDeleteRows="False" HeadersVisibility ="Column"
Background="White" SelectionMode="Single" FontSize="15">
<DataGrid x:Name="Grid" AlternationCount="2" IsReadOnly="True" PreviewMouseLeftButtonUp="Grid_PreviewMouseLeftButtonUp" MouseDoubleClick="Grid_MouseDoubleClick" 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="False" CanUserDeleteRows="False" HeadersVisibility ="Column" Background="White"
SelectionMode="Single" FontSize="15" Margin="0,0,0,60">
<DataGrid.RowStyle >
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Height" Value="30" />
@@ -54,11 +53,55 @@
<!--列信息绑定-->
<DataGridTextColumn Header="ProcessID" Binding="{Binding ProgramID}" Width="0" MinWidth="0" MaxWidth="0"/>
<DataGridTextColumn Header="{x:Static lang:Resources.ProcessName}" Width="400" Binding="{Binding ProgramName}" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Group}" Width="90" Binding="{Binding Group}" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Step}" Width="90" Binding="{Binding Step}" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Time}" Width="100" Binding="{Binding Time}" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Remark}" Width="*" Binding="{Binding Notes}" IsReadOnly="True"/>
</DataGrid.Columns>
</DataGrid>
<ContentControl x:Name="container"/>
<StackPanel x:Name="scr" VerticalAlignment="Bottom" Height="60" Background="#FF00204E" Orientation="Horizontal" Margin="0,0,0,0">
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
<ListViewItem Width="150" MouseLeftButtonUp="ListViewItem_New" x:Name="Resume">
<StackPanel Orientation="Horizontal" >
<materialDesign:PackIcon Kind="NewBox" Width="40" Height="30" Margin="10" VerticalAlignment="Center" Foreground="#FF1368BD"/>
<TextBlock Text="{x:Static lang:Resources.New}" 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_Rename" IsEnabled="False" x:Name="Rename">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Rename" Width="40" Height="30" Margin="10" VerticalAlignment="Center" Foreground="#FF1368BD"/>
<TextBlock Text="{x:Static lang:Resources.Rename}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
</StackPanel>
</ListViewItem>
</ListView>
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
<ListViewItem Width="150" MouseLeftButtonUp="ListViewItem_Remark" IsEnabled="False" x:Name="Remark">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Note" Width="40" Height="30" Margin="10" VerticalAlignment="Center" Foreground="#FF1368BD"/>
<TextBlock Text="{x:Static lang:Resources.Remark}" 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>
</Grid>
</UserControl>
+105 -23
View File
@@ -1,4 +1,5 @@
using System;
using SunlightCentralizedControlManagement_SCCM_.WindowsView;
using System;
using System.Collections.Generic;
using System.Data;
using System.Windows;
@@ -19,7 +20,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
}
private SQLiteHelper SQLiteHelpers = null; //定义数据库
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
DataSet sql; //内存数据缓存
public void Programgroup_sql()
@@ -53,8 +54,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
frm.ShowDialog();*/
}
void InputBox_new_accept(object sender, EventArgs e)//新建按钮窗口返回
{
// void InputBox_new_accept(object sender, EventArgs e)//新建按钮窗口返回
// {
//事件的接收者通过一个简单的类型转换得到InputBox的引用
/* InputBox frm = (InputBox)sender;
//接收到InputBox的TextBox值
@@ -79,25 +80,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
Programgroup_ID = ID;
Programgroup_sql();*/
}
// }
private void ProgramgroupView_del_Click(object sender, RoutedEventArgs e)//删除
{
/* if(Programgroup_Numder == null)return;
///弹窗提示确认删除
if (System.Windows.Forms.MessageBox.Show(Properties.Resources.Confirm + Properties.Resources.Delete + Programgroup_Numder, "Delete ",
System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
{
///执行删除
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
SQLiteHelpers.Delete("ProgramName", "ProgramID='" + Programgroup_ID + "'", null);
SQLiteHelpers.Close();
Programgroup_sql();
}
Programgroup_Numder = null;
Programgroup_ID = null;*/
}
private void ProgramgroupView_Rename_Click(object sender, RoutedEventArgs e)//重命名按钮
{
@@ -154,7 +139,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
public static string Programgroup_Numder { get; set; }
public static string Programgroup_ID { get; set; }
private void Grid_SelectionChanged(object sender, SelectionChangedEventArgs e)//表格选择事件
private void Grid_PreviewMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)//表格选择事件
{
int rownum = Grid.SelectedIndex;//获取鼠标选中行并定义变量
if (rownum != -1)//判断鼠标定位是否有效
@@ -162,6 +147,103 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
Programgroup_ID = (Grid.Columns[0].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第0列,
Programgroup_Numder = (Grid.Columns[1].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第1列,
}
edit.IsEnabled = true;
Rename.IsEnabled = true;
Remark.IsEnabled = true;
Delete.IsEnabled = true;
}
private void Grid_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)//双击表格编辑事件
{
}
private void ListViewItem_New(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
InputBox frm = new InputBox();
frm.Accept += new EventHandler(InputBox_new_accept);
frm.ShowDialog();
}
void InputBox_new_accept(object sender, EventArgs e)//新建按钮窗口返回
{
//事件的接收者通过一个简单的类型转换得到InputBox的引用
InputBox frm = (InputBox)sender;
//接收到InputBox的TextBox值
string VALUE = frm.InputValue;
string ID = DateTime.Now.ToString("yyMMddHHmmss"); //id为时间合
Dictionary<string, object> Program_new = new Dictionary<string, object>();//缓存函数
Program_new.Add("ProgramName", VALUE);
Program_new.Add("ProgramID", ID);
Program_new.Add("Step", "0");
Program_new.Add("Time", "0:00");
Program_new.Add("Notes", null);
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
SQLiteHelpers.InsertData("ProgramName", Program_new);// 执行插入
SQLiteHelpers.Close(); //关闭连接
Programgroup_Numder = VALUE;
Programgroup_ID = ID;
Programgroup_sql();
}
private void ListViewItem_edit(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
edit.IsEnabled = false;
Rename.IsEnabled = false;
Remark.IsEnabled = false;
Delete.IsEnabled = false;
}
private void ListViewItem_Rename(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
edit.IsEnabled = false;
Rename.IsEnabled = false;
Remark.IsEnabled = false;
Delete.IsEnabled = false;
}
private void ListViewItem_Remark(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
edit.IsEnabled = false;
Rename.IsEnabled = false;
Remark.IsEnabled = false;
Delete.IsEnabled = false;
}
private void ListViewItem_Delete(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
edit.IsEnabled = false;
Rename.IsEnabled = false;
Remark.IsEnabled = false;
Delete.IsEnabled = false;
if (Programgroup_Numder == null) return;
///弹窗提示确认删除
if (System.Windows.Forms.MessageBox.Show(Properties.Resources.Confirm + Properties.Resources.Delete + Programgroup_Numder, "Delete ",
System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
{
///执行删除
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
SQLiteHelpers.Delete("ProgramName", "ProgramID='" + Programgroup_ID + "'", null);
SQLiteHelpers.Close();
Programgroup_sql();
}
Programgroup_Numder = null;
Programgroup_ID = null;
}
}
}