private void InviaTemplateESchede(string ip, params String[] idSchede) { String tempString = null; IEnumerable <Scheda> schedeRichieste = from Scheda s in _schede.Keys where idSchede.Contains(s.IdScheda) select s; tempString = DocumentoMaster.GetIstance().Persister.FormatScheda(schedeRichieste); if (tempString == null) { throw new InvalidOperationException("Schede non correttamente formattate"); } _output(this, new GestoreGiocatoriMessageEventArgs(ip, new PersistanceFileSchedeMessageEventArgs(tempString))); Scheda[] sc = schedeRichieste.ToArray <Scheda>(); ElementoTemplate templateRichiesto = null; if (_schede.Values.Count == 0) { templateRichiesto = DocumentoMaster.GetIstance().Persister.LoadTemplate(DocumentoMaster.GetIstance().Path + DocumentoMaster.GetIstance().CurrentDescrittore.IdPartita + "/Template.xml"); } else { templateRichiesto = sc.Length > 0 ? _schede[sc[0]] : _schede.Values.ToArray <ElementoTemplate>()[0]; } tempString = null; tempString = DocumentoMaster.GetIstance().Persister.FormatTemplate(templateRichiesto); if (tempString == null) { throw new InvalidOperationException("Template non correttamente formattato"); } _output(this, new GestoreGiocatoriMessageEventArgs(ip, new PersistanceFileTemplateMessageEventArgs(tempString))); }
protected virtual void NuovaSchedaConfermata(String name) { _schedePendenti.Remove(name); ElementoTemplate template = _schede.Values.Count > 0? _schede.Values.First <ElementoTemplate>() : Documento.GetIstance().Persister.LoadTemplate(Documento.GetIstance().Path + Documento.GetIstance().CurrentDescrittore.IdPartita + "/Template.xml"); _schede.Add(GeneraScheda(template, name), template); SalvaSchede(); InitValues(); RefreshSchedeView(_schedeView); }
private void ConfermaNuovaScheda(object sender, EventArgs e) { if (sender is Button) { Button button = sender as Button; String ip = (button.Tag as String); String name = _schedeView.SelectedNode.Text; ElementoTemplate template = _schede.Values.Count > 0 ? _schede.Values.First <ElementoTemplate>() : Documento.GetIstance().Persister.LoadTemplate(Documento.GetIstance().Path + Documento.GetIstance().CurrentDescrittore.IdPartita + "/Template.xml"); Scheda nuovaScheda = GeneraScheda(template, name); _schede.Add(nuovaScheda, template); _gestoreGiocatori.AddSchede(ip, nuovaScheda); _schedePendenti.Remove(name); _schedaPanel.Controls.Clear(); InitValues(); RefreshSchedeView(_schedeView); _output(this, new Utility.Messages.GestoreGiocatoriMessageEventArgs(ip, new NuovaSchedaConfermataMessageEventArgs(name))); SalvaSchede(); } }