( Index )


Brief Information about the January 2016 CSIG Meeting

General Review of .NET Programs Covered Past Year ......    by B. Arnold

NEWS:   http:// www.techsupportalert.com /content/microsoft- visual-studio- now-free-non- commercial-use.htm

(General Csig Info)   


TreeMain Window
Sample     Sample     Sample     Sample    

Welcome to the CSIG, a Special Interest Group of the ACGNJ. This group is a "Special Interest Group" of the ACGNJ devoted to discussing programming languages in general and C, C++, and C++ for Windows programming in particular. Each month a small but hopefully useful program (complete with source code) is presented for discussion.

This month we will be reviewing the .NET programs that were discussed over the last 12 months using the latest Microsoft compilers. Most of the programs may be compiled using the C# .Net compiler included with Visual Studio as well as the free (!!!) Visual Studio Express compiler. Additionally, since C++ has many similarities with C# or C-Sharp, these compilers may also be used with modifications to the source files.

This is a CLI DOT NET program is coded using C-sharp (C#) and is very similar to C++.  It also still uses the same DOT NET libraries.

The program uses a number of DOT NET Library functions including the following:
DragDrop Windows Forms CLASSES Buttons
DialogResult GetDataPresent Image Close
Show Dispose C# Format
String Button_Click DOT NET Rectangle
Height Width MouseDown DragEnter
GetProperty PropertyInfo GetValue Graphics
Drawing2d SaveFileDialog MessageBox Visible
IntersectsWith Rectangle Intersect Stack
Stack.Push Stack.Pop Stack.Count Timer

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 4.5
C++ 9.0, etc.
.Net 4.5, etc.
Common Language Infrastructure

Sample Code

namespace Crop { public partial class Form1 : Form { public Form1() { InitializeComponent(); } ////////////////////////////// ////////////////////////////////// // // Suffix _SC = Screen Coordinates // Suffix _CC = Client Coordinates // Rectangle cropRectangle_CC; Point startPoint_CC; bool isDrag = false; bool fileChanged = false; ////////////////////////////// ////////////////////////////////// // // Drag and Drop step 3 of 3. The users releases the mouse to drop the image. // private void Form1_DragDrop(object sender, DragEventArgs e) { if (fileChanged) // Prompt user. { // Title = Bad Result // Default Button = No // Message = Caution System.Windows.Forms.DialogResult Result; Result = MessageBox.Show(this, "Cropped Image will be Disregarded! Continue?", "Drop New File", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (Result != System.Windows.Forms.DialogResult.Yes) return; } if (e.Data.GetDataPresent(DataFormats.FileDrop)) { if (this.pictureBox1.Image != null) this.pictureBox1.Image.Dispose(); // Get a list of filenames but use only the 1st name. string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); if (files.Length > 0) { files[0] = files[0].ToLower(); if (files[0].EndsWith(".jpg")) { try { this.pictureBox1.Image = Image.FromFile(files[0]); imageData.Text = String.Format("{0} x {1}", pictureBox1.Image.Width, pictureBox1.Image.Height); fileChanged = false; this.pictureBox1.Visible = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "E R R O R"); return; } } } } this.Activate(); } // Drag and Drop step 2 of 3. The users drags the image into the program's GUI. // Note: Step 1 is Form1 AllowDrop property has been set to true. // private void Form1_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy; else e.Effect = DragDropEffects.None; }


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