Blue Theme Orange Theme Green Theme Red Theme
 
Home | Forums | ASP.NET 2.0 Tutorials | Web Services | How Do I...? | Class Browser | WPF Quick Starts | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
Team Foundation Server Hosting
Search :       Advanced Search »
Home » Pocket PC » Rotating the text display on a Pocket PC/Win CE device

Rotating the text display on a Pocket PC/Win CE device

In this article let us try to understand why rotating a text/bitmap is difficult to achieve on a Pocket PC 2003/Win CE 4.2 device.

Page Views : 6477
Downloads : 128
Rating :
 Rate it
Level : Intermediate
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
Download Files:
RotateText_WinCE.zip
 
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 

Let us first try to understand why rotating a text/bitmap is difficult to achieve on a Pocket PC 2003/Win CE 4.2 device.

The Compact Framework supports only a subset of the graphical output features of the Desktop Framework. You can do all of the more commonly required text drawing operations such as selecting different fonts by name, in different sizes and styles, and also control the color of drawn text.But this is a small price to pay for the small memory footprint occupied by the Compact Framework.

The System.Drawing.Graphics namespace is commonly used for almost any forms in the desktop framework, hence it has got lots of facilities to draw any kind of image on to the device context. However this namespace in the smaller version of the framework or the compact framework as It is commonly called is having only a very few classes/functionalities.

However there are means to overcome these short comings by making use of the win32 functions readily available/provided to the compact world.

Let me take a real world solution and give you an insight into it.

Problem at hand:

A Route sales Representative of Company A carries out a order/ sales for one of his prominent client (say for Wal-Mart) and after delivering the goods to his client he comes with his Pocket PC to take a signature from him for the delivery made.

Diagram 1: Signature Capture

Well This paper doesn't talk about how do we capture the signature (I will give you a hint ...Capture the Mouse Down and Up events and store the points into an Points[].To serialize it/or make it persistent store these points into an xml file (To simplify the reading of these points) ...You may probably find this in my next article J

Let us come back to our main discussion .So how we achieve this. As I told you I want to demonstrate a real life example. We also know that the data that is being displayed in the device are all dynamic depending on the store number, the sales ticket number, date and the quantity of item ordered by the client.

So we have to dynamically fill the display by retrieving these data from the local DB (ASA Database as it is commonly known).

Ok so the bottom line is we cannot rotate the control so what do we do rotate the font instead.

We will basically be making use of Win 32 functions from coredll (the most commonly imported dll in any of the smart device application.

In this sample I have made use of CreateFont and DrawText functions of the coredll.

Steps to be followed:

  1. Create a smart device application.

  2. Add labels and the panel where the signature is to be done.

  3. In the paint event get the control names and the data (from the DB) and store it into an array list.

  4. Pass these 2 array list to a user defined function called RotateText
    ie.. RotateText(mControlNames,mControlValues);

  5. Create a handle of the font to be used.
    IntPtr hFont = FontCache.CreateFont ("Tahoma", 9, FontStyle.Regular, 900);
    Important observation is the last parameter used i.e. 900 which indicates 90 degrees.

  6. Perform this operation for each control having text.
    Rectangle r = new Rectangle (ctl.ClientRectangle.X + 10, ctl.ClientRectangle.Bottom - 10, ctl.ClientRectangle.Width, -ctl.ClientRectangle.Height);
    FontCache.DrawText (hDC, hFont, arrControlNames [0].ToString (), arrControlNames[0].ToString ().Length,
    ref r, Win32.DT_TOP, Color. Black, Color. White);
    The win 32 functions Drawtext and CreateFont will have to be defined.

Definition for Win 32 Functions: (Refer attached source code)

For the signature part I have made use of a signature control (derived from control class) which displays a .png file on the panel.

This user control plays an important role when the client signs on the png file. As explained earlier derive this form Control class and override the Mouse Up, Mouse down and the Mouse move events to capture the movement of the mouse (stylus) on device. Generate an xml file to make these points persistent.

Hope you have got a brief insight into how rotation of the text can be implemented on a smart device.

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
pinto.philip
I am MCSD.NET working as Senior Software Engineer with HP India.
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
Team Foundation Server Hosting
Become a Sponsor
 Comments
maybe a little bit of something different by Matt On December 7, 2010

Good work.

Reply | Email | Modify 
Team Foundation Server Hosting
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.