| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- 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;
- namespace ivf_tl_Manage.UserControls
- {
- /// <summary>
- /// OrderControl.xaml 的交互逻辑
- /// </summary>
- public partial class OrderControl : UserControl
- {
- public OrderControl()
- {
- InitializeComponent();
- }
- public int State
- {
- get { return (int)GetValue(StateProperty); }
- set { SetValue(StateProperty, value); }
- }
- // Using a DependencyProperty as the backing store for State. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty StateProperty =
- DependencyProperty.Register("State", typeof(int), typeof(OrderControl), new PropertyMetadata(0, new PropertyChangedCallback(StatePropertyChangedCallback)));
- private static void StatePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (e.NewValue == null)
- return;
- int newValue = int.Parse(e.NewValue.ToString());
- var source = (OrderControl)d;
- switch (newValue)
- {
- case 0:
- source.img_up.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/orderControl_gray_up.png", UriKind.Absolute));
- source.img_dwon.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/orderControl_gray_dwon.png", UriKind.Absolute));
- break;
- case 1:
- source.img_up.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/orderControl_blue_up.png", UriKind.Absolute));
- source.img_dwon.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/orderControl_gray_dwon.png", UriKind.Absolute));
- break;
- case 2:
- source.img_up.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/orderControl_gray_up.png", UriKind.Absolute));
- source.img_dwon.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/orderControl_blue_dwon.png", UriKind.Absolute));
- break;
- default:
- break;
- }
- }
- public string Text
- {
- get { return (string)GetValue(TextProperty); }
- set { SetValue(TextProperty, value); }
- }
- // Using a DependencyProperty as the backing store for TextProperty. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty TextProperty =
- DependencyProperty.Register("Text", typeof(string), typeof(OrderControl), new PropertyMetadata(null, new PropertyChangedCallback(TextPropertyChangedCallback)));
- private static void TextPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (e.NewValue == null) return;
- string newValue = e.NewValue.ToString();
- if (string.IsNullOrEmpty(newValue)) return;
- var source = (OrderControl)d;
- source.btn_order.Text = newValue;
- }
- public bool isSelect
- {
- get { return (bool)GetValue(isSelectProperty); }
- set { SetValue(isSelectProperty, value); }
- }
- // Using a DependencyProperty as the backing store for isSelect. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty isSelectProperty =
- DependencyProperty.Register("isSelect", typeof(bool), typeof(OrderControl), new PropertyMetadata(false, new PropertyChangedCallback(IsSelectPropertyChangedCallback)));
- private static void IsSelectPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- bool? newValue = e.NewValue as bool?;
- if (newValue == null)
- return;
- var source = (OrderControl)d;
- if (source.isSelect)
- {
- source.btn_order.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D75AC"));
- }
- else
- {
- source.btn_order.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D4D4D"));
- source.State = 0;
- }
- }
- private bool clicktype = true;
- private void img_dwon_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- clicktype = true;
- isSelect = true;
- State = clicktype ? 2 : 1;
- }
- private void img_up_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- clicktype = false;
- isSelect = true;
- State = clicktype ? 2 : 1;
- }
- private void StackPanel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- if (e.OriginalSource is not Image)
- {
- clicktype = !clicktype;
- State = clicktype ? 2 : 1;
- isSelect = true;
- }
- }
- }
- }
|