Line | |
---|
1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using System.Linq; |
---|
4 | using System.Text; |
---|
5 | using System.ComponentModel; |
---|
6 | using System.Windows; |
---|
7 | using System.Diagnostics.CodeAnalysis; |
---|
8 | using System.Windows.Input; |
---|
9 | using Com.Piwigo.Wpf.Command; |
---|
10 | |
---|
11 | namespace Com.Piwigo.Wpf.Helper |
---|
12 | { |
---|
13 | public class AppHelper |
---|
14 | { |
---|
15 | private static bool? _isInDesignMode; |
---|
16 | |
---|
17 | /// <summary> |
---|
18 | /// Gets a value indicating whether the control is in design mode (running in Blend |
---|
19 | /// or Visual Studio). |
---|
20 | /// </summary> |
---|
21 | public static bool IsInDesignModeStatic |
---|
22 | { |
---|
23 | get |
---|
24 | { |
---|
25 | if (!_isInDesignMode.HasValue) |
---|
26 | { |
---|
27 | var prop = DesignerProperties.IsInDesignModeProperty; |
---|
28 | _isInDesignMode |
---|
29 | = (bool)DependencyPropertyDescriptor |
---|
30 | .FromProperty(prop, typeof(FrameworkElement)) |
---|
31 | .Metadata.DefaultValue; |
---|
32 | } |
---|
33 | |
---|
34 | return _isInDesignMode.Value; |
---|
35 | } |
---|
36 | } |
---|
37 | |
---|
38 | /// <summary> |
---|
39 | /// Gets a value indicating whether the control is in design mode (running under Blend |
---|
40 | /// or Visual Studio). |
---|
41 | /// </summary> |
---|
42 | [SuppressMessage( |
---|
43 | "Microsoft.Performance", |
---|
44 | "CA1822:MarkMembersAsStatic", |
---|
45 | Justification = "Non static member needed for data binding")] |
---|
46 | public bool IsInDesignMode |
---|
47 | { |
---|
48 | get |
---|
49 | { |
---|
50 | return IsInDesignModeStatic; |
---|
51 | } |
---|
52 | } |
---|
53 | |
---|
54 | static public void ExecuteCommand<T>(object parameter) where T : AsyncCommand |
---|
55 | { |
---|
56 | AsyncCommand cmd = PwgCmdProvider.GetByType<T>(); |
---|
57 | if (cmd != null) |
---|
58 | { |
---|
59 | if (cmd.CanExecute(parameter)) |
---|
60 | { |
---|
61 | cmd.Execute(parameter); |
---|
62 | } |
---|
63 | } |
---|
64 | } |
---|
65 | } |
---|
66 | |
---|
67 | |
---|
68 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.