using System.Collections.Generic; using System.Windows; namespace PdmSwPlugin.UI { public class DProperty { public static List GetBlob(CustomRichBox control) { return (List)control.GetValue(BlobProperty); } public static void SetBlob(CustomRichBox control, List value) { control.SetValue(BlobProperty, value); } public static readonly DependencyProperty BlobProperty = DependencyProperty.RegisterAttached("Blob", typeof(List), typeof(DProperty), new PropertyMetadata(null, PropertyChangedCallback)); private static void PropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args) { List arr = args.NewValue as List; 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); } /// /// 图片最大宽度 /// /// /// 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)); } }