1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using Aitex.UI.Charting.ViewModel;
- using Aitex.UI.Charting.Model;
- namespace Aitex.UI.Charting.View
- {
- /// <summary>
- /// Interaction logic for DataSourceView.xaml
- /// </summary>
- public partial class DataSourceView : UserControl
- {
- public DataSourceView()
- {
- InitializeComponent();
- Loaded += new RoutedEventHandler(DataSourceView_Loaded);
- _viewModel = new DataSourceViewModel();
- DataContext = _viewModel;
- }
- DataSourceViewModel _viewModel;
- void DataSourceView_Loaded(object sender, RoutedEventArgs e)
- {
- //_viewModel = new DataSourceViewModel();
- //DataContext = _viewModel;
- }
- /// <summary>
- /// DataGrid的SelectionChange不支持ICommand接口,此处采用message handling方式处理
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void DataSource_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if(dataGrid_DataSources.SelectedItem != null)
- {
- CommonViewModel.Instance.CurrentSelectedDataSource = (IDataSource)dataGrid_DataSources.SelectedItem;
- }
- }
- #if false
- /// <summary>
- /// Template模板中的事件不能通过ICommand绑定
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void DataSource_SyncTime(object sender, SelectionChangedEventArgs e)
- {
- if (sender is ComboBox)
- {
- var combo = (ComboBox)sender;
- var selection = combo.SelectedItem as RecipeSyncPoint;
- string sourceName = (string)((ComboBox)sender).Tag;
- _viewModel.SyncSourceTimeCommand.Execute(new Tuple<string, DateTime, string>(sourceName, selection.StepTime, selection.StepName));
- }
- }
- #endif
- private void DataSource_Export(object sender, RoutedEventArgs e)
- {
- string sourceName = (string)((Button)sender).Tag;
- Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
- dlg.FileName = sourceName.Replace("/", "_").Replace(":", "_").Replace(" ", "_"); // Default file name
- dlg.DefaultExt = ".arch"; // Default file extension
- dlg.Filter = "Archive File (.arch)|*.arch"; // Filter files by extension
- // Show open file dialog box
- Nullable<bool> result = dlg.ShowDialog();
- if (result.HasValue && result.Value)
- {
- DataSourceExportingDialog processDialog = new DataSourceExportingDialog(sourceName, dlg.FileName) { Owner = Application.Current.MainWindow };
- processDialog.Show();
- }
- }
- private void DataSource_Remove(object sender, RoutedEventArgs e)
- {
- var sourceName = (string)((Button)sender).Tag;
- CommonViewModel.Instance.RemoveDataSource(sourceName);
- }
- }
- }
|