public RuleBG(RuleBG rule) { Ora = rule.Ora; Minuti = rule.Minuti; getIMAGE(rule.IMGPath); STYLE = rule.STYLE; }
private void btnsavesci_Click(object sender, EventArgs e) { var arrOra = lora.ToArray(); var arrCose = lcose.ToArray(); var arrDrop = lcombo.ToArray(); bool errore = false; string szerrore = ""; List <RuleBG> res = new List <RuleBG>(); for (int i = 0; i < lcose.Count; i++) { if (!arrCose[i].Parent.IsDisposed) { try { var s = new RuleBG( arrOra[i].Value.Hour, arrOra[i].Value.Minute, arrCose[i].Text, arrDrop[i].SelectedItem.ToString()); res.Add(s); } catch (Exception ee) { szerrore = ee.Message; errore = true; } } } if (!errore) { File.Delete(Out.FileRuleBG); if (res.Count > 0) { File.WriteAllLines(Out.FileRuleBG, res.Select(r => r.ToString())); Task.Run(() => { RuleBG.Attuale(res).Set(); }); } nasconditi(true); } else { MessageBox.Show(szerrore, "ERRORE", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Ricarica() { flowLayoutPanel1.Controls.Clear(); lora.Clear(); lcose.Clear(); lcombo.Clear(); ITMES.Clear(); if (File.Exists(Out.FileRuleBG)) { Enabled = false; var Inorder = new List <RuleBG>(); foreach (var sv in Out.leggiTXT(Out.FileRuleBG)) { try { Inorder.Add(new RuleBG(sv)); } catch (Exception ef) { if (Out.IS_ON_NET) { MessageBox.Show(ef.Message, "Problema", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Connsesisone internet assente! alcune immagini potrebbero andare perse\nIl programma verrà chiuso!", "Problema", MessageBoxButtons.OK, MessageBoxIcon.Error); chiudu = true; Application.Exit(); } } } Inorder = Inorder.OrderBy(f => f.MinutiOra).ToList(); if (Inorder.Count > 0) { Task.Run(() => { RuleBG.Attuale(Inorder).Set(); }); } Inorder.ForEach(sv => { addRuleBG(sv); }); Enabled = true; flowLayoutPanel1.Update(); } }
private void timer1_Tick(object sender, EventArgs e) { if (DateTime.Now.Second == 0) { var notInorder = new List <RuleBG>(); foreach (var sv in Out.leggiTXT(Out.FileRuleBG)) { try { var kk = new RuleBG(sv); if (DateTime.Now.Hour == kk.Ora && DateTime.Now.Minute == kk.Minuti && DateTime.Now.Second == 0) { kk.Set(); } } catch { } } } }
private void addRuleBG(RuleBG svgl) { addRuleBG(svgl.Ora, svgl.Minuti, cosa: svgl.IMGPath, stile: svgl.FormatStile); }