Code Snippets
Assembly_GetVersion
public static string Assembly_GetVersion(
System.Reflection.Assembly objAssembly)
{
string GetVersion = "";
try
{
if (gbEND_GENERAL)
return GetVersion;
string slocation;
int iDebugAttributeLength;
string sDebugFlag = "";
slocation = objAssembly.Location;
objAssembly = System.Reflection.Assembly.LoadFrom(slocation);
iDebugAttributeLength = objAssembly
.GetCustomAttributes(typeof(System.Diagnostics.DebuggableAttribute), false)
.Length;
if (iDebugAttributeLength > 0)
sDebugFlag = "D";
if (iDebugAttributeLength == 0)
sDebugFlag = "R";
GetVersion =
System.Diagnostics.FileVersionInfo
.GetVersionInfo(slocation)
.ProductVersion
+ sDebugFlag;
}
catch (System.Runtime.InteropServices.COMException ex)
{
mobjCOMException = ex;
}
catch (Exception ex)
{
mobjException = ex;
}
finally
{
if (gbDEBUG_GENERAL_ERRMSG ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"GetVersion",
msCLASSNAME,
"",
mobjCOMException,
mobjException);
}
}
return GetVersion;
}
Graphics_FontNew
public static System.Drawing.Font Graphics_FontNew(
string sFontName,
float sngFontSize,
bool bBold,
bool bItalic,
bool bUnderline,
bool bStrikeout)
{
try
{
if (gbEND_GENERAL)
return null;
System.Drawing.Font objFont;
System.Drawing.FontStyle objFontStyle = 0;
if (bBold == false)
objFontStyle |= System.Drawing.FontStyle.Regular;
if (bBold == true)
objFontStyle |= System.Drawing.FontStyle.Bold;
if (bItalic == true)
objFontStyle |= System.Drawing.FontStyle.Italic;
if (bUnderline == true)
objFontStyle |= System.Drawing.FontStyle.Underline;
if (bStrikeout == true)
objFontStyle |= System.Drawing.FontStyle.Strikeout;
objFont = new System.Drawing.Font(sFontName, sngFontSize, objFontStyle);
return objFont;
}
catch (System.Runtime.InteropServices.COMException ex)
{
mobjCOMException = ex;
}
catch (Exception ex)
{
mobjException = ex;
}
finally
{
if (gbDEBUG_GENERAL ||
(mobjCOMException != null || mobjException != null))
{
clsError.Handle(
"FontNew",
msCLASSNAME,
"",
mobjCOMException,
mobjException);
}
}
return null;
}
Graphics_ReturnDrawingColor
public static System.Drawing.Color Graphics_ReturnDrawingColor(
string sColour)
{
try
{
if (gbEND_GENERAL)
return default(System.Drawing.Color);
System.Drawing.Color objColor = default(System.Drawing.Color);
switch (sColour.ToUpper())
{
case "WHITE":
objColor = System.Drawing.Color.White;
break;
case "YELLOW":
objColor = System.Drawing.Color.Yellow;
break;
}
return objColor;
}
catch (System.Runtime.InteropServices.COMException ex)
{
gobjCOMException = ex;
}
catch (Exception ex)
{
gobjException = ex;
}
finally
{
if (gbDEBUG_GENERAL ||
(gobjCOMException != null || gobjException != null))
{
clsError.Handle(
"ReturnDrawingColor",
"clsCmdBar",
"",
gobjCOMException,
gobjException);
}
}
return default(System.Drawing.Color);
}
Resource_SaveAs
public void Resource_SaveAs(
string sResourceFileName,
string sFolderPath,
string sFileName,
bool bDeleteIfExists,
bool bInformUser = true)
{
string sNameSpace;
System.IO.Stream objStream;
System.IO.FileStream objFileStream;
try
{
if (modGeneral.File_Exists(sFolderPath + sFileName, false))
{
if (bDeleteIfExists)
{
modGeneral.File_Delete(sFolderPath, sFileName, "");
}
else
{
if (bInformUser)
{
// tell user the file already exists and will be replaced
}
}
}
sNameSpace = System.Reflection.Assembly
.GetExecutingAssembly()
.GetName()
.Name
.ToString();
objStream = System.Reflection.Assembly
.GetExecutingAssembly()
.GetManifestResourceStream(sNameSpace + "." + sResourceFileName);
objFileStream = new System.IO.FileStream(
sFolderPath + sResourceFileName,
System.IO.FileMode.CreateNew);
if (objStream != null)
{
for (long lcount = 0; lcount <= objStream.Length - 1; lcount++)
{
objFileStream.WriteByte((byte)objStream.ReadByte());
}
}
objFileStream.Close();
}
catch (Exception ex)
{
modMessages.Exception(
System.Reflection.MethodBase.GetCurrentMethod(),
null,
ex);
}
}
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited Top