public async Task <Posizione> Indirizzo2Posizione(String indirizzo) { Posizione p = new Posizione(); Console.WriteLine(indirizzo); var locations = await Geocoding.GetLocationsAsync(indirizzo); var location = locations?.FirstOrDefault(); try { if (location == null) { return(p); } else { p.latitudine = location.Latitude; p.longitudine = location.Longitude; p.indirizzo = indirizzo; } } catch { Console.WriteLine("ERORE FAI I TESTE"); } //String i = await this.Posizione2IndirizzoAsync(new Position(p.latitudine, p.longitudine)); //Console.WriteLine(i); return(p); }
private async void TapGestureRecognizer_Tapped_ultimaPosizioneFrame(object sender, EventArgs e) { indicatore.IsEnabled = true; indicatore.IsRunning = true; try { Posizione p = (sender as Frame).BindingContext as Posizione; if (p == null) { return; } await Navigation.PushAsync(new MappaPage(p)); } catch (Exception ex) { await DisplayAlert("Errore", $"Problema apertura mappa: {ex.Message}", "OK"); } finally { indicatore.IsEnabled = false; indicatore.IsRunning = false; } }
private async void TapGestureRecognizer_Tapped_visualizzaMappa(object sender, EventArgs e) { SettaIndicatore(indicatoreAuto, true); try { bool check = await CheckPermessi(); if (!check) { return; } Posizione pos = await device.GetUltimaPosizioneSalvata(); if (pos == null) { await DisplayAlert("Attenzione", $"Nessuna posizione salvata", "OK"); return; } await Navigation.PushAsync(new MappaPage(pos)); } catch (Exception ex) { await DisplayAlert("ERRORE", $"Si è verificato un problema: {ex.Message}", "OK"); } finally { SettaIndicatore(indicatoreAuto, false); } }
private Posizione GeneraPosizioneCasuale(IEnumerable <Posizione> posizioniEsistenti) { double distanzaMinima = 0; int tentativi = 10; Tuple <Posizione, double> migliorePosizione = null; do { var posizione = new Posizione(random.Next(0, opzioni.LarghezzaPianoDiGioco), random.Next(0, opzioni.AltezzaPianoDiGioco)); if (posizioniEsistenti.Any()) { distanzaMinima = posizioniEsistenti.Min(p => CalcolaDistanzaTraDuePosizioni(p, posizione)); if (migliorePosizione == null || migliorePosizione.Item2 < distanzaMinima) { migliorePosizione = new Tuple <Posizione, double>(posizione, distanzaMinima); } } else { return(posizione); } } while (distanzaMinima < opzioni.DistanzaMinimaTraRobot && --tentativi >= 0); return(migliorePosizione.Item1); }
public SituazionePartita(DenominazioneRobot denominazione, Posizione posizione) { PunteggioPartita = 0; PunteggioRound = 0; Denominazione = denominazione; Posizione = posizione; }
public MappaPage(Posizione _posizione) { InitializeComponent(); this.posizione = _posizione; InizializzaMappa(); }
private async void PosBtn_clicked(object sender, EventArgs e) { Posizione p = await positionAdapter.Indirizzo2Posizione(pos_entry.Text); Preferences.Set("latitudineDefault", p.latitudine.ToString()); Preferences.Set("longitudineDefault", p.longitudine.ToString()); Preferences.Set("indirizzoDefault", p.indirizzo); }
private async void search_btn_Clicked(object sender, EventArgs e) { this.progressBar.Opacity = 1; this.progressBar.ProgressTo(0.80, 1500, Easing.CubicInOut); filtri.nomeMateria = en_materia.Text; //filtri.posizione = (Posizione) await positionAdapter.calcolaPosizione(); //filtri.posizione = await positionAdapter.Indirizzo2Posizione(Preferences.Get("indirizzoCorrente", null)); Posizione pos = new Posizione(); //if(Preferences.Get("latitudineCorrente", null) == null && Preferences.Get("longitudineCorrente", null) == null) if (Preferences.Get("isUsingCurrentPos", null) == null) { await DisplayAlert("Per eseguire la ricerca è necessaria la tua posizione", "Accendi la posizione del dispositivo o inserisci un indirizzo", "Ok"); } else { filtri.posizione = await positionAdapter.decidiPosizione(); /*pos.latitudine = double.Parse(Preferences.Get("latitudineCorrente", null)); * pos.longitudine = double.Parse(Preferences.Get("longitudineCorrente", null)); * pos.indirizzo = Preferences.Get("indirizzoCorrente", null); * filtri.posizione = pos;*/ RisultatoRicercaInsegnanti[] insegnanti = await InsegnantiService.GetInsegnanti(filtri); if (insegnanti != null) { foreach (RisultatoRicercaInsegnanti r in insegnanti) { r.distanza = this.positionAdapter.approssimaDistanza(r.distanza); /* * if (r.valutazioneMedia == null || r.valutazioneMedia == "") * { * //qualcosa per togliere la valutazione * r.valutazioneMedia = "-"; * }*/ } insegnanti_list.IsVisible = true; ListaDiMaterie.IsVisible = false; insegnanti_list.ItemsSource = insegnanti; this.lb_errore.IsVisible = false; } else { this.ListaDiMaterie.IsVisible = false; this.lb_errore.IsVisible = true; insegnanti_list.IsVisible = false; Console.WriteLine("Nessun insegnante"); } } this.WelcomeLabel.IsVisible = false; await this.progressBar.ProgressTo(1, 200, Easing.CubicInOut); this.progressBar.Opacity = 0; this.progressBar.ProgressTo(0, 0, Easing.Linear); }
public PosizioneDTO Update(PosizioneDTO DTO) { using (CaronteContext caronteCtx = new CaronteContext()) { Posizione tmpAna = caronteCtx.Posizione.Find(DTO.IDPosizione); DTO.ToEntity(tmpAna); caronteCtx.SaveChanges(); return(this.Get(tmpAna.IDPosizione)); } }
public PosizioneDTO New(PosizioneDTO DTO) { using (CaronteContext caronteCtx = new CaronteContext()) { Posizione tmp = DTO.ToEntity(); caronteCtx.Posizione.Add(tmp); caronteCtx.SaveChanges(); return(this.Get(tmp.IDPosizione)); } }
public Task <int> SalvaPosizioneAsync(Posizione posizione) { if (posizione.Id != 0) { return(Database.UpdateAsync(posizione)); } else { this.DeleteFirstRowsAsync().Wait(); return(Database.InsertAsync(posizione)); } }
private async Task calcolaPosizione() { Posizione pos = (Posizione)await positionAdapter.calcolaPosizione(); if (pos != null) { Preferences.Set("latitudineCorrente", pos.latitudine.ToString()); Preferences.Set("longitudineCorrente", pos.longitudine.ToString()); Preferences.Set("indirizzoCorrente", pos.indirizzo); } else { await DisplayAlert("Impossibile accedere alla posizione", "Prova ad accendere il GPS", "OK"); } }
private static Posizione ParsePoint(string p) { int x, y; Posizione xy = null; //Point? xy = null; p = p.Replace(" ", ""); string[] pos = p.Split(','); if (pos.Length == 2 && int.TryParse(pos[0], out x) && int.TryParse(pos[1], out y)) { //xy = new Point(x, y); xy = new Posizione(x, y, Posizione.DEF_W, Posizione.DEF_H); } return(xy); }
private async void btn_indirizzo_Clicked(object sender, EventArgs e) { Posizione pos = await this.positionAdapter.Indirizzo2Posizione(this.en_indirizzo.Text); if (pos != null) { //parent.GetPositionButton().Text = pos.indirizzo; //parent.filtri.posizione = pos; Preferences.Set("isUsingCurrentPos", "no"); Preferences.Set("latitudineDefault", pos.latitudine.ToString()); Preferences.Set("longitudineDefault", pos.longitudine.ToString()); Preferences.Set("indirizzoDefault", pos.indirizzo); parent.setPositionButtonTextValue(); } parent.Opacity = 1; await Rg.Plugins.Popup.Services.PopupNavigation.Instance.PopAsync(true); }
private async void listaPosizioni_ItemTapped(object sender, ItemTappedEventArgs e) { try { Posizione p = e.Item as Posizione; await Navigation.PushAsync(new MappaPage(p)); if (sender is ListView listView) { listView.SelectedItem = null; } } catch (Exception ex) { await DisplayAlert("Errore", $"Problema apertura mappa: {ex.Message}", "OK"); } }
public bool CheckPosition(Posizione p) { if (this.GetMapFoto != null && p != null) // ESISTE UNA FOTO LOCALE O PARENT { Bitmap b = new Bitmap(Image.FromFile(this.GetMapFoto), new Size(Posizione.DEF_W, Posizione.DEF_W)); Color c = b.GetPixel(p.X, p.Y); if (!ClassStruttura.IsPositionColor(c)) { return(false); } else { return(true); } } return(true); }
public async Task <Posizione> decidiPosizione() { Posizione pos = new Posizione(); if (Preferences.Get("isUsingCurrentPos", null) == "no") { pos.latitudine = double.Parse(Preferences.Get("latitudineDefault", null)); pos.longitudine = double.Parse(Preferences.Get("longitudineDefault", null)); pos.indirizzo = Preferences.Get("indirizzoDefault", null); } else { await calcolaPosizione(); pos.latitudine = double.Parse(Preferences.Get("latitudineCorrente", null)); pos.longitudine = double.Parse(Preferences.Get("longitudineCorrente", null)); pos.indirizzo = Preferences.Get("indirizzoCorrente", null); } return(pos); }
protected async override void OnAppearing() { base.OnAppearing(); try { Posizione ultimaPosSalvata = await device.GetUltimaPosizioneSalvata(); if (ultimaPosSalvata != null) { dataUltimaAcquisizioneLabel.Text = $"Piu recente: {ultimaPosSalvata.DataAcquisizione.ToString("dd/MM/yyyy HH:mm")}"; //localitaUltimaAcquisizioneLabel.Text = $"{ultimaPosSalvata.NomeCitta} {ultimaPosSalvata.Via}"; } else { dataUltimaAcquisizioneLabel.Text = "Piu recente: Nessuna acquisizione"; } } catch (Exception ex) { await DisplayAlert("ERRORE", $"Si è verificato un problema: {ex.Message}", "OK"); } }
public async Task <Posizione> calcolaPosizione() { Posizione p = null; try { var request = new GeolocationRequest(GeolocationAccuracy.Medium); var location = await Geolocation.GetLocationAsync(request); if (location != null) { p = new Posizione(); p.latitudine = location.Latitude; p.longitudine = location.Longitude; p.indirizzo = (string) await Posizione2IndirizzoAsync(new Position(location.Latitude, location.Longitude)); } } catch { return(p); } return(p); }
public void CreaNotifica(Posizione posizione, DateTime dateTime) { if (!channelInitialized) { CreateNotificationChannel(); } Intent intent = new Intent(AndroidApp.Context, typeof(NotificationReceiver)); intent.PutExtra(TitleKey, CostantiDominio.TITOLO_NOTIFICA); intent.PutExtra(MessageKey, CostantiDominio.MESSAGGIO_NOTIFICA); intent.PutExtra(IdNotifica, posizione.Id); PendingIntent pendingIntent = PendingIntent.GetBroadcast(AndroidApp.Context, pendingIntentId, intent, PendingIntentFlags.OneShot); Java.Util.Calendar calendar = Java.Util.Calendar.Instance; calendar.Set(Java.Util.CalendarField.HourOfDay, dateTime.Hour); calendar.Set(Java.Util.CalendarField.Minute, dateTime.Minute); calendar.Set(Java.Util.CalendarField.Second, 0); AlarmManager alarmManager = AndroidApp.Context.GetSystemService(Context.AlarmService) as AlarmManager; alarmManager.Set(AlarmType.RtcWakeup, calendar.TimeInMillis, pendingIntent); }
public void Sposta(Posizione posizione) { //TODO: deve esserci un massimo consentito Posizione = posizione; }
private double CalcolaDistanzaTraDuePosizioni(Posizione posizione1, Posizione posizione2) { return(Math.Sqrt(Math.Pow(posizione1.X - posizione2.X, 2.0) + Math.Pow(posizione1.Y - posizione2.Y, 2.0))); }
private void button1_Click(object sender, EventArgs e) { int Posizione, NumOrd; int DataOrd; DateTime DataCommessa; DialogResult dialogResult = MessageBox.Show("Sei sicuro di voler eliminare l'importazione degli ordini selezionati?", "Eliminazione importazione ordine", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { foreach (DataGridViewRow row in ordiniImportatiDataGridView.SelectedRows) { Posizione = row.Index; textBox1.AppendText("Riga: " + Posizione.ToString() + Environment.NewLine); NumOrd = (int)ordiniImportatiDataGridView.Rows[Posizione].Cells[3].Value; DataOrd = (int)ordiniImportatiDataGridView.Rows[Posizione].Cells[4].Value; DataCommessa = DateTime.ParseExact(DataOrd.ToString(), "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None); textBox1.AppendText("Ordine numero: " + row.Index.ToString() + Environment.NewLine); int risultato; string filtro = "NrCommessa = " + NumOrd + " AND DataCommessa = " + DataOrd; try { risultato = (int)target2021DataSet.Commesse.Compute("MAX(Stato)", filtro); } catch { risultato = 0; } if (risultato > 0) { MessageBox.Show("Impossibile eliminare l'importazione dell'ordine " + NumOrd.ToString() + "! Non tutte le righe sono in Stato 0!"); } else { // Prima elimino le righe della tabella Commesse DataRow[] Riga = target2021DataSet.Commesse.Select("NrCommessa = " + NumOrd.ToString() + " AND DataCommessa = '" + DataCommessa.ToShortDateString() + "'"); foreach (DataRow R in Riga) { R.Delete(); } commesseTableAdapter.Update(target2021DataSet.Commesse); // Poi elimino la riga dalla tabella OrdiniImportati DataRow[] Riga2 = target2021DataSet.OrdiniImportati.Select("Numero = " + NumOrd.ToString() + "AND Data = " + DataOrd); foreach (DataRow R in Riga2) { R.Delete(); } ordiniImportatiTableAdapter.Update(target2021DataSet.OrdiniImportati); // Poi ri-setto il flag in ACCESS int data = DataOrd; ImpostaPesoCliente(NumOrd, data, 0); // Poi ri-setto il flag in tabella dettaglio_ordini_multirig in locale su SQL ImpostaPesoLocale(NumOrd, DataOrd); // DA FARE MessageBox.Show("Importazione ordine " + NumOrd.ToString() + " eliminata con successo!"); } } } else if (dialogResult == DialogResult.No) { //do something else } }
private async void bt_SalvaProfilo_Clicked(object sender, EventArgs e) { this.IsEnabled = false; //nome insegnante.nomeDaVisualizzare = this.en_nome.Text; //tariffa insegnante.tariffa = float.Parse(this.en_tariffa.Text); //gruppo if (this.cb_gruppo.IsChecked) { insegnante.gruppo = 1; } else { insegnante.gruppo = 0; } //posizione if (en_indirizzo.Text != null) { Posizione pos = new Posizione(); pos = await positionAdapter.Indirizzo2Posizione(en_indirizzo.Text); pos.id = insegnante.posizione.id; insegnante.posizione = pos; } //contatti Contatti c = new Contatti(); c.cellulare = this.en_cellulare.Text; c.emailContatto = this.en_email.Text; c.facebook = this.en_facebook.Text; insegnante.contatti = c; //materie if (!Preferences.Get("isInsegnante", false)) { insegnante.materie = new List <Materia>(); } Entry en = (Entry)StL_materie.Children[0]; if (en.Text != null) { foreach (var element in this.StL_materie.Children) { Entry entry = (Entry)element; if (entry.Text != null) { insegnante.materie.Add(new Materia(entry.Text)); } } } //descrizione int indice = 1; if (insegnante.descrizione == null) { insegnante.descrizione = new List <SezioneProfilo>(); } else { indice = insegnante.descrizione.Count + 1; } foreach (var element in this.stl_descrizione.Children) { Frame frame = (Frame)element; StackLayout stack = (StackLayout)frame.Content; SezioneProfilo s = new SezioneProfilo(); //Entry entryIndice = (Entry)stack.Children[0]; s.indice = indice;//int.Parse(entryIndice.Text); Entry entryTitolo = (Entry)stack.Children[0]; s.titolo = entryTitolo.Text; Editor entryCorpo = (Editor)stack.Children[1]; s.corpo = entryCorpo.Text; s.idInsegnante = insegnante.id; this.insegnante.descrizione.Add(s); indice++; } //modalità insegnante.modalita = this.pck_modalità.SelectedIndex; //profiloPublico insegnante.profiloPubblico = 0; //id insegnante.id = int.Parse(Preferences.Get("id", (-1).ToString())); insegnante.recensioni = new List <Recensione>(); if (insegnante.id != -1) { InsegnantiService.Save(insegnante); Preferences.Set("isInsegnante", true); Navigation.InsertPageBefore(new ProfilePage2(insegnante, "salva"), this); await Navigation.PopAsync(); //await Navigation.PushAsync(new ProfilePage2(insegnante)); } else { Console.WriteLine("Errore"); } this.IsEnabled = true; }
public void CancellaNotifica(Posizione posizione) { throw new NotImplementedException(); }
public static bool UpdateStruttura(OleDbConnection cnn, int id, string _nome, string _sigla, int?_ripiano, Posizione _posizione) { string nome = "'" + _nome.Trim() + "'"; string sigla = "'" + _sigla.Trim() + "'"; //string pos = (_posizione.HasValue) ? "'" + (_posizione.Value.X.ToString() + "," + _posizione.Value.Y.ToString()) + "'" : " null "; string pos = (_posizione != null) ? "'" + (_posizione.X.ToString() + "," + _posizione.Y.ToString()) + "'" : " null "; string ripiano = (_ripiano.HasValue) ? _ripiano.ToString() : " null "; string str = " UPDATE MapStruttura SET nome = " + nome + ", sigla = " + sigla + ", posizione = " + pos + ", ripiano = " + ripiano + " WHERE id = " + id.ToString(); OleDbCommand cmd = new OleDbCommand(str, cnn); if (cmd.ExecuteNonQuery() > 0) { return(true); } return(false); }
public static int SaveStruttura(OleDbConnection cnn, string _nome, string _sigla, int?_ripiano, TipoStruttura ts, Struttura _parent, int?_livello, Posizione _posizione) { string parentid = (_parent == null) ? " null " : _parent.id.ToString(); string nome = "'" + _nome.Trim() + "'"; string sigla = "'" + _sigla.Trim() + "'"; //string livello = _livello.ToString(); string livello = (_livello.HasValue) ? _livello.Value.ToString() : " null "; string pos = (_posizione != null) ? "'" + (_posizione.X.ToString() + "," + _posizione.Y.ToString()) + "'" : " null "; string ripiano = (_ripiano.HasValue) ? _ripiano.ToString() : " null "; string str = "INSERT INTO MapStruttura (parentID, nome, sigla, tipostrutturaID, livello, posizione, ripiano) " + " VALUES (" + parentid + ", " + nome + ", " + sigla + ", " + ts.id + ", " + livello + ", " + pos + ", " + ripiano + ")"; string str2 = "Select @@Identity"; int ID = 7; OleDbCommand cmd = new OleDbCommand(str, cnn); cmd.ExecuteNonQuery(); cmd.CommandText = str2; ID = int.Parse(((object)cmd.ExecuteScalar()).ToString()); return(ID); }
public PosizioneVentola(Diametro diametro, Posizione posizione, bool occupato) { _diametro = diametro; _posizione = posizione; _occupato = occupato; }
public Task <int> DeletePosizioneAsync(Posizione item) { return(Database.DeleteAsync(item)); }