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));
|
}
|
}
|