Monthly Archives: January 2018

Extract comments from a group of files in C#

I’m finishing up another book (I’ll announce it when it’s ready in a week or so) and I’m working through one of the thornier issues of any programming book: spell-checking code comments. I already have an example to extract comments … Continue reading

Posted in files, strings, syntax | Tagged , , , , , , , , , , , , | Leave a comment

Justify paragraphs in C#

This example adds the ability to justify paragraphs to the example The example Align text by lines in C#. This is a bit more complicated than aligning text on the left, right, or center. (I don’t know why Microsoft didn’t … Continue reading

Posted in fonts, graphics, printing, strings | Tagged , , , , , , , , , , , , , , | Leave a comment

Align text by lines in C#

The example Draw paragraphs one line at a time in C# shows how to draw the lines of a paragraph one at a time. Once you can do that, it’s a simple matter to align text one line at a … Continue reading

Posted in fonts, graphics, printing, strings | Tagged , , , , , , , , , , , , , | 1 Comment

Draw paragraphs one line at a time in C#

My next few posts show how to draw paragraphs on a Graphics object in various ways. The examples draw on PictureBox controls, but it’s important to remember that they work with any Graphics object including the one that you are … Continue reading

Posted in graphics, printing, strings | Tagged , , , , , , , , , , | 1 Comment

Print values in a grid in C#

This example prints a set of values in a grid. The following DrawValueGrid method does all of the printing. It’s long but the pieces are relatively simple. // Draw a grid containing the indicated values. private void DrawValueGrid(Graphics gr, RectangleF … Continue reading

Posted in graphics, printing | Tagged , , , , , , , , , , | Leave a comment

Use Word to make a PDF containing pictures in C#

The example Make a Word document containing pictures in C# shows how to make a Word document containing pictures taken from selected files. This example is similar to the that one (see that post for details) except it saves the … Continue reading

Posted in files, graphics, interoperability, Office, Word | Tagged , , , , , , , , , , , , , , , , | Leave a comment

Make a Word document containing pictures in C#

Occasionally you may want to combine selected pictures to make a Word document. This example shows one way you can search for files matching a pattern and then add them to a new Word document. This is a fairly long … Continue reading

Posted in files, graphics, interoperability, Office, Word | Tagged , , , , , , , , , , , , , , | 3 Comments

Quick tip: Use pinvoke.net to get information about API functions for use in C#

Platform Invocation Services (pinvoke) lets allows managed .NET code call unmanaged API functions that are implemented in a DLL. The functions in a DLL are exposed via an Application Programming Interface (API). The enormous .NET runtime library wraps many API … Continue reading

Posted in API | Tagged , , , , , , , , , , | Leave a comment

Find Visual Studio’s Immediate window

For some reason, the Immediate window seems to be a never-ending subject for Microsoft treasure hunts. It seems like each new release of Visual Studio moves the Immediate window to a new location buried deep within the menu hierarchy. In … Continue reading

Posted in IDE, Windows Forms programming | Tagged , , , , , , , | Leave a comment

Map device coordinates to world coordinates in C#

Sometimes it’s convenient to draw in one coordinate system (called world coordinates) and map those coordinates to the screen’s device coordinates. The example Map points between coordinate systems in C# shows how to do this in C#. For example, the … Continue reading

Posted in drawing, graphics, transformations | Tagged , , , , , , , , , , | Leave a comment