private void Single_button_Click(object sender, RoutedEventArgs e) { ICogImage image = fifo.Acquire(out int a); display.Image = image; display.Fit(); }
private void Button_Click(object sender, RoutedEventArgs e) { display.StartLiveDisplay(fifo.Operator, true); display.Fit(); }
public void FitImage() { m_cogDisplay.Fit(true); }
private void AssignCogRecordToDisplay(Control cogDisplay, ICogRecord cogRecord) { if (cogDisplay.Visible != true) { return; } if (cogDisplay.InvokeRequired) { cogDisplay.BeginInvoke(new _delParamCogDisplayIcogRecord(AssignCogRecordToDisplay), new object[] { cogDisplay, cogRecord }); return; } if (cogDisplay is CogRecordsDisplay) { (cogDisplay as CogRecordsDisplay).Subject = cogRecord; } else if (cogDisplay is CogDisplay) { CogDisplay cDisplay = cogDisplay as CogDisplay; try { //cogDisplay.Visible = false; if (cogRecord.SubRecords == null || cogRecord.SubRecords.Count == 0) { return; } if (cogRecord.Content != null && cogRecord.Content is List <ICogRecord> ) { List <ICogRecord> recordList = cogRecord.Content as List <ICogRecord>; CogGraphicInteractiveCollection cogGraphicInteractCollection = new CogGraphicInteractiveCollection(); foreach (ICogRecord record in recordList) { // Assign image if it is not there if ((cDisplay.Image == null || !(cDisplay.Image is CogImage8Grey)) && CogCamera != null) { // Assign image lock (CogCamera.LockCogDisplay) { cDisplay.Image = record.SubRecords[0].Content as ICogImage; cDisplay.Fit(true); } } cDisplay.InteractiveGraphics.Clear(); if (IsDisplayGraphic) { //Assign graphic if any foreach (ICogRecord subRecord in record.SubRecords[0].SubRecords) { if (subRecord.Content is CogGraphicCollection) { CogGraphicCollection contentCollect = subRecord.Content as CogGraphicCollection; if (contentCollect != null) { foreach (CogCompositeShape graphic in contentCollect) { //cDisplay.InteractiveGraphics.Add(graphic, this.Name, false); cogGraphicInteractCollection.Add(graphic); } } } if (subRecord.Content is ICogGraphicInteractive) { //cDisplay.InteractiveGraphics.Add(subRecord.Content as ICogGraphicInteractive, this.Name, false); cogGraphicInteractCollection.Add(subRecord.Content as ICogGraphicInteractive); } } if (EnableDisplayTimeLabel) { CogGraphicLabel cogLabel = new CogGraphicLabel(); cogLabel.SelectedSpaceName = "@"; cogLabel.Color = CogColorConstants.Green; cogLabel.SetXYText(TimeLabelLocX, TimeLabelLocY, DateTime.Now.ToString("HH:mm:ss:fff")); cogGraphicInteractCollection.Add(cogLabel); } cDisplay.InteractiveGraphics.AddList(cogGraphicInteractCollection, this.Name, false); //(cogDisplay as CogDisplay).Invalidate(); } } } else { // Assign image if it is not there if ((cDisplay.Image == null || !(cDisplay.Image is CogImage8Grey)) && CogCamera != null) { // Assign image lock (CogCamera.LockCogDisplay) { //(cogDisplay as CogDisplay).Image = cogRecord.SubRecords[0].Content as ICogImage; cDisplay.Image = cogRecord.SubRecords[cogRecord.SubRecords.Count - 1].Content as ICogImage; cDisplay.Fit(true); } } cDisplay.InteractiveGraphics.Clear(); if (IsDisplayGraphic) { // Assign graphic if any CogGraphicInteractiveCollection cogGraphicInteractCollection = new CogGraphicInteractiveCollection(); foreach (ICogRecord record in cogRecord.SubRecords[cogRecord.SubRecords.Count - 1].SubRecords) { if (record.Content is CogGraphicCollection) { CogGraphicCollection contentCollect = record.Content as CogGraphicCollection; foreach (CogObjectBase objBase in contentCollect) { ICogGraphicInteractive graphic = objBase as ICogGraphicInteractive; if (graphic != null) { //cDisplay.InteractiveGraphics.Add(graphic, this.Name, false); cogGraphicInteractCollection.Add(graphic); } } } else if (record.Content is ICogGraphicInteractive) { //cDisplay.InteractiveGraphics.Add(record.Content as ICogGraphicInteractive, this.Name, false); cogGraphicInteractCollection.Add(record.Content as ICogGraphicInteractive); } } if (EnableDisplayTimeLabel) { CogGraphicLabel cogLabel = new CogGraphicLabel(); cogLabel.SelectedSpaceName = "@"; cogLabel.Color = CogColorConstants.Green; cogLabel.SetXYText(TimeLabelLocX, TimeLabelLocY, DateTime.Now.ToString("HH:mm:ss:fff")); cogGraphicInteractCollection.Add(cogLabel); } cDisplay.InteractiveGraphics.AddList(cogGraphicInteractCollection, this.Name, false); //(cogDisplay as CogDisplay).Invalidate(); } } } finally { //cogDisplay.Visible = true; //cogDisplay.Update(); } //CogDisplayResult =new Bitmap((cogDisplay as CogDisplay).CreateContentBitmap(CogDisplayContentBitmapConstants.Image, null, 0)); } else { // There is no Cognex Display, do nothing } }