Exemple #1
0
        public object GetData()
        {
            var td = new TaskSchedulerData();
            td.Name = UserName.Text;
            td.Surname = UserSurname.Text;
            td.Patronimyc = UserPatronymic.Text;
            if (MaleButton.Checked)
            {
                td.Gender = Gender.Male;
            }
            if (FemaleButton.Checked)
            {
                td.Gender = Gender.Female;
            }

            foreach (TaskData ed in ListBox1.Items)
            {
                td.Tasks.Add(ed);
            }

            var ms = new MemoryStream();
            PhotoBox.Image.Save(ms, ImageFormat.Png);
            td.Photo = ms.GetBuffer();

            return td;
        }
Exemple #2
0
 private void InitScheduler()
 {
     var SchedulerName = GetPath();
     if (SchedulerName != null && System.IO.File.Exists(SchedulerName))
     {
         var xs = new XmlSerializer(typeof(TaskSchedulerData));
         var file = System.IO.File.OpenRead(SchedulerName);
         pd = (TaskSchedulerData)xs.Deserialize(file);
         file.Close();
     }
     else
     {
         pd = new TaskSchedulerData();
     }
 }
Exemple #3
0
 public Form1()
 {
     LoadedP = new TaskSchedulerData();
     InitializeComponent();
 }
Exemple #4
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            if (UserName.Text == string.Empty && ListBox1.Items.Count == 0 || PhotoBox.Image == null)
            {
                var RERER = new EmptyError();
                RERER.ShowDialog();
            }
            else
            {

                var pd = new TaskSchedulerData();
                if (!(MaleButton.Checked || FemaleButton.Checked))
                {
                    var box = new NoNoMessageBox();
                    box.ShowDialog();
                    if (box.DialogResult == DialogResult.OK)
                    {
                        pd.Gender = Gender.NoSelected;
                        box.Close();
                    }
                    else
                    {
                        return;
                    }
                }

                var sfd = new SaveFileDialog() {Title = "Сохранение данных", Filter = "файл планировщика|*.ts"};
                var result = sfd.ShowDialog(this);
                if (result != DialogResult.OK)
                    return;

                pd.Name = UserName.Text;
                pd.Surname = UserSurname.Text;
                pd.Patronimyc = UserPatronymic.Text;

                if (PhotoBox.Image != null)
                {
                    var ms = new MemoryStream();
                    PhotoBox.Image.Save(ms, ImageFormat.Png);

                    pd.Photo = ms.GetBuffer();
                }

                if (MaleButton.Checked)
                {
                    pd.Gender = Gender.Male;
                }
                if (FemaleButton.Checked)
                {
                    pd.Gender = Gender.Female;
                }

                foreach (TaskData ed in ListBox1.Items)
                {
                    pd.Tasks.Add(ed);
                }

                var xs = new XmlSerializer(typeof (TaskSchedulerData));
                var file = File.Create(sfd.FileName);
                xs.Serialize(file, pd);
                file.Close();

                var s = Application.StartupPath + "\\Profiles\\" + pd.Name + " " + pd.Patronimyc + " " + pd.Surname;
                file = File.Create(s);
                xs.Serialize(file, pd);
                file.Close();
            }
        }