Files
cameramanager/CSharpLibrary/FormsInterfaces/GeneralLibrary.cs
T
2025-05-15 16:01:31 +02:00

71 lines
1.5 KiB
C#

/***************************************************/
//
//
/***************************************************/
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Globalization;
namespace IPadLibrary.FormsInterfaces {
/// <summary>
/// Collect all general porpouse routines used by forms.
/// </summary>
class GeneralLibrary {
/// <summary>
/// Used to drawing the Form borders only.
/// </summary>
public static void DrawFormBorder(object sender, PaintEventArgs e) {
Graphics g = e.Graphics;
Form f = (Form) sender;
Size drawArea = new Size(f.ClientSize.Width, f.ClientSize.Height);
// Drawing the cornice
g.DrawRectangle(Pens.Black, 0, 0, drawArea.Width-1, drawArea.Height-1);
g.DrawRectangle(Pens.White, 1, 1, drawArea.Width-3, drawArea.Height-3);
g.DrawRectangle(Pens.LightGray, 2, 2, drawArea.Width-5, drawArea.Height-5);
}
public static string float2string(float num) {
return String.Format("{0:0.00}", num).Replace(',','.');
}
public static float string2float(string text) {
return float.Parse( text, new NumberFormatInfo() );
}
public static PointF convertStr2Point(string xstr, string ystr) {
NumberFormatInfo nfi = new NumberFormatInfo(); // Number Format Info used for '.'
float x, y;
x = float.Parse( xstr, nfi );
y = float.Parse( ystr, nfi );
return ( new PointF(x, y) );
}
public static bool isNegative(float num) {
return ( num < 0.0f );
}
} // end class
} // end namespace