Esempio n. 1
0
        }//FUNZIONE CHE RITORNA BOOLEANO SE STRINGA E' CONTENUTA NELL'OGGETTO

        public static SerializableBindingList <Veicolo> Search(string s, System.Collections.Generic.List <Veicolo> lst, char sep = ' ')
        {
            string[] search = s.Split(sep);
            SerializableBindingList <Veicolo> results = new SerializableBindingList <Veicolo>();//LISTA RISULTATI

            foreach (Veicolo item in lst)
            {
                if (item.Contains(search[0]))
                {
                    results.Add(item);
                }
            }
            for (int i = 0; i < search.Length; i++)
            {
                for (int j = 0; j < results.Count; j++)
                {
                    if (!results[j].Contains(search[i]))
                    {
                        results.Remove(results[j]);
                        j--;
                        if (results.Count == 1)
                        {
                            break;
                        }
                    }
                }
                if (results.Count == 1)
                {
                    break;
                }
            }
            return(results);
        }
        public static void SerializeToXml <T>(SerializableBindingList <T> objectlist, string pathName)
        {
            XmlSerializer x      = new XmlSerializer(typeof(SerializableBindingList <T>));
            TextWriter    writer = new StreamWriter(pathName);

            x.Serialize(writer, objectlist);
        }
Esempio n. 3
0
        private static void createBody(ref string aus, SerializableBindingList <Veicolo> lista, int i)
        {
            string veicoloImg = string.Empty;
            string tipo       = string.Empty;
            string num        = "";

            if (lista[i] is Auto)
            {
                veicoloImg = selectImage("auto");
                tipo       = "Numero airbag";
                num        = (lista[i] as Auto).NumAirbag.ToString();
            }
            else
            {
                veicoloImg = selectImage("moto");
                tipo       = "Marca sella";
                num        = (lista[i] as Moto).MarcaSella;
            }

            aus += "<div class = \"veicolo\">";
            aus += $"<img src = \"img/{veicoloImg}\">";
            aus += $"<div class = \"titolo\">{lista[i].Marca} {lista[i].Modello}";
            aus += $"<div class = \"didascalia\"> Cilindrata: {lista[i].Cilindrata}<br> Potenza(KW): {lista[i].PotenzaKw}<br> {tipo}: {num} </div>";
            aus += "</div>";
            aus += "</div>";
        }
Esempio n. 4
0
        public static SerializableBindingList <Veicolo> deserializeObject(IEnumerable <object> objectlist)
        {
            SerializableBindingList <Veicolo> list = new SerializableBindingList <Veicolo>();

            foreach (var item in objectlist)
            {
                //list.Add(item);
            }

            return(list);
        }
        //public static void SerializeToJson<T>(IEnumerable<T> objectlist, string pathName)
        //{
        //    string json = JsonConvert.SerializeObject(objectlist, Formatting.Indented);
        //    File.WriteAllText(pathName, json);
        //}

        public static void CreateHtml(SerializableBindingList <Veicolo> l, string index = ".\\www\\index.html", string index_skeleton = ".\\www\\indexSkeleton.html")
        {
            string html        = File.ReadAllText(index_skeleton);
            string newElements = "";

            foreach (Veicolo v in l)
            {
                newElements += $"<tr><td>{v.Targa}</td><td>{v.Marca}</td><td>{v.Modello}</td></tr>";
            }
            html = html.Replace("{{mainContent}}", newElements);
            html = html.Replace("{{mainTitle}}", "carShop");
            html = html.Replace("{{subTitle}}", "Cerca il tuo amico!");
            File.WriteAllText(index, html);
            System.Diagnostics.Process.Start(index);
        }
Esempio n. 6
0
        public static SerializableBindingList <Veicolo> deserializeObject(IEnumerable <object> objectlist)
        {
            SerializableBindingList <Veicolo> lst = new SerializableBindingList <Veicolo>();

            foreach (var item in objectlist)
            {
                string str = item.ToString();
                if (str.Contains("NumAirbag"))
                {
                    //Auto a = new Auto(item["Targa"].ToString(), item["NumAirbag"].ToString(), )
                }
            }

            return(lst);
        }
        public SerializableBindingList <Veicolo> GetVeicoliList(DataTable t)
        {
            SerializableBindingList <Veicolo> l = new SerializableBindingList <Veicolo>();

            foreach (DataRow r in t.Rows)
            {
                if (Convert.ToInt32(r["AutoMoto"]) == 1)
                {
                    l.Add(new Auto(Veicolo.SetArray(r)));
                }
                else
                {
                    l.Add(new Moto(Veicolo.SetArray(r)));
                }
            }
            return(l);
        }
Esempio n. 8
0
        public static void createHtml(SerializableBindingList <Veicolo> lista, string pathName, string skeletonPathName = @".\www\index-skeleton.html")
        {
            string html = File.ReadAllText(skeletonPathName);

            html = html.Replace("{{head-title}}", "ALBUM VEICOLI");
            html = html.Replace("{{body-title}}", "SALONE VEICOLI NUOVI E USATI");


            string aus = "<h3>  </h3>";

            for (int i = 0; i < lista.Count; i++)
            {
                createBody(ref aus, lista, i);
            }

            html = html.Replace("{{main-content}}", aus);
            File.WriteAllText(pathName, html);
        }
Esempio n. 9
0
        public static void createHtml(SerializableBindingList <Veicolo> lista, string pathName, string skeletonPathName = @"E:\Triennio\QUARTA_SUP\Informatica\Progetti\VenditaVeicoliSolution\fileStorage/www/index-skeleton.html")
        {
            string html = File.ReadAllText(skeletonPathName);

            html = html.Replace("{{head-title}}", "ALBUM VEICOLI");
            html = html.Replace("{{body-title}}", "SALONE VEICOLI NUOVI E USATI");


            string aus = "<h3>  </h3>";

            for (int i = 0; i < lista.Count; i++)
            {
                createBody(ref aus, lista, i);
            }

            html = html.Replace("{{main-content}}", aus);
            File.WriteAllText(pathName, html);
        }