添加 MX-PD-盘古 项目文件
将 MX-PD-盘古 - new 目录下的所有文件添加到主仓库
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using MwFramework.Controls.PatternTemplate.ViewModel;
|
||||
using Stylet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MainShell.Common.VisionTemple.ViewModel
|
||||
{
|
||||
public class VisionTempleViewModel : Screen
|
||||
{
|
||||
public string Name { get; set; } = "VisionTempleModel";
|
||||
|
||||
private MatchTemplateService _service;
|
||||
|
||||
public MatchTemplateService Service
|
||||
{
|
||||
get { return _service; }
|
||||
set
|
||||
{
|
||||
_service = value;
|
||||
OnPropertyChanged(nameof(Service));
|
||||
}
|
||||
}
|
||||
|
||||
public VisionTempleViewModel()
|
||||
{
|
||||
_service = new MatchTemplateService();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
using MainShell.Common.VisionTemple.View;
|
||||
using MainShell.Hardware;
|
||||
using Stylet;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
|
||||
namespace MainShell.Common.VisionTemple.ViewModel
|
||||
{
|
||||
public class VisionTempleWindowViewModel : Screen
|
||||
{
|
||||
private readonly VisionTempleViewModel _visionTemple;
|
||||
private VisionTempleWindow _window;
|
||||
private bool _isShuttingDown;
|
||||
private readonly HardwareManager _hardwareManager;
|
||||
|
||||
public VisionTempleWindowViewModel(HardwareManager hardwareManager)
|
||||
{
|
||||
DisplayName = "视觉模板制作";
|
||||
_visionTemple = new VisionTempleViewModel();
|
||||
_visionTemple.Service = new MwFramework.Controls.PatternTemplate.ViewModel.MatchTemplateService();
|
||||
_visionTemple.Service.CameraModel.IsShowFoldDialog = false;
|
||||
_hardwareManager = hardwareManager;
|
||||
}
|
||||
|
||||
private string _templatePath;
|
||||
/// <summary>
|
||||
/// 模版路径
|
||||
/// </summary>
|
||||
public string TemplatePath
|
||||
{
|
||||
get { return _templatePath; }
|
||||
set
|
||||
{
|
||||
_templatePath = value;
|
||||
_visionTemple.Service.CameraModel.TemplatePath = value;
|
||||
}
|
||||
}
|
||||
|
||||
public VisionTempleViewModel VisionTemple
|
||||
{
|
||||
get
|
||||
{
|
||||
return _visionTemple;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCamera(CameraType cameraType)
|
||||
{
|
||||
switch (cameraType)
|
||||
{
|
||||
case CameraType.MapCamera:
|
||||
_visionTemple.Service.Cameras = _hardwareManager.CameraAxisManager.BottomCameraAxisDevices;
|
||||
break;
|
||||
case CameraType.TopPositionCamera:
|
||||
_visionTemple.Service.Cameras = _hardwareManager.CameraAxisManager.TopCameraAxisDevices;
|
||||
break;
|
||||
case CameraType.TopWideCamera:
|
||||
_visionTemple.Service.Cameras = _hardwareManager.CameraAxisManager.WideCameraAxisDevices;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if(_visionTemple.Service.Cameras!=null&& _visionTemple.Service.Cameras.Count>0)
|
||||
{
|
||||
_visionTemple.Service.SelectItem = _visionTemple.Service.Cameras[0];
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowWindow()
|
||||
{
|
||||
if (_window == null)
|
||||
{
|
||||
_window = new VisionTempleWindow();
|
||||
_window.DataContext = this;
|
||||
_window.Closing += OnWindowClosing;
|
||||
}
|
||||
|
||||
Window owner = Application.Current != null ? Application.Current.MainWindow : null;
|
||||
if (owner != null && _window.Owner == null)
|
||||
{
|
||||
_window.Owner = owner;
|
||||
owner.Closing += OnOwnerClosing;
|
||||
}
|
||||
|
||||
if (_window.IsVisible)
|
||||
{
|
||||
if (_window.WindowState == WindowState.Minimized)
|
||||
{
|
||||
_window.WindowState = WindowState.Normal;
|
||||
}
|
||||
|
||||
_window.Activate();
|
||||
return;
|
||||
}
|
||||
|
||||
_window.Show();
|
||||
_window.Activate();
|
||||
}
|
||||
|
||||
private void OnWindowClosing(object sender, CancelEventArgs e)
|
||||
{
|
||||
if (!_isShuttingDown)
|
||||
{
|
||||
e.Cancel = true;
|
||||
_window.Hide();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnOwnerClosing(object sender, CancelEventArgs e)
|
||||
{
|
||||
_isShuttingDown = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user