Jump to content
Xtreme .Net Talk

Nerseus

*Experts*
  • Posts

    2607
  • Joined

  • Last visited

Everything posted by Nerseus

  1. Depending on what you want to do with the filtered/sorted data, you might use a DataView (if you need binding, mostly) or a DataRow[] select (faster, good for looping and doing stuff with each row). An example of each: DataView dv = new DataView(ds.Tables[0], "Age >= 18 and Age <=30", "Age DESC, Sex ASC, Name ASC", DataViewRowState.CurrentRows); // The default row types to be returned by "Select" are DataViewRowState.CurrentRows DataRow[] rows = ds.Tables[0].Select("Age >= 18 and Age <=30", "Age DESC, Sex ASC, Name ASC"); The sort can have ASC or DESC for each field: "Age DESC, Sex ASC, Name ASC". Fields default to ASC so you don't really have to specify that for Sex and Name above. The filter works great, but it's more like the WHERE clause than the Group By. A DataTable has a Compute method that can take aggregates, including filters. For example: object sum = ds.Tables[0].Compute("AVG(Age)", "Age >= 18 and Age <= 30"); The Compute method returns an object because, if I remember right, it might return System.DBNull.Value. While the Compute method is close to a Group By, it's not the same and there is no direct equivalent that I can think of. For example, a Group By allows you to get an ID and a count at the same time, including a HAVING clause: SELECT CustomerNumber, count(*) FROM Customer GROUP BY CustomerNumber HAVING sum(NumSales) > 10 (completely made up query) To do this in .NET you'd need a Select for each CustomerNumber (if you want unique you'd have to work at it :)) and then use a Compute on each of those individually. You CAN have an expression column in a DataTable and it contain contain aggregate functions, but it would only give you what you wanted if you split the table into two tables. In the dummy query above, you'd have to put the CustomerNumber in one table and the NumSales field in a child table. Then you could add an expression column to the parent table that SUMmed up the NumSales column. If that's not how your tables are setup, that may not be the easiest thing to do. Generally, if you want to do anything with aggregate functions or GROUP BY you normally try doing that in SQL and returning the result. Or, if you're using a Grid, have the grid do the summing (many 3rd party grids provide robust grouping/summing options). -nerseus
  2. I've noticed that .NET 2003 seems a lot "smarter" when you're debugging. If you define a simple int and set it to 0 and run it (never using it again in a function), the compiler will often show "undefined value" even though you clearly set it to 0. The same goes for objects that are defined but never "used". The compiler, I think, is trimming out that code since it detects it never being used. In the cases where it says "undefined value" are you using the variable farther down, or just testing the initialization? Try creating a class level field and setting that if you just need to test. If that's not it, let me know and I'll see if I can narrow it down. -Nerseus
  3. It would depend on the type of 2D game - there are a LOT of things to consider. At the simplest you could define your artwork (textures, basically) to work at the lowest resolution: 800x600 in your case. If they want the screen bigger, do one of two things: add extra space around the edge or scale up your textures automatically. With the first solution, you might end up with really small objects. With the second solution, you might get unreadable textures (or just ugly). For some games you may even want to lock them into a particular resolution to prevent the problems above. I think the original Diablo did that. Many card games do this as well. If your textures are (or can be) created as vector graphics, then scaling is no problem. A vector graphic is one that is defined entirely through formulas to recreate the "texture" on the fly. Drawing things with lines, circles, filled rectangles, etc. A game like Asteroids could, conceivably, be done like this. It's probably not a suitable option as most decent games need *some* kind of pre-rendered graphics. Other options might be creating all your 2D graphics in 2 or 3 scales. Say you're writing Majong and you draw everything to fit at 800x600. Your pieces may be 32x48 pixels. When you move to 1024x768 and you scale up, you may get some really ugly graphics. So you recreate all your graphics as 48x64. When you start the game, you pick one of these two "tilesets". If they want somthing bigger, maybe 1280x1024, you could pick either set and scale them up or just leave some "whitespace" on the edges. Other options are to create LARGE textures and do everything in 3D even though you render as 2D. Hopefully the large textures, with some good mipmaps (smaller versions of the large texture), would scale well at lower resolutions. I'd definitely pick your game FIRST, then try and figure out how best to implement it. I would strongly advise against developing some kind of reusable engine to create a slew of 2D games, as you're likely to spend the majority of time on the engine and not get your game done. -ner
  4. First, the base class's constructors are called first, then the ones for the derived classes (in the order of the hierarchy). For overloaded events, like Paint, make sure your classes are overriding the default Paint method and not just using an event handler. To "hook" the paint event you can do one of two things (both I suppose - but no point): 1. Override the base class's Paint event. 2. Implement an event handler If you hook the event, then the derived class would also hook the event. It's probably best to override the Paint event handler in your case. In your derived class, you override it again and call "base.Paint(sender, e);" to call the one in the base class. Your base class, which also overrides the Paint event handler, would have the exact same line (base.Paint...). In general, it would be better for your base class to override a method. Your derived class would also override and call base.Method(). Depending on the method and your needs, you might call the base method as the very first thing you do, or the very last. Sometimes you might not want to call it all if you decide you don't want any of the base class's functionality. -ner
  5. To "call an event in a derived" class, you need only call a function in your base class and mark the base method as overridable (VB) or virtual (C#). For example: Base class A: Create a method "CallMe" with no code (unless you want seme default behavior, in which case put in some code). Make sure it's marked overridable or virtual. From the method that you want to raise the event from, just call this method (CallMe). Inherited Class B (inherts from A): Override the method CallMe to do whatever you want. When class A needs to "call the event" it's really just calling the method in class B. You would only need events if you want an outside class to get the event. In that case, do the above AND have class A's CallMe raise an event that an outside class could hook into. (If you do this, then class B's CallMe method would first call base.CallMe() to get that default behavior of raising the event.) -nerseus
  6. I don't know about perfect. When I post now, it's from home and I don't currently have VS to test with so things may not compile as-is. I should put that in my signature... ;) -nerseus
  7. If it's for personal use, I can offer a suggestion: keep your "backup" files in one location. For example, I keep all my "personal" files in a folder called "myusername" on my D:\. When/if I need to reinstall windows or just backup the "good" files, they're all in one place. If they can't go there because some files live elsewhere (always possible), you might have a batch file that you update to automatically copy files to your "myusername" folder. Favorites are a good example since they live in the Documents and Settings area. For work I do something similar, but I have a whole drive set aside for the "backup" stuff. That includes my sourcecode (which has my test projects and such), sourcesafe (local copy) and downloads, among other things. To backup I need everything on that drive, plus "My Documents" and Favorites. It's generally best to keep your "list" in one place, be it a batch file, a txt document, or just a piece of paper. -nerseus
  8. You want Mobile Devices? The *definitely* become a Cowboy and go with Whidbey. The coolest plugin "form" designer wizard I have EVER seen inside any version of Visual Studio. If you like custom forms like Winamp's skins, then Whidbey Mobile development is for YOU! -Nerseus
  9. I do this on my machine, but not automated when I shutdown. If most people are like me then they rarely shutdown on purpose. Home users might, but I think you're referring to "business" users. What I use is a simple batch file that runs on a schedule - every night around 2am (I think). Some files can't be backed up without shutting down applications (like my Outlook PST file), so I either remember to shut it down or it doesn't get backed up. I can't help so much for what you want, but I can offer up this: 1. Services, in general, aren't supposed to show any UI. A prompt to the user might very well go unnoticed if they hit "Shut Down" then walk away. 2. If windows is shutting down and you popup a messagebox windows might do 1 of 2 things (both bad): either shutdown your service after 10 or 30 seconds (not enough time to backup) or NEVER shutdown unless the user answers the prompt (if they walk away early, their machine doesn't shutdown). I know there's a way to setup a script to run when you log into a Domain. There *might* be a similar feature for shutting down. I'm no admin so I can't say for sure. Now, you *might* do this, if you really want it: Write an app that users use to Shutdown their PC. They'd have to be trained to NOT use the Start Menu->Shutdown, but go through your EXE. It could do whatever you want and then shutdown. You could even prompt them and wait for 30 seconds (your prompt would appear immediately). If no one answered, just shutdown. -nerseus
  10. Suppose you have a form named MyDialog with a public string Entry. Make sure the "Ok" button (btnOk below) has it's DialogResult property set to "Ok" or set it manually in code, in the click event. Should be no need to set the Close button's DialogResult property since the form will use a default of either "None" or "Cancelled" or something like that. If you only care about "Ok", then that's all you need to set. public class MyDialog : System.Windows.Form { public string Entry = string.Empty; public MyDialog(string myFilename, string someText, Image myImage) { // Use myFilename, someText, and myImage for whatever... } private void btnOk_Click(object sender, System.EventArgs e) { // Set the public string Entry to the value of a textbox Entry = textBox1.Text; this.Close(); } } A "close" or "cancel" button would just call this.Close. The default value of Entry would always be string.Empty unless btnOk is clicked. In the calling form: public class MyForm : System.Windows.Form { private void btnOpenDialog_Click(object sender, System.EventArgs e) { Image i; // Define or get some image to pass to the popup MyDialog frm = new MyDialog("c:\\filename", "Hello World", i); DialogResult result = frm.ShowDialog(); // Ok should only be returned if the Ok button was pressed. if(result==DialogResult.Ok) { // This should work... string myEntry = frm.Entry; } // Manually dispose all forms that use ShowDialog frm.Dispose(); } } You can get some "weird" behavior from setting a button's DialogResult property. For example, if you had set btnOk's DialogResult to "Ok" above, and then had code in the Ok button's click that exited early because of non-valid data, the popup would STILL close! You'd have to remember to set the DialogResult back to None (or something) or else the form would automatically close. In fact, I don't think you even need "this.Close();" in btnOk_Click IF you have its DialogResult set. -Nerseus
  11. Maybe you should state your intentions. To me, a "bot" typically means a computer program running to simulate a real user. Why would you want a "bot" for MSN? Or, are you asking "How do I interface with MSN service"? As in, are you trying to write your own instant messaging software that uses the messenger service DLL to talk to other MSN clients (something like Trillian, which "talks" to MSN, AOL, Yahoo, ICQ, etc.). In any case, I doubt I could help... but thought I'd ask some questions since I didn't quite understand what you wanted. -ner
  12. You can always have all of your events (or the common ones at least) fire an event that triggers your flag. For example, if you're in C# and you have two textboxes: textBox1.TextChanged += new System.EventHandler(this.textBox_Changed); textBox2.TextChanged += new System.EventHandler(this.textBox_Changed); // farther down private void textBox_Changed(object sender, System.EventArgs e) { // Form-level variable or property (a property could enable a "Save" button) HasChanges = true; } By "common" I mean you'd need an event for each event type. Above, you could tie any contro's approprate event to textBox_Changed, provided the event was a System.EventHandler type. For something like a combobox with a SelectedIndexChanged event, you'd need a *second* event handler and tie all of your comboboxes to it. If ALL of your textBoxes are "bound", then you could automate the code by looping through all controls on a form and checking their type and wiring up an event automatically. Also, if you stored the original value in something like a Tag property (on all controls), then you could wire up ALL control's Leave event and compare some value of the control to the Tag property. If you do custom binding where you set and read the values of controls manually then you get speed at runtime but you get more complex code (usually harder to maintain as well). As you develop more and more apps, you'll likely develop a "framework" of classes and methods (such as looping through all controls and wiring up TextChanged events) to automate some of your custom binding. In the end, you may end up with code that runs at the same speed as the natively bound controls. Something to keep in mind when weighing the benefits of native binding versus custom "binding". I've tried custom and native and they both have their pros/cons. The new features of .NET make it a LOT easier to do native binding, especially given the power of the Parse/Format events and the features of the DataSet. -Nerseus
  13. Also, I've found the new Visual Studio to be a bit less buggy when dealing with Windows Forms applications. I don't spend all that much time doing ASP.NET work except for webservices and they've worked just about as expected. In VW 2002 I used to get fairly frequent crashes in VS (one a day or every other day when rebuilding large projects then opening WinForm designers). It also had a knack for just dropping out code in my InitializeComponent method. I got in the habit of always checking my changes before checking anything into SourceSafe. The only "bad" bug I've seen in VS 2003 is a VS crash that occurs sometime after referenced assemblies are updated (they point to a network share). Occasionally, VS won't show intellisense anymore. That my clue to get out fast! If I don't and do something like open the Object Browser or go to Class View, VS will popup a console window and then disappear. At least I get the "warning" so I can save first :) So, VS is a bit better. The new framework has a LOT to offer - I'd check out MSDN website to get details to see if it's worth it. It's not without problems if you have a LARGE project. You might need to investigate some time to see how the upgrade will go. We had to spend a few days changing out code that did Xsl transformations since it became a "requirement" that you had trusted namespaces (or something like that - obvisouly *I* didn't have to do that upgrade :)). There's also the perceived benefit to clients. I can't name a single professional project developed and compiled in VB4. I know quite a few in VB5 and a bunch in VB6. But VB4 was the first to introduce classes and... well, it had it's problems. When VB5 came out, our clients wanted VB5... NOT that a client should dictate what language or version you use, but if you only have one client and you "want" to upgrade anyway, it might make it a lot easier. Some clients work the other way and want to go with the "trusted" (older) product since they think it might be more stable. Ideally, it would be "your" job to give them the most accurate information and make the decision from there. Do the benefits of upgrading outweight the downsides? How much time would you lose upgrading? What's the ROI if the cost is significant (might be small since you might get a "free" copy)? Or, if you're a "cowboy", then just upgrade to Whidbey technical preview release and go for it! -nerseus
  14. If you're not binding, you might still be able to use the DataSet. I imagine you have some code to take the values out of controls and put them into a DataSet or some SQL INSERT/UPDATE/DELETE? If so, maybe you'd be better off moving the data from the controls into the DataSet, which will make the dataset marked as "Inserted", "Updated", etc. Something to keep in mind. I've seen people put the original values in the Tag property of a control. Personally, it feels wrong to overuse the Tag property. But, it might work for you. -Nerseus
  15. Having used both GeForce and ATI - the simple answer, from me, is the ATI card. I have a 9500 Pro (slower than 9700 Pro but faster than the 9600 Pro - go figure) and FarCry demo played beautifully. HalfLife 2 will *probably* play better on an ATI card since they seemed to have made some kind of deal (Valve and ATI). If nothing else, the shader implementation that Valve goes with will probably be either faster or better implemented for ATI's drivers - but who knows if that will translate into more than 1 or 2 FPS in the end. I wouldn't think either choice would be a landslide. I don't think you'll be disappointed with either card and from what I've seen, a few FPS difference isn't really going to make that much difference. If you can save $30 (heck, even $10) why not? Visually, they both run great with all the "extras" turned on. The antialiasing and anistropic filtering alone make a lot of games look a lot nicer. Since you're buying now, before HL2, it's hard to say if one card will look much nicer than another for some of those advanced games. -Ner
  16. In addition to Jabe's comments, if you bind to a DataSet you can check the DataSet's HasChanges property which will quickly tell you if anything's changed, and what. A DataSet also automatically stores the "original" value alongside the changed value so you can compare them. -Nerseus
  17. Ever since I "upgraded" to use Sun's java virtual machine, my browsing experience has drastically declines when Java is needed. When I try and run Yahoo Pool (Billiards, free version through Yahoo.com), all the fonts are SO small. I'm sure MS's version wasn't perfect, just what I got used... I hate change (sometimes)! -ner
  18. Here's a thread where I talk about Transcender practice exams. As a note: if you've NO practical experience in .NET, I would strongly encourage you to NOT take these tests. The purpose of the test isn't to prove that you can pass it, it's meant as a way to prove that you know the test's topics. With a lot of practicing in .NET, you should probably be able to pass most of the language based tests within a few months of using .NET. I would try and learn as much about .NET as you can, on your own. Then when you feel comfortable enough to write a program if someone requested it, then start practicing for the exams. -Nerseus
  19. For the Windows part... I've only seen Visual Studio "eat and lose" my code in version 1.0, not the newer 1.1. It will also lose your event handlers if you cut and paste the controls. A pasted control doesn't normally keep the event handlers, from what I've seen. Also, if you use a version control system like SourceSafe, you can easily compare files before checking them in to see what's changed. It's harder to do when you're first working on a form since you'll likely have a LOT of changes and no one wants to look/compare every changed line. -Nerseus
  20. To add to what Machaira said, what parts do you need help with? If you say "the whole thing" then you're outta luck - I'd suggest by starting to learn programming in general. You list a LOT of stuff that you want to do. What do you need help with: 1. Reading a text file. 2. Loading images dynamically. 3. Adding radio buttons. 4. How to determine what the choices and answer are. -Nerseus
  21. To expand on Plausably's solution, I'd offer a little more: Assuming you may have some textboxes where you *want* this behavior and some where you don't, try creating a new class/control that inherits from TextBox and has this event overriden to do what you want. On your form, use the new class type instead of TextBox. Also, I'm guessing that this is to enter a hex byte value (can't think of another reason to have a lot of textboxes that need only 2 chars and "auto-tab" to another box). If so, the new control type could not JUST check for 2 chars (and trim), but enforce it to be valid characters (0-9, A-F) and auto-uppercase the characters (a property on a Textbox that I don't remember offhand). By using the new type, you wouldn't have to hook up each event handler. -nerseus
  22. I think there may be some confusion about what your company is buying - this is partly Microsoft's fault as they have blended .NET with Visual Studio. You don't buy "VB.NET" or "C#" or the compiler - that's ALL free. What you are buying is Visual Studio, in one of a number of forms. You can buy the Visual Studio for VB.NET edition or you could buy something like Visual Studio Enterprise (which include support for all languages plus a lot of extras). You don't have to pay ANY money to write, compile, and distribute/sell a .NET application the last I heard - the .NET framework and its compiler are free. I'm only trying to be clear because I'm not sure what you have and what you're looking for. It's probably best to talk to Microsoft directly when you have purchasing questions. They're very upfront about the costs, discounts you might get for multiple versions, and letting you know what each "edition" offers so you can make your own decision. From my experience they are not pushing the Enterprise Edition - they tend to try and figure out what you'll be doing and offer the right product. MS also sells an "MSDN Universal" product, which offers a LOT of stuff - at a hefty price. I think it was around $2500 last I checked, but you get discounts for multiple copies. It includes the Enterprise edition of Visual Studio, Office, operating systems (WinXP, Win2003, etc.), SQL Server and more. These editions CAN be used on your developer box. There are some restrictions, but MS can explain them. For example, you can install SQL Server Enterprise on a server and use it (or on your local machine) as long as you don't use them for YOUR business needs. Meaning, you can use it to create databases and develop against. When you go to sell or distribute your application and its database, the client must buy a copy of SQL Server. If you decide to write a time-reporting application to keep track of your company's hours, then your company would have to buy a copy of SQL Server since it's being used for your business needs. -nerseus
  23. lol - Robert Plant :) That's the lead singer of Led Zeppelin (among others). Robert Smith currently looks *similar* to his younger days. That is to say, not so good. I haven't checked recently, but The Cure has switched members a LOT. Robert Smith has been the only one that's always been there. I saw the Pepsi Smash show and... well, I'll wait til the album comes out to pass judgement. Generally, the Cure releases albums in the following order: a lighter, poppier album followed by a darker, moody album. Bloodflowers, their last album, was the darker album so you might expect the next one to be a light and poppy album (along the lines of "Friday I'm in Love"). We'll see. -Nerseus edited to remove so many smilies
  24. You don't need to write your own conversion, unless I'm missing something. Just use the appropriate ToString function: ' 6/8/2004 @ 14:33:31 or 2:33:31 PM Dim d1 As DateTime = new DateTime(2004, 6, 8, 14, 33, 31) Debug.WriteLine("Military: " + d1.ToString("HH:mm")) Debug.WriteLine("Civilian: " + d1.ToString("hh:mmtt")) (I manually typed in the VB code from C#, might not be 100%) -ners
  25. I've seen the issue on a number of different machines, including WinXP (my right aligned bold problem) as well as Win2000. It's annoying and makes certain things look unprofessional. It's too bad, because aside from writing your own Label control (it's own Paint event), there's not much you can do except wait for MS to "fix" GDI+. -nerseus
×
×
  • Create New...