6 changed files with 289 additions and 7 deletions
@ -0,0 +1,106 @@ |
|||
<Window x:Class="SunlightCentralizedControlManagement_SCCM_.WindowsView.User" |
|||
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:SunlightCentralizedControlManagement_SCCM_.WindowsView" |
|||
xmlns:ConvertMoels="clr-namespace:SunlightCentralizedControlManagement_SCCM_.ConvertMoels" |
|||
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties" |
|||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" |
|||
xmlns:viewmodel="clr-namespace:SunlightCentralizedControlManagement_SCCM_.ViewModel" |
|||
mc:Ignorable="d" Loaded="user_Loaded" |
|||
Title="MAC_SET" Height="720" Width="900" MinHeight="720" MinWidth="900" |
|||
BorderBrush="White" Background="White"> |
|||
<Grid> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition/> |
|||
<RowDefinition Height="5"/> |
|||
<RowDefinition/> |
|||
<RowDefinition Height="100"/> |
|||
</Grid.RowDefinitions> |
|||
<GridSplitter Grid.Row="1" Height="5" HorizontalAlignment="Stretch" Background="#FFCECECE"/> |
|||
<Grid Grid.Row="0"> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition MinWidth="300" MaxWidth="600"/> |
|||
<ColumnDefinition Width="5"/> |
|||
<ColumnDefinition/> |
|||
</Grid.ColumnDefinitions> |
|||
<GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Stretch" Background="#FFCECECE"/> |
|||
<Grid Grid.Column="0"> |
|||
<!--名--> |
|||
<TextBox x:Name="_Name" Height="30" Margin="105,10,10,100" VerticalAlignment="Top" FontSize="16" MaxLines="1" /> |
|||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="15,10,0,100" TextWrapping="Wrap" Text="{x:Static lang:Resources.USER}" |
|||
VerticalAlignment="Top" Width="85" FontSize="20"/> |
|||
<!--密码--> |
|||
<TextBox x:Name="Pasword" Height="30" Margin="105,55,10,50" VerticalAlignment="Top" FontSize="16" MaxLines="1" InputMethod.IsInputMethodEnabled="False" /> |
|||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="15,55,0,50" TextWrapping="Wrap" Text="{x:Static lang:Resources.Password}" |
|||
VerticalAlignment="Top" Width="80" FontSize="20"/> |
|||
<!--组--> |
|||
<ComboBox x:Name="GROUP" Height="30" Margin="105,100,10,100" Text="USER" VerticalAlignment="Top" FontSize="16" IsReadOnly="True" IsEditable="True"> |
|||
<ComboBoxItem Content="CHIEF"></ComboBoxItem> |
|||
<ComboBoxItem Content="POWERUSER"></ComboBoxItem> |
|||
<ComboBoxItem Content="USER"></ComboBoxItem> |
|||
</ComboBox> |
|||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="15,100,0,100" TextWrapping="Wrap" Text="{x:Static lang:Resources.Group}" |
|||
VerticalAlignment="Top" Width="45" FontSize="20"/> |
|||
<!--备注--> |
|||
<TextBox x:Name="Note" Height="30" Margin="105,145,10,50" VerticalAlignment="Top" FontSize="16" MaxLines="1"/> |
|||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="15,145,0,50" TextWrapping="Wrap" Text="{x:Static lang:Resources.Remark}" |
|||
VerticalAlignment="Top" Width="40" FontSize="20"/> |
|||
</Grid> |
|||
<ScrollViewer Grid.Column="2" Margin="0" VerticalScrollBarVisibility="Auto"> |
|||
<WrapPanel Orientation="Horizontal" x:Name="Capacity" Background="White" Margin="0,0,0,0"> |
|||
</WrapPanel> |
|||
</ScrollViewer> |
|||
</Grid> |
|||
<!--表--> |
|||
<DataGrid Grid.Row="2" x:Name="DataGriduser" MouseDoubleClick="DataGridMac_MouseDoubleClick" SelectionMode="Single" AlternationCount="2" IsReadOnly="True" |
|||
d:ItemsSource="{d:SampleData ItemCount=999}" AutoGenerateColumns="False" MinColumnWidth="30" |
|||
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="{x:Null}" |
|||
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" Grid.ColumnSpan="2" |
|||
CanUserResizeRows="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" |
|||
CanUserResizeColumns="False" CanUserSortColumns="False" HeadersVisibility ="Column" Background="{x:Null}"> |
|||
<DataGrid.RowStyle > |
|||
<Style TargetType="{x:Type DataGridRow}"> |
|||
<Style.Triggers> |
|||
<Trigger Property="ItemsControl.AlternationIndex" Value="0"> |
|||
<Setter Property="Background" Value="#FFFFFFFF" /> |
|||
</Trigger> |
|||
<Trigger Property="ItemsControl.AlternationIndex" Value="1"> |
|||
<Setter Property="Background" Value="#FFF0F0F0" /> |
|||
</Trigger> |
|||
<Trigger Property="IsMouseOver" Value="False"> |
|||
</Trigger> |
|||
</Style.Triggers> |
|||
</Style> |
|||
</DataGrid.RowStyle> |
|||
<DataGrid.CellStyle> |
|||
<Style TargetType="DataGridCell"> |
|||
<Setter Property="BorderThickness" Value="0"/> |
|||
<Setter Property="MinWidth" Value="20"/> |
|||
<Style.Triggers> |
|||
<Trigger Property="IsSelected" Value="True"> |
|||
<Setter Property="Background" Value="#FFC0C0C0"/> |
|||
<Setter Property="BorderBrush" Value="#FFC0C0C0"/> |
|||
<Setter Property="Foreground" Value="#000000"/> |
|||
</Trigger> |
|||
</Style.Triggers> |
|||
</Style> |
|||
</DataGrid.CellStyle> |
|||
<DataGrid.Columns> |
|||
<DataGridTextColumn Header="{x:Static lang:Resources.USER}" Binding="{Binding UserCode}" Width="200" FontSize="15" MaxWidth="200" MinWidth="200" CanUserReorder="False"/> |
|||
<DataGridTextColumn Header="{x:Static lang:Resources.Group}" Binding="{Binding GROUP_CODE}" Width="200" FontSize="15" MaxWidth="200" MinWidth="200" CanUserReorder="False"/> |
|||
<DataGridTextColumn Binding="{Binding Capacity}" FontSize="15" MaxWidth="0" MinWidth="0" CanUserReorder="False"/> |
|||
<DataGridTextColumn Header="{x:Static lang:Resources.Remark}" Binding="{Binding Note}" Width="600" FontSize="15" MinWidth="100" CanUserReorder="False"/> |
|||
</DataGrid.Columns> |
|||
</DataGrid> |
|||
<!--存储按钮--> |
|||
<Button Grid.Row="3" Content="存储" HorizontalAlignment="Right" Height="50" VerticalAlignment="Center" Width="100" FontSize="30" |
|||
Click="Button_Preservation" Margin="0,0,200,0"> |
|||
</Button> |
|||
<!--删除按钮--> |
|||
<Button Grid.Row="3" Content="删除" HorizontalAlignment="Right" Height="50" VerticalAlignment="Center" Width="100" FontSize="30" |
|||
Click="Button_Delete" Margin="0,0,50,0"> |
|||
</Button> |
|||
</Grid> |
|||
</Window> |
@ -0,0 +1,85 @@ |
|||
using SunlightCentralizedControlManagement_SCCM_.View; |
|||
using System; |
|||
using System.Data; |
|||
using System.Data.SqlClient; |
|||
using System.Text.RegularExpressions; |
|||
using System.Windows; |
|||
using System.Windows.Controls; |
|||
using System.Windows.Input; |
|||
|
|||
namespace SunlightCentralizedControlManagement_SCCM_.WindowsView |
|||
{ |
|||
/// <summary>
|
|||
/// Machine.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class User : Window |
|||
{ |
|||
|
|||
CheckBox[] checkBoxes = new CheckBox[99]; |
|||
string[] strings = new string[0] { }; |
|||
public User() |
|||
{ |
|||
WindowStartupLocation = WindowStartupLocation.CenterScreen; |
|||
InitializeComponent(); |
|||
} |
|||
|
|||
private async void user_Loaded(object sender, RoutedEventArgs e)//打开页面执行
|
|||
{ |
|||
for (int i = 0; i < strings.Length; i++) |
|||
{ |
|||
checkBoxes[i] = new CheckBox(); |
|||
checkBoxes[i].Content = strings[i].ToString(); |
|||
checkBoxes[i].FontSize = 20; |
|||
checkBoxes[i].Width = 80; |
|||
checkBoxes[i].Height = 50; |
|||
checkBoxes[i].IsEnabled = false; |
|||
Capacity.Children.Add(checkBoxes[i]); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
private void Tb_KeyFloating(object sender, TextCompositionEventArgs e)//输入事件
|
|||
{ |
|||
//Regex re = new Regex("[^0-9.-]+");
|
|||
Regex re = new Regex(@"^[.][0-9]+$|^[0-9]*[.]{0,1}[0-9]*$");// 非负浮点数
|
|||
e.Handled = !re.IsMatch(e.Text); |
|||
} |
|||
string Capacity_; |
|||
private void DataGridMac_MouseDoubleClick(object sender, MouseButtonEventArgs e)//数据表双击事件
|
|||
{ |
|||
int rownum = DataGriduser.SelectedIndex;//获取鼠标选中行并定义变量
|
|||
if (rownum != -1)//判断鼠标定位是否有效
|
|||
{ |
|||
/*定位选中行及指定列单元格文本信息*/ |
|||
_Name.Text = (DataGriduser.Columns[0].GetCellContent(DataGriduser.Items[rownum]) as TextBlock).Text.Trim();//定位第列
|
|||
GROUP.Text = (DataGriduser.Columns[1].GetCellContent(DataGriduser.Items[rownum]) as TextBlock).Text.Trim(); |
|||
Capacity_ = (DataGriduser.Columns[2].GetCellContent(DataGriduser.Items[rownum]) as TextBlock).Text.Trim(); |
|||
Note.Text = (DataGriduser.Columns[3].GetCellContent(DataGriduser.Items[rownum]) as TextBlock).Text.Trim(); |
|||
} |
|||
|
|||
Pasword.Text = null; //清除密码框
|
|||
} |
|||
|
|||
private async void Button_Preservation(object sender, RoutedEventArgs e)//保存按钮事件
|
|||
{ |
|||
Regex re_number = new Regex(@"^[0-9]+(.[0-9]{1,2})?$");//校验用正则表达式有1~2位小数的正实数
|
|||
Regex re_char = new Regex(@"^[A-Za-z0-9\s@()()/+!!_-]+$");//校验用正则表达式由数字,26个英文字母,空白字符和@()()/+!!_-组成的字符串
|
|||
|
|||
string name = _Name.Text; |
|||
string password = Pasword.Text; |
|||
string Group = GROUP.Text; |
|||
int Cap = 0; |
|||
string note = Note.Text; |
|||
string Stuff_sql; |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
private async void Button_Delete(object sender, RoutedEventArgs e)//删除按钮事件
|
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue