Esempio n. 1
0
        private ElementoTemplate LoadContenuto(XmlElement contenuto)
        {
            string     nome                      = contenuto.GetAttribute("name");
            string     tipo                      = contenuto.GetAttribute("tipo");
            string     formulaProva              = contenuto.GetAttribute("formula");
            bool       modificabile              = contenuto.HasAttribute("modificabile");
            bool       confermaMaster            = contenuto.HasAttribute("conferma");
            bool       identificatorePersonaggio = contenuto.HasAttribute("identificatore");
            TipoValore tipoValore;

            try { tipoValore = (TipoValore)Enum.Parse(typeof(TipoValore), tipo); }
            catch { tipoValore = TipoValore.Testo; }
            ElementoTemplate child = new Contenuto(nome, tipoValore, formulaProva, modificabile, confermaMaster, identificatorePersonaggio);

            return(child);
        }
Esempio n. 2
0
        protected void ModificaCampoScheda(string idScheda, string idCampo, string valore)
        {
            bool      isValid    = true;
            int       defaultInt = default(int);
            Scheda    scheda     = (from s in _schede.Keys where s.IdScheda == idScheda select s).ElementAt(0);
            Contenuto et         = GetContenutoById(_schede[scheda], idCampo);

            if (et == null)
            {
                isValid = false;
            }
            switch (et.Tipo)
            {
            case TipoValore.Numero:
                if (String.IsNullOrEmpty(valore))
                {
                    valore = defaultInt + "";
                }
                else if (!Int32.TryParse(valore, out defaultInt))
                {
                    isValid = false;
                }
                break;

            case TipoValore.Testo: break;

            default: isValid = false; break;
            }

            if (isValid)
            {
                scheda.SetValore(idCampo, valore);
                _values[GenerateId(idScheda, idCampo)][0] = valore;
            }
            _values[GenerateId(idScheda, idCampo)][1] = null;
            if (_schedaCorrente != null)
            {
                if (_schedaCorrente.IdScheda == idScheda)
                {
                    DisplayScheda();
                }
            }
            this.ColoraSchedeView(_schedeView.Nodes);
        }
Esempio n. 3
0
 protected Contenuto GetContenutoById(ElementoTemplate root, string idCampo)
 {
     if (root.Id == idCampo && root is Contenuto)
     {
         return(root as Contenuto);
     }
     else if (root is Contenitore)
     {
         foreach (ElementoTemplate et in (root as Contenitore).Children)
         {
             Contenuto result = GetContenutoById(et, idCampo);
             if (result != null)
             {
                 return(result);
             }
         }
     }
     return(null);
 }
Esempio n. 4
0
 private void SaveContenuto(Contenuto contenuto)
 {
     _writer.WriteStartElement("Contenuto");
     _writer.WriteAttributeString("name", contenuto.Id);
     _writer.WriteAttributeString("tipo", contenuto.Tipo.ToString());
     _writer.WriteAttributeString("formula", contenuto.FormulaProva);
     if (contenuto.Modificabile)
     {
         _writer.WriteAttributeString("modificabile", "");
     }
     if (contenuto.ConfermaMaster)
     {
         _writer.WriteAttributeString("conferma", "");
     }
     if (contenuto.IdentificatorePersonaggio)
     {
         _writer.WriteAttributeString("identificatore", "");
     }
     _writer.WriteEndElement();
 }
Esempio n. 5
0
        protected void DisplaySchedaRecursion(Scheda scheda, TableLayoutPanel table, ElementoTemplate et, int level)
        {
            if (level < 0)
            {
                level = 0;
            }
            if (_schedaCorrente == null)
            {
                return;
            }
            String tabs = "";

            for (int i = 0; i < level; i++)
            {
                tabs += "      ";
            }

            if (et is Contenitore)
            {
                Label l = new Label();
                l.AutoSize = true;
                l.Text     = tabs + ((Contenitore)et).Id;
                table.Controls.Add(l);
                for (int i = 0; i < table.ColumnCount - 1; i++)
                {
                    table.Controls.Add(new Label());
                }

                foreach (ElementoTemplate el in ((Contenitore)et).Children)
                {
                    DisplaySchedaRecursion(scheda, table, el, level + 1);
                }
            }
            else if (et is Contenuto)
            {
                Contenuto con = (Contenuto)et;
                DisplayContenuto(scheda, table, con, level);
            }
        }
Esempio n. 6
0
        protected virtual void DisplayContenuto(Scheda scheda, TableLayoutPanel table, Contenuto con, int level)
        {
            if (_schedaCorrente == null)
            {
                return;
            }
            String tabs = "";

            for (int i = 0; i < level; i++)
            {
                tabs += "      ";
            }

            String key = con.Id;
            Label  l   = new Label();

            l.AutoSize = true;
            l.Text     = tabs + key;
            table.Controls.Add(l);

            Label l2 = new Label();

            l2.AutoSize = true;
            l2.Text     = scheda.GetValore(key);
            table.Controls.Add(l2);

            TextBox tb = new TextBox();

            tb.Text = scheda.GetValore(key);
            table.Controls.Add(tb);

            String[] ProprietaTag = new String[] { scheda.IdScheda, con.Id, scheda.GetValore(con.Id), null };
            //ID scheda | ID campo | Valore vecchio | Valore nuovo

            Button conferma = new Button();

            conferma.Text   = "Conferma";
            conferma.Tag    = ProprietaTag;
            conferma.Click += ModificaCampoScheda;
            table.Controls.Add(conferma);

            Button cancella = new Button();

            cancella.Text   = "Cancella";
            cancella.Tag    = con;
            cancella.Click += RipristinaCampoScheda;
            table.Controls.Add(cancella);
        }