|
|
@@ -81,17 +81,20 @@ namespace TeamAAS_VP.Views.Home
|
|
|
{
|
|
|
// 注意:CreateContentBitmap 可能比较耗时,但你这里已经在 UI 线程里调用了;
|
|
|
// 如果卡顿明显,建议把 bitmap 生成放到后台线程(需谨慎处理线程访问)
|
|
|
- var bmp = (Bitmap)disp.CreateContentBitmap(Cognex.VisionPro.Display.CogDisplayContentBitmapConstants.Custom);
|
|
|
-
|
|
|
- SaveImage(
|
|
|
- render.SaveImageModel,
|
|
|
- render.SaveImagePathModel,
|
|
|
- render.SavePath,
|
|
|
- render.Image,
|
|
|
- bmp,
|
|
|
- render.Result,
|
|
|
- render.IsCompress
|
|
|
- );
|
|
|
+ App.Current.Dispatcher.BeginInvoke(new Action(() =>
|
|
|
+ {
|
|
|
+ var bmp = (Bitmap)disp.CreateContentBitmap(Cognex.VisionPro.Display.CogDisplayContentBitmapConstants.Custom);
|
|
|
+
|
|
|
+ SaveImage(
|
|
|
+ render.SaveImageModel,
|
|
|
+ render.SaveImagePathModel,
|
|
|
+ render.SavePath,
|
|
|
+ render.Image,
|
|
|
+ bmp,
|
|
|
+ render.Result,
|
|
|
+ render.IsCompress
|
|
|
+ );
|
|
|
+ }));
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
@@ -103,7 +106,7 @@ namespace TeamAAS_VP.Views.Home
|
|
|
/// <summary>
|
|
|
/// 【核心】根据 obj.Count 自动生成 1~16 个显示格子(标题+CogRecordDisplay)
|
|
|
/// </summary>
|
|
|
- private void ViewModel_UpdateLayout(System.Collections.ObjectModel.ObservableCollection<Models.ShowRender> obj)
|
|
|
+ private async void ViewModel_UpdateLayout(System.Collections.ObjectModel.ObservableCollection<Models.ShowRender> obj)
|
|
|
{
|
|
|
System.Windows.Media.FontFamily font = Application.Current.Resources["DefaultFont"] as System.Windows.Media.FontFamily;
|
|
|
|
|
|
@@ -158,7 +161,10 @@ namespace TeamAAS_VP.Views.Home
|
|
|
var host = new WindowsFormsHost()
|
|
|
{
|
|
|
Tag = sr.ProceductName,
|
|
|
- Child = new CogRecordDisplay() { Tag = sr.ProceductName }
|
|
|
+ Child = new CogRecordDisplay()
|
|
|
+ {
|
|
|
+ Tag = sr.ProceductName,
|
|
|
+ }
|
|
|
};
|
|
|
vmRenders.Add(sr.Id, host);
|
|
|
|
|
|
@@ -175,9 +181,9 @@ namespace TeamAAS_VP.Views.Home
|
|
|
Titles.Add(sr.Id, title);
|
|
|
|
|
|
// (3) 配置 VisionPro 显示属性
|
|
|
- ConfigureCogDisplay((CogRecordDisplay)host.Child);
|
|
|
+ //ConfigureCogDisplay((CogRecordDisplay)host.Child);
|
|
|
|
|
|
- // (4) 子Grid(标题 + 显示)
|
|
|
+ // (3) 子Grid(标题 + 显示)
|
|
|
var cell = new Grid();
|
|
|
cell.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); // 标题
|
|
|
cell.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) }); // 图像
|
|
|
@@ -191,7 +197,7 @@ namespace TeamAAS_VP.Views.Home
|
|
|
Grid.SetRow(host, 1);
|
|
|
Grid.SetColumn(host, 0);
|
|
|
|
|
|
- // (5) 放到主 gridRender 中
|
|
|
+ // (4) 放到主 gridRender 中
|
|
|
int row = i / cols;
|
|
|
int col = i % cols;
|
|
|
|