WinForms in Mono - Problems with form repainting - c#

I have a WinForms Application. I need it to run also in Mono.
I have a problem with form repainting. There are many controls in the form. When I resize the form or when I try to update it (it needs to be updated on timer tick), the repainting does not work . Sometimes the controls are placed right, but it flickers, sometimes the the controls do not move or resize at all, some of the controls (buttons) seem to be disabled, some of them even disappear or are displayed twice.
In .NET I had similar problems, but enabling double-buffering on form solved them. But it seems that it does not work in Mono at all and I really don't know what to do.
On resize I need to move and resize the controls and redraw pictures in PictureBoxes.
I also have a problem with the above mentioned timer - the tick event fires only once and then almost everything on the form stops working, but I think it may be connected with the repainting problem.
If someone had an advice on how to correctly repaint a WinForms form in Mono, I would appreciate it.

Related

How to redraw revealed windows on (custom) window resize

I have a somewhat strange issue in WPF, where I have created a custom window type (comes with a notification icon and custom chrome, mainly). Under normal circumstances it works fine (e.g. resizing using handles etc). However, when trying to make the window automatically size to content, I've ended up with a situation where it can resize smaller without redrawing the windows behind it.
When the window is moved (via DragMove()), it correctly repaints everything behind it, but until it either moves or is hidden, nothing happens.
Can anyone tell me what messages DragMove() is generating that cause the area that was previously hidden by the window client area to invalidate and repaint correctly? I've tried WM_PAINT pointed at my custom window, but either it does nothing (e.g. windows doesn't expect a WM_PAINT message from me) or it only repaints the current client area, not the previous one.
Whilst I was not able to identify why the issue was occurring, and this isn't an answer to the question I posed, I was able to resolve the problem by taking a different approach. Previously, I had been binding on MaxHeight and MinHeight; what eventually worked was using SizeToContent instead (which doesn't suffer from the same inability to render restore background as binding to MaxHeight and MinHeight did in my approach), and then removed the ability to resize my control.
This isn't the answer (if anyone does know how force windows to redraw the area that a window used to occupy, I'd still be interested), but it does solve the problem.

Windows Forms Resizing And Overlapping UserControls

I have a Windows Form with 9 identical user controls that are directly adjacent to one another. On my screen the form looks fine, but when running a coworkers machine, the window gets resized and the user controls overlap. Does anyone know how i can prevent them from overlapping? I don't mind that the window is resizing on different machines, I just don't want any lost information or partially hidden elements.
Thank you in advance.
You could use a FlowLayoutPanel. It won't work in every situation, depending on what kind of controls you intend to place inside it. I'm not sure what your user control look like, but I just added a FlowLayoutPanel and added about a dozen buttons inside it, and it takes care of
adjusting the layout for me when the end-user resizes the form, maintaining padding around each button and avoiding overlapping.
If your user controls can flow around each other, and it doesn't matter if they are side by side or one over the other, you may want to check this out.

How do I create transparent labels over a Video control

I'm pretty much out of ideas here... for everything else, setting the background color to Color.Transparent or setting the TransparencyKey works fine...
I have an mp4 Video which I need to play as a "background" of my form. To do this, I'm currently using the WMP control. My problem: I can't add any controls on top of it, since they always render a background. Which looks ** on the video...
Any suggestions?
A hack I've used successfully in a similar situation:
Create a separate, borderless, transparent form (transparency works best at the Form level)
Host button controls on that form
Launch the control form when your video form launches
Wire event handling such that the floating form always moves, resizes etc. whenever the main form changes
Calculate position of the floating for based on parent form's specs
Always push the floating form to the top, above the parent form
Told you it was a hack. But if you get all the events and calculations wired up it should work fine.
P.S. I also recall having to do a poll timer with a function that made sure every 250 millis or so that the Z-order of the two forms was what you wanted. (Switching apps and windows changed the z-order unexpectedly and w/o events, thus the polling solution.)
P.S. II It is very easy to prototype the feasibility of this solution. Just create a separate app with the above-mentioned specs and move it over your video. (You will need to retain the Form border to be able to move/resize the window easily.)
Try rendering your labels using GDI+:
You can see sample here: (the Using GDI+ for drawing images with transparency part):
http://www.broculos.net/en/article/how-use-transparent-images-and-labels-windows-forms

Form is not laid out correctly

I have a WinForms form hosted in VB6 application (I am not sure if this is significant). Sometimes form controls are layouted incorrectly (primarily Anchor property doesn't work). If I just resize a form by mouse - the form is drawn as it should. Is there any method that may solve my layout problems without manual form resizing? I tried PerformLayout, Invalidate and Refresh methods... but they don't solve my problem.
You could handle the form's Layout event to layout the controls the way they should be.

Problem in Drag And Move Forms in .Net

I Write a Windows Application By C Sharp.
I Use a Picture in Background of my Form (MainForm) And I Use Many Picture in Buttons in This Form,And also I Use Some Panel And Label with Transparent Background Color.
My Forms,Panels And Buttons has flicker. I solve this problem by a method in this thread.
But Still when other Forms Start over this Form,my Forms hangs when I Drag and Move my Forms over this Form.How can I Solve this Problem to Move And Drags my Forms easily And Speed?
Edit::
My Forms Load Data From Access 2007 DataBase file.I Use Datasets,DataGridViews And Other Components to Load And show Data in My Forms.
You just made it less obvious that your form paints very slowly by using the techniques shown in my answer. The tricks don't speed it up, they merely make the ugliness less visible. But they fall flat when you have to paint your form from scratch, which happens when you move another window across it. The painting cannot keep up with the barrage of paint requests that are generated each time the overlapping form moves by one or more pixels.
An instant fix is to upgrade your operating system to Vista or Windows 7, windows don't overlap anymore with Aero enabled.

Categories

Resources