|
Actually, the undo-redo option is use for UI changing.
e.g. wrong deleting in listview item,
wrong arranging in listview,
wrong setting of my customer object, position etc...
this is quite a wide range I need to record, looks complex to do this...
|
|
|
|
|
azusakt wrote:
this is quite a wide range I need to record, looks complex to do this...
Yeah, it sounds like you need to build a class heirarchy to do it.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
So, do you know where can I find a good example ?
I really have no idea how to do this ~
Christian Graus wrote:
Yeah, it sounds like you need to build a class heirarchy to do it.
what will the class do ?? can anyone help?
|
|
|
|
|
Examples probably exist on the web, but I don't know of any. I did this years ago, for a paint program. I think we stored small bitmaps that represented the section of the image that was changed, along with a position to draw them back.
azusakt wrote:
what will the class do ??
If there's a wide variety of changes to be done, each class will be able to perform the modifications needed to undo one action. I'd imagine they might use the visitor pattern ? I'd imagine a base class, then a derived class at least for each type of object that can have an undo done on it.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Undo can be done using the Memento pattern. U can get help on this pattern from the internet. Maybe some examples too
« Superman »
|
|
|
|
|
Another couple options - one of which is common - is for each command (which Christian was probably referring to) to store how it undoes itself and then use a linked-list to store each command along with state information.
Another example uses memory protection faults to your advantage. See Undo and Redo the "Easy" Way[^], which also includes links to several other articles that discuss other methods, some of which Christian mentioned.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
What trouble am I gonna get into trying to convert C# code to FORTRAN 95 Code? DOes anyone have a solution to any known issues? Is there a .NET solution?
Jack Connolly
|
|
|
|
|
Is there a .Net Fortran 95 compiler?
|
|
|
|
|
You'll probably have some problems trying to convert .NET Framework classes to FORTRAN.
I don't know of any examples of this being done. But like the other posted said, look for a FORTRAN.NET solution. Fujitsu and Lahey are trying to get a .NET version of FORTRAN together.
RageInTheMachine9532
|
|
|
|
|
I am trying to write a crude version of c#.The fn. looks like this:
static void sscanf(string input, string format, params object[] paramlist)
{
string pattern = @"\b\S+\b";
MatchCollection matches1 = Regex.Matches(input, pattern);
MatchCollection matches2 = Regex.Matches(format, @"\b\S+\b");
for(int i = 0; i < matches1.Count; i++)
{
if (matches2[i].Value == "s")
paramlist[i] = matches1[i].Value;
else if (matches2[i].Value == "d")
{
try
{
int ii = int.Parse(matches1[i].Value);
paramlist[i] = ii;
}
catch (Exception exc)
{
Console.WriteLine(exc.Message);
}
}
else if (matches2[i].Value == "f" || matches2[i].Value == "lf")
{
try
{
double dd = double.Parse(matches1[i].Value);
paramlist[i] = dd;
}
catch (Exception exc)
{
Console.WriteLine(exc.Message);
}
}
}
}
and can be called for example as:
sscanf(str, "%s %s %lf %lf %d", os1, os2, od1, od2, oi1);
The problem I am facing is that the variables are being passed by value not by reference. Can anyone please help me? the c# compiler does not allow me to use the keyword ref in conjunction with params.
The cause of the problem - It seems to me is that object is not a reference type. This is how I tested:
say we have a fn. fn1 like:
static void fn1(object obj)
{
int i = 10;
obj = i;
}
now in main:
int i = 0;
object obj = new object();
obj = i;
fn1();
i = (int) obj;
i remains as 0 instead of 10.
pl. mail me at fd97207 yahoo if you know the answer.
|
|
|
|
|
String formatting like this is already supported in the .NET Framework. See my article, Custom String Formatting in .NET[^], for reasons why it is much better (also see the message board at the bottom) and ways to use methods like String.Format , Console.WriteLine (any TextWriter.WriteLine , actually), and StringBuilder.AppendFormat , as well as IFormattable implementations' ToString(String, IFormatProvider) methods.
The problem here, though, is that you're passing value types which are pass by value unless you use the ref keyword when passing them and in your method declaration. Since you're passing them in an array, you can't do this, though. They really don't need to be passed by reference, though - you're not changing them. Value types are allocated on the stack instead of the heap because it's more efficient (among other reasons, which are discussed throughout the .NET Framework SDK documentation and online).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I use System.Diagnostics.Debug.Assert(); a lot, but resently I have noticed that the asserts are compiled into release builds, so my release builds actually asserts
It only does it sometimes, sometime I can change something in my program and rebuild and it works as expected, but when recompiling, it starts to throw asserts again (of course only if it comes to a codition where I assert in the code, but that should be removed in release builds)
Anyone seen that before?
- Anders
Money talks, but all mine ever says is "Goodbye!"
ShotKeeper, my Photo Album / Organizer Application[^]My Photos[^]
|
|
|
|
|
Debug.Assert - like many of Debug 's methods - uses the ConditionalAttribute specifying "DEBUG". So, make sure your build configuration with which you're having problems does not define the DEBUG pre-proc def. By default, only the TRACE pre-proc def is defined in Release builds.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
I figured you would've, but I hesitated to say anything bad about the compiler...Microsoft may be watching.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
is there a way i can write a program to use my scanner to scan a document and save it as a .jpg
chad
|
|
|
|
|
try this article (http://www.codeproject.com/dotnet/twaindotnet.asp?target=scanner). It is good enough to do what you want. There is another one in msdn but is more complicated.
If you need all of the functionality of a scanner you have to build something custom.
From Greece:
Dimitris Iliopoulos
dimilio@yahoo.com
|
|
|
|
|
Can someone explain me, how to get an URL from IE an how to open an URL from an application in IE.
|
|
|
|
|
The latter is easy:
ProcessStartInfo psi = new ProcessStartInfo();
psi.UseShellExecute = true;
psi.FileName = "http://www.codeproject.com";
Process.Start(psi); This will open the URL in the default browser (see below for how to use IE specifically). The former is not as easy, but also not difficult.
In your project, add a reference to %WINDIR%\System32\shdocvw.dll. This will create an interop assembly which defines the InternetExplorerClass class. This represents either a new or running instance of IE. You can use either Nagivate or Navigate2 to direct the user to a URL using IE. You can use the LocationURL to get the current URL for the top-level instance of IE.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Does anybody know how to add custom items&values into this dialog? I mean custom attribute classes defined like in AssemblyInfo.cs (e.g.: AssemblyVersion ) whose are visible in this dialog.
Thank u for help.
|
|
|
|
|
What dialog are you talking about?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I mean "version" tab on "properties" dialog (after right-click on .dll or .exe file and selecting "properties" from pop-up menu). There is frame labeled "other version information". I want to add item there. And i want to do it throught attributes in c# (or by other way). Do u know now? Thanks for ur response.
btw i don't have english version of windowsXP so i asked my friend how are these things called. I hope he told me the truth 
|
|
|
|
|
Besides the attributes you already mentioned, there is only the AssemblyFileVersionAttribute (so that you can make the file version different from the assembly version, which is often good when performing upgrades to an existing code base for minor bugs).
Also, these are used by the compiler / assembler to create a VersionInfo block in the .rsrc section of the PE/COFF executable. If you wanted to do this using attributes, you'd have to write your own compiler.
If you want to extract information from custom attributes in your assembly, you could create a property tab by implementing the necessary COM interfaces (like IShellPropSheetExt ), load the CLR and your AppDomain using the unmanaged hosting APIs for .NET, then extract information from your assembly-level custom attributes, but I doubt that's what you're after.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ohh... so you say :"If you wanted to do this using attributes, you'd have to write your own compiler. "
cool idea! maybe in future, who knows...(i am ) but create property tabs sounds quite better. I will try it.
Thank u.
DNH
|
|
|
|