( Index )
Month

 

Brief Information about the October 2015 CSIG Meeting

Sort Uniq - A Simple Sorting Program in VS2015 - Sort and Remove Duplicates

by Bruce Arnold

(General Csig Info)    This month's application is a Microsoft C-sharp program that deals with logic and graphics. We will also be discussing the latest Microsoft free compiler Visual Studio 2015. This new software has many new industry features such as:

Visual Studio Community 2015
Framework .NET 4.6
Support for Windows, Linux, and Os X
DotNet Open Source on Github
Support for all phones
C# Version 6
Code syntax simplification like string formatting
Website: gethub.com/dotnet/roslyn
Universal Windows Apps: Phones, Tablets, Raspberry Pi, etc.




Sample


 

Welcome to the CSIG, a Special Interest Group of the ACGNJ. This is an exciting time for the C Language programming since Microsoft now has 4 different language compilers: C++, C++ Express, C-Sharp, and C-Sharp Express. These are all capable of creating Windows (tm) programs. (Some are FREE!)

The program for this month simply reads a file into the listbox and then optionally sorts it with several options. We will discuss the creation of the graphics window as well as the code that handles the buttons and other operations.  The program as written is well suited for handling text files up to about 50,000 lines. Above that size changes are required to make the program more responsive to the user.  Next month, I plan to increase the complexity of the program by discussing the need for background threads.  Programmers can get a head start by checking the following web site:  "http://stuff.seans.com/2009/05/21/net-basics-do-work-in-background-thread-to-keep-gui-responsive/"


There are a number of ways to refer to Microsoft's latest compilers and code. Here's what Wikipedia says: The Common Language Infrastructure (CLI) is an open specification developed by Microsoft that describes the executable code and runtime environment that form the core of the Microsoft .NET Framework. The specification defines an environment that allows multiple high-level languages to be used on different computer platforms without being rewritten for specific architectures.

Microsoft .Net Framework 3.5
C++ 9.0
.Net 3.5
CLI
Common Language Infrastructure
Managed

Sample Code from Previous Meetings

        //
        //   Paint Message Handler
        //
        private void Form1_Paint(System.Object sender, System.Windows.Forms.PaintEventArgs e)
            {
            Rectangle windowRect = ClientRectangle;   // Get size of window.
            Graphics g = e.Graphics;

            g.FillEllipse(BalloonBrush,               // Fill the whole balloon with color
                BalloonCenter.X - BalloonRadius,
                BalloonCenter.Y - BalloonRadius,
                2 * BalloonRadius,
                2 * BalloonRadius);
            g.DrawEllipse(Pens.Black,               // Draw a black line around it.
                BalloonCenter.X - BalloonRadius,
                BalloonCenter.Y - BalloonRadius,
                2 * BalloonRadius,
                2 * BalloonRadius);
            g.DrawEllipse(Pens.White,               // Draw a white line around it.
                BalloonCenter.X - BalloonRadius - 1,
                BalloonCenter.Y - BalloonRadius - 1,
                2 * BalloonRadius + 2,
                2 * BalloonRadius + 2);

            Font mFont = new Font("Arial", 24, FontStyle.Bold);
            string mstring = "Catch Me!";
            SizeF mFontSize = g.MeasureString(mstring, mFont);
            g.DrawString(mstring, mFont,
                Brushes.Yellow,
                (float)BalloonCenter.X - (mFontSize.Width / 2),
                (float)BalloonCenter.Y - (mFontSize.Height / 2));
            }


        //
        // Randomize the center of the balloon
        //
        Point Form1_GetRandPoint(Rectangle rr)
            {
            Point pp = new Point();
            if ((rr.Right - rr.Left) < 1 || (rr.Bottom - rr.Top) < 1)
                {
                pp.X = 0;
                pp.Y = 0; return pp;   // trap potential   d i v i d e  by zero
                }
            pp.X = rr.Left + pRand.Next(rr.Right - rr.Left + 1);
            pp.Y = rr.Top + pRand.Next(rr.Bottom - rr.Top + 1);
            return pp;
            }


        //
        // Randomize the color of the Balloon to descrete values.
        //
        Color Form1_GetRandColor()
            {
            int[] arg = new int[3];
            arg[0] = 0; arg[1] = 128; arg[2] = 192;
            int[] alpha = new int[3];
            alpha[0] = 0xEF; alpha[1] = 0xF0; alpha[2] = 0xFF;
            return Color.FromArgb(
                alpha[2],               // leave alpha solid.
                arg[pRand.Next(3)],
                arg[pRand.Next(3)],
                arg[pRand.Next(3)]
            );
            }


SOURCE CODE

Source Code Files

For help, email me at b a r n o l d @ i e e e . o r g
Back to C++ Main Page