Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ExpressionDarkUtility.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Collections.Generic;
5 using System.Linq;
6 using System.Text;
7 using System.Threading.Tasks;
8 using System.Windows;
9 using Xceed.Wpf.AvalonDock;
10 
11 namespace SiliconStudio.Presentation.ExpressionDark
12 {
13  public static class ExpressionDarkUtility
14  {
15  /// <summary>
16  /// Applies a new theme, containing the origianl AvalonDock one plus overridden resources.
17  /// </summary>
18  /// <param name="dockingManager">The DockingManager instance to fix the theme.</param>
19  public static void FixExpressionDarkTheme(this DockingManager dockingManager)
20  {
21  if (dockingManager == null)
22  throw new ArgumentNullException("dockingManager");
23 
24  dockingManager.Theme = new FixedExpressionDarkTheme();
25  }
26 
27  /// <summary>
28  /// Applies a new theme, containing the original AvalonDock one plus overridden resources.
29  /// </summary>
30  /// <param name="window">The Window that contains the AvalonDock's DockingManager.</param>
31  /// <returns>Returns true if the DockingManager has been found, false otherwise.</returns>
32  public static bool FixExpressionDarkTheme(this Window window)
33  {
34  var dockingManager = FindDockingManager(window);
35 
36  if (dockingManager == null)
37  return false;
38 
39  dockingManager.FixExpressionDarkTheme();
40 
41  return true;
42  }
43 
44  /// <summary>
45  /// Finds the DockingManager instance.
46  /// </summary>
47  /// <param name="root">The node from where to look for the DockingManager.</param>
48  /// <returns>Returns the DockingManager instance, null otherwise.</returns>
49  private static DockingManager FindDockingManager(DependencyObject root)
50  {
51  if (root == null)
52  return null;
53 
54  if (root is DockingManager)
55  return (DockingManager)root;
56 
57  foreach (var child in LogicalTreeHelper.GetChildren(root))
58  {
59  var result = FindDockingManager(child as DependencyObject);
60  if (result != null)
61  return result;
62  }
63 
64  return null;
65  }
66  }
67 }
static bool FixExpressionDarkTheme(this Window window)
Applies a new theme, containing the original AvalonDock one plus overridden resources.
static void FixExpressionDarkTheme(this DockingManager dockingManager)
Applies a new theme, containing the origianl AvalonDock one plus overridden resources.