新增加 利润统计Window。
隐藏利润统计按钮 增加 Common 文件夹 内部是WPF公用类库
This commit is contained in:
1 parent
4a7af051b2
commit
7c6f91f207
25 files changed
+6462
-3554
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 _29WxOrderWpf.Common
|
||||
{
|
||||
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