添加项目文件。
This commit is contained in:
1 parent
15313a5f75
commit
dd43cf0135
30 files changed
+3002
No files matched your search
@@ -0,0 +1,38 @@
|
||||
<UserControl x:Class="SunlightAggregationManager.View.SettingPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:SunlightAggregationManager.View"
|
||||
xmlns:lang="clr-namespace:SunlightAggregationManager"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="720" d:DesignWidth="1080">
|
||||
<Grid>
|
||||
|
||||
<ComboBox HorizontalAlignment="Left" Height="40" Margin="150,10,0,0" x:Name="comboBoxLanguage" VerticalAlignment="Top" Width="400" FontSize="24"/>
|
||||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,10,0,0" TextWrapping="Wrap" Text="{x:Static lang:ResourceLanguage.Language}" VerticalAlignment="Top" Width="120" FontSize="25" Padding="0,0,0,0"/>
|
||||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,60,0,0" TextWrapping="Wrap" Text="{x:Static lang:ResourceLanguage.SERVER}" VerticalAlignment="Top" Width="120" FontSize="25"/>
|
||||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,110,0,0" TextWrapping="Wrap" Text="{x:Static lang:ResourceLanguage.Mode}" VerticalAlignment="Top" Width="120" FontSize="25"/>
|
||||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,160,0,0" TextWrapping="Wrap" Text="{x:Static lang:ResourceLanguage.SQL}" VerticalAlignment="Top" Width="120" FontSize="25"/>
|
||||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,210,0,0" TextWrapping="Wrap" Text="{x:Static lang:ResourceLanguage.user}" VerticalAlignment="Top" Width="120" FontSize="25"/>
|
||||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,260,0,0" TextWrapping="Wrap" Text="{x:Static lang:ResourceLanguage.Password}" VerticalAlignment="Top" Width="120" FontSize="25"/>
|
||||
<TextBox x:Name="TEXT_SQLIP" HorizontalAlignment="Left" Height="40" Margin="150,60,0,0" TextWrapping="NoWrap" VerticalAlignment="Top" Width="400" FontSize="24"/>
|
||||
<ComboBox x:Name="TEXT_SQMOD" Height="40" Margin="150,110,0,0" VerticalAlignment="Top" Width="400" FontSize="24" HorizontalAlignment="Left"/>
|
||||
<TextBox x:Name="TEXT_SQLNAME" HorizontalAlignment="Left" Height="40" Margin="150,160,0,0" TextWrapping="NoWrap" VerticalAlignment="Top" Width="400" FontSize="24"/>
|
||||
<TextBox x:Name="TEXT_SQLUSER" HorizontalAlignment="Left" Height="40" Margin="150,210,0,0" TextWrapping="NoWrap" VerticalAlignment="Top" Width="400" FontSize="24"/>
|
||||
<TextBox x:Name="TEXT_SQLPASWORD" HorizontalAlignment="Left" Height="40" Margin="150,260,0,0" TextWrapping="NoWrap" VerticalAlignment="Top" Width="400" FontSize="24"/>
|
||||
<Button Content="{x:Static lang:ResourceLanguage.Test}" HorizontalAlignment="Left" Height="35" Margin="370,335,0,0" VerticalAlignment="Top" Width="80" Click="test_Click"/>
|
||||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,335,0,0" x:Name="textlog" TextWrapping="Wrap" Text="------------" VerticalAlignment="Top" Width="140" FontSize="20"/>
|
||||
|
||||
|
||||
<CheckBox x:Name="EnableTCP" Content="{x:Static lang:ResourceLanguage.EnableTCP}" HorizontalAlignment="Left" Margin="600,10,0,0" VerticalAlignment="Top" Height="40" Width="300" FontSize="24"
|
||||
Checked="EnableTCP_Checked" Unchecked="EnableTCP_Unchecked"/>
|
||||
<CheckBox x:Name="EnableHTTP" Content="{x:Static lang:ResourceLanguage.EnableHTTP}" HorizontalAlignment="Left" Margin="600,60,0,0" VerticalAlignment="Top" Height="40" Width="300" FontSize="24"
|
||||
Checked="EnableHTTP_Checked" Unchecked="EnableHTTP_Unchecked"/>
|
||||
<CheckBox x:Name="EnableTLS" Content="{x:Static lang:ResourceLanguage.EnableTLS}" HorizontalAlignment="Left" Margin="600,110,0,0" VerticalAlignment="Top" Height="40" Width="300" FontSize="24"
|
||||
Checked="EnableTLS_Checked" Unchecked="EnableTLS_Unchecked"/>
|
||||
|
||||
<Button Content="{x:Static lang:ResourceLanguage.save}" HorizontalAlignment="Right" Height="35" Margin="470,335,0,0" VerticalAlignment="Bottom" Width="80" Click="save_Click"/>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,157 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
//using System.Data.SqlClient;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Text;
|
||||
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 SunlightAggregationManager.View
|
||||
{
|
||||
/// <summary>
|
||||
/// SettingPage.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class SettingPage : UserControl
|
||||
{
|
||||
//调用配置文件
|
||||
private readonly UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "Configini.ini");
|
||||
|
||||
public SettingPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
string[] Language = { "en-US", "zh-CN", "zh-TW" };
|
||||
string[] SQMOD = { "Windows Authentication", "SQL SERVER" };
|
||||
comboBoxLanguage.ItemsSource = Language;
|
||||
TEXT_SQMOD.ItemsSource = SQMOD;
|
||||
try
|
||||
{
|
||||
comboBoxLanguage.Text = Configini.IniReadvalue("SYS", "Language");
|
||||
TEXT_SQLIP.Text = Configini.IniReadvalue("SQL_SERVER", "SQL1"); //读配置文件
|
||||
TEXT_SQLNAME.Text = Configini.IniReadvalue("SQL_SERVER", "SQL2");
|
||||
TEXT_SQMOD.Text = Configini.IniReadvalue("SQL_SERVER", "SQL3");
|
||||
TEXT_SQLUSER.Text = Configini.IniReadvalue("SQL_SERVER", "SQL4");
|
||||
TEXT_SQLPASWORD.Text = Configini.IniReadvalue("SQL_SERVER", "SQL5");
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
|
||||
private async void test_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// UI 更新:显示正在测试
|
||||
textlog.Text = "TEST";
|
||||
// 建议使用静态缓存的画笔,避免频繁创建对象导致内存抖动
|
||||
textlog.Foreground = Brushes.Blue;
|
||||
try
|
||||
{
|
||||
// 构建连接字符串
|
||||
var builder = new SqlConnectionStringBuilder
|
||||
{
|
||||
DataSource = TEXT_SQLIP.Text,
|
||||
InitialCatalog = TEXT_SQLNAME.Text,
|
||||
IntegratedSecurity = TEXT_SQMOD.Text == "Windows Authentication",
|
||||
TrustServerCertificate = true
|
||||
};
|
||||
|
||||
if (!builder.IntegratedSecurity)
|
||||
{
|
||||
builder.UserID = TEXT_SQLUSER.Text;
|
||||
builder.Password = TEXT_SQLPASWORD.Text;
|
||||
}
|
||||
|
||||
// 异步连接数据库
|
||||
await using var conn_SC = new SqlConnection(builder.ConnectionString);
|
||||
|
||||
// 使用 OpenAsync 代替 Open,避免卡死界面
|
||||
await conn_SC.OpenAsync();
|
||||
using (var cmd = new SqlCommand("SELECT 1", conn_SC))
|
||||
{
|
||||
cmd.ExecuteReader();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// 失败处理
|
||||
textlog.Text = "Link timeout";
|
||||
textlog.Foreground = Brushes.Red;
|
||||
return; // 直接返回,不执行后续代码
|
||||
}
|
||||
|
||||
// 成功处理
|
||||
textlog.Text = "Link succeed";
|
||||
textlog.Foreground = Brushes.Green;
|
||||
|
||||
Console.WriteLine("IP = "+TEXT_SQLIP.Text);
|
||||
Console.WriteLine("DataBase = " + TEXT_SQLNAME.Text);
|
||||
Console.WriteLine("Link succeed");
|
||||
|
||||
// 弹出对话框本身会阻塞 UI 线程
|
||||
MessageBoxResult SqlShow = System.Windows.MessageBox.Show(
|
||||
"Whether the connection is successfully saved",
|
||||
"SQL",
|
||||
MessageBoxButton.YesNo,
|
||||
MessageBoxImage.Information);
|
||||
|
||||
if (SqlShow == MessageBoxResult.Yes)
|
||||
{
|
||||
Configini.IniWritevalue("SQL_SERVER", "SQL1", TEXT_SQLIP.Text);
|
||||
Configini.IniWritevalue("SQL_SERVER", "SQL2", TEXT_SQLNAME.Text);
|
||||
Configini.IniWritevalue("SQL_SERVER", "SQL3", TEXT_SQMOD.SelectedValue?.ToString());
|
||||
Configini.IniWritevalue("SQL_SERVER", "SQL4", TEXT_SQLUSER.Text);
|
||||
Configini.IniWritevalue("SQL_SERVER", "SQL5", TEXT_SQLPASWORD.Text);
|
||||
|
||||
Console.WriteLine("Save database settings");
|
||||
}
|
||||
}
|
||||
|
||||
private void save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Configini.IniWritevalue("SYS", "Language", comboBoxLanguage.SelectedValue?.ToString());
|
||||
Configini.IniWritevalue("SQL_SERVER", "SQL1", TEXT_SQLIP.Text);
|
||||
Configini.IniWritevalue("SQL_SERVER", "SQL2", TEXT_SQLNAME.Text);
|
||||
Configini.IniWritevalue("SQL_SERVER", "SQL3", TEXT_SQMOD.SelectedValue?.ToString());
|
||||
Configini.IniWritevalue("SQL_SERVER", "SQL4", TEXT_SQLUSER.Text);
|
||||
Configini.IniWritevalue("SQL_SERVER", "SQL5", TEXT_SQLPASWORD.Text);
|
||||
|
||||
Console.WriteLine("Save global settings");
|
||||
}
|
||||
|
||||
//是否启用tcp
|
||||
private void EnableTCP_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Configini.IniWritevalue("NETWORK", "TCP", "1");
|
||||
}
|
||||
|
||||
private void EnableTCP_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Configini.IniWritevalue("NETWORK", "TCP", "0");
|
||||
}
|
||||
|
||||
private void EnableHTTP_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Configini.IniWritevalue("NETWORK", "HTTP", "1");
|
||||
}
|
||||
|
||||
private void EnableHTTP_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Configini.IniWritevalue("NETWORK", "HTTP", "0");
|
||||
}
|
||||
|
||||
private void EnableTLS_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Configini.IniWritevalue("NETWORK", "TLS", "1");
|
||||
}
|
||||
|
||||
private void EnableTLS_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Configini.IniWritevalue("NETWORK", "TLS", "0");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<UserControl x:Class="SunlightAggregationManager.View.StatePage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:SunlightAggregationManager.View"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="720" d:DesignWidth="1080">
|
||||
<Grid>
|
||||
<TextBox x:Name="LOG" TextWrapping="Wrap" Margin="5,200,5,5" FontSize="16"/>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,33 @@
|
||||
using Net.Codecrete.QrCodeGenerator;
|
||||
using SunlightAggregationManager.UserClass;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
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;
|
||||
using static System.Net.WebRequestMethods;
|
||||
|
||||
namespace SunlightAggregationManager.View
|
||||
{
|
||||
/// <summary>
|
||||
/// StatePage.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class StatePage : UserControl
|
||||
{
|
||||
public StatePage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<UserControl x:Class="SunlightAggregationManager.View.UserPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:SunlightAggregationManager.View"
|
||||
xmlns:ConvertMoels="clr-namespace:SunlightAggregationManager.ConvertMoels"
|
||||
xmlns:lang="clr-namespace:SunlightAggregationManager"
|
||||
xmlns:viewmodel="clr-namespace:SunlightAggregationManager.ViewModel"
|
||||
d:DataContext="{d:DesignInstance Type=viewmodel:MainWindowViewModel}"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="720" d:DesignWidth="1080">
|
||||
<!--设定变换器-->
|
||||
<UserControl.Resources>
|
||||
<ConvertMoels:StatenConvert x:Key="StatenConvert"/>
|
||||
<ConvertMoels:StatenERRConvert x:Key="StatenERRConvert"/>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<DataGrid x:Name="DataGridmachinesdata"
|
||||
ItemsSource="{Binding UserData.DefaultView}"
|
||||
SelectionChanged="DataGridmachinesdata_SelectionChanged"
|
||||
SelectionMode="Single"
|
||||
AlternationCount="2"
|
||||
IsReadOnly="True"
|
||||
FontSize="26"
|
||||
Margin="5,5,5,5"
|
||||
AutoGenerateColumns="False"
|
||||
MinColumnWidth="30"
|
||||
HorizontalGridLinesBrush="#FFC9C9C9"
|
||||
VerticalGridLinesBrush="#FFC9C9C9"
|
||||
GridLinesVisibility="All"
|
||||
BorderBrush="#CCCCCC"
|
||||
BorderThickness="1,1,1,1"
|
||||
ColumnHeaderHeight="40"
|
||||
HorizontalContentAlignment="Right"
|
||||
CanUserReorderColumns="False"
|
||||
VerticalContentAlignment="Center">
|
||||
<DataGrid.RowStyle >
|
||||
<Style TargetType="{x:Type DataGridRow}">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
|
||||
<Setter Property="Background" Value="#FFFFFFFF" />
|
||||
<Setter Property="Height" Value="40" />
|
||||
</Trigger>
|
||||
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
|
||||
<Setter Property="Background" Value="#FFF0F0F0" />
|
||||
<Setter Property="Height" Value="40" />
|
||||
</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.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="{x:Static lang:ResourceLanguage.information}" Click="MenuItem_Information"/>
|
||||
<MenuItem Header="{x:Static lang:ResourceLanguage.Offine}" Click="MenuItem_Offine"/>
|
||||
<MenuItem Header="{x:Static lang:ResourceLanguage.Enable}" Click="MenuItem_Enable"/>
|
||||
<MenuItem Header="{x:Static lang:ResourceLanguage.Disable}" Click="MenuItem_Disable"/>
|
||||
</ContextMenu>
|
||||
</DataGrid.ContextMenu>
|
||||
<DataGrid.Columns>
|
||||
<!--列信息绑定-->
|
||||
<DataGridTextColumn Header="{x:Static lang:ResourceLanguage.user}" Width="200" FontSize="26"
|
||||
Binding="{Binding User}" MaxWidth="200" MinWidth="200" CanUserReorder="False"/>
|
||||
|
||||
<DataGridTextColumn Header="{x:Static lang:ResourceLanguage.Name}" Width="200" FontSize="26"
|
||||
Binding="{Binding Name}" MaxWidth="200" MinWidth="200" CanUserReorder="False"/>
|
||||
<DataGridTextColumn Header="{x:Static lang:ResourceLanguage.state}" Width="120" FontSize="26"
|
||||
MaxWidth="120" MinWidth="120" CanUserReorder="False">
|
||||
<!--事件名称:工作状态数字转文字显示,转换器StatenConvert-->
|
||||
<DataGridTextColumn.ElementStyle>
|
||||
<Style TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Text" Value="{Binding Path=State,Converter={StaticResource StatenConvert}}">
|
||||
</Setter>
|
||||
<Setter Property="Foreground" Value="{Binding Path=State,Converter={StaticResource StatenERRConvert}}">
|
||||
</Setter>
|
||||
</Style>
|
||||
</DataGridTextColumn.ElementStyle>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn Header="{x:Static lang:ResourceLanguage.Department}" Width="150" FontSize="26"
|
||||
Binding="{Binding Department}" MinWidth="150" CanUserReorder="False"/>
|
||||
<DataGridTextColumn Header="{x:Static lang:ResourceLanguage.LastLoginIP}" Width="250" FontSize="26"
|
||||
Binding="{Binding LastLoginIP}" MinWidth="250" CanUserReorder="False"/>
|
||||
<DataGridTextColumn Header="{x:Static lang:ResourceLanguage.LastLoginTerminal}" Width="300" FontSize="26"
|
||||
Binding="{Binding LastLoginTerminal}" MinWidth="300" CanUserReorder="False"/>
|
||||
<DataGridTextColumn Header="{x:Static lang:ResourceLanguage.LastLoginTime}" Width="300" FontSize="26"
|
||||
Binding="{Binding LastLoginTime}" MinWidth="300" CanUserReorder="False"/>
|
||||
<DataGridTextColumn Header="{x:Static lang:ResourceLanguage.LastActionTime}" Width="300" FontSize="26"
|
||||
Binding="{Binding LastActionTime}" MinWidth="300" CanUserReorder="False"/>
|
||||
<DataGridTextColumn Header="{x:Static lang:ResourceLanguage.LastOfflineTime}" Width="300" FontSize="26"
|
||||
Binding="{Binding LastOfflineTime}" MinWidth="300" CanUserReorder="False"/>
|
||||
<DataGridTextColumn Header="{x:Static lang:ResourceLanguage.Groups}" Width="200" FontSize="26"
|
||||
Binding="{Binding Groups}" MinWidth="200" CanUserReorder="False"/>
|
||||
<DataGridTextColumn Header="{x:Static lang:ResourceLanguage.information}" Width="*" FontSize="26"
|
||||
Binding="{Binding Note}" MinWidth="200" CanUserReorder="False"/>
|
||||
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,90 @@
|
||||
using SunlightAggregationManager.UserClass;
|
||||
using SunlightAggregationManager.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
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;
|
||||
using System.Xml.Linq;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Sockets;
|
||||
|
||||
namespace SunlightAggregationManager.View
|
||||
{
|
||||
/// <summary>
|
||||
/// UserPage.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class UserPage : UserControl
|
||||
{
|
||||
public UserPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private string user_id = "";
|
||||
|
||||
private void DataGridmachinesdata_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
int rownum = DataGridmachinesdata.SelectedIndex;//获取鼠标选中行并定义变量
|
||||
if (rownum != -1)//判断鼠标定位是否有效
|
||||
{
|
||||
var row_ = DataGridmachinesdata.Columns[0].GetCellContent(DataGridmachinesdata.Items[rownum]);
|
||||
if (row_ is TextBlock textBlock)
|
||||
{
|
||||
user_id = textBlock.Text;//定位第0列,
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void MenuItem_Information(object sender, RoutedEventArgs e)//信息
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private async void MenuItem_Offine(object sender, RoutedEventArgs e)//下线
|
||||
{
|
||||
var _state = MainWindowViewModel.Selet_Memory(MainWindowViewModel._userData, "State", "User='" + user_id + "'");
|
||||
var _user = MainWindowViewModel.Selet_Memory(MainWindowViewModel._userData, "LinkID", "User='" + user_id +"'");
|
||||
|
||||
if ((_user != null)&&(_state?.ToString()=="20"))
|
||||
{
|
||||
foreach (var item in AsyncTcpServer.service.Clients)
|
||||
{
|
||||
if (item.Id == _user.ToString())
|
||||
{
|
||||
await item.CloseAsync();
|
||||
|
||||
//在断开连接后,释放对象。
|
||||
item.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void MenuItem_Enable(object sender, RoutedEventArgs e)//启用账号
|
||||
{
|
||||
MainWindowViewModel.Updata_Memory(MainWindowViewModel._userData, "User='" + user_id + "'", "0", "State");
|
||||
}
|
||||
|
||||
private void MenuItem_Disable(object sender, RoutedEventArgs e)//停用账号
|
||||
{
|
||||
MainWindowViewModel.Updata_Memory(MainWindowViewModel._userData, "User='" + user_id + "'", "99", "State");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<UserControl x:Class="SunlightAggregationManager.View.imgQR"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:SunlightAggregationManager.View"
|
||||
mc:Ignorable="d"
|
||||
Loaded="imgQR_Loaded"
|
||||
d:DesignHeight="720" d:DesignWidth="1080">
|
||||
<Grid>
|
||||
<TextBlock Text="APP" Margin="300,100,20,10" Foreground="Black" HorizontalAlignment="Left" FontSize="48" VerticalAlignment="Top"/>
|
||||
<TextBlock Text="LINK" VerticalAlignment="Top" Margin="0,100,300,10" Foreground="Black" HorizontalAlignment="Right" FontSize="48"/>
|
||||
<Image x:Name="imgQR_app" MinWidth="300" MinHeight="300" MaxWidth="300" MaxHeight="300" Width="300" Height="300" Stretch="Uniform" Margin="200,0,0,0" HorizontalAlignment="Left"/>
|
||||
<Image x:Name="imgQR_link" MinWidth="300" MinHeight="300" MaxWidth="300" MaxHeight="300" Width="300" Height="300" Stretch="Uniform" HorizontalAlignment="Right" Margin="0,0,200,0"/>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,105 @@
|
||||
using Net.Codecrete.QrCodeGenerator;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
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.Media.TextFormatting;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using static System.Net.WebRequestMethods;
|
||||
|
||||
namespace SunlightAggregationManager.View
|
||||
{
|
||||
/// <summary>
|
||||
/// StatePage.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class imgQR : UserControl
|
||||
{
|
||||
//调用配置文件
|
||||
private readonly UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "Configini.ini");
|
||||
|
||||
|
||||
public imgQR()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成二维码
|
||||
/// 调用示例: imgQR_CREATE("TEST", imgQR);;
|
||||
/// </summary>
|
||||
/// <param name="data">[字符串]</param>
|
||||
/// <param name="Image">Image控件</param>
|
||||
void imgQR_CREATE(string DAT, System.Windows.Controls.Image image)
|
||||
{
|
||||
// 生成二维码对象
|
||||
QrCode qr = QrCode.EncodeText(DAT, QrCode.Ecc.Medium);
|
||||
|
||||
// 手动绘制 Bitmap (不使用扩展方法)
|
||||
int scale = 10; // 每个点的像素大小
|
||||
int border = 4; // 边距
|
||||
int size = (qr.Size + border * 2) * scale;
|
||||
// 创建位图
|
||||
using (Bitmap bmp = new Bitmap(size, size))
|
||||
{
|
||||
using (Graphics gfx = Graphics.FromImage(bmp))
|
||||
{
|
||||
// 填充背景(白色)
|
||||
gfx.Clear(System.Drawing.Color.White);
|
||||
|
||||
// 绘制二维码点阵(黑色)
|
||||
using (System.Drawing.Brush brush = new SolidBrush(System.Drawing.Color.Black))
|
||||
{
|
||||
for (int y = 0; y < qr.Size; y++)
|
||||
{
|
||||
for (int x = 0; x < qr.Size; x++)
|
||||
{
|
||||
if (qr.GetModule(x, y))
|
||||
{
|
||||
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(
|
||||
(x + border) * scale,
|
||||
(y + border) * scale,
|
||||
scale, scale);
|
||||
gfx.FillRectangle(brush, rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 转换为 WPF 的 BitmapImage 并显示
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
|
||||
ms.Position = 0;
|
||||
|
||||
BitmapImage bitmapImage = new BitmapImage();
|
||||
bitmapImage.BeginInit();
|
||||
bitmapImage.StreamSource = ms;
|
||||
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
|
||||
bitmapImage.EndInit();
|
||||
|
||||
// 赋值给 Image 控件 (假设控件名为 imgQR)
|
||||
image.Source = bitmapImage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void imgQR_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string text_APP = "TEST"; // 要生成二维码的内容
|
||||
string text_LINK = Configini.IniReadvalue("SYS", "LINK"); // 要生成二维码的内容
|
||||
|
||||
imgQR_CREATE(text_APP, imgQR_app);
|
||||
imgQR_CREATE(text_LINK, imgQR_link);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<UserControl x:Class="SunlightAggregationManager.View.logPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:SunlightAggregationManager.View"
|
||||
mc:Ignorable="d"
|
||||
Loaded="logPage_Loaded"
|
||||
d:DesignHeight="720" d:DesignWidth="1080">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="600"/>
|
||||
<ColumnDefinition Width="5"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ComboBox Height="45" x:Name="comboBox_log" VerticalAlignment="Top" FontSize="20" Background="#FF90BEFF"
|
||||
DropDownClosed="comboBox_log_DropDownClosed" BorderBrush="#FF00204E" Padding="1,1,1,1"/>
|
||||
<DataGrid Grid.Column="0" x:Name="gridLog" Margin="0,50,0,0" HeadersVisibility ="Column"
|
||||
IsReadOnly="True" AutoGenerateColumns="False" MouseDoubleClick="DataGrid_gridLogClick" >
|
||||
<DataGrid.Columns>
|
||||
<!--列信息绑定-->
|
||||
<DataGridTextColumn Binding="{Binding Name}" Header="Name" Width="195" MaxWidth="195" MinWidth="195" CanUserReorder="False"/>
|
||||
<DataGridTextColumn Binding="{Binding Length}" Header="Volume" Width="50" MaxWidth="150" MinWidth="100" CanUserReorder="False"/>
|
||||
<DataGridTextColumn Binding="{Binding CreationTimeUtc}" Header="Creation time" Width="150" MaxWidth="150" MinWidth="150" CanUserReorder="False"/>
|
||||
<DataGridTextColumn Binding="{Binding LastWriteTimeUtc}" Header="Last modified time" Width="150" MaxWidth="150" MinWidth="150" CanUserReorder="False"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Stretch" Background="#FF00204E"/>
|
||||
<RichTextBox Grid.Column="2" x:Name="Logtext" IsReadOnly="True" Background="White" SelectionBrush="White"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,143 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
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 SunlightAggregationManager.View
|
||||
{
|
||||
/// <summary>
|
||||
/// logPage.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class logPage : UserControl
|
||||
{
|
||||
public logPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private readonly string Log_time = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
DataTable logdataTable = new DataTable(); //建立缓存
|
||||
long TEXT_L;
|
||||
|
||||
private void logPage_Loaded(object sender, RoutedEventArgs e)//页面打开事件
|
||||
{
|
||||
comboBox_log.ItemsSource = new string[3] { "Log", "ERR", "Exchange" };
|
||||
comboBox_log.Text = "Log";
|
||||
|
||||
logdataTable.Columns.Add("Name", typeof(string));
|
||||
logdataTable.Columns.Add("Length", typeof(int));
|
||||
logdataTable.Columns.Add("CreationTimeUtc", typeof(string));
|
||||
logdataTable.Columns.Add("LastWriteTimeUtc", typeof(string));
|
||||
|
||||
DirectoryInfo loginfo = new DirectoryInfo(System.Environment.CurrentDirectory + "\\Log"); //new文件夹
|
||||
logdataTable.Clear();
|
||||
foreach (var item in loginfo.GetFiles())
|
||||
{
|
||||
DataRow FileRow = logdataTable.NewRow();
|
||||
FileRow["Name"] = item.Name;
|
||||
FileRow["Length"] = item.Length / 1024;
|
||||
FileRow["CreationTimeUtc"] = item.CreationTimeUtc;
|
||||
FileRow["LastWriteTimeUtc"] = item.LastWriteTimeUtc;
|
||||
logdataTable.Rows.Add(FileRow);
|
||||
}
|
||||
logdataTable.DefaultView.Sort = "Name DESC";
|
||||
gridLog.ItemsSource = logdataTable.DefaultView.ToTable().DefaultView;
|
||||
}
|
||||
|
||||
private void LOG_file()//建立列表
|
||||
{
|
||||
DirectoryInfo loginfo = new DirectoryInfo(System.Environment.CurrentDirectory + "\\" + comboBox_log.Text); //new文件夹
|
||||
logdataTable.Clear();
|
||||
foreach (var item in loginfo.GetFiles())
|
||||
{
|
||||
DataRow FileRow = logdataTable.NewRow();
|
||||
FileRow["Name"] = item.Name;
|
||||
FileRow["Length"] = item.Length / 1024;
|
||||
FileRow["CreationTimeUtc"] = item.CreationTimeUtc;
|
||||
FileRow["LastWriteTimeUtc"] = item.LastWriteTimeUtc;
|
||||
logdataTable.Rows.Add(FileRow);
|
||||
}
|
||||
logdataTable.DefaultView.Sort = "Name DESC";
|
||||
gridLog.ItemsSource = logdataTable.DefaultView.ToTable().DefaultView;
|
||||
}
|
||||
|
||||
private void DataGrid_gridLogClick(object sender, MouseButtonEventArgs e)//数据表双击事件
|
||||
{
|
||||
int rownum = gridLog.SelectedIndex;//获取鼠标选中行并定义变量
|
||||
if (rownum != -1)//判断鼠标定位是否有效
|
||||
{
|
||||
/*定位选中行及指定列单元格文本信息*/
|
||||
//获取单元格内容
|
||||
var cellContent = gridLog.Columns[0].GetCellContent(gridLog.Items[rownum]);
|
||||
//安全转换为 TextBlock 并获取文本
|
||||
var textValue = (cellContent as TextBlock)?.Text;
|
||||
if (!string.IsNullOrEmpty(textValue))
|
||||
{
|
||||
LOGDATA_file(textValue);//
|
||||
}
|
||||
|
||||
var Content_L = gridLog.Columns[1].GetCellContent(gridLog.Items[rownum]);
|
||||
var Value_L = (Content_L as TextBlock)?.Text.ToString();
|
||||
if (!string.IsNullOrEmpty(Value_L))
|
||||
{
|
||||
TEXT_L = long.Parse(Value_L) * 1024 + 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取文件显示到前端
|
||||
/// 调用示例: LOGDATA_file(file path);
|
||||
/// </summary>
|
||||
/// <param name="path">文件路径</param>
|
||||
private async void LOGDATA_file(string dat) //读取文件显示到前端
|
||||
{
|
||||
Logtext.SelectAll();
|
||||
Logtext.Cut();
|
||||
Logtext.Document = new FlowDocument();
|
||||
string filePath = System.Environment.CurrentDirectory + "\\" + comboBox_log.Text + "\\";
|
||||
try
|
||||
{
|
||||
Logtext.AppendText("Loading...");
|
||||
string log_ = "";
|
||||
string log_DAT = await Task<string>.Run(() =>
|
||||
{
|
||||
// 使用StreamReader读取文件
|
||||
using (StreamReader reader = new StreamReader(filePath + dat))
|
||||
{
|
||||
// 读取文件直到文件的末尾
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
// 添加文件的每一行到RichTextBox
|
||||
log_ = log_ + reader.ReadLine() + "\n";
|
||||
}
|
||||
}
|
||||
return log_;
|
||||
});
|
||||
Logtext.SelectAll();
|
||||
Logtext.Cut();
|
||||
Logtext.AppendText(log_DAT);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 处理可能发生的任何异常
|
||||
MessageBox.Show("Error reading file: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox_log_DropDownClosed(object sender, EventArgs e)
|
||||
{
|
||||
LOG_file();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user