ImageList.cs :  » GUI » wx-NET » wx » SampleImageView » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » GUI » wx NET 
wx NET » wx » SampleImageView » ImageList.cs

using wx;
using System;
using System.Drawing;
using System.Collections;

namespace wx.SampleImageView{
    /**
     * Class to display a list of images.  The scrolled window helps us with
     * managing scrollbars when the window's contents are too large to be
     * displayed.
     */
    public class ImageList : ScrolledWindow
    {
        private ImageViewer m_viewer;

        /**
         * Sets up the image list.
         *
         * The base class is initialized with a default window position,
         * and a static size of width = 150, The '-1' for height means that
         * the height of the window is unconstrained.
         */
        public ImageList(Window parent, ImageViewer viewer)
            : base(parent, -1, wxDefaultPosition, new Size(140, -1))
        {
            m_viewer = viewer;

            // A flex grid sizer will be used to align the images horizontally.
            // This is used, because the flex grid allows for entries to be
            // of various sizes.
            FlexGridSizer sizer = new FlexGridSizer(1, 0, 0);

            // For now, our sizer will remain empty until images are loaded.

            Sizer = sizer;

            // Initialize the scrollbars
            SetScrollbars(0, 1, 0, 0);
        }

        /**
         * Lists the images in the given list of image file names.
         */
        public void ListImages(string[] images)
        {
            // Clear our list
            ClearImages();

            // Add the images
        Console.WriteLine("Adding images ...");
            foreach(string imageFile in images) {

        Console.WriteLine("   + " + imageFile);
                // Create a thumbnail will display the image
                Thumbnail thumb = new Thumbnail(this, imageFile);
                
                // Hook in our event handler
                thumb.ThumbnailClicked = 
                    new Thumbnail.ThumbnailClick(OnThumbnailClicked);

                // Add the bitmap button to the sizer.
                Sizer.Add(thumb, 1, Stretch.wxEXPAND);

                // A horizontal static line is used to help seperate the 
                // images in the list.
                StaticLine line = new StaticLine(this, -1, wxDefaultPosition, 
                                                 wxDefaultSize, 
                                                 StaticLine.wxLI_HORIZONTAL);

                // The static line is added with a small border on the bottom
                Sizer.Add(line, 0, Stretch.wxEXPAND | Direction.wxBOTTOM, 3);

                // Fit inside tells the scrolled window to reset the scrollbars,
                // so that the entire window's contents can be scrolled.
                FitInside();
            }

            m_viewer.Bitmap = null;
        }

        /**
         * Clear all the images in the list.
         */
        private void ClearImages()
        {
            // This will remove all the windows (images) that are in the sizer.
            // 
            // The 'true' parameter tells the sizer to delete the windows as
            // well.  If 'false' were given, we would have to manually do 
            // this.
            Sizer.Clear(true);

            System.GC.Collect();
        }

        public void OnThumbnailClicked(string fileName, wx.Bitmap bmp)
        {
            m_viewer.Bitmap = bmp;

            // Set the main frame's title
            Parent.Parent.Title = fileName;
        }
    }
}

www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.