Exemplo n.º 1
0
        private void AssignLastRunRecord(ICogRecord lastRunRecord)
        {
            CognexCamera8 cogCam = CogCamera;

            if (cogCam != null && cogCam.CogDisplayWindows != null && cogCam.CogDisplayWindows.Count > 0)
            {
                //Parallel.ForEach<CogDisplay>(cogCam.CogDisplayWindows, currentDisplay =>
                //{

                //    if (lastRunRecord == null)
                //    {
                //        lastRunRecord = CogToolGroup.CreateLastRunRecord();
                //    }
                //    //currentDisplay.Image = null;
                //    //currentDisplay.Invalidate();
                //    AssignCogRecordToDisplay(currentDisplay as Control, lastRunRecord);

                //});

                foreach (CogDisplay cogDisplay in cogCam.CogDisplayWindows)
                {
                    if (lastRunRecord == null)
                    {
                        lastRunRecord = CogToolGroup.CreateLastRunRecord();
                    }
                    //cogDisplay.Image = null;
                    AssignCogRecordToDisplay(cogDisplay as Control, lastRunRecord);
                }
            }
        }
Exemplo n.º 2
0
        public override void AssignAcquireImageToWindows(Image acquireImage)
        {
            CognexCamera8 cogCam = CogCamera;

            if (cogCam != null && cogCam.CogDisplayWindows != null && cogCam.CogDisplayWindows.Count > 0)
            {
                ICogImage cogImage = null;
                if (acquireImage != null)
                {
                    if (acquireImage is Bitmap)
                    {
                        cogImage = new CogImage24PlanarColor(acquireImage as Bitmap);
                    }
                    else
                    {
                        cogImage = acquireImage as ICogImage;
                    }
                }


                Parallel.ForEach <CogDisplay>(cogCam.CogDisplayWindows, currentDisplay =>
                {
                    if (!currentDisplay.IsDisposed)
                    {
                        if (object.ReferenceEquals(currentDisplay.Image, acquireImage))
                        {
                            System.Diagnostics.Debug.WriteLine("Saved time in AssignImageToWindows.  Image already there");
                        }
                        else
                        {
                            currentDisplay.BeginInvoke(new MethodInvoker(delegate { currentDisplay.Image = cogImage; }));
                        }
                    }
                });
            }
        }