|
|
|
I couldn't get to sleep last night so I decided to pick up my copy of Petzold's Programming C# book, eventually (around 3) I did nod off, and I seem to remember it going on for a bit about sizes of characters etc. I'll try and find where I was.
What did you need to find the width of a character for? Do you need the size in pixels, points etc.? That should help me know whether what I was reading about is relevent.
--
Paul
"I need the secure packaging of Jockeys. My boys need a house!"
- Kramer, in "The Chinese Woman" episode of Seinfeld
MS Messenger: paul@oobaloo.co.uk
Sonork: 100.22446
|
|
|
|
|
|
Is there a quicker way to evaluate a string expression to a value than to compiled to code in an assembly first?
string exp = "(3 + 4) * 5 / 7";<br />
<br />
int result = IWantThisFunction(exp);
I looked at the article on the site, but that uses CodeDOM and compiles an assembly making it terribly slow ( say trying to call the function several 100000 times)
Thanx for helping
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
Well... parsing is always a possibility, if it's just arithmetic. I would imagine somebody's already created a calculator with .NET, which would mean just taking their code and trimming out all GUI stuff.
-Domenic Denicola- [CPUA 0x1337]
MadHamster Creations
"I was born human. But this was an accident of fate - a condition merely of time and place. I believe it's something we have the power to change..."
|
|
|
|
|
You mean something like this?
int i = (int) Evaluator.Evaluator.DoEval("1 + 3");<br />
<br />
MessageBox.Show(i.ToString());
Take this bit of code; and put it in a file called eval.js
package Evaluator
{
public class Evaluator
{
static function DoEval(str : String) {
return eval(str);
}
}
}; Now compile with this command line
jsc /target:library /out:eval.dll eval.js (you'll have to make sure the directory %windir%\microsoft.net\framework\%net_version%\ is in your path)
Now add a reference to eval.dll and to the Microsoft.JScript assemblies; execute the code above
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
Thanx James,
But again it is SLOW Not that slow, but about 4 times , compared to using delegates for the functions (in my case only +,-,*,/). Looks like I'm stuck with my solution, not that its bad comparing the other 2 options.
Results:
Using JScript: Time taken: 54979ms and evaluated 529293 expressions
Using delegates: Time taken: 16053ms and evaluated 529293 expressions
This basically a number(really formula) solving program. Its based on a local TV show: For those interested here are the rules.
You will be presented with 6 randomly selected numbers from the high & low groups - "high" contains one each of 100, 75, 50 and 25 and "low" contains two each of 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10.
Use some or all of the selected numbers (but do not use a number twice) and by means of basic arithmetical skills, (addition, subtraction, multiplication and division) try to reach the random total given. The quicker you complete the task, the better. In the game, you have a 30 seconds time limit. Note: Division operation must leave no remainder.
Example:
Given a target of say 345, and the numbers as 100, 25, 8, 3, 6, 2. The shortest answer will be (((100 + 25) - 8) * 3) - 6.
At first when starting this I thought this would be easy, but it did prove alot more difficult, but I got it in the end
Anyone wanna try it as well?
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
(100+25-8-2)*3
(8+6)*25)-3-2
Bill F
|
|
|
|
|
Has anyone written a IE Toolbar in C#?
There is an article on this site...
My problem is that my toolbar becomes invisible -
not shown in the IE toolbar section.
Has someone encountered this problem and
can someone help me?
|
|
|
|
|
I seem to be the only one getting a System.Security.SecurityException when trying to run two demo apps from Articles on this site. The articles are at:
#1 Displaying a Notify Icon's Balloon Tool Tip
#2 An Alternative Implementation of the NotifyIcon Class
Both these projects & articles are by the same Author. I am trying to work with him to fix the problem, however, since he can create the problem it is difficult.
I am hoping maybe someone else can try them and see if they get the exception when the click the ADD button. There are details of what we have talked about so far in the comment forums for the second article listed above.
If someone else has this problem, or if someone has seen this type of problem then please let us know.
Here is the info provided from the exception dialog:
<br />
Additional information: <br />
Request for the permission of type System.Security.Permissions.SecurityPermission, <br />
mscorlib, Version=1.0.3300.0, Culture=neutral,<br />
PublicKeyToken=b77a5c561934e089 failed<br />
It states a permission request faild. Please any help?
Thanks,
Aalst
|
|
|
|
|
Tried it and it works
Check your .Net settings in the Control Panel perhaps
I did read the comments from the article. Can you perhaps send a compiled exe for us to test?
Stupid question, but can the .exe be run from a local drive successfully?
I assume S: is a network share. Who compiled that exe?
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
Well that was the problem I was running it from a network share. Which I think is stupid if that causes a problem. It should not matter where I run it from. BTW the exe that is included in that article causes the problem from a network share but not when I copy it to my local drive.
That is bizard.
BTW what .NET settings in the Control Panel? I do not have any .NET applet in there.
Do you or anyone know why this is not allowed to work from a network share? And if so how can it be fixed?
Thanks Leppie for pointing me in the right direction!!
Aalst.
|
|
|
|
|
Aalst wrote:
BTW what .NET settings in the Control Panel? I do not have any .NET applet in there.
Oops under Admin tools in Control Panel. But it think all u mite need todo is set a security flag on the program/class when u compile it. I have never done this, but it seems the logical step.
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
Yeah I checked, and there are no compiler options to fix this. I only have 3 choices.
1 - Don't run code from network shares.
2 - Increase the trust level on a assembly by assembly bases.
3 - Adjust the Intranet Zone security to Full Trust.
I did 3 and it works fine. In my mind, Intranet and Local machine security are the same since I am the Admin. So I do not usually consider this. So I should not have this problem again.
Thanks for your help...
Aalst
|
|
|
|
|
Aalst wrote:
Do you or anyone know why this is not allowed to work from a network share?
The only code that is given full trust is that which is run from the My Computer zone. Code on a network share operates from the Local Intranet zone, which doesn't have Full Trust.
The Local Intranet zone doesn't get Full Trust because you can't *always* trust those on your network (cable provider, school network, etc).
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
You're not allowed to do this because the code isn't on your machine. Giving remote code full trust makes it much easier for malicious code to spread; all somebody needs to do to infect your machine is get a copy of their code onto the network share.
|
|
|
|
|
Does anyone have an example of changing the quality of a JPEG that you are saving out with the Bitmap.Save() method?
Thanks,
Steven
|
|
|
|
|
Hi Folks,
Most of my programming experience has been on the back-end / server side and I am begging to work on a new Windows project at home.
As I work through the UI, I often find myself wondering if my approach is efficient or "Good." Most of my concern comes when looking at how the program responds to UI events like button clicks ect.
Again, I am on bit of uncertain ground with the UI apps so please bear with me if my questions are a bit off or inaccurate. So on with the questions.
Is it best to construct objects and call methods directly in the ui event handling code (i.e. on_Click)? Or should I attempt to decouple it further by using delegates and registering event listeners in some type of worker class? And if I use this approach how would you suggest manipulating a moderately complex set of controls…. Is it wise to make the run-time changes directly from the event handlers or should a worker class again be employed?
Again, sorry if these question have been less than informed or asked in the past.
Any suggestions are appreciated.
Thanks again
|
|
|
|
|
I have always coded the creation of objects directly into the event handlers. I think it would be fairly inefficient and complex to create a worker class that does that stuff for you.
David Stone
It seemed similar to someone saying, "Would you like to meet my knife collection?"
Ryan Johnston on Elaine's sig
|
|
|
|
|
Thanks for the reply David,
The real source of my anxiety comes from having quite a bit of stuff going on in the even handlers (object creation, method calls, and UI componet manipulation)and worring that perhaps I am not following what are considered the best practices.
Mabey I'll relax about a little
Thanks
|
|
|
|
|
Chris Austin wrote:
Mabey I'll relax about a little
I would. I've done tons of stuff on one button click before. Just remember to try not to interrupt the UI experience though. If you have so much stuff that the UI can't respond to any of the user's movements, then you might want to consider multithreading the app.
David Stone
But Clinton wasn't a predictable, boring, aging, lying, eloquent, maintainer-of-the-status-quo. He was a predictable, boring-but-trying-to-look-hip, aging-and-fat-but-seemingly-oblivious-to-it, lying-but-in-sadly-blatant-ways, not-eloquent-but-trying-to-make-up-for-it-by-talking-even-more, bringer-in-of-scary-and-potentially-dangerous-new-policies. And there was also Al Gore. It just wasn't *right*.
Shog9
|
|
|
|
|
May I point you to Joseph M. Newcomer's article "Optimization: Your Worst Enemy", in particular the 5 paragraph section titled "When not to optimize".
All of Joe Newcomer's articles deserve a read; but that one really opened my eyes.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
Interesting article. While I agree there is little point in optimizing for optimization's sake, the real opportunity here is code reuse. Separating your business logic from the interface makes it easier to reuse the code. One has to weigh the benefits against the added complexity
Bill F
|
|
|
|
|
and this is my third - last question guys ;]
i dont want the user to be able to change the selection, i only want the program to be able to change it
overriding OnSelectionChanged() or OnMouseDown() doesnt work
ps. i cant just disable the list box, because i dont want the colors
dimmed, and when you disable a control you dont have any influence on the colors it displays on the screen
manson
|
|
|
|