private void _worker_ProgressChanged(object sender, ProgressChangedEventArgs e) { //TODO: Update number of actions performed per total... int performed = ActionList.Where(x => x.IsTaskPerformed == true).Count(); int total = ActionList.Count(); if (OnUpdateNumberOfTasksPerformed != null) { OnUpdateNumberOfTasksPerformed(this, string.Format("{0}|{1}", performed, total)); } }
void process_actionOfCups(Objects detectObject, Mat mat, TextBlock label_msg, TextBlock label_s, float[] pos, int drawY1, int drawY2) { if (wantTrans == true) { pos = camToWorkSpace(pos); } detectObject.setPos_m(pos[0], pos[1], pos[2]); Objects.states s = detectObject.State(); if (startDemo == true) { if (s == Objects.states.stop) { CvInvoke.Line(mat, new Point(timeTick, drawY1), new Point(timeTick, drawY2), new MCvScalar(50, 50, 50)); } else if (s == Objects.states.move) { CvInvoke.Line(mat, new Point(timeTick, drawY1), new Point(timeTick, drawY2), new MCvScalar(50, 150, 150)); if (handing == detectObject)//如果拿著的東西跟移動的東西一樣,代表繼續移動 { } else//如果拿著的東西跟移動的東西"不"一樣,代表要新增東西 { if (cups.All(cup => cup != handing))//代表前面不是杯子 這樣才會有place //第一次也會進入(因為handing會是null) { } else//代表前面有東西 {//所以這個時候handing是前一個拿起的東西(已經被放下的那個) this.Dispatcher.Invoke((Action)(() => { ActionList.Add(new ActionBaseList("Place", handing.Name, new SolidColorBrush(Colors.Black), new SolidColorBrush(handing.color))); LV_actionBase.Items.Add(ActionList[ActionList.Count() - 1]); if (handing.Distanse(dripTrayPos) < dripTrayD)//代表在drip tray上 { ActionList.Add(new ActionBaseList(" to", subactInfo.place.DripTray.ToString(), new SolidColorBrush(Colors.Black), new SolidColorBrush(Colors.Black))); LV_actionBase.Items.Add(ActionList[ActionList.Count() - 1]); } else { ActionList.Add(new ActionBaseList(" to", (handing.getNowPos()).ToString("mm", "3(", "0"), new SolidColorBrush(Colors.Black), new SolidColorBrush(handing.color))); LV_actionBase.Items.Add(ActionList[ActionList.Count() - 1]); } })); //ActionBaseAdd("Place", handing.Name, color1: Color.FromArgb(240, 230, 176), color2: handing.color); } this.Dispatcher.Invoke((Action)(() => { if (detectObject.Distanse(dripTrayPos) < dripTrayD)//代表在drip tray上 { ActionList.Add(new ActionBaseList("Pick up", subactInfo.place.DripTray.ToString(), new SolidColorBrush(Colors.Black), new SolidColorBrush(Colors.Black))); LV_actionBase.Items.Add(ActionList[ActionList.Count() - 1]); } else { ActionList.Add(new ActionBaseList("Pick up", detectObject.Name, new SolidColorBrush(Colors.Black), new SolidColorBrush(detectObject.color))); LV_actionBase.Items.Add(ActionList[ActionList.Count() - 1]); } })); // ActionBaseAdd("Pick up", detectObject.Name, color1: Color.FromArgb(255, 200, 14), color2: detectObject.color); } handing = detectObject; } }//startDemo == true this.Dispatcher.Invoke((Action)(() => { label_s.Text = s.ToString(); label_msg.Text = ($"{ (detectObject.getX_m() * 1000).ToString("0.0")},{(detectObject.getY_m() * 1000).ToString("0.0")},{(detectObject.getZ_m() * 1000).ToString("0.0")}mm"); })); }