MarkDetail1.xaml.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. using ivf_tl_Manage.ViewModels;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. namespace ivf_tl_Manage.Views
  17. {
  18. /// <summary>
  19. /// MarkDetail1.xaml 的交互逻辑
  20. /// </summary>
  21. ///
  22. public partial class MarkDetail1 : UserControl
  23. {
  24. private MarkDetailViewModel1 vm;
  25. public MarkDetail1()
  26. {
  27. InitializeComponent();
  28. Loaded += (s, e) =>
  29. {
  30. vm = (MarkDetailViewModel1)this.DataContext;
  31. if (vm != null) InitNav();
  32. };
  33. this.Unloaded += (s, e) =>
  34. {
  35. Canvas_Root.Children.Clear();
  36. vm = null;
  37. DataContext = null;
  38. };
  39. }
  40. private void InitNav()
  41. {
  42. _nav_StackPanel.Children.Clear();
  43. for (int i = 0; i < vm.NavList.Count; i++)
  44. {
  45. var item = vm.NavList[i];
  46. if (i == vm.NavList.Count - 1)
  47. {
  48. TextBlock textBlock1 = new TextBlock();
  49. textBlock1.Margin = new Thickness(8, 0, 0, 0);
  50. textBlock1.FontWeight = FontWeights.Bold;
  51. textBlock1.Foreground = new SolidColorBrush(Colors.Black);
  52. textBlock1.FontSize = 32d;
  53. textBlock1.VerticalAlignment = VerticalAlignment.Center;
  54. textBlock1.Text = item.NavName;
  55. _nav_StackPanel.Children.Add(textBlock1);
  56. return;
  57. }
  58. Button button = new Button();
  59. button.Content = item.NavName;
  60. button.FontWeight = FontWeights.Bold;
  61. button.FontSize = 28d;
  62. button.BorderThickness = new Thickness(0);
  63. button.Background = new SolidColorBrush(Colors.Transparent);
  64. button.Style = App.Current.FindResource("ButtonStyle1") as Style;
  65. if (i == 0)
  66. {
  67. button.Margin = new Thickness(0, 0, 0, 0);
  68. }
  69. else
  70. {
  71. button.Margin = new Thickness(8, 0, 0, 0);
  72. }
  73. button.Click += (s, e) =>
  74. {
  75. if (vm != null) vm.NavList.Clear();
  76. if (item is PatientManageViewModel patient)
  77. {
  78. patient.SetTLInfo(AppData.Instance.CurrentTlInfo);
  79. AppData.Instance.MainWindowViewModel.CurrentViewModle = patient;
  80. return;
  81. }
  82. AppData.Instance.MainWindowViewModel.CurrentViewModle = item;
  83. };
  84. TextBlock textBlock = new TextBlock();
  85. textBlock.Margin = new Thickness(8, 0, 0, 0);
  86. textBlock.VerticalAlignment = VerticalAlignment.Center;
  87. textBlock.FontWeight = FontWeights.Bold;
  88. textBlock.FontSize = 28d;
  89. textBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#9B9B9B"));
  90. textBlock.Text = ">";
  91. _nav_StackPanel.Children.Add(button);
  92. _nav_StackPanel.Children.Add(textBlock);
  93. }
  94. }
  95. private void ListViewItem_MouseUp(object sender, MouseButtonEventArgs e)
  96. {
  97. }
  98. private void ListView_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
  99. {
  100. ScrollViewer viewer = _scrollview;
  101. if (viewer == null)
  102. return;
  103. double num = Math.Abs((int)(e.Delta / 2));
  104. double offset = 0.0;
  105. if (e.Delta > 0)
  106. {
  107. offset = Math.Max((double)0.0, (double)(viewer.VerticalOffset - num));
  108. }
  109. else
  110. {
  111. offset = Math.Min(viewer.ScrollableHeight, viewer.VerticalOffset + num);
  112. }
  113. if (offset != viewer.VerticalOffset)
  114. {
  115. viewer.ScrollToVerticalOffset(offset);
  116. e.Handled = true;
  117. }
  118. }
  119. private void Button_Click(object sender, RoutedEventArgs e)
  120. {
  121. AppData.Instance.MainWindowViewModel.CurrentViewModle = new DevManageViewModel();
  122. }
  123. private void Button_Click_patient(object sender, RoutedEventArgs e)
  124. {
  125. AppData.Instance.MainWindowViewModel.CurrentViewModle = AppData.Instance.MainWindowViewModel.patientManageViewModel;
  126. }
  127. private void Button_Click_Detail(object sender, RoutedEventArgs e)
  128. {
  129. //AppData.Instance.MainWindowViewModel.CurrentViewModle = vm.DetailViewModel;
  130. }
  131. private void Button_Click_Mark_Detail(object sender, RoutedEventArgs e)
  132. {
  133. //var vm = ((MarkDetailViewModel1)this.DataContext);
  134. //AppData.Instance.MainWindowViewModel.CurrentViewModle = new MarkDetailViewModel(vm.DetailViewModel,vm.DishId,vm.Title);
  135. }
  136. private void RecordButton_Click_patient(object sender, RoutedEventArgs e)
  137. {
  138. //AppData.Instance.MainWindowViewModel.CurrentViewModle = vm.RecordViewModel;
  139. }
  140. private void RecordButton_Click_Detail(object sender, RoutedEventArgs e)
  141. {
  142. //AppData.Instance.MainWindowViewModel.CurrentViewModle = vm.DetailViewModel;
  143. }
  144. private void RecordButton_Click_Mark_Detail(object sender, RoutedEventArgs e)
  145. {
  146. //AppData.Instance.MainWindowViewModel.CurrentViewModle = vm.MarkDetailViewModel ;
  147. }
  148. private void _markDetailItem_ImageMouseEnterEvent(bool arg1, ImageSource arg2)
  149. {
  150. if (arg1)
  151. {
  152. this.Image_Big.Source = arg2;
  153. this.Canvas_BigImage.Visibility = Visibility.Visible;
  154. }
  155. else
  156. {
  157. this.Canvas_BigImage.Visibility = Visibility.Hidden;
  158. }
  159. }
  160. private void _scrollview_ManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
  161. {
  162. e.Handled = true;
  163. }
  164. }
  165. }