Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
wwb
Aug 17, 2004

Casimirus posted:

Is there a simple way to not do DTD validation when present in an XML file while using one of the higher level functions like DataTable.ReadXml() ?

I was going to write a short program, a 5 liner, that has to run on a system with Windows firewall blocking outgoing connections, and apparently these two things are incompatible. The articles that I've found about this would have me use 400% more code than I would have had, just because an XML file of all things can't phone home.

And out of curiosity, what's to stop a CSRF attack just by setting that DTD value?

Never runned into this, and I suspect the issue is on the ADO side of things. Or, personally, I would just deserialize an object graph rather than use a DataSet in most cases. If it was a situation where I needed DataSet like features, I would just run with XDocument and linq.

Adbot
ADBOT LOVES YOU

thebruce
Jul 4, 2004

I'm having a few problems getting some of the fundamentals of .net, so I have some questions.

Say a method in my class does some work. It takes a long time, so I want to feed some progress back to my user via a textbox on my Winforms form.

Simple then, or is it? I seem to be making this difficult for myself - there seem to be so many ways of doing this.

Here's what I think (correct me if I'm wrong):

1) Keeping The GUI Active: The DoWork method of the function should be assigned to a different thread since it can take a long time to keep the gui active. This should be done using thread pooling or a background worker - but which one? Or something different?

2) Communicating With The User I'm not sure about this one - events? Delegates? One method I thought would be to have a delegate in the class, and the DoWork method of the class can call it to update the status of whats happening - something like void updateStatus(string message). I would then attached listeners outside of the class so that when updateStatus is called, it updates the text box.

The advantage of 2) seems to be that multiple things could subscribe to the updates, such as another function to write the status to a log file. Also, multiple objects could share the textbox update function to that the user is seeing status updates from multiple objects.

This brings me to events - it seems I could do 2) using events and passing EventArgs with my message in it. Is this what events are for? Are there any good examples of when to use events vs delegates?

Thanks!

PhonyMcRingRing
Jun 6, 2002
I'd use a BackgroundWorker if you don't need any the super fine tuning of working with threads yourself. It already has all the DoWork/Progress/Complete/Cancellation stuff built in for you.

The only real difference between events and delegates are the syntactical sugar that's added to events. They both function identically otherwise. Events are mainly used to indicate that an object did something and some external object might wanna take note of it. Ex: Buttons have Click events because the form with a button on it is gonna want to know when its button was clicked so it can do something.

EventArgs are used to pass any additional data about why an event's being raised. For example, the BackgroundWorker class has a RunWorkerComplete event that passes a RunWorkerCompleteEventArgs object. That object will have properties that tell you whether or not the background operation was cancelled, if there was an exception, and a few other things.

raminasi
Jan 25, 2005

a last drink with no ice
Yeah, if you're not doing something super-complicated then BackgroundWorkers are dead loving simple to use (so if you use one and it seems difficult at all there's probably an easier way).

uXs
May 3, 2005

Mark it zero!
I've been trying the new async stuff from the tech preview and that seems even easier. I haven't tried cancellation or progress reporting though.

Bozart
Oct 28, 2006

Give me the finger.
So I'm trying to learn C# and .NET and I have a small project that I'm going to work on. But because I am new to everything I don't know the typical objects or packages used for specific work, and I was wondering if I could get some guidance.

I want to put together a screensaver that works like the apple tv picture flow thing, where you have a black background and random pictures float up from the bottom of the view at various distances from the viewer. Obviously this is going to take some 3D work, so probably some DirectShow is called for - but there is some newfangled Media Foundation thing too - which one should I use?

More simply, are there any good built-in objects to handle command line arguments? I know how to pass them in and handle strings, and I could do it that way with no problem. However, it seems like a common situation and I have an aversion to reinventing the wheel. What is the typical approach to handle command line arguments?

Slightly more complicated - a screensaver is going to need a configuration. What set of tools to people usually use to handle a configuration - a file? a registry entry? something else? Again, what package is typically used to make this stuff a no brainer and bulletproof?

Finally, I find msdn somewhat difficult to use and navigate. Is there some trick to it?

scarymonkey
Jul 15, 2003

by angerbeet
^^^ MSDN is a reference, not a learning tool. If you want to learn the basics of the language hit up a book or google for tutorials. Do you have experience in other languages? You probably want to approach the screen saver as first a regular desktop application, then figure out/look up the hooks to make it a screen saver.

Codeproject has a bunch of C#/.NET code samples for you to peruse on many different topics. stackoverflow is also a great resource to peruse various programming related questions. Seriously when it comes to programming in any language google is your friend. Just type in your question and there's bound to be a bunch of relevant results.

http://www.codeproject.com/KB/WPF/WPFScreenSaver.aspx
http://www.codeproject.com/KB/cs/scrframework.aspx

Think of C#/.NET as the logic construct, when it comes to UI there are bunch of different frameworks that sit on top of .NET. Depending on your needs and skill set you choose the best one for a particular task.

A quick rundown of the most popular ones:

XNA/Managed DirectX for high performance 3D or gaming in C#.

WPF (Windows Desktop apps) /Silverlight (Cross Platform/Web Plugin/Sandboxed Desktop) : For modern looking user interfaces (completely skinable user interfaces/animations/video/etc..) using a XML like language to define user interface elements.

Winforms : For old looking line of business applications or simple tools you need to make quickly by drag and dropping widgets onto a form.

Mono : For C# on other (Linux) platforms.

------------------
On another topic I wan to chime in to say if you're using Prism instead of Caliburn to do your MVVM development you're making your life harder than it should be.

scarymonkey fucked around with this message at 04:11 on Feb 19, 2011

Tres Burritos
Sep 3, 2009

So I've been trying to flash an infrared LED from a usb to serial port adapter. I've verified that I can make the LED turn on an off in c# by using either DtrEnable, BreakState or RtsEnable. I'm sending out these LED pulses to a mini helicopter and I know what the protocols for the pulses are.

So far I've been using a stopwatch to time the on and off pulses of the LED. I'm pretty sure that this is the wrong thing to do and I have to dick around with baudrates. However I'm not quite sure where to start. The pulses are a specific length, so should I be able to set a baudrate and then just port.write() a byte array of ones and zeroes?

Never really worked with com ports like this before.

mobby_6kl
Aug 9, 2009

by Fluffdaddy
Speaking of BackgroundWorker, I'm pretty inexperienced with C# but still found it very easy to work with. However one thing's been bothering me a bit, though it's not strictly necessary for the functionality at all. I wanted each BW to have its own progress bar, but I'm not sure how to approach this. I considered adding an instance of PB to the class with data that I give to the BW, but then how would I update it, when I can only pass an int with ReportProgress... Any suggestions on how to proceed here?

FrantzX
Jan 28, 2007
public void BackgroundWorker::ReportProgress(int percentProgress, object userState)

mobby_6kl
Aug 9, 2009

by Fluffdaddy
:doh: Thanks! At first I thought that wasn't a very helpful reply, but that's exactly what was needed and it works fine now. Don't know how I overlooked this in the first place.

Hoborg
Oct 19, 2006

by T. Mascis

Tres Burritos posted:

So I've been trying to flash an infrared LED from a usb to serial port adapter. I've verified that I can make the LED turn on an off in c# by using either DtrEnable, BreakState or RtsEnable. I'm sending out these LED pulses to a mini helicopter and I know what the protocols for the pulses are.

So far I've been using a stopwatch to time the on and off pulses of the LED. I'm pretty sure that this is the wrong thing to do and I have to dick around with baudrates. However I'm not quite sure where to start. The pulses are a specific length, so should I be able to set a baudrate and then just port.write() a byte array of ones and zeroes?

Never really worked with com ports like this before.

You'd want to keep all of that on a single thread (that isn't the GUI or entry thread) that uses spinlocks for precise blocking behaviour, you cannot rely on any timer that performs context-switching (e.g. System.Threading.Timer). If you're simply surrounding your Stopwatch code in a while loop then that's one way of doing it. It sounds hacky, but that's how you do things.

If your LED flashes only need to be accurate to the closest millisecond then you'll be okay, for anything with a higher precision then you'd want to do that in hardware (build a simple circuit with hardware timers that's controlled by your program).

Bozart
Oct 28, 2006

Give me the finger.
Alright let's just try this: is there a class or library typically used to handle all of the usual command line argument interpretation and exception handling? (defaults, allowing either -/, abbreviations, etc.)

This stuff is simple but I hate rolling my own stuff when it is certain that it has been answered again and again. And where to find this (other than google, which isn't all that useful without a few solid sources of recipes or whatever) will probably be more useful than the answer in the first place.

gibbed
Apr 10, 2006

Bozart posted:

Alright let's just try this: is there a class or library typically used to handle all of the usual command line argument interpretation and exception handling? (defaults, allowing either -/, abbreviations, etc.)

This stuff is simple but I hate rolling my own stuff when it is certain that it has been answered again and again. And where to find this (other than google, which isn't all that useful without a few solid sources of recipes or whatever) will probably be more useful than the answer in the first place.
I use NDesk.Options.

Piss Witch
Oct 23, 2005

Not sure whether to put this here or in the making games megathread, but i've run into another roadblock.

http://code.google.com/p/rougeliek/source/browse/#svn%2Ftrunk%2FRougeliek

I've been working on writing a screen buffer, trying not to use Console.Clear() so i don't get that flickering that you get on refresh. I tried making it write over all the screen tiles, but that worked out slower, unsurprisingly, and without a method for clearing, it starts getting really patchy with remnants and artifacts kicking about after the character has moved.

Anyone with any ideas about what direction to take this in? I was thinking about basically just forcing a redraw on a tile that's been previously used, avoiding the need for a screen redraw, or is putting up with the flicker of using Console.Clear() just a reality i'll have to live with?

ninjeff
Jan 19, 2004

Bellend Sebastian posted:

Not sure whether to put this here or in the making games megathread, but i've run into another roadblock.

http://code.google.com/p/rougeliek/source/browse/#svn%2Ftrunk%2FRougeliek

I've been working on writing a screen buffer, trying not to use Console.Clear() so i don't get that flickering that you get on refresh. I tried making it write over all the screen tiles, but that worked out slower, unsurprisingly, and without a method for clearing, it starts getting really patchy with remnants and artifacts kicking about after the character has moved.

Anyone with any ideas about what direction to take this in? I was thinking about basically just forcing a redraw on a tile that's been previously used, avoiding the need for a screen redraw, or is putting up with the flicker of using Console.Clear() just a reality i'll have to live with?

Check out Console.MoveBufferArea.

magic_toaster
Dec 26, 2003
No.
Resource locking

My company uses a third part application (Visual Cron) to run "jobs" at specified times. A job is essentially just running a console application with a specific parameter, and the program sends an email.

However, if any two (or more) jobs were to run at the same time (e.g. 12:00:00 AM), we have an issue because each application tries to open a connection to a server that cannot handle that may concurrent connections. So I need a way to determine if any other job is currently running.

One suggestion has been to write a value into a table in the database as soon as the first job begins running, and then each subsequent job will hit the database continually checking for that value, and will not continue until the value is no longer in the database.

This seems perfectly feasible, but feels really sloppy to me. Plus, I can only imagine the concurrency issues we may face if 20+ jobs get run at the same time.

Is there a cleaner way of handling this? Open to all ideas!

Bozart
Oct 28, 2006

Give me the finger.

gibbed posted:

I use NDesk.Options.

Just what I was looking for, thanks.

POKEMAN SAM
Jul 8, 2004
I have a question regarding server processes (that is, processes that run on servers.) I have an application that I wrote that I need to always be running on a server I have control over and I was wondering what the easiest way might be to make sure it stays running after a reboot (I'm not worried about it crashing, that's a separate problem.)

Any pointers?

wwb
Aug 17, 2004

magic_toaster posted:

Resource locking

My company uses a third part application (Visual Cron) to run "jobs" at specified times. A job is essentially just running a console application with a specific parameter, and the program sends an email.

However, if any two (or more) jobs were to run at the same time (e.g. 12:00:00 AM), we have an issue because each application tries to open a connection to a server that cannot handle that may concurrent connections. So I need a way to determine if any other job is currently running.

One suggestion has been to write a value into a table in the database as soon as the first job begins running, and then each subsequent job will hit the database continually checking for that value, and will not continue until the value is no longer in the database.

This seems perfectly feasible, but feels really sloppy to me. Plus, I can only imagine the concurrency issues we may face if 20+ jobs get run at the same time.

Is there a cleaner way of handling this? Open to all ideas!

Definitely sounds kid of ugly. Not sure how the internals are archetected, one thing that comes to mind would be to stand up a service to act as a broker between your jobs and the app. It could ensure there is only one connection without having your apps worry about who else is running.

Fatal flaw in your plan there is the fatal flaw with every locking file/record/what have you -- this works great until a job fails then nothing will start because the lock is still in place.

gibbed
Apr 10, 2006

Ugg boots posted:

I have a question regarding server processes (that is, processes that run on servers.) I have an application that I wrote that I need to always be running on a server I have control over and I was wondering what the easiest way might be to make sure it stays running after a reboot (I'm not worried about it crashing, that's a separate problem.)

Any pointers?
Barring adding an actual service entry, schedule task?

POKEMAN SAM
Jul 8, 2004

gibbed posted:

Barring adding an actual service entry, schedule task?

Well, the process needs to be running 24/7, so maybe a service is what I want? Services just sound so heavyweight to me, but maybe there's no reason to not just write it as a service (however the hell I'd do that, but I could learn).

Dren
Jan 5, 2001

Pillbug
I have three projects, a library and two apps that use that library. They all currently build as part of the same solution and are checked into the same directory in source control. My goal is to put them into different directories in source control so that my CI server triggers builds on the appropriate projects instead of on all the projects. What is the best way to organize the projects in Visual Studio 2008 when they are all in different directories?

Should I make solutions for each of the apps that include the library project? Should I be publishing the binary for the library somewhere and referencing it? If I were to reference the published binary is there a good way to do that (like the way Ivy or Maven handle jars)?

_aaron
Jul 24, 2007
The underscore is silent.

magic_toaster posted:

Resource locking
Can you use named mutexes?

http://msdn.microsoft.com/en-us/library/f55ddskf.aspx

For any jobs that need to access the same resource, first acquire a named mutex for that resource. Anything trying to acquire a mutex with a name already in use will wait until it's released.

wwb
Aug 17, 2004

Ugg boots posted:

Well, the process needs to be running 24/7, so maybe a service is what I want? Services just sound so heavyweight to me, but maybe there's no reason to not just write it as a service (however the hell I'd do that, but I could learn).

Code-wise, the best bet is to write the processing code as a stand-alone library and integrate it with "containers" such as your service. Never have written a production service -- we have always found out we don't actually need one but rather a command line app -- but it is pretty straightforward. Just add a new Windows Service project.

Now, the real question is if you need a service. In most cases, you really just need a message queue and a batch processor. Or at least that has been my experience.

@Dren: can you post an example of your folder tree? Something isn't lining up. Honestly, unless something is huge or horribly bloated or you are paying for CI access by the minute, building all three isn't really hurting anyone.

POKEMAN SAM
Jul 8, 2004

Dren posted:

Should I make solutions for each of the apps that include the library project? Should I be publishing the binary for the library somewhere and referencing it? If I were to reference the published binary is there a good way to do that (like the way Ivy or Maven handle jars)?

Typically I have my files laid out like:

SomePath\Services\MyLibrary\MyLibrary.csproj
SomePath\Tools\MyAwesomeToolA\MyAwesomeToolA.csproj
SomePath\Tools\MyAwesomeToolA\MyAwesomeToolA.sln
SomePath\Tools\MyAwesomeToolB\MyAwesomeToolB.csproj
SomePath\Tools\MyAwesomeToolB\MyAwesomeToolB.sln

So a solution for each application, and each of those solutions references the library by including the csproj for that library. In the solution files, the paths look lik ..\..\Services\MyLibrary\MyLibrary.csproj, which I think is as sane as anything else to deal with.

Beats the alternatives, I figure.

POKEMAN SAM
Jul 8, 2004

wwb posted:

Code-wise, the best bet is to write the processing code as a stand-alone library and integrate it with "containers" such as your service. Never have written a production service -- we have always found out we don't actually need one but rather a command line app -- but it is pretty straightforward. Just add a new Windows Service project.

Now, the real question is if you need a service. In most cases, you really just need a message queue and a batch processor. Or at least that has been my experience.

@Dren: can you post an example of your folder tree? Something isn't lining up. Honestly, unless something is huge or horribly bloated or you are paying for CI access by the minute, building all three isn't really hurting anyone.

Honestly I will write it as a console application at first, since that's how I'm familiar doing it. The application every 5 minutes (or so) runs a list of tasks to update a database. The webserver then pulls from this database when we get a client request, because the actual queries take too long to complete. I'd put it in the ASP.NET HttpApplication code, but we need the database to be updated even when no one is connecting to the webserver, because we need to keep historical data, as well.

magic_toaster
Dec 26, 2003
No.

_aaron posted:

Can you use named mutexes?

http://msdn.microsoft.com/en-us/library/f55ddskf.aspx

For any jobs that need to access the same resource, first acquire a named mutex for that resource. Anything trying to acquire a mutex with a name already in use will wait until it's released.

At quick glance this would appear to be exactly what I need! Thank you very much!

Zhentar
Sep 28, 2003

Brilliant Master Genius

Bellend Sebastian posted:

I've been working on writing a screen buffer, trying not to use Console.Clear() so i don't get that flickering that you get on refresh. I tried making it write over all the screen tiles, but that worked out slower, unsurprisingly, and without a method for clearing, it starts getting really patchy with remnants and artifacts kicking about after the character has moved.

If you keep an array of the previous frame, then you can compare it to the contents of the current frame, and only redraw/clear the tiles that have changed.

Dren
Jan 5, 2001

Pillbug

wwb posted:

@Dren: can you post an example of your folder tree? Something isn't lining up. Honestly, unless something is huge or horribly bloated or you are paying for CI access by the minute, building all three isn't really hurting anyone.

Here is a simplification of my directory structure.
Project/src/Project.sln
Project/src/GUI/Gui.csproj
Project/src/TestTool/TestTool.csproj
Project/src/Library/Library.csproj

Currently, my CI tool (pre-fork Hudson) polls on Project. When there is a change, the CI tool rebuilds everything. Our versioning is tied to a build number that comes from the CI tool. Thus, when something changes in the TestTool, the GUI and library get their version number incremented and a new build is kicked off, essentially for no reason. These new builds cause confusion as people try to figure out if a new build got kicked off because of a change that mattered or a change that didn't matter.

I would like to separate the projects in the CI tool. Ugg Boots's suggestion is along the lines of what I was thinking, just include the .csproj of the library in a solution for each of the tools. The extra build time won't hurt anything. The purist in me didn't want to rebuild the library unnecessarily which is why I asked the question.

Since the GUI and TestTool are effectively my deliverables the sensible thing to do would be to reorg my directories to look like this:
Project/src/Library/Library.csproj
Project/src/GUI/GUI.sln
Project/src/GUI/GUI.csproj
Project/src/TestTool/TestTool.sln
Project/src/TestTool/TestTool.csproj

The CI polling is set up at the directory level. This causes a problem. If I set up two projects in the CI server, one for each deliverable (GUI and TestTool), my CI server will trigger on changes to GUI or TestTool but will not trigger when Library changes.

I could work around this problem in the SCM tool (Starteam) by linking Library into a subdirectory of both GUI and TestTool. However I would rather not resort to this approach because Starteam is a horrible piece of poo poo.

An approach involving binary dependency management like that offered by maven would be superior since there would be a config file in each project that would have to change in order to use a new library version. The CI tool would see that change and appropriately trigger a build.

I don't think I want to use maven but after reading this post it sounds like I'm making a case for it.

Anyone having any ideas for managing this mess in a nice way?

wwb
Aug 17, 2004

EDIT: original response sounds real wierd given how long it took and intervening posts. Lets try this again:

Yeah, best way to fix this would be to have a separate "release" branch in the source control server and a separate release configuration to build that branch. Failing that, you can easily setup the solution to put the GUI in a separate folder and using a .csproj file.

How we set stuff up is to do something like:

-Project/Source Control Root
--lib
---binary dependencies NOT covered by NuGet
--docs
---documentation and such
--build
---tools needed to build project
--src
---Packages
----for nuget stuff
---Solution.sln
---BuildScript.bat
---Build.xml
---MyCoreLibrary
----MyCoreLibrary.csproj
---MyCommandLineUtility
----MyCommandLineUtility.csproj
---MyWebsite
----MyWebsite.csproj

Would just update the library as a dependency in /lib just like anything else.

Keeping your shared library in the solution is not a half bad idea -- it makes things like using refactoring tools possible. If it just gets parachuted in by DLL, you have to manually fix code when the API changes.

wwb fucked around with this message at 20:36 on Feb 21, 2011

Piss Witch
Oct 23, 2005

Zhentar posted:

If you keep an array of the previous frame, then you can compare it to the contents of the current frame, and only redraw/clear the tiles that have changed.

The absolute worst thing about this is i have a method that exists that pretty much does this. Right now the only thing that forces a redraw is player movement (and a few other debug commands that don't really matter), i have a method set up that when the player moves, the previous coordinates are checked to see if they contained anything, if it does, it redraws it, if not it doesn't. This has eliminated the flicker and left me with a bit of an annoying bug, but i think i can get to the bottom of that.

Thanks for kickstarting my brain. :D

Dren
Jan 5, 2001

Pillbug
I've decided to do this
Project/src/Library/Library.csproj
Project/src/GUI/GUI.sln
Project/src/GUI/GUI.csproj
Project/src/TestTool/TestTool.sln
Project/src/TestTool/TestTool.csproj

Where my solutions include the library project.

To solve my CI server dependency problems I am going to create a dummy job that builds nothing but gets kicked off when the library changes. When the dummy job finishes it will kick off the jobs for the GUI and the Test tool.

Hardcoding the dependency structure in the CI server is not ideal but it seems better than any of the other solutions.

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.
I have a class with a public BindingList<Material> MaterialList get/set property and an associated UserControl that lets the user select a Material out of that BindingList via a drop-down comboBox.

By itself the UserControl compiles and works great, however when I try to add it to a Form the compiler starts generating a flurry of these errors:



This doesn't really point me to the location the error is occurring, but after Googling the error message it seems that the Designer is trying to serialize the BindingList property for some reason. The discussions of this error that I can find suggest adding one or the other of these two attributes to the BindingList property of the UserControl:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]

Unfortunately, neither of these attributes seem to do anything. Any ideas as to how to stop the Designer from messing with the BindingList?


edit: After playing around with it a little bit more it looks like the DesignerSerializationVisibility.Hidden attribute does work. When I put it in for the first time the Designer already contained a ton of mangled code that produced errors which made it look like the attribute was being ignored. Quitting and re-starting VS after adding the attribute fixed the issue.

PDP-1 fucked around with this message at 02:53 on Feb 23, 2011

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
I'm using BinarySerialization to serialize a class. But it seems to serialize properties:

code:
[Serializable]
public class TestObject
{
    public int TestProperty
    {
        get;
        private set;
    }
        
    ...
}
The value I set TestProperty to gets serialized. How can I make it so that it doesn't? I can't use [NonSerialized] because it isn't a field.

HappyHippo fucked around with this message at 03:49 on Feb 23, 2011

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

HappyHippo posted:

I'm using BinarySerialization to serialize a class. But it seems to serialize properties:

code:
[Serializable]
public class TestObject
{
    public int TestProperty
    {
        get;
        private set;
    }
        
    ...
}
The value I set TestProperty to gets serialized. How can I make it so that it doesn't? I can't use [NonSerialized] because it isn't a field.

You have to make it a full property to set attributes on it.

code:
[Serializable]
public class TestObject
{
    [NonSerialized]
    private int _testProperty;

    public int TestProperty
    {
        get { return _testProperty; }
    }
        
    ...
}

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
I was hoping that wouldn't be the case. Oh well.

Horse Cock Johnson
Feb 11, 2005

Speed has everything to do with it. You see, the speed of the bottom informs the top how much pressure he's supposed to apply. Speed's the name of the game.
Can anyone recommend an alternative drawing API to System.Drawing? What I need to be able to do is load up an image from disk, resize it, and draw rectangles on it - kind of like Facebook's tagging functionality. We currently do this just fine using System.Drawing but the whole thing will periodically poo poo itself with errors from GDI+ like "out of memory" or "a generic error occurred in GDI+".

I know the System.Windows.Media.Imaging namespace has some classes that I can work with but I'm just wondering if there's something better out there.

Mongolian Queef
May 6, 2004

Horse Cock Johnson posted:

Can anyone recommend an alternative drawing API to System.Drawing? What I need to be able to do is load up an image from disk, resize it, and draw rectangles on it - kind of like Facebook's tagging functionality. We currently do this just fine using System.Drawing but the whole thing will periodically poo poo itself with errors from GDI+ like "out of memory" or "a generic error occurred in GDI+".

I know the System.Windows.Media.Imaging namespace has some classes that I can work with but I'm just wondering if there's something better out there.

I can't really answer your question, but are you sure you dispose everything you create? I haven't had any problems and I use it to draw graphs onto live video for hours.

Edit: Actually I have had that exception, but I think it was related to loading an image from file and then trying to save it back. But that would happen all the time and not just sometimes.

Mongolian Queef fucked around with this message at 14:34 on Feb 23, 2011

Adbot
ADBOT LOVES YOU

_aaron
Jul 24, 2007
The underscore is silent.
WPF binding/filtering question:

I've got a view model with a boolean property (call it IsChecked). On another view model, there's an ObservableCollection of these objects. I want two have two list boxes in a window. One will display the entire collection of these objects as check boxes (bound to the IsChecked property), and the other will display only the items that are checked in the first list box. For example:

List 1     | List 2
+++++++++++++++++++++++
[x] Item 1 | Item 1
[ ] Item 2 | Item 3
[x] Item 3 | Item 4
[x] Item 4 |
[ ] Item 5 |


Can I somehow bind both of these list boxes to the same collection and specify some filter for the second list box?

  • Locked thread