sharpenrocks / Sharpen

Visual Studio extension that intelligently introduces new C# features into your existing codebase
https://sharpen.rocks
MIT License
418 stars 32 forks source link

Selected text in the Sharpen Results view is unreadable when the view loses focus #28

Closed afrlan closed 5 years ago

afrlan commented 5 years ago

"On my machine" double clicking an item goes to the referenced line in the code and makes selected text in Sharpen Results window unreadable. I haven't modified any display settings in Visual Studio.

Suggestion: verify that the contrast between background and text is sufficient and tweak accordingly.

image

ironcev commented 5 years ago

The issue does not appear only on double click but in general when the Sharpen Results view loses focus with an item selected. Therefore I've renamed the issue.

ironcev commented 5 years ago

@kurtanr's comment in Croatian:

Pogledao sam što zapravo koristi VisualStudio kao tree kontrolu u npr. SolutionExploreru. Koriste Microsoft.Internal.VisualStudio.PlatformUI.PivotTreeView iz Microsoft.VisualStudio.Shell.15.0.dll. U DLL-u je to javna klasa koja nasljeđuje Microsoft.Internal.VisualStudio.PlatformUI.VirtualizingTreeView javnu klasu. No na netu je jako teško naći neke informacije o tim klasama i primjer njihova korištenja. Zapravo, nisam uspio naći ni kreirati sample koji radi - uspješno sam bindao kolekciju itema na tree, no nodovi tree-a nisu vidljivi. Dodatno, klik na nevidljivi node rezultira sa exceptionom u Microsoft.Internal.VisualStudio.PlatformUI.PivotTreeViewItem.SetupEnteringRenameMode (a nisam uspio pronaći kako reći nodeu da isključi rename). U VS je DataContext PivotTreeViewItem klase Microsoft.Internal.VisualStudio.PlatformUI.VirtualizingTreeView+TreeNode, no TreeNode je interna klasa unutar VirtualizingTreeView, tako da je nije moguće izvana instancirati. Uglavnom, bila je zgodna ideja, no mislim da odustajem od nje.

I also wouldn't go for PivotTreeView. It will just turn the theming/coloring issue we have now with other more serious.

When I was adding the tree view I struggled to get the styles/colors well and finally gave up with this issue. The regular WPF TreeView uses styles and colors defined by Visual Studio so that it automatically fits to the VS theme and also that it get changed when the VS theme changes.

Another possible approach would be not to use VS colors and themes but a similar one and get the whole control over tree view styles and to switch between a dark and white theme on our own. @tom-englert uses this approach in his excellent ResXResourceManager. I would like to stick to VS theming but I am also fine with Tom's approach.

tom-englert commented 5 years ago

@ironcev The regular WPF controls do not follow the VS theme colors, except for foreground and background, which is introduced by these two lines in the root controls xaml file:

<UserControl
   ...
   Background="{DynamicResource {x:Static vsshell:VsBrushes.WindowKey}}"
   Foreground="{DynamicResource {x:Static vsshell:VsBrushes.WindowTextKey}}"

For simple controls this may be fine, but as soon as some control uses custom colors for e.g. highlighting, these are still the colors matching the system colors, not the VS colors. That's why you get this conflict here - foreground matches the VS dark theme, because its inherited, but the custom background is designed for the systems regular (light) them. So to solve this, either give up theming by removing the two lines in the root control, or use custom themable styles for all your controls.

tom-englert commented 5 years ago

Just realized that you already have explicitly styled the tree view, just these colors seem to be wrong. I'll have a look...