|
maybe this [^] can help
Have Fun
Never forget it
|
|
|
|
|
i want to change .net calender .i need persian month calender .i want to change normal calender to my favorite calender .how can i do ?
|
|
|
|
|
here were to start
Code Project[^]
MSDN [^]
Have Fun
Never forget it
|
|
|
|
|
Hey guys, I have an efficiency question.
Does an if statement with a single condition take up more cpu time than an assignment statement?
Ex, which is more efficient:
if (objA != objB)
objA = objB;
or just
objA = objB;
|
|
|
|
|
What!!!!
if (objA != objB)
{objA = objB;}
this is an if with an assignment
objA = objB;
this is just an assignment
both have different purpose
if u add an "if" more micro second pass
that it
Have Fun
Never forget it
|
|
|
|
|
Fudge Mutator wrote: Does an if statement with a single condition take up more cpu time than an assignment statement?
Almost certainly.
Unless your assignment is very complex (like a deep, deep copy of a large object), the time to do the comparison will outweigh just doing the assignment each time, regardless.
Let's say you want to make two strings equal, if and only if they are not the same. So you compare them first like this:
static void CheckAndMakeEqual(ref string myString1, ref string myString2)
{
if (myString1 != myString2)
myString1 = myString2;
}
...you might think you are saving time by avoiding the assignment if the strings are already equal.
But the code below will be much faster even if you know the strings are equal the vast, vast majority of the time:
static void JustMakeEqual(ref string myString1, ref string myString2)
{
myString1 = myString2;
}
...more than four times faster, in this case:
After 100,000,000 iterations,<br />
CheckAndMakeEqual() ran in 0.4808 seconds;<br />
JustMakeEqual() ran in 0.1180 seconds.
Here is the timing code, if you want to try this out for yourself. Notice that the strings are always equal (i.e. the assignment never happens) and still just doing the assignment each time is much faster.
Code Here:
using System;
using System.Diagnostics;
class Program
{
static void CheckAndMakeEqual(ref string myString1, ref string myString2)
{
if (myString1 != myString2)
myString1 = myString2;
}
static void JustMakeEqual(ref string myString1, ref string myString2)
{
myString1 = myString2;
}
static void Main(string[] args)
{
const int RepeatCount = 100000000;
string myString1 = "This";
string myString2 = "This";
Console.WriteLine("Testing CheckAndMakeEqual() {0} times. Timer started...", RepeatCount);
Stopwatch timer = Stopwatch.StartNew();
for (int i = 0; i < RepeatCount; i++)
{
CheckAndMakeEqual(ref myString1, ref myString2);
}
timer.Stop();
Console.WriteLine("Timer stopped. Execution Time: {0} seconds.", timer.Elapsed.ToString());
Console.WriteLine("\nTesting JustMakeEqual() {0} times. Timer started...", RepeatCount);
timer = Stopwatch.StartNew();
for (int i = 0; i < RepeatCount; i++)
{
JustMakeEqual(ref myString1, ref myString2);
}
timer.Stop();
Console.WriteLine("Timer stopped. Execution Time: {0} seconds.", timer.Elapsed.ToString());
}
}
Enjoy,
Robert C. Cartaino
modified on Tuesday, July 22, 2008 2:55 PM
|
|
|
|
|
Okay, thanks that's what I thought. I was just asking because my company has the "
if (myString1 != myString2)
myString1 = myString2;
"
kinda thing all over their code and I couldn't understand why, but the people who wrote it have been here for 10 years longer than me and I thought they were probably right =P
Thanks again
|
|
|
|
|
Fudge Mutator wrote: have been here for 10 years
Then they're likely used to C or some other language.
|
|
|
|
|
This is all very irrelevant, if you can avoid the check in the first place, then do so, otherwise you have no option but to use it.
|
|
|
|
|
Generally I wouldn't bother with the if .
But if the class has a custom != operator and/or a copy constructor you might need it.
Only testing with your particular class will tell.
|
|
|
|
|
absolutely positively yes.
[ADDED] Assuming it's about variables, not properties.[/ADDED]
modified on Tuesday, July 22, 2008 2:23 PM
|
|
|
|
|
Good People,
I am about to finish an application I am working on. The target audience is the general consumer. Do you have any application deployment tool recommendations?
ClickOnce and Windows Installer (by MSDN's own admission) seems to be primarily for enterprise environments wherein much is known about who will be using it and how. However, I need something that would be great for the average joe/josephine who will be downloading and using the software.
Thanks,
BP
|
|
|
|
|
It depends on what your requirements are for the installer. If all you need is a license agreement, possibly some registry changes, and a sparse amount of user input then I would say a Visual Studio Setup project should be sufficient. It's extremely easy to setup (VS has a wizard for creating the project) and the installer is straightforward for the end user. There's limited customization, but you also won't have to learn any scripting languages. It really depends on how much effort you want to put into it, and if you want to customize the look and feel of the installer.
|
|
|
|
|
Thanks Garrett.
Indeed, all I need the user to do is accept the license agreement and provide the license code or somehow authenticate the software.
I have two quick questions:
1) Can I at least put my own graphic on the install screens (e.g. a company logo, etc...)?
2) Does Visual Studio Setup allow me to ensure that the user has a license (i.e. provide a license or authorization key)?
These are really the only functions that I need.
Thanks again.
|
|
|
|
|
You can set a custom banner for the graphics. As for the license, you can provide a license where the user has to agree, and you can also request a user name, organization, and serial number. Here's a brief explanation of how to validate a serial number (although it's old, the idea should be the same): http://support.microsoft.com/kb/253683[^]
|
|
|
|
|
Thanks Garret. I appreciate the information.
|
|
|
|
|
Hi,
1) I am sure that you can use your own images on installation screens. It is pretty easy in Vs Wizard to customize your installation forms.
2) As far as I know licensing is kinda different platform, it requires additional tools. Well I am not sure but I think you cannot handle licensing only with VS setup wizard. I suggest googling on this issue...
Hope this helps.
|
|
|
|
|
I was given the following class to C# clean up. It's a mess.
****
using System;
private enum sections
{
section1 = 1,
section2 = 2,
section3 = 3
}
namespace My.Name.Space{
public class UppperClass
{
abstract public void NoClass();
private string upper
public string Upper
{
get
{
Upper = value;
}
Put
{
return(Upper);
}
private void UpperDiv(interface number1, number2)
{
private int upperResult;
upperResult==number1/number2;
return result;
}
}
public class MiddleClass : UppperClass
{
UpperClass[] upperArray;
upperArray = new UpperClass[5];
for(int i=0; int<= upperArray.length; i+)
{
upperArray[int] = new UpperClass();
}
public void MiddleDiv()
{
int middleResult = 0;
int sumOfAllResults;
middleResult=UpperDiv(1,2);
sumOfAllResults= ++middleResult;
}
}
public class LowerClass : UpperClass
{
string lowerString;
private Boolean initialized = false;
public void LowerClass(int paramInt) //Base Method overload 1, return nothing
{
initialized=1;
}
public string LowerClass(int paramInt) //Base Method Overload 2, return string
{
lowerString = paraamInt.ToString;
return lowerString;
}
public override void NoClass()
{
MiddleDiv(3,4);
}
}
********
|
|
|
|
|
You best get started then, it shouldn't take too long
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Hey,
I am trying to multithread my xml parsing routine but it seems that there are some issues with accessing attributes.
I have created a recursive xml parser using the composite pattern. So it means that I have a state class (a node in the xml file) which parses itself and depending on the child it creates another state and tells it to parse itself in a seperate thread and passes it the child node containing its data. The parse function for all my classes do not modify the xml node, they only read attributes. None of the functions should end up with the same xml node.
However when I run it in threaded mode... all my parse functions end up with the same xml node even if i am passing them a different node. If i set a break on each parse function the xml will be loaded correctly (i guess because it has time to finish the thread) but otherwise they end up parsing the same thing somehow.
mRootState = ParseContext(mNode);
mRootState.IsRoot = true;
foreach (XmlNode mChildNode in mNode.ChildNodes)
{
if (mChildNode.Name == "State")
{
if (mChildNode.Attributes["type"].Value == "Context")
{
Context mNewContext = new Context();
mRootState.Children.Add(mNewContext);
Thread t = new Thread(delegate() { mNewContext.Parse(mChildNode); });
t.Start();
mThreads.Add(t);
}
}
}
I am not sure why the keep ending up with the same xml node because they are supposed to be passed a different child node each time. Do I need to lock something? Or what is the problem?
|
|
|
|
|
I want to create a control on the form when the MouseDown event on the form fires and then use the MouseMove event on the newly created control to drag the control around the form. Unfortunately the MouseMove event doesn't appear to fire on the new control until the mouse button is released! ... This is the simplest cut down of the issue I could create.
private void button1_MouseMove(object sender, MouseEventArgs e)
{
this.Text = "Button: e.x=" + e.X.ToString() + " e.y=" + e.Y;
}
private void Form2_MouseMove(object sender, MouseEventArgs e)
{
this.Text = "Form: e.x=" + e.X.ToString() + " e.y=" + e.Y;
}
private void Form2_MouseDown(object sender, MouseEventArgs e)
{
Button button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
button1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.button1_MouseMove);
this.Controls.Add(button1);
this.ResumeLayout(false);
}
Is it possible to 'wire up' the MouseMove event so that it will fire on the new control before the mouse button is released ?
Michael
modified on Tuesday, July 22, 2008 11:35 AM
|
|
|
|
|
private bool Draged = false;
private int clickOffsetX;
private int clickOffsetY;
private void Sensor_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.Draged = true;
clickOffsetX = e.X;
clickOffsetY = e.Y;
}
}
private void Sensor_MouseMove(object sender, MouseEventArgs e)
{
if (this.Draged && e.Button.Equals(MouseButtons.Left))
{
this.Left += e.X - this.clickOffsetX;
this.Top += e.Y - this.clickOffsetY;
}
}
use the above
it works fine to me with a user control i've built that acts like a sensor
and can be moved around in an area of deployment
hope it helps
Have Fun
Never forget it
|
|
|
|
|
Thanks for sharing your code Half-life! thats the most elegant implementation of the 'moving control' solution I have seen It still doesn't solve my problem though, which is getting that MouseMove event to fire on the newly created control before the Mouse button has been released
|
|
|
|
|
I figured it out!
My problem had nothing to do with the control being new at all. When you MouseDown on the form, the form 'Captures' all subsequent mouse events until the next MouseUp... That is why my button control was not getting any events, the Form was stealing them!
The solution was to force the parent form to 'release' the capture so that the new button could receive the MouseMove event...
private void Form2_MouseDown(object sender, MouseEventArgs e)
{
Button button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
this.Controls.Add(button1);
button1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.button1_MouseMove);
this.Capture = false;
this.ResumeLayout(false);
}
|
|
|
|
|
HI All,
Sorry for the vague title, but I have a scenario as below, which I am hoping to automate – but not really sure where to begin!
We have two c# windows applications:-
1) Creates XML files for order entry & places them on the network.
2) A user manually navigates to a section in another c# windows app to see if there are any xml orders to import.
I am wanting to write a new routine, which could be running in the background, that would check to see if any new xml files are placed on the network - if so can it mimic the steps which the user takes to import these xml orders?
I'm sure it can - I just dont know what to search for on google - any help would be much appreciated
Lady Programmers are a rare breed!
|
|
|
|