Windows In WPF can make use of a property which makes the window to automatically adjust its own size to fit its content. The related property in WPF is
SizeToContent which can be set to
Manual (the default),
WidthAndHeight. The last item makes the window shrink or grow so that it will fit its content.
The same effect can be made in Windows Forms using the
AutoSizeMode properties of the form. Simply set
true and also do not forget to set
GrowAndShrink. This effect is not visualized during design.
The following pieces of code help you figure out how two intervals overlap, and provides tools to represent them in a way that is useful for debugging purposes. This job is quite easy to accomplish, but since it is written too frequently each time from scratch, I have put them in this gist.
IntervalOverlapKinds.cs file defines the
IntervalOverlapKinds enumeration. The interval detection is carried out in the static methods of the
This piece of code is useful if you intend to work on a string processing algorithm. There are times, that you need to see the real content of a string while showing them in a windows form, console, and so on. This little method may help:
Suppose that you intend to find a string or a token (i.e., whole word, instead of a substring) and change their color in some
RichTextBox. The following code snippets will help. The
FindStringAndSetColor method looks for instances of an arbitrary string in the contents of the
RichTextBox, while the
FindTokenAndSetColor method looks for whole words (tokens).