I have a complex, multi-threaded WPF application which works relatively well. Sometimes the controls of a dialog gets rendered twice on different positions. The result of this is an unreadable dialog.
Below is an example of an own written popup (opaque background with buttons on it), but it also happens on normal dialogs. Can anybody help me?
Related
I'm keep getting the feedback that one WinForms control is rendered as blank (no window title, no button text, etc.) as can be seen in the screenshot below. This is a rare issue that seems to happen only after the application runs for a very long time. I am not even able to reproduce it so I assume the UI code is not the problem hence I don't post it here.
I'm wondering if this has to do with windows running out of window handles, or something else? Any advices why this could happen?
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.
So my problem is this. I have a form with a panel in it. This panel serves as the container for multple different usercontrols, of which only one is visible at a time. Some of said usercontrols display a lot of data from the DB, so loading them takes a little bit of time (the data is shown in a bound datagridview). I tried creating a LoadData-method for these controls that I then launch in separate threads and once they've done their work, they enable the actual buttons on the main form for displaying them.
There were, however, many different problems. First, I can't call this.Invoke on the usercontrol until its handle is created, which seems quite hard to force, especially if I want to show a splash screen during the initialization (the main form's handle isnt created yet).
I did manage to force this by setting the form.Visible = true and then calling form.CreateControl followed by form.visible = false. This does, however, show the form blinking on the screen which doesn't look nice.
I also tried not using Invoke if the handle is not yet created, but this brings me to the problem of my data object being created in a different thread and then not being accessible for the control's "normal" thread.
So as is probably quite obvious, I'm quite lost when it comes to multithreading, especially so with winforms, and even more so at the launch of the application. My explanation might also be rather confusing, but I'll try and clarify if it's needed.
So what is the correct way of doing this?
Hard to know where to start with this.
Can't figure out whether your problems are premature optimistion, or trying to retro fit multi-threading.
If I had say a six buttons and one panel and the buttons flipped a usercontrol in the panel to visible, My thread would return a user control, which I'd then add to the panel and then enable it's related button.
Takes all the synchronisation stuff right out of the equation, and gives you maximum scope for optimistion the getting and setting up of the controls.
Or you could setup all the user controls but not bind them and get your threads to bind on completion, I prefer the former way though, a bit more abstraction and you could get to define a view, mark it up with some useful attribute and just get you main form to kick off a process which would "just do it".
I'm building a control that comprises 15x15 = 225 buttons, and needs to be resizable. Because it's a grid, anchoring and docking won't work. I've tried both TableLayoutPanel as well as handling the resize event to manually place and size controls. In both cases, resizing is unacceptably slow. Suspend/Resume Layout in the resize function when I'm manually handling the layout doesn't help.
Is there something fundamental that I can change to speed things up, or is this just a limitation of the native controls? I understand I can build a custom control from scratch, handling the clicks and painting myself -- though I'd prefer to stick with the native controls if possible.
Edit
I know it's a lot of buttons. My question is a technical one; not one about UI design.
WinForms doesn't handle displaying this many controls at the same time unfortunately.
If I were in your situation I would first consider if I could split up the form in several pages. In many cases that would be easier to understand for the user as well.
But in your case that doesn't seem to be an option. Are you making something like a minesweeper style game? There you have a grid of buttons that all are clickable. In such a situation I would suggest you go for a custom owner drawn control where you consolidate all the buttons in one control. Don't build a composite control that contains 225 buttons - that won't help at all :-)
A final option could be to switch to WPF. WPF uses hardware accelerated rendering so it may be faster, but with so many controls not even that may help.
I'd like to implement a feature in my application where show a dialog to the user, and the main form (similar to how jQuery looks). My only idea is to take a screenshot of the form, place it as the background of a panel (with opacity to my liking) then pushing the panel over everything on the form. I have to believe there is a better way of doing this, any suggestions?
The Opacity property is what you need to "dim" a form. You'll need to create an overlay, my code in this thread shows how to do this.
Be careful to not make it look like your program is displaying a UAC prompt. While perhaps appropriate in browsers, the user will never have any trouble recognizing that a window overlaid by a dialog is disabled. Controls paint themselves differently to make it clear.
Why not just set the opacity to something like 50% of the parent window just before launching the modal dialog and then back to 100% when the modal dialog is dismissed? This isn't exactly what you're asking for serves the same function for the end user.
If you do want to do something like your JQuery example you would indeed have to do the screen cap/augment/set as background idea that you described.
I know this is an old thread but if still interested you can take a look at this project.
Download Project