diff --git a/HKCardOUT/Logic/RemoteService.cs b/HKCardOUT/Logic/RemoteService.cs index bee2c0b..2ca5a04 100644 --- a/HKCardOUT/Logic/RemoteService.cs +++ b/HKCardOUT/Logic/RemoteService.cs @@ -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"} } } } diff --git a/HKCardOUT/ViewModels/AdWindowViewModel.cs b/HKCardOUT/ViewModels/AdWindowViewModel.cs index 6dfcc6c..efbcabc 100644 --- a/HKCardOUT/ViewModels/AdWindowViewModel.cs +++ b/HKCardOUT/ViewModels/AdWindowViewModel.cs @@ -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(res); if (res != null) { Foods.Clear(); diff --git a/HKCardOUT/Views/AdWindow.xaml b/HKCardOUT/Views/AdWindow.xaml index 4f144b2..8f760c5 100644 --- a/HKCardOUT/Views/AdWindow.xaml +++ b/HKCardOUT/Views/AdWindow.xaml @@ -14,9 +14,6 @@ Background="#3f4c5d" WindowStyle="None" mc:Ignorable="d"> - " + input + ""); 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);