添加 MX-PD-盘古 项目文件
将 MX-PD-盘古 - new 目录下的所有文件添加到主仓库
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<UserControl x:Class="MainShell.Common.VisionTemple.View.VisionTempleView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:MainShell.Common.VisionTemple.View" xmlns:control="http://www.maxwell.com/controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
|
||||
<control:CameraVision DataContext="{Binding Service}" Name="cameraVision">
|
||||
<control:CameraVision.CameraHost>
|
||||
<control:CameraAxisControlA
|
||||
Items="{Binding CameraModel.CameraShowViewModel.Items}"
|
||||
Source="{Binding CameraModel.CameraShowViewModel.CurrentImage, Mode=OneWay}"
|
||||
TabSelectedIndex="{Binding SelectCameraIndex}"
|
||||
Cameras="{Binding Cameras}"
|
||||
Device="{Binding SelectItem}"
|
||||
ImportFile="{Binding CameraModel.ImportFile}"
|
||||
Regions="{Binding CameraModel.CameraShowViewModel.Regions}"
|
||||
IsClear="{Binding CameraModel.CameraShowViewModel.IsClear}"
|
||||
IsShowContext="True"
|
||||
ShapeThickness="1" IsShowSolidLine="True" DrawInConcurrency = "False"/>
|
||||
</control:CameraVision.CameraHost>
|
||||
</control:CameraVision>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace MainShell.Common.VisionTemple.View
|
||||
{
|
||||
/// <summary>
|
||||
/// VisionTempleView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class VisionTempleView : UserControl
|
||||
{
|
||||
public VisionTempleView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<Window x:Class="MainShell.Common.VisionTemple.View.VisionTempleWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:view="clr-namespace:MainShell.Common.VisionTemple.View"
|
||||
mc:Ignorable="d"
|
||||
Title="{Binding DisplayName}"
|
||||
Height="875"
|
||||
Width="1000"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Background="White">
|
||||
<Grid Background="White">
|
||||
<view:VisionTempleView DataContext="{Binding VisionTemple}" />
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace MainShell.Common.VisionTemple.View
|
||||
{
|
||||
/// <summary>
|
||||
/// VisionTempleWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class VisionTempleWindow : Window
|
||||
{
|
||||
public VisionTempleWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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