Dreamine.UI.Wpf.Controls
1.0.1
Dreamine.UI.Wpf.Controls 사용자 인터페이스 기능과 구성 요소를 제공합니다.
Toggle main menu visibility
로딩중...
검색중...
일치하는것 없음
DreamineTextBlock.cs
이 파일의 문서화 페이지로 가기
1
using
System.Windows;
2
using
System.Windows.Controls;
3
using
System.Windows.Input;
4
5
namespace
Dreamine.UI.Wpf.Controls
6
{
15
public
class
DreamineTextBlock
: TextBlock
16
{
25
static
DreamineTextBlock
()
26
{
27
DefaultStyleKeyProperty.OverrideMetadata(typeof(
DreamineTextBlock
),
28
new
FrameworkPropertyMetadata(typeof(
DreamineTextBlock
)));
29
30
var uri =
new
Uri(
"/Dreamine.UI.Wpf.Themes;component/DreamineTextBlockStyle.xaml"
, UriKind.RelativeOrAbsolute);
31
32
if
(Application.Current !=
null
)
33
{
34
bool
alreadyAdded = Application.Current.Resources.MergedDictionaries
35
.OfType<ResourceDictionary>()
36
.Any(x => x.Source !=
null
&& x.Source.Equals(uri));
37
38
if
(!alreadyAdded)
39
{
40
var dict =
new
ResourceDictionary { Source = uri };
41
Application.Current.Resources.MergedDictionaries.Add(dict);
42
}
43
}
44
}
45
54
public
static
readonly DependencyProperty
CommandProperty
=
55
DependencyProperty.RegisterAttached(
56
"Command"
,
57
typeof(ICommand),
58
typeof(
DreamineTextBlock
),
59
new
PropertyMetadata(
null
,
OnCommandChanged
));
60
69
public
static
readonly DependencyProperty
CommandParameterProperty
=
70
DependencyProperty.RegisterAttached(
71
"CommandParameter"
,
72
typeof(
object
),
73
typeof(
DreamineTextBlock
),
74
new
PropertyMetadata(
null
));
75
84
public
static
readonly DependencyProperty
CommandTriggerNameProperty
=
85
DependencyProperty.RegisterAttached(
86
"CommandTriggerName"
,
87
typeof(
string
),
88
typeof(
DreamineTextBlock
),
89
new
PropertyMetadata(
null
));
90
123
public
static
void
SetCommandTriggerName
(DependencyObject obj,
string
value)
124
=> obj.SetValue(
CommandTriggerNameProperty
, value);
125
166
public
static
string
GetCommandTriggerName
(DependencyObject obj)
167
=> (string)obj.GetValue(
CommandTriggerNameProperty
);
168
201
public
static
void
SetCommand
(DependencyObject obj, ICommand value) => obj.SetValue(
CommandProperty
, value);
202
243
public
static
ICommand
GetCommand
(DependencyObject obj) => (ICommand)obj.GetValue(
CommandProperty
);
244
277
public
static
void
SetCommandParameter
(DependencyObject obj,
object
value)
278
=> obj.SetValue(
CommandParameterProperty
, value);
279
312
public
static
object
GetCommandParameter
(DependencyObject obj)
313
=> obj.GetValue(
CommandParameterProperty
);
314
347
private
static
void
OnCommandChanged
(DependencyObject d, DependencyPropertyChangedEventArgs e)
348
{
349
if
(d is UIElement element)
350
{
351
// 마우스 클릭
352
element.AddHandler(UIElement.PreviewMouseUpEvent,
new
MouseButtonEventHandler((s, e) =>
353
{
354
TryExecuteCommand
(d,
"PreviewMouseUp"
, e);
355
}),
true
);
356
}
357
}
358
391
392
private
static
void
TryExecuteCommand
(DependencyObject d,
string
eventName, RoutedEventArgs eventArgs)
393
{
394
var rawTrigger =
GetCommandTriggerName
(d);
395
if
(
string
.IsNullOrEmpty(rawTrigger))
396
return
;
397
398
var triggerList = rawTrigger.Split(
','
)
399
.Select(x => x.Trim())
400
.Where(x => !
string
.IsNullOrEmpty(x));
401
402
if
(!triggerList.Contains(eventName, StringComparer.OrdinalIgnoreCase))
403
return
;
404
405
var command =
GetCommand
(d);
406
var parameter =
GetCommandParameter
(d) ?? eventArgs;
407
408
if
(command?.CanExecute(parameter) ==
true
)
409
command.Execute(parameter);
410
}
411
}
412
}
Dreamine.UI.Wpf.Controls
Definition
DreamineCheckSelector.xaml.cs:6
Dreamine.UI.Wpf.Controls.DreamineTextBlock.TryExecuteCommand
static void TryExecuteCommand(DependencyObject d, string eventName, RoutedEventArgs eventArgs)
Definition
DreamineTextBlock.cs:392
Dreamine.UI.Wpf.Controls.DreamineTextBlock.SetCommand
static void SetCommand(DependencyObject obj, ICommand value)
Definition
DreamineTextBlock.cs:201
Dreamine.UI.Wpf.Controls.DreamineTextBlock.GetCommandTriggerName
static string GetCommandTriggerName(DependencyObject obj)
Definition
DreamineTextBlock.cs:166
Dreamine.UI.Wpf.Controls.DreamineTextBlock.OnCommandChanged
static void OnCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
Definition
DreamineTextBlock.cs:347
Dreamine.UI.Wpf.Controls.DreamineTextBlock.CommandProperty
static readonly DependencyProperty CommandProperty
Definition
DreamineTextBlock.cs:54
Dreamine.UI.Wpf.Controls.DreamineTextBlock.CommandParameterProperty
static readonly DependencyProperty CommandParameterProperty
Definition
DreamineTextBlock.cs:69
Dreamine.UI.Wpf.Controls.DreamineTextBlock.GetCommand
static ICommand GetCommand(DependencyObject obj)
Definition
DreamineTextBlock.cs:243
Dreamine.UI.Wpf.Controls.DreamineTextBlock.SetCommandParameter
static void SetCommandParameter(DependencyObject obj, object value)
Definition
DreamineTextBlock.cs:277
Dreamine.UI.Wpf.Controls.DreamineTextBlock.CommandTriggerNameProperty
static readonly DependencyProperty CommandTriggerNameProperty
Definition
DreamineTextBlock.cs:84
Dreamine.UI.Wpf.Controls.DreamineTextBlock.SetCommandTriggerName
static void SetCommandTriggerName(DependencyObject obj, string value)
Definition
DreamineTextBlock.cs:123
Dreamine.UI.Wpf.Controls.DreamineTextBlock.GetCommandParameter
static object GetCommandParameter(DependencyObject obj)
Definition
DreamineTextBlock.cs:312
Dreamine.UI.Wpf.Controls.DreamineTextBlock.DreamineTextBlock
static DreamineTextBlock()
Definition
DreamineTextBlock.cs:25
Controls
DreamineTextBlock.cs
다음에 의해 생성됨 :
1.17.0