public static MemorialDayCollection Load(string path)
        {
            MemorialDayCollection memorialDays = new MemorialDayCollection();

            try
            {
                using (FileStream data = new FileStream(path, FileMode.OpenOrCreate))
                {
                    if (data.Length == 0)
                    {
                        throw new Exception("Bad File");
                    }
                    BinaryReader br    = new BinaryReader(data);
                    uint         count = br.ReadUInt32();
                    for (int i = 0; i < count; i++)
                    {
                        UInt32 y = br.ReadUInt32();
                        UInt32 m = br.ReadUInt32();
                        UInt32 w = br.ReadUInt32();
                        UInt32 d = br.ReadUInt32();

                        memorialDays.Add(new MemorialDay(y, m, d,
                                                         br.ReadString(),
                                                         br.ReadString(),
                                                         br.ReadString()));
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message + "\n\n加载纪念日数据失败。", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(memorialDays);
        }
Exemplo n.º 2
0
        private void NewDate()
        {
            MemorialDay md = editForm.Create();

            if (md != null)
            {
                memorialDays.Add(md);
                DayListView.Items.Add(md.GetListViewItem());
            }
        }