예제 #1
0
파일: ViewModel.cs 프로젝트: tforsberg/z
 public void AddDataSource(DataSource ds)
 {
     if (ds.Model != this)
     {
         throw new Exception("This data source does not belong to this model.");
     }
     _sources.Add(ds);
 }
예제 #2
0
 // add a data source to the model
 void _btnAddSource_Click(object sender, RoutedEventArgs e)
 {
     var ds = new DataSource(Model);
     var dlg = new ModalDialog("Add Data Source", new DataSourceEditor(), ds);
     dlg.ShowDialog(MessageBoxButton.OKCancel);
     dlg.Closed += (ss, ee) =>
     {
         if (!ee.Cancel)
         {
             Model.AddDataSource(ds);
         }
     };
 }
예제 #3
0
 void DataSources_CurrentChanged(object sender, EventArgs e)
 {
     if (_ds != null)
     {
         _ds.Tables.CurrentChanged -= Tables_CurrentChanged;
     }
     _ds = _vm.DataSources.CurrentItem as DataSource;
     if (_ds != null)
     {
         _ds.Tables.CurrentChanged += Tables_CurrentChanged;
     }
     OnCanExecuteChanged();
 }