schangxiang@126.com
2025-11-04 f5ed29dc26c7cd952d56ec5721a2efc43cd25992
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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
{
    /// <summary>
    /// OperateAuditView.xaml 的交互逻辑
    /// </summary>
    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();
        }
    }
}