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; using XImagingXhandler.XDAL; using DataRWDAL; using System.Windows.Media.Animation; using XHandler.Class; using System.Text.RegularExpressions; namespace XHandler.View.OperateAudit { /// /// OperateAuditView.xaml 的交互逻辑 /// public partial class OperateAuditView : UserControl { public event EventHandler closeEvent; string ID; public OperateAuditView(string id) { InitializeComponent(); ID = id; OperateAuditLog operateAuditLog = OperateAuditLogDB.GetAOperateAuditLogFromdb(ID); if (operateAuditLog != null) { this.tbxOperateType.Text = operateAuditLog.OperateType.ToString(); this.tbxOperateObject.Text = operateAuditLog.OperateObject.ToString(); this.tbxOperateResult.Text = operateAuditLog.OperateResult.ToString(); this.tbxOperaterName.Text = operateAuditLog.CreateName.ToString(); this.tbxOperateTime.Text = operateAuditLog.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"); //int height = GetNewLineCount(operateAuditLog.OperateContent)*40; //this.tbxOperateContent.Height= height; this.tbxOperateContent.Text = operateAuditLog.OperateContent.ToString(); } } static int GetNewLineCount(string input) { // 正则表达式匹配任何形式的换行符:\r\n, \n, \r string pattern = @"\r\n|\n|\r"; MatchCollection matches = Regex.Matches(input, pattern); return matches.Count; } private void Button_Click(object sender, RoutedEventArgs e) { if (EventResponseController.Instance.CanExecute() == false) return; Storyboard storyboard = new Storyboard(); DoubleAnimation doubleAnimation = new DoubleAnimation(600, 0, new Duration(TimeSpan.FromSeconds(0.25))); Storyboard.SetTarget(doubleAnimation, border);//Target对象 Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("Width"));//Target属性 storyboard.Children.Add(doubleAnimation); ObjectAnimationUsingKeyFrames showAnimation = new ObjectAnimationUsingKeyFrames(); showAnimation.BeginTime = TimeSpan.FromSeconds(0); Storyboard.SetTarget(showAnimation, border); Storyboard.SetTargetProperty(showAnimation, new PropertyPath("(UIElement.Visibility)")); DiscreteObjectKeyFrame closeKeyFrame = new DiscreteObjectKeyFrame(Visibility.Collapsed, TimeSpan.FromSeconds(0.26)); showAnimation.KeyFrames.Add(closeKeyFrame); storyboard.Children.Add(showAnimation); storyboard.Completed += delegate { closeEvent?.Invoke(this, EventArgs.Empty); }; storyboard.Begin(); } private void UserControl_Loaded(object sender, RoutedEventArgs e) { Storyboard storyboard = new Storyboard(); DoubleAnimation doubleAnimation = new DoubleAnimation(0, 500, new Duration(TimeSpan.FromSeconds(0.25))); Storyboard.SetTarget(doubleAnimation, border);//Target对象 Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("Width"));//Target属性 storyboard.Children.Add(doubleAnimation); ObjectAnimationUsingKeyFrames showAnimation = new ObjectAnimationUsingKeyFrames(); showAnimation.BeginTime = TimeSpan.FromSeconds(0); Storyboard.SetTarget(showAnimation, border); Storyboard.SetTargetProperty(showAnimation, new PropertyPath("(UIElement.Visibility)")); DiscreteObjectKeyFrame closeKeyFrame = new DiscreteObjectKeyFrame(Visibility.Visible, TimeSpan.FromSeconds(0.01)); showAnimation.KeyFrames.Add(closeKeyFrame); storyboard.Children.Add(showAnimation); storyboard.Begin(); } } }