source: extensions/PiwigoLib/PiwigoWpf/Helper/AppHelper.cs @ 11922

Last change on this file since 11922 was 11922, checked in by bayral, 13 years ago

Async image thumbail retriving

File size: 1.9 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.ComponentModel;
6using System.Windows;
7using System.Diagnostics.CodeAnalysis;
8using System.Windows.Input;
9using Com.Piwigo.Wpf.Command;
10
11namespace 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.CanExecute(parameter))
58            {
59                cmd.Execute(parameter);
60            }
61        }
62    }
63
64
65}
Note: See TracBrowser for help on using the repository browser.