madskristensen / SolutionColors

A Visual Studio extension
Apache License 2.0
76 stars 11 forks source link

Implement also in floating Test Explorer windows #5

Open AndySteelApd opened 2 years ago

AndySteelApd commented 2 years ago

Thanks for this great extension :)

I always have the Text Explorer window pulled out onto separate monitors. Can this colourisation also be implemented at the bottom of this window as well so it's easier to identify which solution the window applies to.

thanks

lsoft commented 2 years ago

@AndySteelApd I took a look. There are 2 questions.

  1. Is it beatify enough? :)

image

  1. You need manually set solution color AFTER Test Explorer window is opened, otherwise it will colorless or has previous color. At the time, I don't know how to overcome it. will this feature be helpful in such conditions? (not very user friendly, so I'm not sure)
mkornreder commented 1 year ago

Hello @lsoft, how did you manage that the frame is displayed like this?

lsoft commented 1 year ago

@mkornreder are you interested for the code? if so, PTAL:

...
                if (options.ShowTaskBarThumbnails || options.ShowTaskBarOverlay)
                {
                    ShowInTaskBar(brush, options);
                }

                if (options.ShowTestExplorer) // <-- added an option
                {
                    ShowInTestExplorer(brush); // <-- show that border
                }

...
        private static void ShowInTestExplorer(SolidColorBrush color)
        {
            foreach (System.Windows.Window w in Application.Current.Windows)
            {
                if (!w.GetType().Name.Contains("FloatingWindow")) //at the moment we support only floating window
                {
                    continue;
                }

                FrameworkElement fe = w.FindChildByItsType("TestWindowToolWindowControl");
                if (fe == null)
                {
                    continue;
                }

                if(fe is Control c)
                {
                    c.BorderBrush = color;
                    c.BorderThickness = new Thickness(General.Instance.Width);
                    break;
                }
            }
        }

and

    public static class WpfExtensions
    {
        public static FrameworkElement FindChildByItsType(
            this DependencyObject root,
            string type
            )
        {
            if (root == null)
            {
                throw new ArgumentNullException(nameof(root));
            }

            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            int childrenCount = VisualTreeHelper.GetChildrenCount(root);

            for (int cc = 0; cc < childrenCount; cc++)
            {
                DependencyObject control = VisualTreeHelper.GetChild(
                    root,
                    cc
                    );

                if (control is FrameworkElement fe)
                {
                    if (fe.GetType().Name == type)
                    {
                        return fe;
                    }
                }

                var result = control.FindChildByItsType(type);
                if (result != null)
                {
                    return result;
                }
            }

            return null;
        }

...
mkornreder commented 1 year ago

Thank you very much.Message ID: @.***>

ghhv commented 4 months ago

+1 seems any separate code window also loses the colour.