dsafa / CSDeskBand

Windows deskband with C#
MIT License
274 stars 65 forks source link

Some problems with calling context menu #37

Open xmoer opened 5 years ago

xmoer commented 5 years ago

Thank the author for making this project, but I found some small problems in use.

  1. Right-click on taskbar tool image is invalid. Context menu can only be displayed by right-clicking in the blank or penetrated area.
  2. In the white taskbar of Windows10 (19H1), CSDeskBand.Wpf tools will have black jagged edges.
dsafa commented 5 years ago

For 1. is it with winforms or wpf? do you have an example screenshot or video. For 2. I'll take a look when the update comes out. wpf doesn't combine too well with the taskbar so there will probably be issues. Thanks.

xmoer commented 5 years ago

Both problems arise on wpf. Question 1 is somewhat indescribable, so I drew a demo graphics.

view

This is a taskbar demo. Wpf was used to draw the blue graphics. Right-click on blue graphics is invalid, context menu can only be displayed by right-clicking in the black area. If the blue graphics is replaced by an image control, the result is the same.

dsafa commented 5 years ago

Thanks for the visual. I believe its because wpf is not bubbling the event up to winforms. I'll see what I can do with that.

dsafa commented 5 years ago

I found that its because the form doesn't pass the click even through to the taskbar. I have a fix for non transparent wpf controls but for transparency i'm not currently sure on how to fix it.

xmoer commented 5 years ago

Yes, it's not easy to solve these two problems. I'm also studying how to fix the second problem (edge jagged for non-black background).

xmoer commented 5 years ago

I found a few strange problems. Control edges have color residues because TranparencyKey & BackColor is imperfect. But transparent methods do not show the same effect in various versions of Windows10.

The background of the system taskbar before 19H1 is black by default, so you won't see black serrated teeth. Now Microsoft has added the light mode, and the taskbar and start menu background can turn white. The problem of edge color residue became serious and I tried many methods.

First, I changed the transparent color to magenta or white, and the result was still terrible. Then I quoted the project: https://github.com/patbec/TaskbarSampleExtension. I modified the file to try to load the WPF control directly.

[File: TaskbarSampleExt/DeskBand.cs]
public class DeskBand : UserControl, IObjectWithSite, IDeskBand2 { …… }
[After editing: ]
public class DeskBand : ElementHost, IObjectWithSite, IDeskBand2 { …… }

Without specifying the transparent color, only "BackColorTransparent = true" is needed to achieve the perfect display effect. Of course, this method only works under 19H1, and will turn into a black background in the old system. The result surprised me.

This may be related to Microsoft's continuous improvement of the system kernel? Multiple strategies may be needed to solve the problem of perfect background transparency.

dsafa commented 5 years ago

Thanks for the news. This is really interesting. I guess we'll just have to rely on microsoft's changes.

dsafa commented 5 years ago

In version 3.1 I updated so transparency works properly. Context menu is still a bit of an issue though

xmoer commented 5 years ago

ContextMenu may not be a problem? Although it's not perfect, we can customize a menu. For example:

<Grid>
    <Grid.ContextMenu>
        <ContextMenu>
            <MenuItem Name="MenuItem1" Header="AAAAA"/>
            <MenuItem Name="MenuItem2" Header="BBBBB"/>
        </ContextMenu>
    </Grid.ContextMenu>
    ……
</Grid>
dsafa commented 5 years ago

Yeah, creating your own context menu is what I would recommend.