Listbook.cs :  » GUI » wx-NET » wx » SampleListbook » 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 » SampleListbook » Listbook.cs
//-----------------------------------------------------------------------------
// wx.NET/Samples - Listbook.cs
//
// wx.NET "Listbook" sample.
//
// Written by Alexander Olk (xenomorph2@onlinehome.de)
// (C) 2004 Alexander Olk
// Licensed under the wxWidgets license, see LICENSE.txt for details.
//
// $Id: Listbook.cs,v 1.2 2007/10/21 15:30:41 harald_meyer Exp $
//-----------------------------------------------------------------------------

using System;
using System.Drawing;

namespace wx.SampleListbook{
  public class ListbookFrame : Frame
  {
    enum Cmd 
    {
      About,
      Quit
    }

    //---------------------------------------------------------------------

    public TextCtrl textCtrl;
    public MyListbook listbook;

    //---------------------------------------------------------------------

    public ListbookFrame(string title, Point pos, Size size)
      : base(title, pos, size)
    {
      // Set the window icon and status bar

      Icon = new wx.Icon("../Samples/Listbook/mondrian.png");

      CreateStatusBar();
      StatusText = "Welcome to the Listbook Sample!";  
      
      Menu menuFile = new Menu();
      menuFile.AppendWL( (int)Cmd.About, "&About", new EventListener( OnAbout ) );
      menuFile.AppendSeparator();
      menuFile.AppendWL( (int)Cmd.Quit, "E&xit\tAlt-X", "Quit this program", new EventListener( OnQuit) );
      
      MenuBar menuBar = new MenuBar();
      menuBar.Append( menuFile, "&File" );
      MenuBar = menuBar;

      textCtrl = new TextCtrl(this, -1, "", wxDefaultPosition, wxDefaultSize, 
        TextCtrl.wxTE_MULTILINE | TextCtrl.wxTE_READONLY | TextCtrl.wxSUNKEN_BORDER );

      Log.SetActiveTarget( textCtrl );

      listbook = new MyListbook( this, -1 );

      BoxSizer bSizer = new BoxSizer( Orientation.wxVERTICAL );
      bSizer.Add( listbook, 1, Stretch.wxGROW );
      bSizer.Add( textCtrl, 0, Stretch.wxGROW );

      Sizer = bSizer;
    }

    //---------------------------------------------------------------------  

    public void OnAbout( object sender, Event e )
    {
      MessageDialog.MessageBox( "wx.NET Listbook sample\n2004 by Alexander Olk", "About",
        Dialog.wxOK | Dialog.wxICON_INFORMATION);
    }

    //---------------------------------------------------------------------  

    public void OnQuit( object sender, Event e )
    {
      Close();
    }
  }   
  
  //---------------------------------------------------------------------  

  public class MyListbook : Listbook
  {
    public ImageList imageList;

    //---------------------------------------------------------------------  

    public MyListbook( Window parent, int id)
      : base( parent, id )
    {
      imageList = new ImageList( 32, 32 );

      // load bitmaps
      for ( int i = 1; i < 16; ++i )
      {
        Bitmap bmp = new Bitmap( String.Format( "../Samples/Listbook/bmp/toblom{0}.png", 
          i.ToString().PadLeft( 2, '0' ) ) );
        imageList.Add( bmp );
      }

      AssignImageList( imageList );

      for ( int i = 1; i < 16; ++i )
      {
        ListbookPanel p = new ListbookPanel( this, -1, i );
        AddPage( p , String.Format( "Picture {0}    ", i ), false, i - 1 );
      } 

      EVT_LISTBOOK_PAGE_CHANGED( -1, new EventListener( OnPageChanged ) );
      EVT_LISTBOOK_PAGE_CHANGING( -1, new EventListener( OnPageChanging ) );
    }

    //---------------------------------------------------------------------  

    public void OnPageChanged( object sender, Event e )
    {
      ListbookEvent le = (ListbookEvent) e;

      Log.LogMessage( "OnPageChanged, old: " + le.OldSelection + ", " +
        "new: " + le.Selection + ", Selection: " + this.Selection );

      e.Skip();
    }

    //---------------------------------------------------------------------  

    public void OnPageChanging( object sender, Event e )
    {
      ListbookEvent le = (ListbookEvent) e;

      Log.LogMessage( "OnPageChanging, old: " + le.OldSelection + ", " +
        "new: " + le.Selection + ", Selection: " + this.Selection );

      e.Skip();
    }
  }

  //---------------------------------------------------------------------  

  public class ListbookPanel : Panel
  {
    public HtmlWindow htmlWindow;
    
    //---------------------------------------------------------------------  

    public ListbookPanel( Window parent, int id, int number )
      : base( parent, id )
    {
      htmlWindow = new HtmlWindow( this );
      htmlWindow.AppendToPage( "<html><body><center><h1>This is HtmlWindow page " +
        number + ".</h1><br><br><br>" + 
        "<img height=\"32\" width=\"32\" alt=\"\" " +
        "src=\"" +
        String.Format( "../Samples/Listbook/bmp/toblom{0}.png", number.ToString().PadLeft( 2, '0' ) ) +
        "\">" +
        "</center></body></html>" );

      BoxSizer bSizer = new BoxSizer( Orientation.wxVERTICAL );
      bSizer.Add( htmlWindow, 1, Stretch.wxGROW );

      Sizer = bSizer;
    }
  }

  //---------------------------------------------------------------------  

  public class ListbookApp : wx.App
  {
    //---------------------------------------------------------------------

    public override bool OnInit()
    {
      ListbookFrame frame = new ListbookFrame("Listbook wxWidgets Sample", new Point(10, 100), new Size(650,340));
      frame.Show(true);

      return true;
    }

    //---------------------------------------------------------------------

    [STAThread]
    static void Main()
    {
      ListbookApp app = new ListbookApp();
      app.Run();
    }

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