コード例 #1
0
        public Canvas PNG_Marca(Bitmap imag, string form, BES.Localiza pos, int sc)
        {
            if (Modulo(sc, 30) == 0 && pos.Noco != "--")
            {
                TextToSpeech.SpeakAsync("Você está na sala " + pos.Nuco + ". No andar " + pos.Andar, Tts_Voz(0.15));
            }
            string x    = pos.X;
            string y    = pos.Y;
            int    diam = 40;
            float  di   = Modulo(sc * 10, diam);

            double x1 = 718 - Convert.ToDouble(x) / 1.5;
            double y1 = 407 - Convert.ToDouble(y) / 1.5;
            double x2 = x1 + di;
            double y2 = y1 + di;

            Paint pin = PNG_Pincel(new int[] { 255, 50, 50 }, sc);

            canvas = new Canvas(imag);

            switch (form.ToLower())
            {
            case "c": canvas.DrawCircle((float)x1, (float)y1, di, pin); break;

            case "r": canvas.DrawRect((float)x1, (float)y1, (float)x2, (float)y2, pin); break;

            default:  break;
                //  default: canvas.DrawCircle((float)x1, (float)y1, di, pin); break;
            }

            string texto = "\n MAC:   " + pos.Mac +
                           "\n Bloco: " + pos.Bloco +
                           "\n Andar: " + pos.Andar +
                           "\n Num:   " + pos.Nuco + " Nome: " + pos.Noco +
                           "\n Area:  " + pos.Area + " Pdir: " + pos.Pd +
                           "\n Lat:   " + Latitude +
                           "\n Lon:   " + Longitud +
                           "\n Alt:   " + Altitude;           // Escreve no campo da interface

            txfot.Text = texto;
            vwima.Invalidate();            // forçar a atualização da imagem1
            vwfot.Invalidate();            // forçar a atualização da imagem2
            return(canvas);
        }
コード例 #2
0
        public BES.Localiza Verifica_Mapa(XmlNodeList Lnodos, BES.beacon bicon)
        {
            BES.Localiza Posicion = new BES.Localiza();
            Posicion.Mac   = "--";
            Posicion.Bloco = "--";
            Posicion.Andar = "--";
            Posicion.X     = "--";
            Posicion.Y     = "--";
            Posicion.Noco  = "--";
            Posicion.Nuco  = "--";
            Posicion.Pd    = "--";
            Posicion.Area  = "--";
            Posicion.Midi  = "M_00.mid";
            Posicion.Foto  = "F_00.png";

            foreach (XmlNode nod in Lnodos)
            {
                XmlAttributeCollection atts = nod.Attributes;
                if (atts["MAC"].Value == bicon.mac)
                {
                    Posicion.Mac   = atts["MAC"].Value;
                    Posicion.Bloco = atts["Bloco"].Value;
                    Posicion.Andar = atts["Andar"].Value;
                    Posicion.X     = atts["X"].Value.Substring(0, 3);
                    Posicion.Y     = atts["Y"].Value.Substring(0, 3);
                    Posicion.Noco  = atts["Noco"].Value;
                    Posicion.Nuco  = atts["Nuco"].Value;
                    Posicion.Pd    = atts["Pd"].Value.Substring(0, 4);
                    Posicion.Area  = atts["Area"].Value.Substring(0, 6);
                    Posicion.Midi  = atts["Midi"].Value;
                    Posicion.Foto  = atts["Foto"].Value;
                    break;
                }
            }
            return(Posicion);
        }
コード例 #3
0
        //Funções de Processamento ----------------------------------------------------
        public async Task  Processar_ON(XmlNodeList Lnodos, bool faz)
        {
            bec_LOrden = new List <BES.beacon> {
            };
            btini.SetBackgroundColor(corverd); btini.Text = "ESCANEANDO...";
            btfin.SetBackgroundColor(corazul); btfin.Text = "PAUSAR";
            btxml.SetBackgroundColor(corazul); btxml.Text = "XML";
            scan = 1;

            BES.beacon beacon1;

            while (escanea)
            {
                await Geolocalizar();

                try
                {
                    bec_inform = "";
                    captura    = "";
                    txcro.Text = Crono(scan);
                    bec_LOrden = new List <BES.beacon> {
                    };
                    bec_Lbruta = await btes.Scan_Beacons();

                    bec_LOrden = bec_Lbruta.OrderByDescending(s => s.rssi).Select(x => x).ToList();
                    beacon1    = bec_LOrden[0];                                         //<-- Pega 1° beacon da lista ordenada
                    BES.Localiza Posic = Verifica_Mapa(Lnodos, beacon1);                //<-- Verifica o local do beacon no mapa XML

                    foreach (BES.beacon b in bec_LOrden)
                    {
                        if (b.distancia < cobertura)
                        {
                            captura += b.mac + " || " + b.nome + " || " + b.distancia.ToString() + "\n";               // mostra apenas os beacons mais próximos
                        }
                    }

                    imagen = PNG_Fotos(MapasPNG[1][0], Posic.Foto, vwima, vwfot);

                    if (Posic.Noco != "--")
                    {
                        PNG_Marca(imagen, "c", Posic, scan);
                    }
                    else
                    {
                        PNG_Marca(imagen, "No marcar", Posic, scan);
                    }

                    txbea.Text = captura;
                    scan      += 1;
                    GC.Collect();                              // limpa memoria
                    GC.WaitForPendingFinalizers();             // limpa memoria
                }
                catch   { bec_inform = "Não achou beacon cadastrado"; }
                finally {
                    txbea.Text = bec_inform;
                    scan      += 1;
                    GC.Collect();                                      // limpa memoria
                    GC.WaitForPendingFinalizers();                     // limpa memoria
                }
            }
        }