Rev | Line | |
---|
[7160] | 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; |
---|
[11904] | 8 | using System.Windows.Input; |
---|
| 9 | using Com.Piwigo.Wpf.Command; |
---|
[7160] | 10 | |
---|
| 11 | namespace Com.Piwigo.Wpf.Helper |
---|
| 12 | { |
---|
| 13 | public class AppHelper |
---|
| 14 | { |
---|
[11904] | 15 | private static bool? _isInDesignMode; |
---|
[7160] | 16 | |
---|
| 17 | /// <summary> |
---|
| 18 | /// Gets a value indicating whether the control is in design mode (running in Blend |
---|
| 19 | /// or Visual Studio). |
---|
| 20 | /// </summary> |
---|
[11904] | 21 | public static bool IsInDesignModeStatic |
---|
[7160] | 22 | { |
---|
| 23 | get |
---|
| 24 | { |
---|
| 25 | if (!_isInDesignMode.HasValue) |
---|
| 26 | { |
---|
| 27 | var prop = DesignerProperties.IsInDesignModeProperty; |
---|
| 28 | _isInDesignMode |
---|
[11904] | 29 | = (bool)DependencyPropertyDescriptor |
---|
[7160] | 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")] |
---|
[11904] | 46 | public bool IsInDesignMode |
---|
[7160] | 47 | { |
---|
| 48 | get |
---|
| 49 | { |
---|
| 50 | return IsInDesignModeStatic; |
---|
| 51 | } |
---|
| 52 | } |
---|
| 53 | |
---|
[11922] | 54 | static public void ExecuteCommand<T>(object parameter) where T : AsyncCommand |
---|
[11904] | 55 | { |
---|
[11922] | 56 | AsyncCommand cmd = PwgCmdProvider.GetByType<T>(); |
---|
[11935] | 57 | if (cmd != null) |
---|
[11904] | 58 | { |
---|
[11935] | 59 | if (cmd.CanExecute(parameter)) |
---|
| 60 | { |
---|
| 61 | cmd.Execute(parameter); |
---|
| 62 | } |
---|
[11904] | 63 | } |
---|
| 64 | } |
---|
[7160] | 65 | } |
---|
| 66 | |
---|
[11904] | 67 | |
---|
[7160] | 68 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.