Exemplo n.º 1
0
        private static ControlzEx.Theming.Theme DetectTheme(BaseMetroDialog dialog)
        {
            if (dialog == null)
            {
                return(null);
            }

            // first look for owner
            var window = dialog.OwningWindow ?? dialog.TryFindParent <MetroWindow>();
            var theme  = window != null?ThemeManager.Current.DetectTheme(window) : null;

            if (theme != null)
            {
                return(theme);
            }

            // second try, look for main window and then for current application
            if (Application.Current != null)
            {
                theme = Application.Current.MainWindow is null
                    ? ThemeManager.Current.DetectTheme(Application.Current)
                    : ThemeManager.Current.DetectTheme(Application.Current.MainWindow);

                if (theme != null)
                {
                    return(theme);
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        private static Tuple<AppTheme, Accent> DetectTheme(BaseMetroDialog dialog)
        {
            if (dialog == null)
            {
                return null;
            }

            // first look for owner
            var window = dialog.OwningWindow ?? dialog.TryFindParent<MetroWindow>();
            var theme = window != null ? ThemeManager.DetectAppStyle(window) : null;
            if (theme?.Item2 != null)
            {
                return theme;
            }

            // second try, look for main window
            if (Application.Current != null)
            {
                var mainWindow = Application.Current.MainWindow as MetroWindow;
                theme = mainWindow != null ? ThemeManager.DetectAppStyle(mainWindow) : null;
                if (theme?.Item2 != null)
                {
                    return theme;
                }

                // oh no, now look at application resource
                theme = ThemeManager.DetectAppStyle(Application.Current);
                if (theme?.Item2 != null)
                {
                    return theme;
                }
            }
            return null;
        }
Exemplo n.º 3
0
        private static Tuple <AppTheme, Accent> DetectTheme(BaseMetroDialog dialog)
        {
            Tuple <AppTheme, Accent> tuple;
            Tuple <AppTheme, Accent> tuple1;

            if (dialog == null)
            {
                return(null);
            }
            MetroWindow metroWindow = dialog.TryFindParent <MetroWindow>();

            if (metroWindow != null)
            {
                tuple = ThemeManager.DetectAppStyle(metroWindow);
            }
            else
            {
                tuple = null;
            }
            Tuple <AppTheme, Accent> tuple2 = tuple;

            if (tuple2 != null && tuple2.Item2 != null)
            {
                return(tuple2);
            }
            if (Application.Current != null)
            {
                MetroWindow mainWindow = Application.Current.MainWindow as MetroWindow;
                if (mainWindow != null)
                {
                    tuple1 = ThemeManager.DetectAppStyle(mainWindow);
                }
                else
                {
                    tuple1 = null;
                }
                tuple2 = tuple1;
                if (tuple2 != null && tuple2.Item2 != null)
                {
                    return(tuple2);
                }
                tuple2 = ThemeManager.DetectAppStyle(Application.Current);
                if (tuple2 != null && tuple2.Item2 != null)
                {
                    return(tuple2);
                }
            }
            return(null);
        }
Exemplo n.º 4
0
        private static MahApps.Metro.Theme DetectTheme(BaseMetroDialog dialog)
        {
            if (dialog == null)
            {
                return(null);
            }

            // first look for owner
            var window = dialog.OwningWindow ?? dialog.TryFindParent <MetroWindow>();
            var theme  = window != null?ThemeManager.DetectTheme(window) : null;

            if (theme != null)
            {
                return(theme);
            }

            // second try, look for main window
            if (Application.Current != null)
            {
                var mainWindow = Application.Current.MainWindow as MetroWindow;
                theme = mainWindow != null?ThemeManager.DetectTheme(mainWindow) : null;

                if (theme != null)
                {
                    return(theme);
                }

                // oh no, now look at application resource
                theme = ThemeManager.DetectTheme(Application.Current);
                if (theme != null)
                {
                    return(theme);
                }
            }

            return(null);
        }
Exemplo n.º 5
0
        private static Tuple<AppTheme, Accent> DetectTheme(BaseMetroDialog dialog)
        {
            if (dialog == null)
                return null;

            // first look for owner
            var window = dialog.TryFindParent<MetroWindow>();
            var theme = window != null ? ThemeManager.DetectAppStyle(window) : null;
            if (theme != null && theme.Item2 != null)
                return theme;

            // second try, look for main window
            if (Application.Current != null)
            {
                var mainWindow = Application.Current.MainWindow as MetroWindow;
                theme = mainWindow != null ? ThemeManager.DetectAppStyle(mainWindow) : null;
                if (theme != null && theme.Item2 != null)
                    return theme;

                // oh no, now look at application resource
                theme = ThemeManager.DetectAppStyle(Application.Current);
                if (theme != null && theme.Item2 != null)
                    return theme;
            }
            return null;
        }