using OS.Spin.ViewModle.Flaw; using System; using System.Windows.Controls; using System.Windows.Media.Imaging; namespace OS.Spin.View.MainWindowControls { /// /// UCFlawArm.xaml 的交互逻辑 /// public partial class UCFlawArm : UserControl { private BitmapImage _isSelectedInfo; private BitmapImage _unSelectedInfo; public UCFlawArm() { InitializeComponent(); } private MFlawSnapView _flaw; public MFlawSnapView FlawInfo { get { return _flaw; } } public UCFlawArm(MFlawSnapView flaw) { InitializeComponent(); _flaw = flaw; _isSelectedInfo = new BitmapImage(new Uri("pack://application:,,,/OS.Spin.View;component/images/图层9拷贝2.png")); _unSelectedInfo = new BitmapImage(new Uri("pack://application:,,,/OS.Spin.View;component/images/图层9拷贝.png")); } private bool _isSelected = false; public bool IsSelected { get { return _isSelected; } set { if (_isSelected == value) { return; } _isSelected = value; var left = Canvas.GetLeft(this); var top = Canvas.GetTop(this); if(_isSelected) { this.Width += 10; this.Height += 10; Flaw.Source = _isSelectedInfo; Canvas.SetLeft(this, left - 5); Canvas.SetTop(this, top - 5); return; } this.Width -= 10; this.Height -= 10; Flaw.Source = _unSelectedInfo; Canvas.SetLeft(this, left + 5); Canvas.SetTop(this, top + 5); } } } }