Editor's Note: Added Cemetech Archives download link.
Download:
Doors CS SDK GUI

I made a rather simple GUI for the Doors CS SDK in C# yesterday, and it seems to be pretty functional. To run it, place this in the root of your Doors CS SDK folder (the folder in which your asm/ and basic/ folders are located), and put this in your asm/ folder. xcompile.bat is basically the same thing as compile.bat, except it returns values if the assembling was successful or not. Also, to use the "Send to WabbitEmu" feature, make sure WabbitEmu.exe is also in the same folder as DCSSDK.exe. The "Send to Calculator" feature doesn't do anything yet, though.

EDIT: Make sure you back up your ASM source files before trying my program.
Oooh, this sounds pretty neat! When you choose to Open File, does an Assemble or Compile option appear? Thanks for working on this. Smile
of course, now I am inclined to do the same thing souvik Very Happy

Nice job with this program, Souvik, works great for me so far. I don't see why I didn't think of doing something like this with my new System.IO knowledge.... Also, Kerm, what happens is that once you select the file, it instantly tries to compile.

edit: By the way, would it be too troubling for you if I could possibly have the source of the program? Just so I can look and play around with it
qazz42 wrote:
of course, now I am inclined to do the same thing souvik Very Happy

Nice job with this program, Souvik, works great for me so far. I don't see why I didn't think of doing something like this with my new System.IO knowledge.... Also, Kerm, what happens is that once you select the file, it instantly tries to compile.

edit: By the way, would it be too troubling for you if I could possibly have the source of the program? Just so I can look and play around with it

Sure, you can have the source. My C# skills are terrible, though.
I have been working with C# for quite a while now, if I see anything I could correct, i'll tell you. (doubt I am at that level though...)
Alright, here's the source:
Form1.cs
Program.cs
I probably messed up a lot in my code, so let me know if I did something I shouldn't have.
No Microsoft prefixes for you, huh? Razz It looks like it was pretty well made for the language, though I can't help but think it would work better as a Tcl/Tk script. It'd be nice if, in the future, it would remember where your WabbitEmu.exe is, and what your last file(s) were.
I'm thinking of making a set-up "wizard" that downloads the SDK from Cemetech and sets it up for you, to make it even easier. I'll try to make it remember WabbitEmu's location and the previously assembled files as well.
That's a great idea! I think you should definitely do that. Smile And as far as C# corrections, perhaps Merthsoft might have some feedback.
_player1537 wrote:
I can't help but think it would work better as a Tcl/Tk script.

I could help with this! I know Tkinter.
_player1537 wrote:
I can't help but think it would work better as a Tcl/Tk script.
Why do you say that? Wouldn't that require users to install much more stuff than just distributing a .exe compiled from the C# program?
ah, interesting use of Process and System.IO, I will definatly study this script later.

One question though, what is the point of
Code:
 private void button1_Click(object sender, EventArgs e)
        {

        }
?

it seems to be an empty method..
You claim that your "C# skills are terrible" - the most important thing is getting something to work, so they can't be all that terrible - good job. Very Happy Bearing that in mind, here are some things I spotted in a quick look through your source code:


Code:
int a = (int)openFileDialog1.ShowDialog();
if (a == 1)

The whole point of enums is to assign meaningful names to integral constants, so turning it into an integer and comparing against a magic number is a strange thing indeed:

Code:
if (openFileDialog1.ShowDialog() == DialogResult.OK)


The use of backslashes in file paths is not a great plan, either; it leads to ugly code (either "folder\\path" or @"folder\path") and won't work on operating systems that don't use the backslash as the path separator (e.g. Linux). Use Path.Combine to build up paths:

Code:
File.Copy(fileName, rootDirPath+"\\asm\\source\\" + filename2, true);
// should be:
File.Copy(fileName, Path.Combine(rootDirPath, "asm", "source", filename2), true);


In a similar vein, don't use the string manipulation routines to parse paths - the Path class is a better bet as it produces clearer code and is less work for you:

Code:
String[] fileArray = fileName.Split('\\');
String filename2 = fileArray[fileArray.Length - 1];
// should be:
string filename2 = Path.GetFileName(fileName);

// and this:
String[] files2Array = filename2.Split('.');
String filename3 = files2Array[0];
// should be:
string filename3 = Path.GetFileNameWithoutExtension(fileName);


I'd recommend using exceptions for structured error handling rather than return codes; I'm sure I don't need to tell you what's wrong with this idiom:

Code:
try
{
    // something that may fail
}
catch { }


Meaningful variable names are very useful to producing clean code - just because the default name for a control is button1 doesn't mean you can't change it. Smile\\asm\\source\\
Thanks for the corrections, benryves. Smile I'll be sure to change that when I get home.
KermMartian wrote:
_player1537 wrote:
I can't help but think it would work better as a Tcl/Tk script.
Why do you say that? Wouldn't that require users to install much more stuff than just distributing a .exe compiled from the C# program?
Mostly because it seemed like it was just buttons, and (I assume) that Tcl has an easy way to execute programs and open files, which seems to be most of what this is. I had originally said Bash, simply because Bash is for opening files, but changed my mind since I wasn't sure if Tk worked in a non-hacky way in Bash. Also, I was saying that in a "It would be fun to write it on Linux" sort of way Smile
How would I make the progress bar increment while the file is downloading?

Code:
       private void button2_Click(object sender, EventArgs e)
        {
            wabbitDLisChecked = checkBox1.Checked;
            WebClient wClient = new WebClient();
            String url = "http://www.cemetech.net/scripts/countdown.php?/text/calcinfo/dcs_sdk.zip&location=archive";
            byte[] dataBuffer = wClient.DownloadData(url);
            MessageBox.Show("DL complete");
            using (ZipFile zip = ZipFile.Read(folderStr+@"\dl\dcssdk.zip")) //using DotNetZip
            {
                zip.ExtractAll(folderStr+@"\tmp",ExtractExistingFileAction.DoNotOverwrite);
            }
           
           
        }
hmmm, I am not familiar with downloading files with C#< but I would assume that you have to increase the Value property of the ProgressBar while the file is downloading. perhaps the amount of bytes of the file currently downloaded could be stored in a value, and as that value increases, so does the ProgressBar Value?
I hope this makes sense; it assumes a button named "downloadSdk" and a progress bar named "downloadSdkProgress" with a Minimum of 0 and a Maximum of 100.


Code:
WebClient sdkDownloader = null;

private void downloadSdk_Click(object sender, EventArgs e) {
           
    // Are we currently downloading something?
    if (sdkDownloader != null) {
        System.Media.SystemSounds.Beep.Play();
        return;
    }

    // Create a new WebClient to download the file.
    sdkDownloader = new WebClient();
           
    // We need to handle the "ProgressChanged" and "FileCompleted" events.
    sdkDownloader.DownloadProgressChanged += new DownloadProgressChangedEventHandler(sdkDownloader_DownloadProgressChanged);
    sdkDownloader.DownloadFileCompleted += new AsyncCompletedEventHandler(sdkDownloader_DownloadFileCompleted);
           
    // Start downloading the file.
    sdkDownloader.DownloadFileAsync(new Uri("http://i.imgur.com/bjxgb.jpg"), "image.jpg");

}

void sdkDownloader_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) {
    // Update the progress bar.
    // See http://msdn.microsoft.com/en-us/library/ms171728.aspx for why BeginInvoke is a good idea.
    BeginInvoke(new MethodInvoker(() => {
        downloadSdkProgress.Value = e.ProgressPercentage;
    }));
}

void sdkDownloader_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) {
    // Dispose the SDK downloader.
    sdkDownloader.Dispose();
    sdkDownloader = null;
    MessageBox.Show("File downloaded!");
}
Interesting. I was curious how frequently the DownloadProgressChangedEvent fires, whether it's every byte, every relevant incoming packet, or some larger increment, but unfortunately I don't see much on that in the documentation.
Woo, progress!

Download links:
DCSSDK.exe
Ionic.Zip.dll
Later, I'm going to merge the DLL and the EXE together with ILMerge, but as of right now you need to have the DLL in the same directory as DCSSDK.exe. Also, to re-run the setup wizard, go to %APPDATA%\dcssdk\ and delete settings.txt.
Edit: Creating desktop shortcuts doesn't work yet.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 4
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement