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; using VisionCommon; using VisionUI; using VisionUI.Camera; using WeldingCommon.Recipes; namespace WeldingCommon.Views { /// /// Interaction logic for UCCommonAutoRun.xaml /// public partial class UCCommonAutoRun : UserControl { public UCCommonAutoRun() { InitializeComponent(); CreateAutoRunCameraView(); } private void CreateAutoRunCameraView() { if (gridCommonAutoRunCameraView.Children.Count == 0) { var fovInfo = VisionRecipeManager.GetFovInfos().FirstOrDefault(); if (fovInfo != null) { var cameraView = IpViewManager.CreateCameraView(fovInfo, eDisplayType.Machine_A); gridCommonAutoRunCameraView.Children.Add(cameraView); } } } private void WindowsFormsHost_Loaded(object sender, RoutedEventArgs e) { var autoPage = WeldingRecipeManager.GetWeldingPage().ScannerCanvasCtrlAutoPage; autoPage.Canvas.CommandScaleToFit(); autoPage.Dock = System.Windows.Forms.DockStyle.Left; windowsFormsHost.Child = autoPage; } private void UserControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { bool isVisible = (bool)e.NewValue; if (isVisible == true) { var autoPage = WeldingRecipeManager.GetWeldingPage().ScannerCanvasCtrlAutoPage; autoPage.Canvas.CommandScaleToFit(); autoPage.Dock = System.Windows.Forms.DockStyle.Left; windowsFormsHost.Child = autoPage; // Camera Live CameraUcManager.Instance.StartLiveAll(eDisplayType.Machine_A); } else { CameraUcManager.Instance.StopLiveAll(); } } } }