|
leppie wrote: Your monitor is not gonna show you more than 60 times a second
Not necessarily true. IF he's using an old CRT he could be running at 100+ FPS. Also there're a handful of LCDs that can run at a native 75hz as a gimic to fool noobs who think it matters like with a CRT.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
hey leppie
mayb useing the term FPS was wrong...
what this panel does in a nutshell is paint a clock(the circle, lines for hours, the numbers everything) and some data in the form of lines(start and end times) and pies(durations).
the animationTimer is used for only one of the situations this control will handel, when activated a pie(duration) will sweep in between two lines(start and stop). The idea of that is to visually represent an employees lunch break in the case that he has a "Windowed Break", lets say from 10am to 2pm to have a 30min break.
the calculateAndUpdateDrawingVariables() method basically increments the DateTime values(these later go though a timeToDegrees() method so that a getPointOnCircle() method can be called). there are also a few ifs to check that the pie isnt sweeping over its "window lines" and another if to switch a bool value that determines if its sweeping left or right.
now the reason the animation timer is 10ms is because thats a nice speed for the pie to move at.
no i have no idea how this will perform on a much slower pc like a users...
leppie wrote: Can you cache the result of the function given the same variables
i belive it can be cached because the pie sweeps left and right all the time. but how'd i do that?
any other comments given the info i just gave you?
thanx
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
HarveySaayman wrote: now the reason the animation timer is 10ms is because thats a nice speed for the pie to move at.
no i have no idea how this will perform on a much slower pc like a users...
Don't use a fixed animation speed and don't rely on the fact that it will have the same speed on all computers.
Use a fixed animation callback (like 30 or 60 fps) and interpolate the actual values between the frames, this will run equally fast on all computers.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Greeeg wrote: Use a fixed animation callback
how would i do that?
Greeeg wrote: don't rely on the fact that it will have the same speed on all computers
it should, im NOT using windows.Forms.Timer BTW... as per This[^] article the multimedia timer which im using has u true(or extremely close to) 1000hz resolution unlike the normal timer or thread.sleep();
the only way i can see this going slower than it is on my dev machine is if the CPU cant calculate fast enough and somehow delay the drawing methods
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
HarveySaayman wrote: 1. Will this give me an accurate frames per second reading?
As accurate as the the timer tick gets called, but pretty close.
I wouldn't use a timer for either of the tasks, but rather fire the events myself, like this:
private void clockPanel_Paint(object sender, PaintEventArgs e)
{
fpsCounter++;
if ((DateTime.Now - lastFrame).TotalMilliseconds >= 1000)
{
fpsString = fpsCounter.ToString();
lastFrame = DateTime.Now;
framecounter = 0;
}
}
The same for the animation timer.
HarveySaayman wrote: 3. quite a bit happens in calculateAndUpdateDrawingVariables(); and it runs 100times per second(animationTimer = 10ms). Any tips on what to avoid in a method like this that runs so many times to use less CPU power?
I would reduce the timer to about 30 or 60 fps, do you really need so many updates?
Only update things that really changed inside this method, do not update any values that did not change. If you do complex math operations with matrices than for example only update the ones that changed.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Greeeg wrote: do you really need so many updates?
for the speed id like the animation to be yes...
read my 2nd post to leppie where i explained what i do more elaborately.
Greeeg wrote: If you do complex math operations
define complex? what happens is a DateTime value is converted to a value in degrees which then goes on to a GetPointOnCircle() method. The animationTick event basically adds one minute to the pies start angle, works out the sweep angle because duration is a given and then invalidates the panel so that the pie is moved to its new location.
i dont know if this is the best way to do this but its the first idea that i came up with
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
How to count the number of startup services and processes using C#. Is there a specific Win32 Class for this.
-----Have A Nice Day-----
|
|
|
|
|
RegistryKey theKey = Registry.LocalMachine.OpenSubKey
@("Software\\Microsoft\\Windows\\CurrentVersion\\Run");
string[] theValueNamesOfKey = theKey.GetValueNames();
|
|
|
|
|
Actually I know about this registry key, but when I count the items in the Run Folder it comes out to be lesser than items listed in the startup section of the msconfig.
-----Have A Nice Day-----
|
|
|
|
|
Actually not.
If you watch msconfig carefully, you can see that it might be having a extra number of start ups, but this registry key will give you only those which are enabled.
|
|
|
|
|
Dude, the registry key you are talking about has nine entries on my computer where as the msconfig shows thirteen. And above all, they all the active. No one of them are INACIVE..
Check out my solution.
-----Have A Nice Day-----
|
|
|
|
|
I created the following method for finding out the number of all the startup processes which is exclusive of the one in the HKLM\Software\Microsoft\CurrentVersion\Run. Here it goes.
public int getStartupProcessCount()
{
RegistryKey theKeyHKLM = Registry.LocalMachine.OpenSubKey(@"Software\\Microsoft\\Windows\\CurrentVersion\\Run");
string[] theValueNamesOfKeyHKLM = theKeyHKLM.GetValueNames();
RegistryKey theKeyHKCU = Registry.CurrentUser.OpenSubKey(@"Software\\Microsoft\\Windows\\CurrentVersion\\Run");
string[] theValueNamesOfKeyHKCU = theKeyHKCU.GetValueNames();
string val;
string dName;
int indexVal;
int countStartupProcessess;
string[] allVal = new string[theValueNamesOfKeyHKCU.Length + theValueNamesOfKeyHKLM.Length];
theValueNamesOfKeyHKLM.CopyTo(allVal, 0);
theValueNamesOfKeyHKCU.CopyTo(allVal, theValueNamesOfKeyHKLM.Length);
countStartupProcessess = allVal.Length;
string[] directories = Directory.GetDirectories("C:\\Documents and Settings");
foreach (string d in directories)
{
foreach(string d1 in Directory.GetDirectories(d))
{
indexVal = d1.LastIndexOf("\\");
dName = d1.Substring(indexVal+1, d1.Length - (indexVal+1));
if (dName.ToUpper() == "START MENU")
{
foreach (string d2 in Directory.GetDirectories(d1))
{
foreach (string d3 in Directory.GetDirectories(d2))
{
indexVal = d3.LastIndexOf("\\");
dName = d3.Substring(indexVal + 1, d3.Length - (indexVal + 1));
if (dName.ToUpper().Trim() == "STARTUP")
{
foreach (string f in Directory.GetFiles(d3))
{
indexVal = f.LastIndexOf(".");
dName = f.Substring(indexVal + 1, f.Length - (indexVal + 1));
if (dName.ToUpper() == "LNK" && dName.ToUpper() != "INI")
countStartupProcessess++;
}
}
}
}
}
}
}
return countStartupProcessess;
}
-----Have A Nice Day-----
|
|
|
|
|
|
You have no file name - C:\Documents and Settings is just a folder
System.IO.File.WriteAllText(@"C:\Documents and Settings<big>\MYFILE>TXT</big>", Entries.ToString());
You will need to change the file name each time, otherwise it will just be overwritten with each new message
Bob
Ashfield Consultants Ltd
|
|
|
|
|
thanks Bob.... but i forgot to include the file in my post (fax.txt).
since entries will be different from time to time, the file needs to be overwritten eachtime the code runs...
|
|
|
|
|
The same applies, you are overwriting the same file all the time!
|
|
|
|
|
ok...so how can i modify the code?
i believe this part here is not working:
Entries.ToAdd(sAMAccountName + " " + displayName + "" + myADFax + " " + strFAXLDAP + "");
|
|
|
|
|
mabby216 wrote: ok...so how can i modify the code?
Just asking that will gain you nothing. If you dont understand the problem, chances are you wont have a clue what the solution does. You need to understand both the problem and the solution, that's the only way you learn.
Else if you are stubborn, and not willing to learn, make a job request on the CP jobs forum, and pay someone to do it.
|
|
|
|
|
OK, so you are only posting some of the code and expecting us to guess whats wrong. Have you tried stepping through the code to see if you have any values? Are there any errors generated?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
I want to know how I can get files from ftp server, what should I use...I haven't used ftp servers before...so I am completely new in that field...thx ahead
|
|
|
|
|
|
hi, i want to define coclass,and progid in my c# com object,but i cant !
can i perform this ?
|
|
|
|
|
iman_kh wrote: coclass
What do you mean?
Freshman
|
|
|
|
|
Hi,
I am using VS2008 and I am trying to access the appSetting value inside the app.config file.
This GetSetting method returns null but there is value in the app.config file?
Any thoughts please?
This is what I am doing:
string logFilePath = Util.GetSetting("LOGFILENAME");
public static string GetSetting(string val)
{
try
{
return ConfigurationSettings.AppSettings[val];
}
catch (Exception ex)
{
return "";
}
finally
{
}
}
--------------
App.Config file contains:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="LOGFILENAME" value="C:\Work\Developments\Services\LogFile\Log.txt" />
<add key="ERRORLOGFILENAME" value="C:\Work\Developments\Services\ErrorLogFile\Log.txt" />
<add key="PATHTOWATCH" value="C:\Work\Developments\" />
</appSettings>
</configuration>
|
|
|
|
|
I use VS 2005 and this works:
Properties.Settings.Default["name"]
|
|
|
|