picoe / Eto

Cross platform GUI framework for desktop and mobile applications in .NET
Other
3.57k stars 325 forks source link

[WinForms] Corrupted images and no tooltips when panel is transformed ToNative() and included in WinForms form #754

Open onomatopeia opened 7 years ago

onomatopeia commented 7 years ago

Projects developed on Windows in Visual Studio 2015 community edition

Project 1 - Eto project comprising of a Panel with some buttons, each button has an image and a tooltip

startBtn = new Button {
    Image = Bitmap.FromResource(Resource.Btns_Start_Icon, type),
    Size = new Size(24,24),
    ToolTip = Resource.Btns_Start_Tooltip
};

Image is kept in the project as an embedded resource. Both the icon and the tool tip are visible. etoforms

Project 2 - Grasshopper project referencing Eto Project Panel (from Project 1) transformed to native and placed in a win forms form:

InitializeComponent();
var nativeView = new SandflyTabsPanel(dataContext).ToNative(true);
nativeView.Dock = System.Windows.Forms.DockStyle.Fill;
Controls.Add(nativeView);

Tooltips are no longer visible and images are barely visible. winforms

cwensley commented 7 years ago

Hi @AgataMigalska ,

Thanks for submitting the issue! What version of Grasshopper and Rhino are you using this in? There may be some high DPI things that cause the WinForms platform to fail.

onomatopeia commented 7 years ago

Rhino: Version 5 SR13 64-bit (5.13.60913.21340, 13/09/2016) Grasshopper: Version August-27,2014 Build 0.9.0076 Work In Progress

DPI of each image is indeed high (360), I changed it to 150 and to 72 but there was no apparent improvement.

SlowLogicBoy commented 7 years ago

I don't know if this will help to fix this problem but: This is Winforms problem, even though winforms scale controls according to DPI automatically, it does not scale images in buttons and that needs to be done manually, had this problem for long time (There are some other controls too, where it doesn't scale images, but don't remember right now).

Also quite some time ago if I add larger image to Image/Picture control (don't remember exact control name) then I need to display, default winform scaler was terrible so I had to resize image manually before putting it in the control and as far as I remember I had to convert it to bitmap to from other image formats.

onomatopeia commented 7 years ago

@SlowLogicBoy Could you elaborate more on "that needs to be done manually"? My images are 24 by 24 pixels (and 360 DPI). The buttons are of Eto.Drawing.Size(24,24). It does not read from Eto.Drawing.Size docs what unit Size is in -- could be pixels, could be points. Then what shall I resize my images to?

SlowLogicBoy commented 7 years ago

@AgataMigalska sorry, for misleading you.

My message was aimed at Eto devs. We have to fix Eto.Winforms to scale images correctly, right now Eto.Winforms are relying on Winforms to scale images, but winforms doesnt scale them, at least correctly.