xxe hace 2 años
padre
commit
c2b5484b6e
Se han modificado 4 ficheros con 365 adiciones y 175 borrados
  1. +2
    -2
      HKCardOUT/Logic/RemoteService.cs
  2. +1
    -2
      HKCardOUT/ViewModels/AdWindowViewModel.cs
  3. +26
    -33
      HKCardOUT/Views/AdWindow.xaml
  4. +336
    -138
      HKCardOUT/Views/AdWindow.xaml.cs

+ 2
- 2
HKCardOUT/Logic/RemoteService.cs Ver fichero

@@ -170,8 +170,8 @@ namespace HKCardOUT.Logic
{
new Locs{ IsShow=true,Key="left"},
new Locs{ IsShow=true,Key="right"},
new Locs{ IsShow=false,Key="top"},
new Locs{ IsShow=true,Key="bottom"}
new Locs{ IsShow=true,Key="top"},
new Locs{ IsShow=false,Key="bottom"}
}
}
}


+ 1
- 2
HKCardOUT/ViewModels/AdWindowViewModel.cs Ver fichero

@@ -37,12 +37,11 @@ namespace HKCardOUT.ViewModels

#endregion

private void FoodsInit(int[] ScreenLoc)
void FoodsInit(int[] ScreenLoc)
{
string GateId = string.Empty;
GateId = DataBus.StoreInfo.Devices.Where(t => t.Address == $"0{ScreenLoc[0]}" || t.Address == $"0{ScreenLoc[1]}").Select(t => t.GateId).FirstOrDefault();
var res = DataBus.Menu.GateFood.Where(t => t.GateId == GateId)?.Select(t => t.Foods)?.FirstOrDefault();
//if (res != null) Foods = new ObservableCollection<string>(res);
if (res != null)
{
Foods.Clear();


+ 26
- 33
HKCardOUT/Views/AdWindow.xaml Ver fichero

@@ -14,9 +14,6 @@
Background="#3f4c5d"
WindowStyle="None"
mc:Ignorable="d">
<!--<Window.Background>
<ImageBrush ImageSource="/HKResouces/bg12.png" />
</Window.Background>-->
<Window.Resources>
<con:TextForegroundConvert x:Key="TextForegroundConvert" />
<Style x:Key="Lbl" TargetType="TextBlock">
@@ -51,7 +48,7 @@
<ColumnDefinition Width=".2*" />
</Grid.ColumnDefinitions>

<Grid>
<Grid x:Name="area1">
<Grid.RowDefinitions>
<RowDefinition Height="60" />
<RowDefinition Height="0.2*" />
@@ -194,37 +191,33 @@
</Grid>

<Grid x:Name="content" Grid.Column="1">
<!--<Grid.RowDefinitions>
<RowDefinition Height=".3*" />
<RowDefinition Height=".7*" />
</Grid.RowDefinitions>-->
<Grid.RowDefinitions>
<RowDefinition Height="60" />
<RowDefinition Height="0.2*" />
<RowDefinition Height="0.2*" />
<RowDefinition />
<RowDefinition Height=".239*" />
<RowDefinition Height=".5*" />
</Grid.RowDefinitions>

<Grid Margin="5">
<Grid.Background>
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
<GradientStop Color="#3f4c5d" />
<GradientStop Offset="1" Color="#3f4c5d" />
<GradientStop Offset="0.5" Color="#8800BEFA" />
</LinearGradientBrush>
</Grid.Background>

<TextBlock
HorizontalAlignment="Center"
FontSize="30"
Foreground="#ddd"
Style="{StaticResource Lbl}"
Text="今日菜品" />
</Grid>


<Grid Grid.Row="1" Grid.RowSpan="2">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="60" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Margin="5">
<Grid.Background>
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
<GradientStop Color="#3f4c5d" />
<GradientStop Offset="1" Color="#3f4c5d" />
<GradientStop Offset="0.5" Color="#8800BEFA" />
</LinearGradientBrush>
</Grid.Background>

<TextBlock
HorizontalAlignment="Center"
FontSize="30"
Foreground="#ddd"
Style="{StaticResource Lbl}"
Text="今日菜品" />
</Grid>
<ListBox
Grid.Row="1"
Background="Transparent"
BorderThickness="0"
ItemsSource="{Binding Foods}"
@@ -261,7 +254,7 @@

<view2:WebView2
x:Name="view2"
Grid.Row="3"
Grid.Row="1"
Margin="5" />
</Grid>



+ 336
- 138
HKCardOUT/Views/AdWindow.xaml.cs Ver fichero

@@ -44,7 +44,8 @@ namespace HKCardOUT.Views
if (bindScreen == 1) { NotchNum[0] = 1; NotchNum[1] = 2; }
if (bindScreen == 2) { NotchNum[0] = 5; NotchNum[1] = 6; }
if (bindScreen == 0) { NotchNum[0] = 3; NotchNum[1] = 4; }
(this.DataContext as AdWindowViewModel).InitData(NotchNum);
var vm = (this.DataContext as AdWindowViewModel);
vm.InitData(NotchNum);

ThreadManage.GetInstance().StartLong(new Action(() =>
{
@@ -60,21 +61,6 @@ namespace HKCardOUT.Views
Thread.Sleep(100);
}), "刷卡队列分配");
}
//if (bindScreen == 2)
//{
// //this.one.Text = "4号档口";
// //this.two.Text = "3号档口";
//}
//if (bindScreen == 1)
//{
// //this.one.Text = "2号档口";
// //this.two.Text = "1号档口";
//}
//if (bindScreen == 0)
//{
// //this.one.Text = "6号档口";
// //this.two.Text = "5号档口";
//}
InitView2(input);

InitControl();
@@ -89,17 +75,16 @@ namespace HKCardOUT.Views

public async void InitView2(string input)
{
var height = this.content.RowDefinitions[3].ActualHeight;
var width = this.content.ActualWidth;
input = input.Replace("100%", $"{width - 35};height:{height - 35}px;margin:0px 0px 0px 0px;");
//input = input.Replace("100%", $"{width-25}px;height:{height-25}px;margin:1px 0px 0px 1px;");
StringBuilder sb = new StringBuilder();
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = this.content.ActualWidth - 9.5;
input = input.Replace("style=\"width: 100%;\"", "");

sb.Append($"<html><body>{input}</body></html>");
StringBuilder sb = new StringBuilder();
sb.Append("<html><style>body {width: " + width + "px;height: " + height + "px;margin: 0;padding:0;}body p {width: " + width + "px;height: " + height + "px;}body p img {width: 100%;height: 100%;}</style><script>function Set(width, height) { var body = document.getElementsByTagName('body')[0]; body.style.width = width + 'px';body.style.height = height + 'px';var p = document.getElementsByTagName('p')[0]; p.style.width = width + 'px';p.style.height = height + 'px';}</script><body>" + input + "</body></html>");
var html = sb.ToString();
await view2.EnsureCoreWebView2Async(null);
view2.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false;
view2.CoreWebView2.Settings.AreDevToolsEnabled = false;
view2.CoreWebView2.Settings.AreDefaultContextMenusEnabled = true;
view2.CoreWebView2.Settings.AreDevToolsEnabled = true;
view2.CoreWebView2.NavigateToString(html);
view2.CoreWebView2.Settings.IsStatusBarEnabled = false;
}
@@ -108,125 +93,338 @@ namespace HKCardOUT.Views
{
ThreadManage.GetInstance().StartLong(() =>
{
if (BindScreen == 0)
{
var GateId = DataBus.StoreInfo.Devices.Where(t => t.Address == "05" || t.Address == "06").Select(t => t.GateId).FirstOrDefault();
var area = DataBus.RangeCtrl.GateSetUp.FirstOrDefault(t => t.GateId == GateId).Locs;

//if (BindScreen == 0)
//{
// var GateId = DataBus.StoreInfo.Devices.Where(t => t.Address == "03" || t.Address == "04").Select(t => t.GateId).FirstOrDefault();
// var area = DataBus.RangeCtrl.GateSetUp.FirstOrDefault(t => t.GateId == GateId).Locs;

// foreach (var item in area)
// {
// switch (item.Key.ToLower())
// {
// case "left":
// if (item.IsShow)
// this.alls.ColumnDefinitions[0].Width = new GridLength(0.2, GridUnitType.Star);
// else
// this.alls.ColumnDefinitions[0].Width = new GridLength(0, GridUnitType.Star);
// break;
// case "top":
// if (item.IsShow)
// this.area3.ColumnDefinitions[0].Width = new GridLength(0.3, GridUnitType.Star);
// else
// this.area3.ColumnDefinitions[0].Width = new GridLength(0, GridUnitType.Star);
// break;
// case "right":
// if (item.IsShow)
// this.alls.ColumnDefinitions[0].Width = new GridLength(0.2, GridUnitType.Star);
// else
// this.alls.ColumnDefinitions[0].Width = new GridLength(0, GridUnitType.Star);
// break;
// case "bottom":
// if (item.IsShow)
// this.area3.ColumnDefinitions[1].Width = new GridLength(0.7, GridUnitType.Star);
// else
// this.area3.ColumnDefinitions[1].Width = new GridLength(0, GridUnitType.Star);
// break;
// default:
// break;
// }
// }


//}
foreach (var item in area)
{
if (item.Key.ToLower().Equals("top"))
{
if (item.IsShow)
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = this.content.ActualWidth - 9.5;
this.content.Dispatcher.Invoke(async () =>
{
content.RowDefinitions[0].Height = new GridLength(0.239, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
else
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = this.content.ActualWidth - 10;
this.content.Dispatcher.Invoke(async () =>
{
content.RowDefinitions[0].Height = new GridLength(0, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
}
if (item.Key.ToLower().Equals("bottom"))
{
if (item.IsShow)
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = this.content.ActualWidth - 9.5;
this.content.Dispatcher.Invoke(async () =>
{
content.RowDefinitions[1].Height = new GridLength(0.5, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
else
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = this.content.ActualWidth - 10;
this.content.Dispatcher.Invoke(async () =>
{
content.RowDefinitions[1].Height = new GridLength(0, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
}
if (item.Key.ToLower().Equals("left"))
{
if (item.IsShow)
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = this.content.ActualWidth - 9.5;
this.alls.Dispatcher.Invoke(async () =>
{
alls.ColumnDefinitions[0].Width = new GridLength(0.2, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
else
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = alls.ColumnDefinitions[0].ActualWidth + this.content.ActualWidth - 10;
this.alls.Dispatcher.Invoke(async () =>
{
alls.ColumnDefinitions[0].Width = new GridLength(0, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
}
if (item.Key.ToLower().Equals("right"))
{
if (item.IsShow)
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = this.content.ActualWidth - 9.5;
this.alls.ColumnDefinitions[2].Width = new GridLength(0.2, GridUnitType.Star);
this.alls.Dispatcher.Invoke(async () =>
{
alls.ColumnDefinitions[2].Width = new GridLength(0.2, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
else
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = alls.ColumnDefinitions[2].ActualWidth + this.content.ActualWidth - 10;
this.alls.Dispatcher.Invoke(async () =>
{
alls.ColumnDefinitions[2].Width = new GridLength(0, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
}
}
}

//if (BindScreen == 1)
//{
// var GateId = DataBus.StoreInfo.Devices.Where(t => t.Address == "01" || t.Address == "02").Select(t => t.GateId).FirstOrDefault();
// var area = DataBus.RangeCtrl.GateSetUp.FirstOrDefault(t => t.GateId == GateId).Locs;
if (BindScreen == 1)
{
var GateId = DataBus.StoreInfo.Devices.Where(t => t.Address == "01" || t.Address == "02").Select(t => t.GateId).FirstOrDefault();
var area = DataBus.RangeCtrl.GateSetUp.FirstOrDefault(t => t.GateId == GateId).Locs;

// foreach (var item in area)
// {
// switch (item.Key.ToLower())
// {
// case "left":
// if (item.IsShow)
// this.alls.ColumnDefinitions[0].Width = new GridLength(0.2, GridUnitType.Star);
// else
// this.alls.ColumnDefinitions[0].Width = new GridLength(0, GridUnitType.Star);
// break;
// case "top":
// if (item.IsShow)
// this.area3.ColumnDefinitions[0].Width = new GridLength(0.3, GridUnitType.Star);
// else
// this.area3.ColumnDefinitions[0].Width = new GridLength(0, GridUnitType.Star);
// break;
// case "right":
// if (item.IsShow)
// this.alls.ColumnDefinitions[0].Width = new GridLength(0.2, GridUnitType.Star);
// else
// this.alls.ColumnDefinitions[0].Width = new GridLength(0, GridUnitType.Star);
// break;
// case "bottom":
// if (item.IsShow)
// this.area3.ColumnDefinitions[1].Width = new GridLength(0.7, GridUnitType.Star);
// else
// this.area3.ColumnDefinitions[1].Width = new GridLength(0, GridUnitType.Star);
// break;
// default:
// break;
// }
// }
//}
foreach (var item in area)
{
if (item.Key.ToLower().Equals("top"))
{
if (item.IsShow)
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = this.content.ActualWidth - 9.5;
this.content.Dispatcher.Invoke(async () =>
{
content.RowDefinitions[0].Height = new GridLength(0.239, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
else
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = this.content.ActualWidth - 10;
this.content.Dispatcher.Invoke(async () =>
{
content.RowDefinitions[0].Height = new GridLength(0, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
}
if (item.Key.ToLower().Equals("bottom"))
{
if (item.IsShow)
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = this.content.ActualWidth - 9.5;
this.content.Dispatcher.Invoke(async () =>
{
content.RowDefinitions[1].Height = new GridLength(0.5, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
else
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = this.content.ActualWidth - 10;
this.content.Dispatcher.Invoke(async () =>
{
content.RowDefinitions[1].Height = new GridLength(0, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
}
if (item.Key.ToLower().Equals("left"))
{
if (item.IsShow)
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = this.content.ActualWidth - 9.5;
this.alls.Dispatcher.Invoke(async () =>
{
alls.ColumnDefinitions[0].Width = new GridLength(0.2, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
else
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = alls.ColumnDefinitions[0].ActualWidth + this.content.ActualWidth - 10;
this.alls.Dispatcher.Invoke(async () =>
{
alls.ColumnDefinitions[0].Width = new GridLength(0, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
}
if (item.Key.ToLower().Equals("right"))
{
if (item.IsShow)
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = this.content.ActualWidth - 9.5;
this.alls.ColumnDefinitions[2].Width = new GridLength(0.2, GridUnitType.Star);
this.alls.Dispatcher.Invoke(async () =>
{
alls.ColumnDefinitions[2].Width = new GridLength(0.2, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
else
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = alls.ColumnDefinitions[2].ActualWidth + this.content.ActualWidth - 10;
this.alls.Dispatcher.Invoke(async () =>
{
alls.ColumnDefinitions[2].Width = new GridLength(0, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
}
}
}

//if (BindScreen == 2)
//{
// var GateId = DataBus.StoreInfo.Devices.Where(t => t.Address == "05" || t.Address == "06").Select(t => t.GateId).FirstOrDefault();
// var area = DataBus.RangeCtrl.GateSetUp.FirstOrDefault(t => t.GateId == GateId).Locs;
if (BindScreen == 2)
{
var GateId = DataBus.StoreInfo.Devices.Where(t => t.Address == "05" || t.Address == "06").Select(t => t.GateId).FirstOrDefault();
var area = DataBus.RangeCtrl.GateSetUp.FirstOrDefault(t => t.GateId == GateId).Locs;

// foreach (var item in area)
// {
// switch (item.Key.ToLower())
// {
// case "left":
// if (item.IsShow)
// this.alls.ColumnDefinitions[0].Width = new GridLength(0.2, GridUnitType.Star);
// else
// this.alls.ColumnDefinitions[0].Width = new GridLength(0, GridUnitType.Star);
// break;
// case "top":
// if (item.IsShow)
// this.area3.ColumnDefinitions[0].Width = new GridLength(0.3, GridUnitType.Star);
// else
// this.area3.ColumnDefinitions[0].Width = new GridLength(0, GridUnitType.Star);
// break;
// case "right":
// if (item.IsShow)
// this.alls.ColumnDefinitions[0].Width = new GridLength(0.2, GridUnitType.Star);
// else
// this.alls.ColumnDefinitions[0].Width = new GridLength(0, GridUnitType.Star);
// break;
// case "bottom":
// if (item.IsShow)
// this.area3.ColumnDefinitions[1].Width = new GridLength(0.7, GridUnitType.Star);
// else
// this.area3.ColumnDefinitions[1].Width = new GridLength(0, GridUnitType.Star);
// break;
// default:
// break;
// }
// }
//}
foreach (var item in area)
{
if (item.Key.ToLower().Equals("top"))
{
if (item.IsShow)
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = this.content.ActualWidth - 9.5;
this.content.Dispatcher.Invoke(async () =>
{
content.RowDefinitions[0].Height = new GridLength(0.239, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
else
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = this.content.ActualWidth - 10;
this.content.Dispatcher.Invoke(async () =>
{
content.RowDefinitions[0].Height = new GridLength(0, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
}
if (item.Key.ToLower().Equals("bottom"))
{
if (item.IsShow)
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = this.content.ActualWidth - 9.5;
this.content.Dispatcher.Invoke(async () =>
{
content.RowDefinitions[1].Height = new GridLength(0.5, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
else
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = this.content.ActualWidth - 10;
this.content.Dispatcher.Invoke(async () =>
{
content.RowDefinitions[1].Height = new GridLength(0, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
}
if (item.Key.ToLower().Equals("left"))
{
if (item.IsShow)
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = this.content.ActualWidth - 9.5;
this.alls.Dispatcher.Invoke(async () =>
{
alls.ColumnDefinitions[0].Width = new GridLength(0.2, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
else
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = alls.ColumnDefinitions[0].ActualWidth + this.content.ActualWidth - 10;
this.alls.Dispatcher.Invoke(async () =>
{
alls.ColumnDefinitions[0].Width = new GridLength(0, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
}
if (item.Key.ToLower().Equals("right"))
{
if (item.IsShow)
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = this.content.ActualWidth - 9.5;
this.alls.ColumnDefinitions[2].Width = new GridLength(0.2, GridUnitType.Star);
this.alls.Dispatcher.Invoke(async () =>
{
alls.ColumnDefinitions[2].Width = new GridLength(0.2, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
else
{
var height = this.content.RowDefinitions[1].ActualHeight - 10;
var width = alls.ColumnDefinitions[2].ActualWidth + this.content.ActualWidth - 10;
this.alls.Dispatcher.Invoke(async () =>
{
alls.ColumnDefinitions[2].Width = new GridLength(0, GridUnitType.Star);
if (view2.CoreWebView2 != null)
await view2.CoreWebView2.ExecuteScriptAsync($"Set({width},{height})");
});
}
}
}
}

Thread.Sleep(5000);
}, $"区域控制{BindScreen}", true);


Cargando…
Cancelar
Guardar