修改 主程序下的Comm文件夹 转到 Frameork中
This commit is contained in:
1 parent
2f9c98b105
commit
1eb5315261
78 files changed
+274
-227
No files matched your search
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace WxOrder.Framework.Commons
|
||||
{
|
||||
public static class DebugVisibility
|
||||
{
|
||||
// 定义一个附加属性
|
||||
public static readonly DependencyProperty EnableProperty =
|
||||
DependencyProperty.RegisterAttached(
|
||||
"Enable",
|
||||
typeof(bool),
|
||||
typeof(DebugVisibility),
|
||||
new FrameworkPropertyMetadata(
|
||||
true, FrameworkPropertyMetadataOptions.AffectsArrange,
|
||||
OnEnableChanged, OnEnableCoerceCall));
|
||||
|
||||
private static object OnEnableCoerceCall(DependencyObject d, object baseValue)
|
||||
{
|
||||
if (d is UIElement element)
|
||||
{
|
||||
#if DEBUG
|
||||
// Debug 模式下,根据属性值决定可见性
|
||||
element.Visibility = (bool)baseValue ? Visibility.Visible : Visibility.Collapsed;
|
||||
#else
|
||||
// Release 模式下,隐藏所有标记了 IsDebug 的元素
|
||||
element.Visibility = Visibility.Collapsed;
|
||||
#endif
|
||||
}
|
||||
|
||||
return baseValue;
|
||||
}
|
||||
|
||||
private static void OnEnableChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is UIElement element)
|
||||
{
|
||||
#if DEBUG
|
||||
// Debug 模式下,根据属性值决定可见性
|
||||
element.Visibility = (bool)e.NewValue ? Visibility.Visible : Visibility.Collapsed;
|
||||
#else
|
||||
// Release 模式下,隐藏所有标记了 IsDebug 的元素
|
||||
element.Visibility = Visibility.Collapsed;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public static bool GetEnable(DependencyObject obj) => (bool)obj.GetValue(EnableProperty);
|
||||
public static void SetEnable(DependencyObject obj, bool value) => obj.SetValue(EnableProperty, value);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user