void Inicio_DragDrop(object sender, DragEventArgs e) { string[] FileList = (string[])e.Data.GetData(DataFormats.FileDrop, false); foreach (string file in FileList) { Path = file; } try { Blackouts = JsonLoader <ListOfBlackouts> .LoadData(Path); Blackouts.Blackouts = Blackouts.Blackouts.OrderBy(x => x.BlackoutBeginning).ToList(); JsonLoader <ListOfBlackouts> .UpdateData(Blackouts, Path); MessageBox.Show("The Json has linked Succesfully!"); Calendario Frm = new Calendario(); Frm.Blackouts = Blackouts; Frm.Path = Path; Frm.Show(); Hide(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void BtnNuevo_Click(object sender, EventArgs e) { try { SaveFileDialog sfd = new SaveFileDialog(); sfd.InitialDirectory = @"C:\"; sfd.RestoreDirectory = true; sfd.FileName = "*.json"; sfd.DefaultExt = "json"; sfd.Filter = "Json Files (*.json)|*.json"; String Jsonstring = JsonConvert.SerializeObject(VoidBlackouts); if (sfd.ShowDialog() == DialogResult.OK) { using (FileStream fs = (FileStream)sfd.OpenFile()) { Byte[] Info = new UTF8Encoding(true).GetBytes(Jsonstring); fs.Write(Info, 0, Info.Length); } MessageBox.Show("The json file has been created in " + sfd.FileName); Blackouts = JsonLoader <ListOfBlackouts> .LoadData(sfd.FileName); Calendario Frm = new Calendario(); Frm.Blackouts = Blackouts; Frm.Path = sfd.FileName; Frm.Show(); Hide(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void Inicio_Load(object sender, EventArgs e) { VoidBlackouts = new ListOfBlackouts(); }