Long image list in forms application - c#

I am trying to populate a large horizontal list with small images.
There may be thousands of these images that need to be scrolled through.
I want to avoid pagination as the non-fluid motion can make distinguishing your position in the list tricky.
I know iOS, Android and Flex have "List Renderer" patterns. How is the best way to accomplish this in Windows Forms?
The list items aren't going to be of uniform sizes. But the size is predicatable without loading the control.
Ie. I can dictate how wide the whole list is going to be, without loading the entire list.

Related

Windows forms dynamically evenly distribute controls?

I am making a lot of camera tracking applications. I want to open the selected cameras in a layout. But mostly one camera will be watched. But I also have to do something to watch multiple. I want the screen to be divided into 2 when there are 2 cameras and when there are 3 cameras, the screen will be divided into 4. I couldn't do it with FlowLayoutControl. Because it is necessary to give dimension to the video control that I added. How should I do such a thing. I'm adding a screenshot of the fixed size control insertion part. I did the thing in the image but gave 200x200 dimensions to the controls inside. This is not what I really want to do. I want controls that change dynamically in size according to the number of controls. How do i do this?

How do I Draw a Chessboard using XAML?

I am working on a project that requires me to develop an application using the Universal Windows Platform (UWP). I have no prior knowledge of developing UWP apps and XAML is completely new to me. Thankfully however, I am competent at writing in C#.
The project I am working on involves recreating the Tafl Board games - Hnefatafl, Brandubh, Tablut, etc.
Now, while I'm fairly confident in my ability to create the underlying logic for the game, I find myself bamboozled when it comes to creating the interface using XAML.
Several different chessboards will need to be rendered: 7x7, 9x9 and 11x11.
So my question is two-fold.
How do I create a chessboard in XAML that will scale appropriately to different window/display sizes and be able to be backed by a grid behind the scenes (i.e. The application can detect which square of the board is touched, etc)
How do I go about rendering a different board depending on the game type selected?
Apologies if this is a terrible question but googling hasn't helped me a whole lot and StackOverflow has always been a great source of information.
You might want to try out the RelativePanel control and use different coloured rectangles for the tiles. This would resize for different screen sizes.
I hope you finally got an answer to this that led you in the right direction. If you didn't here are some ideas that might narrow your research terms and get your going. I'd give you working samples but youd did mention it is for a school project :).
Using a listbox and manupulating the base style can be a relatively
good way to go, and very reusable. This also fulfills your
requirement of knowing the tile currently selected as the listbox
already handles that. I used this technique for a Sudoku board that
had alternating colors for the different regions.
Create a UserControl with properties for the number of columns and
rows you need for your board and then dynamically add the rows and
columns to the grid. If your game model has a list of tiles and
each tile has a column and row property that can be mapped to the
column and row indices of the grid, you could potentially bind to it
quite easily.
Create a custom control that handles the columns,
rows and other aspects of the board itself in c# and the rendering
in XAML. I personally shy away from this just because the existing
controls are already so flexible that with enough ingenuity you can
create what you need with out of the box controls.

Drawing a big number of images in C# Windows Forms

I'm creating a map editor for game in C# Windows Forms. What I need is a grid that will have to store even a few thousands of images.
My first approach was to create a Panel control and then add multiple PictureBoxes to it. Unfortunately 2000 images took about 3 seconds to draw.
Then I decided to try creating Rectangles and drawing Images on them in Panel's OnPaint() method in hope to get better results but it's still very slow.
Is there any better, efficient way to render so many images in Windows Forms?
Thanks in advance for any advices.
Use the Paint event as you have done but...
As part of the loading of the images, cache a zoomed out version where you merge 16 images into one, which is only 125 images, when you zoom out over a certain scale, switch to using the pre-rendered zoomed out version.
You can do that as often as you like for multiple zoom levels with the idea of keeping as few images as possible on screen at anyone time. So you could divide it by 4 again.
I do this for a project which has a map comprised of 65536 images (256 x 256). The cache is also writted to disk so each time you zoom out you see the same number of images. In my editior I can only view 16 images at any one time, even if I'm looking at the whole map.
You can further improve on the this by knowing the available options to the user (e.g. Pan and Zoom) this gives you a limited subset of images the user could potentially view next so you can preload these to improve performance.
You'll increased load time initially but I bet you already have a significant load time pulling 2000 images off disk

Scrollable Controls and Areas in .NET with GDI+

I am having trouble understanding the proper way to create a scrollable area within a custom control using C#, .NET 3.5 and GDI+.
Is there any documentation from Microsoft about the correct way to go about doing so? Is there a decent primer anywhere on the web?
My concerns are mainly: if I create a large graphical canvas in memory, what are the specific details about how large the canvas can (and should be)? What are the performance considerations? How much of the scrollable area should I render in advance?
For example, if I were rendering a very large graphical plot from pre-existing data, should I just render the ENTIRE plot to graphic memory and then blit it into the "scrollable" area? Or, would that exhaust available graphic related memory and start writing into the paging file?
Clarification:
For example, your web-broser isn't "redrawing" the client area everytime you scroll by re-rendering all of the elements. Static elements of the page are rendered once to a large surface, and when you move the scroll bar, the starting offset of the pre-render is simply modified.
That is the sort of behavior I'm going for. I don't want to "draw the content that would be between the start and end values for my scroll range" on paint events.
If you are talking WinForms - derive your control from ScrollableControl. Define the Client Size and just paint the appropriate portion in OnPaint.
The control handles all scrolling details for you

How to handle 1000+ images in a C# Application?

A winform control for displaying a list of images is currently implemented with a flowlayoutpanel and a collection of pictureboxes. But even at thumbnail scale (64x64) when we when start to approach 1000+ images we get OutOfMemory exceptions - our actual problem lies from the thumbnail generation part and the creation of the Image object.
I haven't been able to find any strategies from the existing image viewing examples on the net regarding a large number of images so does anybody have any links or strategies for solving this problem of displaying a list of 1000+ images?
As a starting point we really only need these image objects around when the thumbnail's picture box is in view. Then we would only have 10 image objects created but is there a smarter way of doing this other than loading and destroying image objects?
Thanks,
Edward
You should display only one screen of images at a time.
When the user drags the scrollbar, destroy those images and load new ones.
WPF handles this in a great way. If you have turned on Virtualization, the ListBox will create only the control that are visible to the screen.
In your case, keep reference to the images in a list. Put a pictureBox, and based on the Scrollbar, change the image on the pictureBox.

Categories