|
Hello all,
I have any unusual question for you all. My piqued interest in the Thai lanugage/culture has prompted me to develop my own Thai Learning System. For the various consonants and vowels I want to animate how to draw each symbol. I was thinking of using a Thai True Type font and for each character animate along it to demostrate how it is drawn.
My problem is how can I read the true type fonts coordinates and animating along the symbol? Perhaps I need to hook the event that actually paints the symbols on the canvas then with my own event actually paint the symbol in some sort of time lapse fashion to present it in an animated fashion.
My other thought was to create a bunch of methods that draw each symbol as lines/arcs/Bezier Curves, but I figured it would be easier tracing the true type font in a generic fashion. With the lines/arcs/Bezier Curves I don't know how to get teh GDI+ engine to animate the points. Is there a way?
If anyone has any other suggestions or a better solution, which I am sure exist, please let me know.
Mark H.
|
|
|
|
|
First of all, .NET doesn't contain such low-level hooks. All you could do is draw the fonts yourself. I'm not even aware of any way to control fonts to such a degree exposed in the Win32 APIs and I've spent over a decade getting headaches from them (though such headaches might have lead to temporary blindness, causing me to miss such functionality )! This would be a function of GDI so you could look into the documentation.
Besides, true type fonts don't really contain any data that would allow you to show how each character is drawn. They contain points that help with resizing but those aren't in any order that is representational to how a human would draw them.
Your best bet will be to - as you didn't want to do - use lines, beziers, etc., to draw the characters.
Might I recommend Macromedia Flash, though? I've seen a lot of examples of similar presentations that actually draw things in steps. You would also be able to easily host this in a web page (you can with .NET controls, but it requires the ~20 MB framework and a pre-installed security policy to allow your code form a specific site to run), any COM client, or even a .NET application (which can be a COM client).
If you wanted to use GDI+ in a .NET application, you would have to worry about all the animation. For example, if you use Graphics.DrawLine to draw a line, the line is just there. It won't be animated. You'd instead have to call Graphics.DrawLine repeatedly to draw longer and longer lines until you reached the desired length! That's easy, though, compared to curves - you would have to calculate each point in the spline or the start and sweep angles for arcs with each iteration of the animation!
You could use Managed DirectX - which will help you with graphics a little - but you'd still need to worry about creating a package to handle the character animation. Things like Flash and even DHTML with vector graphics already have this support - you just have to tell it how to animate what you want.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Your best bet is to use freetype, refer the XFree86 codebase
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Sorry if this is a common problem that people already know the answer to, but...
I've written a cool app for use in aircraft navigation, and it draws a compass rose by drawing to a graphics path and then using a matrix to rotate it.
Except this functionality is missing in the PocketPC GDI+ library.
Apart from the obvious (write my own anti-aliased rotation code) is there anything I can do to get this to work on a PocketPC?
TIA.
for (int i = 0; i < 360; i+=10)
{
GraphicsPath gpRose = new GraphicsPath();
gpRose.AddLine(centre.X, centre.Y - radius - 3, centre.X, centre.Y - radius - 13);
if (i%30 == 0)
{
gpRose.AddString(i.ToString("000"), new FontFamily("Arial"), (int)FontStyle.Regular, 10, new PointF(centre.X - hdgWidth/2, centre.Y - radius - 25), null);
}
Matrix roseMatrix = new Matrix();
roseMatrix.RotateAt((float)(i-iActualHeading), new PointF(centre.X, centre.Y));
gpRose.Transform(roseMatrix);
e.Graphics.DrawPath(p, gpRose);
}
|
|
|
|
|
While the GraphicsPath and Matrix classes aren't supported in the Compact Framework, the Graphics class is. It won't be easy since you'll have to do a lot of calculates instead of harnessing the power of the Matrix (and I thought the "Matrix" was a bad thing! ), but you could perform all the drawing using the methods of the Graphics class.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I tried to port a custom control earlier today, and althought the Graphics class is availble, its severly limited.
I did notice a GAPI .NET wrapper on pocketpcdn.com[^]
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Hi, all,
I've stumbled upon a behavior of the .NET RichTextBox that I think is a bug, and I wanted somebody to do a sanity check before I report this to MS.
Below is a code listing. It displays a form with a RichTextBox control in it. Ctrl++ and Ctrl+- increase/decrease zoom. Space and Backspace keys change content of the text box.
Currently, zoom step is 0.5. Notice that when zoom factor is 2.0 (you can make it that by pressing Ctrl++ twice), the text box doesn't retain the zoom factor when its content changes. When you uncomment MessageBox statement in DisplayText (uses Clear() method of the text box class) method, you can more glimpse of the weird behavior. It is actually different with the MessageBox there. Increase zoom to 2.0 by pressing Ctrl++ twice and then press Space or Backspace repeatedly and notice zoom factor change from 2.0 to 1.0 to 2.0 to 1.0, …
After that, change the zoom step to, say, 0.3 (zoom factor doesn't become 2.0 with this step), and notice that the box behaves as expected (the zoom factor remains as set).
Is this a bug or reflection of my wrong expectations?
Thanks
----------------------------------
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace BugInZoomFactor
{
/// <summary>
/// Summary description for Form2.
/// </summary>
public class BugInZoomFactorForm : System.Windows.Forms.Form
{
private System.Windows.Forms.RichTextBox richTextBox1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private float zoomFactor = 1.0f;
private float zoomStep = 0.5f;
public BugInZoomFactorForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
this.KeyPreview = true;
DisplayText("Initial text");
}
private void DisplayText(string text)
{
richTextBox1.Clear();
richTextBox1.ZoomFactor = zoomFactor;
//MessageBox.Show("control's zoom factor is " + richTextBox1.
ZoomFactor.ToString());
richTextBox1.AppendText(text);
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.SuspendLayout();
//
// richTextBox1
//
this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)
((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.richTextBox1.Location = new System.Drawing.Point(16, 154);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.ReadOnly = true;
this.richTextBox1.Size = new System.Drawing.Size(672, 382);
this.richTextBox1.TabIndex = 4;
this.richTextBox1.Text = "";
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(704, 541);
this.Controls.Add(this.richTextBox1);
this.Name = "BugInZoomFactorForm";
// this.Text = "Form2";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.
OnKeyDown);
this.ResumeLayout(false);
}
#endregion
private void OnKeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode == Keys.Oemplus && e.Control)
{
if(zoomFactor < 64.0)
{
zoomFactor += zoomStep;
richTextBox1.ZoomFactor = zoomFactor;
}
}
else if(e.KeyCode == Keys.OemMinus && e.Control)
{
if(zoomFactor > 1.0)
{
zoomFactor -= zoomStep;
richTextBox1.ZoomFactor = zoomFactor;
}
}
else if(e.KeyCode == Keys.Space)
{
DisplayText("Subsequent text");
}
else if(e.KeyCode == Keys.Back)
{
DisplayText("Initial text");
}
}
[STAThread]
static void Main()
{
BugInZoomFactorForm form = new BugInZoomFactorForm();
Application.Run(form);
}
}
}
|
|
|
|
|
I'm seeing this behavior too, odd. I don't see anything wrong with your code right off hand (hey, just have to check before filing a bug ) and looking at the IL for the RichText.set_ZoomFactor (and a subsequent call to a private method) doesn't show any calculation bugs either. I'm guessing this is actually a problem with the Rich Edit common control somewhere in the EM_SETZOOM message handler.
So, googling for "Rich Edit" EM_SETZOOM[^] shows you're not the only one! Feel free to report, though. Maybe someone hasn't yet. Never know.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Problem: I need to call a function when either a combo box selection is changed or some new text is typed into the combo box.
SelectedIndexChanged takes care of the first half, but I can't figure out the OnTextChanged part.
Does anyone know what event is triggered when a user types in text into the ComboBox?
I know there are Enter and Leave events... but then I will have to keep track of whether the text changed myself, and that's my very last resort, because I have a gut feeling (called laziness ) that there has to be a better way to do this
Does anyone have any ideas?
Thank you,
Elena
Elena
|
|
|
|
|
elena12345 wrote:
Does anyone have any ideas?
When you form loads up, store an intial value within a public variable, the add an event handler for KeyDown , something like this should work:
public string buffer = "something";
private void comboBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
{
ComboBox cb = sender as ComboBox;
if(cb != null)
{
if(cb.Text != buffer)
{
}
}
}
}
- Nick Parker My Blog
|
|
|
|
|
Hi Nick,
Thank you for your reply.
I don't see the advantage of using the KeyDown event instead of the Leave event. I got to store the value and do everytyhing manually anyway.
Plus neither KeyDOwn nor Leave will catch the cases when the ComboBox is set programmatically.
I guess there is no ComboBox.OnSelectedValueChaged silver bullet.
Thanks again,
Elena
|
|
|
|
|
The TextChanged event fires if your ComboBox.DropDownStyle is set to ComboBoxStyle.DropDown . The unfortunate part is that is fires for every character typed, so you might want to handle the LostFocus event or the Validating event in order to add the new text or to call the function after the text is entered in its entirety.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
For those interested, here is what I ended up doing.
But first a little mode details on my case: it's a login dialog, and whenever the value in ServerComboBox changes I have to go and pull a list of databases off the server and put it into the DBComboBox.
This might look like an overkill with ServerComboBox.Leave, ServerComboBox.SelectedIndexChanged, and DBComboBox.DropDown handlers.
I would skip Leave & SelectedIndexChanged and just do DropDown if I didn't have to make a call to the server. When I do the call the the server on DropDown, the GUI hangs a little, so it's better to do it right when the ServerComboBox is changed.
Why do I have the DropDown handler at all: there is one case when Leave & SelectedIndexChanged don't do it: on startup when there is no history in the registry and we use the hardcoded default value for the ServerComboBox.
I don't know if I am making sence or it's too specific to my problem. Here it is anyway:
Let me know if you see any way to improve the code.
So here it is:
/// <summary>
/// The DbComboBox is dependent on the ServerComboBox and has to display the databases
/// available for the selected server.
/// </summary>
class DbComboBox : ComboBox
{
string m_onEnterServerName = ""; //the name of the server we pulled databases from the last time
ComboBox m_ServerComboBox;
/// <summary>
/// Constructor
/// </summary>
/// <param name="ServerComboBox">server combo box that we need to display Dbs for</param>
public DbComboBox(ComboBox ServerComboBox):base()
{
m_ServerComboBox = ServerComboBox;
//handles user changes but not programatic updates
//programatic updates are handled by SelectedIndexChange and a call to RefreshDbHistory
//from Server property in the SignIn dialog
m_ServerComboBox.Leave += new System.EventHandler(ServerChangedEventHandler);
//handles selection change, but not when the user types in something new
m_ServerComboBox.SelectedIndexChanged += new System.EventHandler(ServerChangedEventHandler);
//in case there is no history and login defaults we need to load DBs for the
//hardcoded default.
this.DropDown += new System.EventHandler(ServerChangedEventHandler);
}
/// <summary>
/// Event handler that is called when we suspect that the selection for the server combo box has changed
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ServerChangedEventHandler(object sender, System.EventArgs e)
{
RefreshDbHistory();
}
/// <summary>
/// Goes to the server, pulls databaselist, populates combobox
/// </summary>
public void RefreshVaultDbHistory()
{
string newServer = m_ServerComboBox.Text;
if ((!newServer.Equals("")) && (!newServer.Equals(m_onEnterServerName)))
{
....
}
}
}
Elena
|
|
|
|
|
Hi,
for my web application, i need to unzip my zip file on server through code. any one help to me.
thanks in advance.
Murali.M
|
|
|
|
|
The guys from #develop have created a nice .Net zip libray, see icsharpcode.net for a download.
The graveyards are filled with indispensible men.
|
|
|
|
|
Hi,
thanks for ur help
Have A Nice Day
|
|
|
|
|
I have a software package that gets installed on a local sql server and the customer can run as many clients as they need. What I need to be able to do is license the package by securing the sql server. For each "sub-office" there should be a license. Each sub-office has its own database on the sql server.
I know that this isn't the right forum. I just though maybe I can get a quick answer since this one has a larger audience. If anything I can implement a custom solution not based on the sql server. Suggestions welcomed.
|
|
|
|
|
So basically you want to license the database itself? We have a similar setup with our flagship product where a single database manages the accounts that can access each of the company databases (or sub-office database in your case). Similar to you, we allow unlimited user accounts. You could even forego this and just use Windows Authentication using SSPI. The thing that maintains how many people can access each database at a time is a .NET Remoting object that caches the current license count for each company (just in case the Remoting object shuts down or something). It hands out licenses and takes care of decrementing those counts when a client disconnects. The latter part is problematic, however, since if your client application crashes there's not really any good way to decrement the count since the clean-up code didn't run. If you don't have to expose your Remoting object through IIS in order to hang-off port 80, you could always poll clients by implementing your own ILease and returning that in GetLifetimeService .
As far as limiting connections in SQL Server, all you can do is limit licenses for a SQL Server instance, but that's nothing that a DBO couldn't change.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Awesome! That is exactly what I was thinking about doing.
One little question. I have my clients automatically find the sql server (multiple sql servers are possible also, I do searching using SQLDMO.ListAvailableSQLServers). What would be the best way of storing the URI? I was thinking maybe store it on the SQL database and have the client look it up. It URI doesn't work or license check fails then client will shutdown.
|
|
|
|
|
Sounds like a good idea. That way, you wouldn't have to worry about clients configuring two different properties - one for the SQL Server connection string and one for the Remoting object URI.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi
I would really appreciate it if anybody can help me!! I must convert a HTML page ..images include into a PDF file and stream the PDF file into a DB.
I have searched the net without any real success.
Thanks
Regardt
Africa is a though country
--"Hello daar vir die Afrikaans sprekende"--
|
|
|
|
|
You have to split this up into two part. First convert then encode and send to server.
Take a look at this site: http://www.verypdf.com/ and see PDFcamp/PDFwriter - it looks like this is the least expensive way of converting html to pdf. If you are looking for more pro components then around at: www.pdfstore.com (Some of the prices out there are scare if you are a startup and dont have much money.)
To put the pdf in database just read the file in and use Convert.ToBase64String() and send it to the database.
|
|
|
|
|
You could also - depending on the RDBMS - store the PDF as a binary stream, which some ADO.NET classes (like those in System.Data.SqlClient ) support. IMO, you should store the PDF on the filesystem and either store the path in the DB or use the primary key as part of the filename, which is what we do in our flagship product.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I'm using the ".NET Configuration Tool" to change the properties of the permissions belongin' to various permission sets. This can be done using the "Properties" dialog available for any built-in permission.
Is there any way to provide such a dialog for a custom permission, a CodeAccessPermission-derived class? The default displays a message like "The Custom Permission is unrestricted", or an xml fragment
rechi
|
|
|
|
|
The mscorcfg.dll assembly for the Microsoft .NET Framework Configuration snap-in is hard-coded to display views and property pages for the built-in permission classes and all the abstract classes are marked private . There is nothing in the .NET base class library for this either, unfortunately. You could take a look at the aforementioned assembly to see if there's any other hooks or interfaces, but it doesn't appear to have any.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|