OpenTheme : An open source graphic user inter...

来源:百度文库 编辑:神马文学网 时间:2024/04/27 15:24:13
  • Download source (external link) - approx 2 Mb

Introduction

OpenTheme is an XML based GUI toolkit with a set of foundation class and WYSIWYG editor. Although it's originally designed for full screen GUI, it is also good for Windowed user interface, with full localization support and arbitary look-and-feel.

I prepared a full tutorial at

  • http://opentheme.sourceforge.net/OpenThemeTutorial.html

Background

When I was developing my OpenHTPC project, I was always thinking about how to make it looking cool. Since I'm not a graphic designer, I know I will never actually design any 'cool' graphics. That brought up an interesting old question, is there a way to completely separate the design of graphic user interface from the design of the business logic?

Well, since I'm confident I'm a fairly good software architect, I think I can do this job better. Finally, I designed this OpenTheme project. In this project, I tried some new technics. And finally I had chance to express my own opinion about software design and implementation in this project.

Using the code

It is still the preliminary Alpha release. So some of the design is still subject to changes. The best way to understand the design is to read the tutorial from a user's point of view.

But this release is already stable enough. The ThemeEditor can be used to design the entire ThemePack. In your code, just use the following code to load a Themepack.

Collapse | Copy Code
// Create a ThemePack    ThemePack tp = ThemePack.FromXml(fileName, null);    // Run through Themes contained in the ThemePack        foreach (Theme curTheme in tp)    {    // ........    }    // Get a Top Level page from Theme    ThemeObject themeObj = curTheme.GetThemeObject(ID);    // Draw this ThemeObject with a Graphics    themeObj.SetBounds(......);    themeObj.RecalculateLayout(Graphics g);    themeObj.Invalidate(Graphics g);

Points of Interest

A Theme is a collection of layered graphics (with alpha transparancy) with layout manager. System provides a set of 'atomic' components such as Images (OpenThemePictureBox), Text (OpenThemeTextBox), Color block (OpenThemeColorBox). Components can contain sub components within their bounds. The sub-components may contain other sub-components.

System also provides some more complicated components with custom code to determine the bounds of its sub-components for more complicated layout management. Those are called 'container' components.

Programmers can easily implement their own 'atomic' components and 'container' components. For example, the system provides a button component to support buttons with absolutly ARBITARY user designed look and feel. Below are the look and feels of that button with different state.

Disabled

Enabled

Active

Focused

Toggled

Another example is the horizontal scrollbar.

The logic is complete to define any popular components (such as button, radio, scrollbar, menu etc) with completely user defined look and feel, for full screen or windowed applications.

The system is very light-weighted. The core part only have barely more than 2000 lines of code and only dependent on some very basic GDI+ functions and XML library. And it doesn't even depend on Windows Forms classes. I would expect it to be ported to Linux platform and .Net compact framework with very little or no modification in the near future.

History

  • Oct. 20, Initial Alpha release.

TODO List:

  • Event model
  • Finish all common controls
  • Visual Studio .Net extensibility integration

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

weiqj

Web Developer

United States

Member
Hello All!

Article Top Sign Up to vote for this article Add a reason or comment to your vote: x

Comments and Discussions

You must Sign In to use this message board.  FAQ 
 
Noise Tolerance  Layout  Per page   
  Msgs 1 to 25 of 105 (Total in Forum: 105) (Refresh) FirstPrevNext good futurejo 4:15 3 Aug '08   thanks
Sign In·View Thread·PermaLink licensing JayTau 20:26 11 May '07   Hi, I would like to ask about licensing this for use in a game! I am poor and living / working in Thailand (a poor country) but I respect intelectual property!

I can not find your (the author's) contact info / email anywhere, please email me at: jasons [AAT] novaleaf [DOOT] [COOM]
Sign In·View Thread·PermaLink 2.00/5 (1 vote) Re: licensing dedel 0:10 20 Aug '07   Have a view at http://sourceforge.net/projects/opentheme/
you can see it is under GPL
Sign In·View Thread·PermaLink Great job man... antecedents 14:53 6 Feb '07   Great job man; I like seeing hard work done like so! As a matter of fact, this is an excellent article bro!! Keep up the great/good/hard work bro!!

Sign In·View Thread·PermaLink Nice but... Marcel Härry 13:51 16 Nov '06   Really nice but unfortunately only for hobbyists and freaks cause not usable in closed source commercial products (GPL)...:(
Sign In·View Thread·PermaLink 1.00/5 (1 vote) Re: Nice but... weiqj 13:55 16 Nov '06   We can make an arrange to grant you a commerical license.
Sign In·View Thread·PermaLink Re: Nice but... KenGuru 21:41 16 Nov '06   That would be nice! for free?!?

Live is to short to be angered about lost chances!
Sign In·View Thread·PermaLink Re: Nice but... weiqj 13:14 18 Nov '06   Depends on what application you are gonna build.
Sign In·View Thread·PermaLink Re: Nice but... stixoffire 11:58 22 Mar '07   I am interested as well, I am a newbie basically - I am building a website, and the Administration Program for the Website and it is in NET 2.0 for the Desktop (I chose Desktop method b/c of some requirements of the application) . This is a one off APP and I am not making anything really off of the project other than to get exposure/experience as a webdeveloper. While themeing is not necessary - I thought it might be cool to do, as I am more of a coder than a creative graphical genius. (I guess I am untalented).
Sign In·View Thread·PermaLink Re: Nice but... weiqj 6:55 23 Mar '07   If OpenTheme is used to in a non-profit or Academic / Educational project, I will grant a free license for that project.

For commercial projects, write me an email so that we can discuss it.
Sign In·View Thread·PermaLink Events obeea 10:45 9 Aug '06   This is a great application but as I'm new to c# I'm struggling to fully utilise its potential.
It's a shame there isn't a demo project giving a pratical example.
Has anyone been able to make use of the event handling of the objects, for example adding a click event at the preview window level to determine if for instance the button labeled 'shutdown' has been pressed.
I can see the themeobject checks for a click event handler but I'm not sure how to set it, well not at the preview window level anyhow.
I can add a click event to the themecontrol but this only fires for the passed themeobject, that being the mainscreen, and not it's children.
Any help would be much appreciated.

obeea
Sign In·View Thread·PermaLink Re: Events weiqj 10:41 11 Aug '06   The only thing you need to do is to get the ThemeObject by name. Then you can hook up your event handler to the object.

Sign In·View Thread·PermaLink public repository? N e m a 9:29 23 Jan '06   Hello,

I am currently evaluating the development of a c# engine similar to OpenTheme.

i would (and could... ) seriously contribute some developments, but there are some points to be discussed first:

- i stronlgy recommend a subverison repository in order to let multiple developers work on the codes simultaneously. if this is new to the author, i can give advice and instructions how to work productively with a repository. (free subversion hosting is not a problem). without a repository, i see no real chance to make this project a public boost.

- it must be possible to use OpenTheme in commercial applications without any GPL restrictions.

- i am not 100% sure about the performance of c#/GDI+, especially if used in realtime critical applications. anyways, i assume that the code structures would allow to be ported to DirectX if necessary...

if you want to get back in touch with me, you find my email here: http://josua.hoengermedia.ch/aboutme.htm

kind greetings and thumbs up for this good work! josua


-- modified at 15:09 Monday 23rd January, 2006
Sign In·View Thread·PermaLink No images, no icons Gord Murdoch 19:28 15 Nov '05   First off, great app. You've obviously put a lot of thought and work into it, so thanks for that.

I have a strange problem with a test app I've written to implement your stock Crystal.English theme. Though the theme displays perfectly in the preview window in the ThemeEditor app, when I use it in a test app, none of the images beside the "My XXXX" items appear, not do those the top left of the form.

I've implemented the ThemePack in my constructor using the following:

ThemePack tp = ThemePack.FromXml( @".\OpenThemePack.otp", null );

foreach( Theme theme in tp.Themes )
{
if( theme.Name == "Crystal.English" )
{
curTheme = theme;
break;
}
}

// Root object
ThemeObject screen = curTheme.GetThemeObject( "MainScreen" );
ThemeObject ctrl = new OpenTheme.WinForms.ThemeControl();

this.ctrl.ThemeObject = screen;
this.Controls.Add( ctrl );

Interestingly enough all of the mouse events work as expected.

Any help would be appreciated.
Sign In·View Thread·PermaLink Re: No images, no icons weiqj 14:49 16 Nov '05   Add the following line of code in the Load event handler of your main form.

Theme.InitDevice(this.CreateGraphics());

BTW, there's a small bug in ColorBox. Correct the Paint function as following:

public override void Paint(Graphics g)
{
g.FillRectangle(new SolidBrush(this.BackColor),
new Rectangle(0, 0, Bounds.Width, Bounds.Height));
base.Paint(g);
}

And thanks for your interest in my project.
Sign In·View Thread·PermaLink Re: No images, no icons Gord Murdoch 8:52 18 Nov '05   Excellent. The fix worked perfectly.

Sign In·View Thread·PermaLink GetRelativeDirectory() error Smangood 19:08 18 Oct '05   Hi,

While try to load image from "Crystal\Image\crystal_back.jpg". I am getting the following error message.

GetRelativeDirectory() error

Please guide me.

Thanks

Sri


Sign In·View Thread·PermaLink Re: GetRelativeDirectory() error Anonymous 17:33 23 Oct '05   All image resources has to be in a sub directory of the ThemePack directory. I'm pretty sure you referenced an image file from outside.
Think about this, if the resource can be referenced randomly, how could you package the Theme for the end users?
Sign In·View Thread·PermaLink An error at runtime Cong Dan 23:39 28 Sep '05   Hi !
I have downloaded your zip file (~ 2MB)
When I set "ThemeEditor" as default project, after Ctrl+F5, it throw an error

and a green highlight at row "...resources.GetOject ..."

//
// _ExplorerImageList
//
this._ExplorerImageList.ImageSize = new System.Drawing.Size(16, 16);

--> this._ExplorerImageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("_ExplorerImageList.ImageStream")));

this._ExplorerImageList.TransparentColor = System.Drawing.Color.Transparent;


I ussualy get this error when my project have an image list. So, could you please tell me the way to fix this problem ?

Thank you so much

PS: my email adress: lcd2612@yahoo.com
Sign In·View Thread·PermaLink Re: An error at runtime weiqj 4:04 1 Oct '05   It's part of the Visual Studio generated file. You can go to design view of ThemePackExplorer to check the _ExplorerImageList.
Sign In·View Thread·PermaLink where can i download the ThemeEditor? Your details have been updated 21:20 11 Aug '05   where can i download the ThemeEditor?
i get one ,but it just used for mobile telephone !

help!
Sign In·View Thread·PermaLink Re: where ican i download the ThemeEditor? weiqj 5:02 14 Aug '05   Just follow the link at the beginning of the article.
Sign In·View Thread·PermaLink Re: where can i download the ThemeEditor? Your details have been updated 17:53 14 Aug '05   Thank you very much, i get it!
But i hava another problem . when i want to Browse a (Bitmap)picture with this ThemeEditor, a error messagebox show "can't load DLL 'PreviewFileOpenDialog.dll'". what can i do ?

My system edition is "win2000 server".
Sign In·View Thread·PermaLink Re: where can i download the ThemeEditor? weiqj 10:53 15 Aug '05   The file PreviewFileOpenDialog.dll is included in the package. You can either copy the file into your system32 directory or copy the file into the same directory of the ThemeEditor executable (both bin\debug and bin\release directory).
Sign In·View Thread·PermaLink Re: where can i download the ThemeEditor? Your details have been updated 16:15 15 Aug '05   Thanks! 谢谢!


Is there any other one to do this work better?
Sign In·View Thread·PermaLink 2.00/5 (1 vote) Last Visit: 22:57 20 Dec '10     Last Update: 3:39 21 Dec '10 12345 Next »

General    News    Question    Answer    Joke    Rant    Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+PgUp/PgDown to switch pages.

PermaLink | Privacy | Terms of Use
Last Updated: 22 Oct 2004

Copyright 2004 by weiqj
Everything else Copyright © CodeProject, 1999-2010
Web22 | Advertise on the Code Project ActiveAnalysis for Silverlight, WinForms, ASP.NET by GrapeCity
ActiveAnalysis is a complete OLAP, data...
www.datadynamics.com Resco MobileForms Toolkit
The richest, most complete and award winning...
www.resco.net Spread for COM/ActiveX by GrapeCity
FarPoint Spread for COM/ActiveX by GrapeCity...
www.farpointspread.com See Also...Creating PDF Documents in ASP.NET
How to create PDF documents in ASP.NET.
A Fast CSV Reader
A reader that provides fast, non-cached,...
A Simplified SQL-CSV Import/Export Functionality
A simplified SQL-CSV import/export functionality.
Importing CSV Data and saving it in database
This article shows how to import CSV data and...
Transferring Data Using SqlBulkCopy
An article on how to transfer data using...
Announcements Mobile Virtual Tech Summit On Demand Got an Azure app? Win an Xbox & Kinect The Daily Insider30 free programming booksDaily News: Signup now.