Пример #1
0
        protected Scheda GeneraScheda(ElementoTemplate e, String nome)
        {
            Scheda s = new Scheda(nome);

            GeneraSchedaRecursion(e, s);
            return(s);
        }
Пример #2
0
        protected virtual void RefreshSchedeView(TreeView tree)
        {
            Scheda scheda = _schedaCorrente;

            tree.Nodes.Clear();
            foreach (Scheda s in _schede.Keys)
            {
                TreeNode parentnode = null;
                foreach (TreeNode t in tree.Nodes)
                {
                    if (t.Tag == _schede[s])
                    {
                        parentnode = t;
                    }
                }
                if (parentnode == null)
                {
                    parentnode      = new TreeNode();
                    parentnode.Tag  = _schede[s];
                    parentnode.Text = _schede[s].Id;
                    tree.Nodes.Add(parentnode);
                }
                TreeNode node = new TreeNode();
                node.Tag  = s;
                node.Text = s.IdScheda;
                parentnode.Nodes.Add(node);
            }
            AddSchedePendenti(tree);
            tree.ExpandAll();
            _schedaCorrente = scheda;

            this.ColoraSchedeView(_schedeView.Nodes);
        }
Пример #3
0
        private IEnumerable <Scheda> ReadScheda()
        {
            List <Scheda> schede      = new List <Scheda>();
            XmlElement    rootElement = (XmlElement)_xmlDocument.SelectSingleNode("Schede");

            if (rootElement == null)
            {
                throw new IOException("Invalid Format Exception");
            }

            foreach (XmlNode elemento in rootElement.ChildNodes)
            {
                if (elemento.LocalName != "Scheda")
                {
                    throw new IOException("Invalid Format Exception - Scheda non valida");
                }
                Scheda s = new Scheda(((XmlElement)elemento).GetAttribute("name"));
                foreach (XmlNode campo in elemento.ChildNodes)
                {
                    if (campo.LocalName != "Campo")
                    {
                        throw new IOException("Invalid Format Exception - Campo non trovato");
                    }
                    s.SetValore(((XmlElement)campo).GetAttribute("name"), ((XmlElement)campo).GetAttribute("valore"));
                }
                schede.Add(s);
            }

            return(schede);
        }
Пример #4
0
 protected void RemoveScheda(Scheda scheda)
 {
     _schede.Remove(scheda);
     foreach (String id in scheda.GetIds())
     {
         String key = GenerateId(scheda.IdScheda, id);
         if (_values.Keys.Contains(key))
         {
             _values.Remove(key);
         }
     }
 }
Пример #5
0
 private void GeneraSchedaRecursion(ElementoTemplate e, Scheda s)
 {
     if (e is Contenitore)
     {
         foreach (ElementoTemplate figlio in ((Contenitore)e).Children)
         {
             GeneraSchedaRecursion(figlio, s);
         }
     }
     else if (e is Contenuto)
     {
         s.SetValore(e.Id, "");
     }
 }
Пример #6
0
 private void OnSchedaSelected(object sender, EventArgs e)
 {
     if (((TreeView)sender).SelectedNode.Tag is Scheda && ((TreeView)sender).SelectedNode.Tag != null)
     {
         _schedaCorrente = (Scheda)((TreeView)sender).SelectedNode.Tag;
         DisplayScheda();
     }
     else
     {
         _schedaPanel.Controls.Clear();
         _schedaCorrente = null;
         OnElementSelected(sender, e);
     }
 }
Пример #7
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);
        }
Пример #8
0
        protected Boolean ColoraSchedeView(TreeNodeCollection nodes)
        {
            Boolean result = false;

            foreach (TreeNode tn in nodes)
            {
                if (tn.Tag is String)
                {
                    if (ColoraSchedeView(tn.Nodes))
                    {
                        tn.BackColor = Color.Yellow;
                        result       = true;
                    }
                    else
                    {
                        tn.BackColor = Color.Empty;
                        result       = false;
                    }
                }
                else if (tn.Tag is Scheda)
                {
                    Scheda s = tn.Tag as Scheda;
                    foreach (String id in s.GetIds())
                    {
                        if (_values[GenerateId(s.IdScheda, id)][1] != null)
                        {
                            tn.BackColor = Color.Yellow;
                            result       = true;
                        }
                    }

                    if (result == false)
                    {
                        tn.BackColor = Color.Empty;
                    }
                }
                else if (tn.Nodes.Count > 0)
                {
                    result = ColoraSchedeView(tn.Nodes);
                }
                else
                {
                    result = false;
                }
            }
            return(result);
        }
Пример #9
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);
        }
Пример #10
0
        private bool IsSchedaErrata(ElementoTemplate e, Scheda s)
        {
            bool result = false;

            if (e is Contenitore)
            {
                foreach (ElementoTemplate figlio in ((Contenitore)e).Children)
                {
                    if (IsSchedaErrata(figlio, s))
                    {
                        return(true);
                    }
                }
            }
            else if (e is Contenuto && !s.GetIds().Contains <String>(e.Id))
            {
                return(true);
            }
            return(result);
        }
Пример #11
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);
            }
        }