Exemple #1
0
        private void btnOpenJob_Click(object sender, EventArgs e)
        {
            bool ignoreChanges = !_viewModel.UnsavedChanges;

            if (_viewModel.UnsavedChanges)
            {
                var result = MessageBox.Show("Are you sure you want to continue?", "Unsaved Changes", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
                ignoreChanges = (result == DialogResult.OK);
            }
            if (ignoreChanges)
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Filter = "2dJob|*.2djob";
                openFileDialog.Title  = "Open Job";
                openFileDialog.ShowDialog();

                if (openFileDialog.FileName != "")
                {
                    var job = JsonConvert.DeserializeObject <Job>(File.ReadAllText(openFileDialog.FileName));
                    _viewModel = new JobViewModel(job);
                    BindDataSource();
                }
            }
        }
Exemple #2
0
 private void jobForm_Load(object sender, EventArgs e)
 {
     _viewModel = new JobViewModel(new Job());
     BindDataSource();
 }