示例#1
0
		/// <summary>
		/// Generating vertex at cursor point. Display input 
		/// form which requires you to enter name of the vertex. 
		/// </summary>
		/// <param name="p">p is current position of the mouse cusror</param>
		/// <returns>Returns generated vertex</returns>
		private Vertex GenerateVert(Point p) {
			if (HaveSpace(p)) {
				InputDialog.InputDialog id = new InputDialog.InputDialog("Enter name of a vertex", "Vertex generation");
				DialogResult dResult = id.ShowDialog(this);
				if (dResult == DialogResult.OK) {
					Vertex v = new Vertex(id.getInput(), p);			
					return v;
				}
			}
			else
				MessageBox.Show("Invalid place to put a vertex!", "Error", MessageBoxButtons.OK);
			return null;
		}
        private void checkNewSub()
        {
            System.Threading.Thread.Sleep(200);
            Subject newsub = sceneSubjects.Last(); 

            
          
                InputDialog.InputDialog dialog2 = new InputDialog.InputDialog("Assign ID and Name to " + newsub.idKinect.ToString(), newsub.idKinect.ToString(), "");

                
                if ((300 * j) + 300 < 1000)
                {
                    dialog2.Left = (300 * j) + 300;
                    dialog2.Top = 300;
                }
                else
                {
                    dialog2.Left = (300 * (j - 3)) + 300;
                    dialog2.Top = 600;
                }

               j++;

               if (dialog2.ShowDialog() == System.Windows.Forms.DialogResult.OK)
               {
                   string[] str = dialog2.ResultText.Split(';');

                   if (str.Length == 3)
                   {

                       if (sceneSubjects.Find(a => a.idKinect.ToString() == str[2]) != null)
                       {
                           sceneSubjects.Find(a => a.idKinect.ToString() == str[2]).id = Convert.ToInt32(str[0]);
                           sceneSubjects.Find(a => a.idKinect.ToString() == str[2]).name[0] = str[1];
                       }


                   }
                   j--;
               }
               else
                   j--;
                    

           
        }
        private void subrec(int j ) 
        {
            InputDialog.InputDialog dialog2 = new InputDialog.InputDialog("Assign ID and Name to " + sceneSubjects[j].idKinect.ToString(), sceneSubjects[j].idKinect.ToString(), "");
            if ((300 * j) + 300 < 1000)
            {
                dialog2.Left = (300 * j) + 300;
                dialog2.Top = 300;
            }
            else
            {
                dialog2.Left = (300 * (j - 3)) + 300;
                dialog2.Top = 600;
            }

            if (dialog2.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string[] str = dialog2.ResultText.Split(';');

                if (str.Length == 3)
                {
                    lock(this)
                    {
                        sceneSubjects.Find(a => a.idKinect.ToString() == str[2]).id = Convert.ToInt32(str[0]);
                        sceneSubjects.Find(a => a.idKinect.ToString() == str[2]).name[0] = str[1];
                    }

                }
            }
                 
        }
示例#4
0
        RecognizedQRCode getInformationDB(Dictionary <string, ZXing.ResultPoint[]> dict)
        {
            RecognizedQRCode rec = new RecognizedQRCode();

            rec.ResolutionCam        = new ResolutionCam();
            rec.ResolutionCam.Width  = w.ToString();
            rec.ResolutionCam.Height = h.ToString();


            foreach (var s in dict)
            {
                //preparo l'informazione del soggetto con la posizione centrale del QRCode
                InfoQRCode inf = new InfoQRCode();
                inf.Positions = new List <Pos>();

                foreach (var v in s.Value)
                {
                    Pos p = new Pos();
                    p.X = v.X.ToString();
                    p.Y = v.Y.ToString();

                    inf.Positions.Add(p);
                }

                // verifico se già conosco il soggetto altrimenti interogo il database
                List <InfoQRCode> sub = SubjRecognition.InfoQRCode.FindAll(a => a.Message.Split('|')[1].Trim() == s.Key);
                if (sub.Count() == 0)
                {
                    //leggo lo status del database se è occupato attendo
                    string state = "";

                    do
                    {
                        yarpPortStatusDB.receivedData(out state);
                    }while (state != "Activo");

                    //apro le connessioni con il db
                    yarpPortCommandDB.openConnectionToDb(dataBaseCommand_OUT, dataBaseCommand_IN);
                    yarpPortReplyDB.openReceiverReplyDb(dataBaseReply_OUT, dataBaseReply_IN);

                    yarpPortCommandDB.sendData("SELECT * FROM subjects WHERE IdSubject=" + s.Key);
                    System.Threading.Thread.Sleep(400);

                    //attendo risposta
                    string reply = "";
                    do
                    {
                        yarpPortReplyDB.receivedData(out reply);
                    }while (reply == "");

                    //se non trovo nulla parte evento che gestire l'inserimento del nuovo soggetto
                    if (reply.Replace("\"", "") == "|")
                    {
                        InputDialog.InputDialog dialog2 = new InputDialog.InputDialog("Assign ID and Name to ", "", "");
                        if (dialog2.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            if (dialog2.ResultText != "unknown")
                            {
                                yarpPortCommandDB.sendData("INSERT INTO subjects (IdSubject,Name,FirstTime) VALUE ('" + s.Key + "','" + dialog2.ResultText + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')");

                                System.Threading.Thread.Sleep(400);

                                reply = "";
                                do
                                {
                                    yarpPortReplyDB.receivedData(out reply);
                                }while (reply == "" || reply == "\"|\"");

                                inf.Message = "unknown";
                            }
                            else
                            {
                                inf.Message = dialog2.ResultText;
                            }
                        }
                        else
                        {
                            inf.Message = dialog2.ResultText;
                        }
                    }
                    else
                    {
                        inf.Message = reply.Replace("\"", "");
                    }



                    yarpPortCommandDB.Close();
                    yarpPortReplyDB.Close();

                    if (inf.Message != "unknown")
                    {
                        SubjRecognition.InfoQRCode.Add(inf);
                    }
                }
                else
                {
                    foreach (InfoQRCode info in sub)
                    {
                        if (info.Message[1] == s.Key[0])
                        {
                            inf.Message = info.Message;
                        }
                    }
                }

                Sub.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
                                           new Action(delegate()
                {
                    Sub.Content = inf.Message;
                }));


                rec.InfoQRCode.Add(inf);
            }


            return(rec);
        }