DataHistoryView.xaml.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. using Venus_MainPages.ViewModels;
  16. namespace Venus_MainPages.Views
  17. {
  18. /// <summary>
  19. /// DataHistoryView.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class DataHistoryView : UserControl
  22. {
  23. public DataHistoryView()
  24. {
  25. InitializeComponent();
  26. //this.DataContext = new DataHistoryViewModel();
  27. }
  28. private DataHistoryViewModel _viewModel;
  29. private void OnChangeLineColor(object sender, RoutedEventArgs e)
  30. {
  31. var btn = (Button)sender;
  32. if (btn != null)
  33. {
  34. int dataId = (int)btn.Tag;
  35. var dlg = new System.Windows.Forms.ColorDialog();
  36. if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  37. {
  38. var newColor = new System.Windows.Media.Color() { A = dlg.Color.A, B = dlg.Color.B, G = dlg.Color.G, R = dlg.Color.R };
  39. System.Drawing.Color _newColor = System.Drawing.Color.FromArgb(newColor.A, newColor.R, newColor.G, newColor.B);
  40. _viewModel = (DataHistoryViewModel)DataContext;
  41. var item = _viewModel.KeyDataObservableCollection.ToList().Find(t => t.UniqueId == dataId);
  42. item.Color = new SolidColorBrush(newColor);
  43. _viewModel.ColorChanged();
  44. }
  45. }
  46. }
  47. }
  48. }