location of userControls on different screens - c#

What is the best way to solve this problem:
I create dynamically in my window application tabs with background image and according to image I put customUserControls. Then I save all tabs, images and userControls to database. So in my database I saved position of the userControls. But if I will open this application with saved information on screen with different resolution, then all userControls will be shown with wrong positions. I was thinking to solve this issue by saving screen resolution to database and before creation of userControls from database check current resolution with resolution from database, and if they differ, recalculate position of userControl.
Is there a better way to solve this issue?

This is filed under WPF. Why would you not layout the controls using the WPF layout grid, stack panels, and such to make use of the power of WPF?
Using the layout controls allows you to have a form that will appear properly no matter how it is re-sized or what resolution screen your application runs on.

Related

Drag and drop the application to another monitor screen

I have an application which fits to full screen mode in my monitor (1920 X 1080) resolution on loading of the form. Once it loads, I will drag the application to another monitor having (1600 X 900) resolution (2 monitors connected to same PC). All the controls will be loosing their location and will be like hidden. Please anybody provide solution for this?
This problem may be more efficiently solved depends on how your format look like.
But generally, you need:
Good way to format your Form, such that it is "robust" against changeable screen size.
you can check the Container on Windows Form like Panel, FlowLayoutPanel, or TableLayoutPanel as well as SplitContainer and Splitter.
All those tools help you to format how your app look.
Flexible way to put and to size your control.
You can learn more about WinForm Control property called Dock and Size to help you put and size your control. And lastly,
Event handler for the Resize event of the Form (and in more complex case, Resize of the Container
There is a limit on what the automatic formatting can do to you. This event handler is to handle whatever you think it cannot be properly handled by all the built-in properties.
You can also learn about BootStrapping. It may help you to format your app.

Best way to Visualise Windows Icons on Form?

Background
I want to drag "icons" from the desktop on to my form, they will then be visualised on the form, not changing in appearance.
When i say "icon", i mean shortcuts, folders and application icons.
Example
Question
What is the best way of recreating the icons on the form. Is there a tried and tested way, or do you have to recreated them using picture
boxes and labels?
What I've Tried so Far?
Picture boxes
Forms
I've had limited success with both, with the latter being the best so far. However both have their limitations.
Notes.
I do not need help with other areas of my problem like, how to drag icons, extracting icons, etc. It's purely just recreating the icon visually i'm struggling with.
Use a ListView and set the view property to LargeIcon.
You can obtain the icons through: Icon.ExtractAssociatedIcon. However, you may need to manage the icons as two files with the same extension may have different icons.
If you only want the image, then you can grab just the icon portion of the control after it's painted.

C# launch form when images fully loaded

I'm making C# application design with images, but when I launch it, I see loading images (~1sec), so how to make simple loader, when images (background, logo, etc..) fully loads, to show my app? I know it's possible but I don't know how to. Thanks so much!
This sounds like standard behaviour. The controls get painted one by one in z-order and if one is slow the rest may appear to flicker.
You could try double buffering the whole form as shown here:
How to fix the flickering in User controls
Alternatively you could suspend the layout while everything is drawn and resume it afterwards:
How do I suspend painting for a control and its children?

Pull image from BitmapCache WinRT

I have an application for the windows store that I need to make emulate the tabs like Internet Explorer. The problem is that I have one control and it won't load into both the AppBar and the main view.
Is there a way to setup the CacheMode in the constructor of the control and then pull a bitmap from the BitmapCache and load that in the tab view in the AppBar? Or am I going about this the wrong way. I don't want to use two different controls due to it being a hack I want this to work with one control.
I am writing this application in C# and XAML.
Any help is appreciated.
A control can only have one parent in all popular XAML technologies, so you can't put it in two places.
You can use RenderTargetBitmap to take a screenshot of a control and put it elsewhere in your layout, but there are plenty of problems with that
It uses additional memory to store the bitmap
You need to figure out when to take that screenshot - typically after all images load and after every layout or content update.
A bitmap is not interactive.
Your best bet might really be to have two copies of the same control. You can create a UserControl to encapsulate any functionality and properties and reuse that control in multiple places easily. If you reference an image by URI - the platform should automatically share the resources for the image used in multiple controls.

WPF slideshow using full screen views as slides

I've been stuck on this for a while now and simply don't know how to proceed. I need to create a slideshow using full screen views (UserControls) as slides. By this I mean that I want to transition between full screen views by means of a sliding animation.
The basic idea is to position one view off screen and to the side of the currently displayed view and then to simply slide them both accross. This works well with small images and objects with a PRESET size.
The problem that I have found is obtaining the actual size of each view at runtime. I need this value to feed to the DoubleAnimation that is responsible for moving the views. How can I find out the 'ActualSize' of each UserControl/view before they are displayed?
If you have any suggestions, I'd be glad to hear them. Many thanks in advance.
UPDATE >>>
While the third party transition code worked well for most situations, it turns out that the main problem that I was having was due to the WPF WebBrowser control.
Apparently, you cannot create a Visual for a VisualBrush from it because it is basically a wrapper for the WinForms control.
Personally, I would go for a project like transitionals to handle the actual transition.
Then you could consider rendering your usercontrol to some Viewboxed Brush and display that full screen. Mark rendle did a project called Code projector which he uses to render Visual Studio's code window to an external screen. That technique could be useful for what you are trying.

Categories