Thread: Favourite program

  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    10

    Favourite program

    I was just curious as to what everyones favourite C# program was. Either a program that they have seen or one they have written themselves...

    You may have spent weeks and possibly months writing it. You may as well tell us all ;-)

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    I wrote a web-crawler to try and track down useless and pointless threads on this board so that I could avoid them.

    Damn thing doesn't work

  3. #3
    Registered User
    Join Date
    Jul 2010
    Posts
    10

    programming

    lol.

    Well it is a general discussion as the forum name suggests and I was just asking people about their favourite programs(whether they had written them themselves or had just seen them)

  4. #4
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    I'm only written a handful of real applications in C# and I typically don't muck around with other's source code unless I'm contributing to the project (which, in the case of C#, I haven't).

    I guess my favorite C# program that I wrote was a graphing calculator for Windows Mobile. It started out simple and I just kept adding features, ultimately performing some simple single-variable calculus (derivation, integration, etc), geometric classification based on partial side/angle data, and a pretty neat "Show work" tool that broke down each of the steps of a particular calculation and explained what and why it did everything it did in the order it did it.

    I stopped it quite a while ago and only dug it up again not too long ago to cosmetically improve the interface (I believe I posted something here regarding that). Anyway, I'd say that was the one I had the most fun with.
    Sent from my iPadŽ

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    This was actually a Silverlight program that I saw, but it was basically a server that allowed two AI clients to play each other in chess through the server. What made this entertaining was that the AI clients were written in JavaScript, which basically allowed you to have various browsers play each other - an interesting way to compare JS engine speeds! According to the presenter, the results were pretty consistent regarding which browser was a better chess player.

  6. #6
    Registered User
    Join Date
    Jul 2010
    Posts
    10

    Favourite programs

    Thats pretty impressive.

    I loved Calculus at school and I would love to have the time to write a program like that!


    Quote Originally Posted by SlyMaelstrom View Post
    I'm only written a handful of real applications in C# and I typically don't muck around with other's source code unless I'm contributing to the project (which, in the case of C#, I haven't).

    I guess my favorite C# program that I wrote was a graphing calculator for Windows Mobile. It started out simple and I just kept adding features, ultimately performing some simple single-variable calculus (derivation, integration, etc), geometric classification based on partial side/angle data, and a pretty neat "Show work" tool that broke down each of the steps of a particular calculation and explained what and why it did everything it did in the order it did it.

    I stopped it quite a while ago and only dug it up again not too long ago to cosmetically improve the interface (I believe I posted something here regarding that). Anyway, I'd say that was the one I had the most fun with.

  7. #7
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    639
    Quote Originally Posted by progcomputeach View Post
    Thats pretty impressive.

    I loved Calculus at school and I would love to have the time to write a program like that!
    What if you didn't post the same questions to every software forum under the sun? You might have then.

    I can't help but get the impression of you being a work experience spammer, they've given you access to the tools but they won't let you start linking to stuff yet

  8. #8
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    A new generation of bots... kind, articulate and somewhat elusive of their true nature of a bot.
    The people behind them are however the same imbeciles they always were.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  9. #9
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    You guys are being pretty hard on this guy... given his board name, I'd imagine he's just posting around trying to research and get ideas for his class.
    Sent from my iPadŽ

  10. #10
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    I guess. I even missed the fact he actually already replied on the thread.
    Please, accept my apologies, progcomputeach. And my thanks to you, too: I prefer to be happily wrong than sadly right.

    My favorite program in C# -- and the one I had most fun doing so far -- was a Rapid Data Entry Application for a known pharmaceutical. You can read all about it here (although in retrospect I could have entered into a bit more detail about it).
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  11. #11
    Make Fortran great again
    Join Date
    Sep 2009
    Posts
    1,413
    IronPython.net /

    Makes doing boring SharePoint work a snap.

  12. #12
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    A more robust version of this one was eventually incorporated into a professional product (I don't have the rights to release the improvements, unfortunately). It's basically just a command-line based WMI object browser. Not the most advanced program, but nonetheless useful.

    Code:
    /*
        Windows Management Instrumentation Enumerator
        [Generates output compatible with the DMTF's Managed Object Format (MOF)]
        Copyright (c) 2009 Sebastian Garth
    
        THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 
        NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
        IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 
        WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
        SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.    
        
        TODO: 
        - Provide connection options (username, password, authentication, timeout, etc.)
        - Detect qualifier 'flavors'
        - Generalize the class so that output is written to any TextWriter object        
    */
    using System;
    using System.Collections;
    using System.Management;
    
    class WmiEnumerator
    {
        public class Option
        {
            public enum Category
            {        
                Definitions, 
                Properties,
                Methods,
                Qualifiers,
                Instances, 
            /*
                IMPORTANT: New option enumerations *must* be added before ProgramOptionCount.
            */                
                ProgramOptionCount
            };
    
            public string Name;
            public bool Enabled;
            public string Description;
            
            public Option( string Name, bool Enabled, string Description )
            {
                this.Name = Name;
                this.Enabled = Enabled;
                this.Description = Description;
            }
        };
        
        Option [ ] ProgramOptions = new Option[ ( int )Option.Category.ProgramOptionCount ];
    
        static void Main( string [ ] CommandLine )
        {
            new WmiEnumerator( CommandLine );
        }
    
        WmiEnumerator( string [ ] CommandLine  )
        {
        /*
            IMPORTANT: Option names *must* be all lowercase (this doesn't apply to user input, however). 
        */
            ProgramOptions[ ( int )Option.Category.Definitions ] = new Option( "definitions", true, "List class definitions" );
            ProgramOptions[ ( int )Option.Category.Properties ] = new Option( "properties", true, "List class member properties" );
            ProgramOptions[ ( int )Option.Category.Methods ] = new Option( "methods", true, "List class member methods" );
            ProgramOptions[ ( int )Option.Category.Qualifiers ] = new Option( "qualifiers", true, "List class/property/method metadata" );
        /*
            NOTE: Enumerating some types of instances generates a huge amount of output, 
            while others cause the program to hang for a while, so this option is disabled, by default.
        */        
            ProgramOptions[ ( int )Option.Category.Instances ] = new Option( "instances", false, "List class instances (use selectively)" );        
            if( CommandLine.Length == 0 )
            {
                Console.WriteLine( @"Usage: [-[<OPTION>][<MODIFIER>]] [\\<SERVER>][\<NAMESPACE(S)>][:<CLASSNAME>]" );
                Console.WriteLine( "Example: wmie.exe root" );
                Console.WriteLine( "Note: Multiple classes/namespaces can be specified, each with custom options" );
                Console.WriteLine( "Option modifiers:" );
                Console.WriteLine( "\t+ : Enable option" );
                Console.WriteLine( "\t- : Disable option" );            
                Console.WriteLine( "Note: If no modifier is specified, option is enabled" );
                Console.WriteLine( "Options:" );
                for( int Index = 0; Index < ProgramOptions.Length; ++Index )
                {
                    Console.WriteLine
                    ( 
                        "\t" + ProgramOptions[ Index ].Name + " : " + ProgramOptions[ Index ].Description 
                        + 
                        " [default: " + ( ProgramOptions[ Index ].Enabled ? "on" : "off" ) + "]" 
                    );
                }
                Console.WriteLine( "Note: Partial option names may be used (if unambiguous)" );
            }
            else foreach( string Command in CommandLine )
            {
                try
                {
                /*
                    NOTE: If the user supplies mangled input that even remotely resembles an option, an IndexOutOfRange exception might
                    be thrown. We'll just leave it up to the exception handler report this, rather than go to extremes to detect it here.
                */            
                    if( Command[ 0 ] == '-' )
                    {        
                        bool OptionState = true;
                        int LastIndex = Command.Length - 1; 
                        char OptionModifier = Command[ LastIndex ];
                        if( OptionModifier == '+' )
                        {
                            --LastIndex;                        
                        }
                        else if( OptionModifier == '-' )
                        {
                            --LastIndex;
                            OptionState = false;
                        }
                        string SelectedOption = Command.Substring( 1, LastIndex ).ToLower( );
                    /*
                        Since partial matches of option names are allowed, we need to ensure that the substring doesn't match multiple options.
                    */
                        int 
                            OptionMatches = 0, 
                            MatchedOptionIndex = 0;
                        for( int Index = 0; Index < ProgramOptions.Length; ++Index )
                        {
                            if( ProgramOptions[ Index ].Name.IndexOf( SelectedOption ) == 0 )
                            {
                                ++OptionMatches;
                                MatchedOptionIndex = Index;
                            }
                        }
                        if( OptionMatches == 1 )
                        {
                            ProgramOptions[ MatchedOptionIndex ].Enabled = OptionState;
                        }
                        else if( OptionMatches > 1 )
                        {
                            throw new Exception( "Ambiguous request for option '" + SelectedOption + "'" );
                        }
                        else/* OptionMatches == 0 */
                        {
                            throw new Exception( "Invalid option '" + SelectedOption + "'" );
                        }                
                    }
                    else
                    {
                        ManagementClass CimClassCategory = new ManagementClass( Command );
                        if( CimClassCategory.Path.IsClass )
                        {
                            PrintClassInformation( CimClassCategory );
                        }
                        else 
                        {
                            EnumerationOptions CimClassEnumerationOptions = new EnumerationOptions( );
                            CimClassEnumerationOptions.EnumerateDeep = true;                        
                            foreach( ManagementClass NextCimClassCategory in CimClassCategory.GetSubclasses( CimClassEnumerationOptions ) )
                            {
                                PrintClassInformation( NextCimClassCategory );                    
                            }
                        }    
                    }    
                }
            /*
                NOTE: Exceptions thrown due to invalid/unservicable WBEM requests are simply reported and then processing continues normally, 
                while malformed option switches, memory access faults, etc, are treated as fatal errors, thus forcing the program to abort.
            */
                catch( ManagementException ManagementExceptionObject )
                {
                    Console.Write( "\nError: " + ManagementExceptionObject.Message );
                }            
                catch( Exception GeneralExceptionObject )
                {
                    Console.Write( "\nFatal: " + GeneralExceptionObject.Message );
                    break;
                }
            }
        }
    
        void PrintClassInformation( ManagementClass CimClassCategory )
        {
            int 
            /*
                Number of spaces per tab.
            */
                DefaultTabSize = 4, 
            /*
                NOTE: To ensure uniform formatting, ClassCategoryIndentation should be some multiple of DefaultTabSize.
            */
                ClassCategoryIndentation = DefaultTabSize * 0, 
                ClassMemberIndentation = Math.Max( ClassCategoryIndentation * 2, DefaultTabSize );
            if( ProgramOptions[ ( int )Option.Category.Definitions ].Enabled )    
            {
                if( ProgramOptions[ ( int )Option.Category.Qualifiers ].Enabled )
                {
                    PrintQualifiers( CimClassCategory.Qualifiers, ClassCategoryIndentation );
                }
                object CimClassSuperclassNameValue = CimClassCategory.SystemProperties[ "__SUPERCLASS" ].Value;
                Console.Write
                ( 
                    GenerateTabString( ClassCategoryIndentation ) + "class " + CimClassCategory.Path.ClassName 
                    + 
                    ( CimClassSuperclassNameValue  == null ? "" :  " : " + CimClassSuperclassNameValue.ToString( ) ) + "\n" 
                    +
                    GenerateTabString( ClassCategoryIndentation ) + "{\n\n" 
                );
                if( ProgramOptions[ ( int )Option.Category.Properties ].Enabled )
                {
                    foreach( PropertyData CimClassProperty in CimClassCategory.Properties )
                    {
                        if( ProgramOptions[ ( int )Option.Category.Qualifiers ].Enabled )
                        {
                            PrintQualifiers( CimClassProperty.Qualifiers, ClassMemberIndentation );    
                        }
                        Console.Write
                        ( 
                            GenerateTabString( ClassMemberIndentation ) + ExpandTypeNameText( CimClassProperty ) + " " 
                            + 
                            CimClassProperty.Name 
                            + 
                            ( 
                                CimClassProperty.Value == null ? "" : " = " + ExpandTypeValueText( CimClassProperty.Value ) 
                            ) 
                            + 
                            ";\n\n"
                        );
                    }
                }    
                if( ProgramOptions[ ( int )Option.Category.Methods ].Enabled )
                {
                    foreach( MethodData CimClassMethod in CimClassCategory.Methods )
                    {
                        if( ProgramOptions[ ( int )Option.Category.Qualifiers ].Enabled )
                        {
                            PrintQualifiers( CimClassMethod.Qualifiers, ClassMemberIndentation );        
                        }                
                        int CimClassMethodOutParameterCount = 
                            CimClassMethod.OutParameters == null ? 0 : CimClassMethod.OutParameters.Properties.Count;
                        PropertyData [ ] CimClassMethodOutParameters = null;
                    /*
                        Print the function return type. If there are more 'out' values, they will be printed as method parameters.
                    */    
                        Console.Write( GenerateTabString( ClassMemberIndentation ) );    
                        if( CimClassMethodOutParameterCount > 0 )
                        {                        
                            CimClassMethod.OutParameters.Properties.CopyTo
                            ( 
                                CimClassMethodOutParameters = new PropertyData[ CimClassMethodOutParameterCount ], 0 
                            );
                            Console.Write( ExpandTypeNameText( CimClassMethodOutParameters[ 0 ] ) + " " );
                        }                
                        Console.Write( CimClassMethod.Name + "(" );
                    /*
                        If non-zero, OutputComma simply indicates that a comma needs to be output before the next parameter.
                    */    
                        int OutputComma = 0;
                        if( CimClassMethod.InParameters != null )
                        {
                            foreach( PropertyData CimClassMethodInParameter in CimClassMethod.InParameters.Properties )
                            {
                                if( OutputComma++ != 0 )
                                {
                                    Console.Write( "," );
                                }
                                Console.Write
                                ( 
                                    " [ IN ] " + ExpandTypeNameText( CimClassMethodInParameter ) + " " 
                                    + 
                                    CimClassMethodInParameter.Name 
                                );
                            }                
                        }
                        if( CimClassMethodOutParameterCount > 1 )
                        {
                        /*
                            We need to skip the first 'out' parameter, since it has already been printed.
                        */
                            for( int Index = 1; Index < CimClassMethodOutParameterCount; ++Index )
                            {                    
                                if( OutputComma++ != 0 )
                                {
                                    Console.Write( "," );
                                }
                                Console.Write
                                ( 
                                    " [ OUT ] " + ExpandTypeNameText( CimClassMethodOutParameters[ Index ] ) + " " 
                                    + 
                                    CimClassMethodOutParameters[ Index ].Name 
                                );
                            }
                        }    
                        Console.Write( " );\n\n" );
                    }        
                }    
                Console.Write( GenerateTabString( ClassCategoryIndentation ) + "};\n\n" );
            }    
            if( ProgramOptions[ ( int )Option.Category.Instances ].Enabled )
            {
                foreach( ManagementObject CimClassInstance in CimClassCategory.GetInstances( ) ) 
                {
                    Console.Write( GenerateTabString( ClassCategoryIndentation ) + "instance of " + CimClassCategory.Path.ClassName + "\n{\n\n" );
                    foreach( PropertyData CimClassInstanceProperty in CimClassInstance.Properties )
                    {                
                        Console.Write
                        ( 
                            GenerateTabString( ClassMemberIndentation ) + ExpandTypeNameText( CimClassInstanceProperty ) + " " 
                            + 
                            CimClassInstanceProperty.Name + " = " 
                            + 
                            ( 
                                CimClassInstanceProperty.Value == null ? "null" : ExpandTypeValueText( CimClassInstanceProperty.Value ) 
                            )  
                            + 
                            ";\n\n"
                        ); 
                    }
                    Console.Write( GenerateTabString( ClassCategoryIndentation ) + "};\n\n" );
                }
            }    
        }
        
        void PrintQualifiers( QualifierDataCollection CimQualifierCollection, int Indentation )
        {
            if( CimQualifierCollection.Count != 0 )
            {
                Console.Write( GenerateTabString( Indentation ) + "[ " );
                int Index = 0;
                foreach( QualifierData CimQualifier in CimQualifierCollection )
                {
                    if( Index++ != 0 )
                    {
                        Console.Write( ", " );
                    }
                    Console.Write( CimQualifier.Name );
                    if( CimQualifier.Value != null )
                    {
                        Console.Write( "( " + ExpandTypeValueText( CimQualifier.Value ) + " )" );
                    }
                }
                Console.Write( " ]\n" );            
            }
        }
        
        static string GenerateTabString( int NumberOfSpaces )
        {
            string TabString = "";
            while( NumberOfSpaces-- > 0 )
            {
                TabString += " ";
            }
            return TabString;    
        }
    
        static string ExpandTypeNameText( PropertyData Property )
        {
            int CimValueNameOffest = 4;
            string PropertyTypeNameText = null;
            string OptionalArrayBrackets = Property.IsArray ? " [ ]" : "";
            if( Property.Type == CimType.Reference )
            {
                PropertyTypeNameText = Property.Qualifiers[ "CIMTYPE" ].Value.ToString( ).Substring( CimValueNameOffest ) 
                + 
                OptionalArrayBrackets + " ref";
            }
            else
            {
                PropertyTypeNameText = Property.Type.ToString( ) + OptionalArrayBrackets;
            }
            return PropertyTypeNameText;    
        }    
        
        static string ExpandTypeValueText( object Object )
        {
            string ExpandedText = null;
            if( Object.GetType( ).IsArray )
            {
                ExpandedText = ExpandTypeArrayValuesText_( Object );
            }                    
            else if( Convert.GetTypeCode( Object ) == TypeCode.String )
            {
                ExpandedText = "\"" + Object.ToString( ) + "\"";
            }    
            else if( Convert.GetTypeCode( Object ) == TypeCode.Char )
            {
                ExpandedText = "'" + Object.ToString( ) + "'";
            }        
            else
            {
                ExpandedText = Object.ToString( );
            }
            return ExpandedText;
        }        
        
    /*
        NOTE: ExpandTypeArrayValuesText_ and ExpandTypeArrayValuesTextIfIsOfType_ should only be called from within ExpandTypeValueText. 
    */
        static string ExpandTypeArrayValuesText_( object Object )
        {
            bool Validated = false;
            string ExpandedText = null;
            ExpandTypeArrayValuesTextIfIsOfType_< System.Object >( Object, ref ExpandedText, ref Validated );
            ExpandTypeArrayValuesTextIfIsOfType_< System.Char >( Object, ref ExpandedText, ref Validated );
            ExpandTypeArrayValuesTextIfIsOfType_< System.String >( Object, ref ExpandedText, ref Validated );        
            ExpandTypeArrayValuesTextIfIsOfType_< System.Boolean >( Object, ref ExpandedText, ref Validated );
            ExpandTypeArrayValuesTextIfIsOfType_< System.Byte >( Object, ref ExpandedText, ref Validated );
            ExpandTypeArrayValuesTextIfIsOfType_< System.SByte >( Object, ref ExpandedText, ref Validated );
            ExpandTypeArrayValuesTextIfIsOfType_< System.UInt16 >( Object, ref ExpandedText, ref Validated );
            ExpandTypeArrayValuesTextIfIsOfType_< System.Int16 >( Object, ref ExpandedText, ref Validated );
            ExpandTypeArrayValuesTextIfIsOfType_< System.UInt32 >( Object, ref ExpandedText, ref Validated );
            ExpandTypeArrayValuesTextIfIsOfType_< System.Int32 >( Object, ref ExpandedText, ref Validated );
            ExpandTypeArrayValuesTextIfIsOfType_< System.UInt64 >( Object, ref ExpandedText, ref Validated );
            ExpandTypeArrayValuesTextIfIsOfType_< System.Int64 >( Object, ref ExpandedText, ref Validated );
            ExpandTypeArrayValuesTextIfIsOfType_< System.Single >( Object, ref ExpandedText, ref Validated );
            ExpandTypeArrayValuesTextIfIsOfType_< System.Double >( Object, ref ExpandedText, ref Validated );
        /*
            This exception should *never* occur. If it does then there is a bug in the program logic.
        */
            if( !Validated )
            {
                throw new Exception( "Logic error: unsupported type conversion" );
            }        
            return ExpandedText;
        }
    
        static void ExpandTypeArrayValuesTextIfIsOfType_< Type >( object Object, ref string ExpandedText, ref bool Validated )
        {
            if( !Validated )
            {
                Validated = true;
                Type [ ] ArrayOfType = null;
                try 
                { 
                    ArrayOfType = ( Type [ ] )Object; 
                }
                catch( Exception ) 
                { 
                    Validated = false;
                }
                if( Validated )
                {
                    ExpandedText = "{ ";
                    for( int Index = 0; Index < ArrayOfType.Length; ++Index )
                    {                            
                        if( Index != 0 )
                        {
                            ExpandedText += ", ";
                        }                
                        ExpandedText += ExpandTypeValueText( ArrayOfType[ Index ] );
                    }
                    ExpandedText += " }";                    
                }
            }
        }
    };
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  13. #13
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Sebastiani doesn't hold back the details.
    Sent from my iPadŽ

  14. #14
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    My favorite C# program? None. Not a single one.
    They're all junk. Pure and utter junk, if you ask me. Only junk comes from a junk programming language. Don't quote me on that, though. That's an opinion.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  15. #15
    That weird Java guy xniinja's Avatar
    Join Date
    Jun 2010
    Posts
    231
    my favorite program programed with c#?
    halo 3 servers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. Replies: 3
    Last Post: 03-04-2005, 02:46 PM