@@ -0,0 +1,20 @@ | |||||
using Stylet; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Windows.Controls.Primitives; | |||||
namespace DTO | |||||
{ | |||||
public class AdDTO : PropertyChangedBase | |||||
{ | |||||
public string Device { get; set; } | |||||
bool _IsActive; | |||||
public bool IsActive | |||||
{ | |||||
get => _IsActive; | |||||
set => SetAndNotify(ref _IsActive, value); | |||||
} | |||||
public string Ad { get; set; } | |||||
} | |||||
} |
@@ -23,6 +23,7 @@ | |||||
<None Remove="HKResouces\背景.jpg" /> | <None Remove="HKResouces\背景.jpg" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="CalcBinding" Version="2.5.2" /> | |||||
<PackageReference Include="HandyControls" Version="3.4.1" /> | <PackageReference Include="HandyControls" Version="3.4.1" /> | ||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" /> | <PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" /> | ||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" /> | <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" /> | ||||
@@ -1,9 +1,12 @@ | |||||
using System; | |||||
using HKCardOUT.Views; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Globalization; | |||||
using System.IO; | using System.IO; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using System.Windows.Data; | |||||
using XExten.Advance.StaticFramework; | using XExten.Advance.StaticFramework; | ||||
namespace HKCardOUT.Helper | namespace HKCardOUT.Helper | ||||
@@ -23,10 +26,37 @@ namespace HKCardOUT.Helper | |||||
public static bool NetWordState { get; set; } = false; | public static bool NetWordState { get; set; } = false; | ||||
public static string Cron { get; set; } | public static string Cron { get; set; } | ||||
public static string SaasRoute { get; set; } | public static string SaasRoute { get; set; } | ||||
public static Dictionary<string, AdWindow> AdStatus { get; set; } = new Dictionary<string, AdWindow>(); | |||||
} | } | ||||
public class ApiRoute | public class ApiRoute | ||||
{ | { | ||||
/// <summary> | |||||
/// 检查卡的状态 | |||||
/// </summary> | |||||
public static string CheckCardStatus = DataBus.SaasRoute + ""; | public static string CheckCardStatus = DataBus.SaasRoute + ""; | ||||
/// <summary> | |||||
/// 同步消费记录 | |||||
/// </summary> | |||||
public static string SyncSaleLog = DataBus.SaasRoute + ""; | public static string SyncSaleLog = DataBus.SaasRoute + ""; | ||||
/// <summary> | |||||
/// 获取档口信息 | |||||
/// </summary> | |||||
public static string PullWindow = DataBus.SaasRoute + ""; | |||||
/// <summary> | |||||
/// 获取店铺信息 | |||||
/// </summary> | |||||
public static string PullShopInfo = DataBus.SaasRoute + ""; | |||||
} | |||||
public class HKConverter : IValueConverter | |||||
{ | |||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |||||
{ | |||||
return (bool)value ? "启用" : "禁用"; | |||||
} | |||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |||||
{ | |||||
return value; | |||||
} | |||||
} | } | ||||
} | } |
@@ -6,7 +6,7 @@ using System.Text; | |||||
using System.Threading; | using System.Threading; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace HKCardOut.Helper | |||||
namespace HKCardOUT.Helper | |||||
{ | { | ||||
public class HKHelper: Singleton<HKHelper> | public class HKHelper: Singleton<HKHelper> | ||||
{ | { | ||||
@@ -6,7 +6,7 @@ using System.Text; | |||||
using System.Threading; | using System.Threading; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace HKCardOut.Helper | |||||
namespace HKCardOUT.Helper | |||||
{ | { | ||||
public class Singleton<T> where T : new() | public class Singleton<T> where T : new() | ||||
{ | { | ||||
@@ -25,5 +25,10 @@ namespace HKCardOUT.Logic.Model | |||||
/// </summary> | /// </summary> | ||||
[SugarColumn(IsNullable = false)] | [SugarColumn(IsNullable = false)] | ||||
public string Location { get; set; } | public string Location { get; set; } | ||||
/// <summary> | |||||
/// 是否同步过了 | |||||
/// </summary> | |||||
[SugarColumn(IsNullable = false)] | |||||
public bool IsSync { get; set; } | |||||
} | } | ||||
} | } |
@@ -32,5 +32,25 @@ namespace HKCardOUT.Logic | |||||
t.NodePath = ApiRoute.SyncSaleLog; | t.NodePath = ApiRoute.SyncSaleLog; | ||||
}).Build().RunStringFirst(); | }).Build().RunStringFirst(); | ||||
} | } | ||||
/// <summary> | |||||
/// 获取档口信息 | |||||
/// </summary> | |||||
public static void PullWindow() | |||||
{ | |||||
IHttpMultiClient.HttpMulti.AddNode(t => | |||||
{ | |||||
t.NodePath = ApiRoute.PullWindow; | |||||
}).Build().RunStringFirst(); | |||||
} | |||||
/// <summary> | |||||
/// 获取店铺信息 | |||||
/// </summary> | |||||
public static void PullShopInfo() | |||||
{ | |||||
IHttpMultiClient.HttpMulti.AddNode(t => | |||||
{ | |||||
t.NodePath = ApiRoute.PullShopInfo; | |||||
}).Build().RunStringFirst(); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,12 +1,15 @@ | |||||
using HKCardOut.Helper; | |||||
using DTO; | |||||
using HKCardOUT.Helper; | using HKCardOUT.Helper; | ||||
using HKCardOUT.Logic.Model; | using HKCardOUT.Logic.Model; | ||||
using HKCardOUT.Logic.Service; | using HKCardOUT.Logic.Service; | ||||
using Stylet; | using Stylet; | ||||
using StyletIoC; | using StyletIoC; | ||||
using System; | using System; | ||||
using System.Collections.Generic; | |||||
using System.Collections.ObjectModel; | using System.Collections.ObjectModel; | ||||
using System.Linq; | |||||
using System.Threading; | using System.Threading; | ||||
using System.Windows.Documents; | |||||
namespace HKCardOUT.ViewModels | namespace HKCardOUT.ViewModels | ||||
{ | { | ||||
@@ -35,6 +38,12 @@ namespace HKCardOUT.ViewModels | |||||
get => _Result; | get => _Result; | ||||
set => SetAndNotify(ref _Result, value); | set => SetAndNotify(ref _Result, value); | ||||
} | } | ||||
ObservableCollection<AdDTO> _Ad; | |||||
public ObservableCollection<AdDTO> Ad | |||||
{ | |||||
get => _Ad; | |||||
set => SetAndNotify(ref _Ad, value); | |||||
} | |||||
#endregion | #endregion | ||||
#region 方法 | #region 方法 | ||||
@@ -61,5 +70,37 @@ namespace HKCardOUT.ViewModels | |||||
}), "循环状态监测线程", false); | }), "循环状态监测线程", false); | ||||
} | } | ||||
#endregion | #endregion | ||||
#region 命令 | |||||
/// <summary> | |||||
/// 广告位置 | |||||
/// </summary> | |||||
/// <param name="input"></param> | |||||
public void UpdateAction(AdDTO input) | |||||
{ | |||||
input.IsActive = !input.IsActive; | |||||
var SC = System.Windows.Forms.Screen.AllScreens.Count(); | |||||
if (SC >= 1) | |||||
{ | |||||
if (input.IsActive) | |||||
{ | |||||
if (!DataBus.AdStatus.ContainsKey(input.Device)) | |||||
{ | |||||
var win = new Views.AdWindow(input.Ad); | |||||
DataBus.AdStatus.Add(input.Device, win); | |||||
win.Show(); | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
if (DataBus.AdStatus.ContainsKey(input.Device)) | |||||
{ | |||||
DataBus.AdStatus[input.Device].Close(); | |||||
DataBus.AdStatus.Remove(input.Device); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
#endregion | |||||
} | } | ||||
} | } |
@@ -19,12 +19,14 @@ namespace HKCardOUT.Views | |||||
/// </summary> | /// </summary> | ||||
public partial class AdWindow : HandyControl.Controls.Window | public partial class AdWindow : HandyControl.Controls.Window | ||||
{ | { | ||||
public AdWindow() | |||||
public AdWindow(string input) | |||||
{ | { | ||||
InitializeComponent(); | InitializeComponent(); | ||||
InitView2(); | |||||
InitView2(input); | |||||
} | } | ||||
public async void InitView2() | |||||
public async void InitView2(string input) | |||||
{ | { | ||||
await view2.EnsureCoreWebView2Async(null); | await view2.EnsureCoreWebView2Async(null); | ||||
view2.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false; | view2.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false; | ||||
@@ -2,10 +2,14 @@ | |||||
x:Class="HKCardOUT.Views.RootView" | x:Class="HKCardOUT.Views.RootView" | ||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||
xmlns:c="clr-namespace:CalcBinding;assembly=CalcBinding" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||
xmlns:hc="https://handyorg.github.io/handycontrol" | xmlns:hc="https://handyorg.github.io/handycontrol" | ||||
xmlns:helper="clr-namespace:HKCardOUT.Helper" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||
xmlns:s="https://github.com/canton7/Stylet" | |||||
xmlns:viewModels="clr-namespace:HKCardOUT.ViewModels" | xmlns:viewModels="clr-namespace:HKCardOUT.ViewModels" | ||||
x:Name="Main" | |||||
Title="海科智慧一卡通平台" | Title="海科智慧一卡通平台" | ||||
d:DataContext="{d:DesignInstance Type=viewModels:RootViewModel}" | d:DataContext="{d:DesignInstance Type=viewModels:RootViewModel}" | ||||
ShowMaxButton="False" | ShowMaxButton="False" | ||||
@@ -15,6 +19,7 @@ | |||||
WindowState="Maximized" | WindowState="Maximized" | ||||
mc:Ignorable="d"> | mc:Ignorable="d"> | ||||
<hc:Window.Resources> | <hc:Window.Resources> | ||||
<helper:HKConverter x:Key="TOC" /> | |||||
<Style x:Key="SaleLogHeader" TargetType="DataGridColumnHeader"> | <Style x:Key="SaleLogHeader" TargetType="DataGridColumnHeader"> | ||||
<Setter Property="FontSize" Value="18" /> | <Setter Property="FontSize" Value="18" /> | ||||
<Setter Property="Background" Value="Transparent" /> | <Setter Property="Background" Value="Transparent" /> | ||||
@@ -34,47 +39,90 @@ | |||||
<hc:Window.Background> | <hc:Window.Background> | ||||
<ImageBrush ImageSource="/HKResouces/背景.jpg" /> | <ImageBrush ImageSource="/HKResouces/背景.jpg" /> | ||||
</hc:Window.Background> | </hc:Window.Background> | ||||
<DataGrid | |||||
AutoGenerateColumns="False" | |||||
Background="Transparent" | |||||
IsReadOnly="True" | |||||
ItemsSource="{Binding Result}" | |||||
Style="{StaticResource DataGridBaseStyle}"> | |||||
<DataGrid.RowStyle> | |||||
<Style BasedOn="{StaticResource DataGridRowStyle}" TargetType="DataGridRow"> | |||||
<Setter Property="Background" Value="Transparent" /> | |||||
<Style.Triggers> | |||||
<Trigger Property="UIElement.IsMouseOver" Value="true"> | |||||
<Setter Property="Background" Value="Transparent" /> | |||||
</Trigger> | |||||
</Style.Triggers> | |||||
</Style> | |||||
</DataGrid.RowStyle> | |||||
<DataGrid.Columns> | |||||
<DataGridTextColumn | |||||
Width="260" | |||||
Binding="{Binding CardNo}" | |||||
ElementStyle="{StaticResource CenterAlignmentStyle}" | |||||
Header="卡号" | |||||
HeaderStyle="{StaticResource SaleLogHeader}" /> | |||||
<DataGridTextColumn | |||||
Width="260" | |||||
Binding="{Binding Money}" | |||||
ElementStyle="{StaticResource CenterAlignmentStyle}" | |||||
Header="金额" | |||||
HeaderStyle="{StaticResource SaleLogHeader}" /> | |||||
<DataGridTextColumn | |||||
Width="260" | |||||
Binding="{Binding Location}" | |||||
ElementStyle="{StaticResource CenterAlignmentStyle}" | |||||
Header="档口" | |||||
HeaderStyle="{StaticResource SaleLogHeader}" /> | |||||
<DataGridTextColumn | |||||
Width="260" | |||||
Binding="{Binding CreateTime, StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" | |||||
ElementStyle="{StaticResource CenterAlignmentStyle}" | |||||
Header="消费时间" | |||||
HeaderStyle="{StaticResource SaleLogHeader}" /> | |||||
</DataGrid.Columns> | |||||
</DataGrid> | |||||
<StackPanel> | |||||
<ListBox | |||||
Background="Transparent" | |||||
BorderThickness="0" | |||||
ItemsSource="{Binding Ad}" | |||||
Style="{StaticResource WrapPanelHorizontalListBox}"> | |||||
<ListBox.ItemsPanel> | |||||
<ItemsPanelTemplate> | |||||
<WrapPanel HorizontalAlignment="Left" VerticalAlignment="Center" /> | |||||
</ItemsPanelTemplate> | |||||
</ListBox.ItemsPanel> | |||||
<ListBox.ItemTemplate> | |||||
<DataTemplate> | |||||
<Button | |||||
Width="100" | |||||
Height="80" | |||||
Margin="20,0,0,0" | |||||
s:View.ActionTarget="{Binding DataContext, ElementName=Main}" | |||||
Command="{s:Action UpdateAction}" | |||||
CommandParameter="{Binding .}" | |||||
Style="{StaticResource ButtonDefault}"> | |||||
<Button.Content> | |||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> | |||||
<TextBlock | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="18" | |||||
FontWeight="Bold" | |||||
Text="{Binding Device}" /> | |||||
<TextBlock | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="18" | |||||
FontWeight="Bold" | |||||
Foreground="Red" | |||||
Text="{Binding IsActive, Converter={StaticResource TOC}}" /> | |||||
</StackPanel> | |||||
</Button.Content> | |||||
</Button> | |||||
</DataTemplate> | |||||
</ListBox.ItemTemplate> | |||||
</ListBox> | |||||
<DataGrid | |||||
AutoGenerateColumns="False" | |||||
Background="Transparent" | |||||
IsReadOnly="True" | |||||
ItemsSource="{Binding Result}" | |||||
Style="{StaticResource DataGridBaseStyle}"> | |||||
<DataGrid.RowStyle> | |||||
<Style BasedOn="{StaticResource DataGridRowStyle}" TargetType="DataGridRow"> | |||||
<Setter Property="Background" Value="Transparent" /> | |||||
<Style.Triggers> | |||||
<Trigger Property="UIElement.IsMouseOver" Value="true"> | |||||
<Setter Property="Background" Value="Transparent" /> | |||||
</Trigger> | |||||
</Style.Triggers> | |||||
</Style> | |||||
</DataGrid.RowStyle> | |||||
<DataGrid.Columns> | |||||
<DataGridTextColumn | |||||
Width="260" | |||||
Binding="{Binding CardNo}" | |||||
ElementStyle="{StaticResource CenterAlignmentStyle}" | |||||
Header="卡号" | |||||
HeaderStyle="{StaticResource SaleLogHeader}" /> | |||||
<DataGridTextColumn | |||||
Width="260" | |||||
Binding="{Binding Money}" | |||||
ElementStyle="{StaticResource CenterAlignmentStyle}" | |||||
Header="金额" | |||||
HeaderStyle="{StaticResource SaleLogHeader}" /> | |||||
<DataGridTextColumn | |||||
Width="260" | |||||
Binding="{Binding Location}" | |||||
ElementStyle="{StaticResource CenterAlignmentStyle}" | |||||
Header="档口" | |||||
HeaderStyle="{StaticResource SaleLogHeader}" /> | |||||
<DataGridTextColumn | |||||
Width="260" | |||||
Binding="{Binding CreateTime, StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" | |||||
ElementStyle="{StaticResource CenterAlignmentStyle}" | |||||
Header="消费时间" | |||||
HeaderStyle="{StaticResource SaleLogHeader}" /> | |||||
</DataGrid.Columns> | |||||
</DataGrid> | |||||
</StackPanel> | |||||
</hc:Window> | </hc:Window> |
@@ -11,13 +11,6 @@ namespace HKCardOUT.Views | |||||
public RootView() | public RootView() | ||||
{ | { | ||||
InitializeComponent(); | InitializeComponent(); | ||||
if (Screen.AllScreens.Count() >= 2) | |||||
{ | |||||
Dispatcher.Invoke(() => | |||||
{ | |||||
//显示广告屏幕 | |||||
}); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } |