chr
7 天以前 43a0207d207390abdeeb3ab9155eebf03edd7b1a
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
using System.Collections.Generic;
using System.Windows;
 
namespace PdmSwPlugin.UI
{
    public class DProperty
    {
        public static List<byte> GetBlob(CustomRichBox control)
        {
            return (List<byte>)control.GetValue(BlobProperty);
        }
 
        public static void SetBlob(CustomRichBox control, List<byte> value)
        {
            control.SetValue(BlobProperty, value);
        }
 
        public static readonly DependencyProperty BlobProperty = DependencyProperty.RegisterAttached("Blob", typeof(List<byte>), typeof(DProperty),
            new PropertyMetadata(null, PropertyChangedCallback));
 
        private static void PropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
        {
            List<byte> arr = args.NewValue as List<byte>;
            if (arr != null)
            {
                (dependencyObject as CustomRichBox).LoadFromBlob(arr.ToArray());
            }
        }
 
 
        public static bool GetDisableEdit(CustomRichBox control)
        {
            return (bool)control.GetValue(DisableEditProperty);
        }
 
        public static void SetDisableEdit(CustomRichBox control, bool value)
        {
            control.SetValue(DisableEditProperty, value);
        }
 
        public static readonly DependencyProperty DisableEditProperty = DependencyProperty.RegisterAttached("DisableEdit", typeof(bool), typeof(DProperty),
            new PropertyMetadata(false, DisableEditChange));
 
        private static void DisableEditChange(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
        {
            bool? flag = args.NewValue as bool?;
            bool res = flag == true ? true : false;
            (dependencyObject as CustomRichBox).ChangeStatus(res);
        }
 
 
        /// <summary>
        /// 图片最大宽度
        /// </summary>
        /// <param name="control"></param>
        /// <param name="value"></param>
        public static void SetPicMaxWidth(CustomRichBox control, double value)
        {
            control.SetValue(PicMaxWidthProperty, value);
        }
 
        public static double GetPicMaxWidth(CustomRichBox control)
        {
            return (double)control.GetValue(PicMaxWidthProperty);
        }
 
        public static readonly DependencyProperty PicMaxWidthProperty = DependencyProperty.RegisterAttached("PicMaxWidth", typeof(double), typeof(DProperty),
            new PropertyMetadata(1000D));
    }
}