|
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Drawing;
using System.Reflection;
namespace AutoDiagramer
{
#region Program CLASS
/// <summary>
/// provides the main access point, and several global variables
/// that may be set from the <see cref="frmSettings">frmSettings</see>
/// form. This class also provides several global methods
/// </summary>
public static class Program
{
#region Instance Fields
//used to effect what is drawn on the class diagram
public static bool _IncludeInterfaces = false;
public static bool _FullConstructorDescribe = true;
public static bool _IncludeFieldType = true;
public static bool _IncludeMethodArgs = true;
public static bool _IncludeMethodReturnType = true;
public static bool _IncludePropValues = true;
public static bool _IncludeEventType = true;
public static bool _AllowEnumOnDiagram = false;
public static bool _AllowDelegatesOnDiagram = false;
public static bool _ShowPropGetters=false;
public static bool _ShowPropSetters=false;
public static int _MAX_Columns = 5;
public static Color _ClassStartColor = Color.LightGray;
public static Color _ClassEndColor = Color.White;
public static Color _ClassBorderColor = Color.SteelBlue;
public static string _BindingFlags="All";
public static string _appVersion = "1.9";
public static bool _isStandAloneApp=false;
private static Random rand = new Random();
#endregion
#region MAIN ENTRY POINT
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmMain());
}
#endregion
#region Public Methods
/// <summary>
/// Gets the user specified BindingFlags that are used to gather reflective information about
/// inidividual Types, within the AnalyseType method of the <see cref="DrawableClass">
/// DrawableClass</see>
/// </summary>
public static BindingFlags RequiredBindings
{
get
{
//start with some initial BindingFlags
BindingFlags bf = BindingFlags.Instance | BindingFlags.DeclaredOnly |
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static;
//do a siwtch
switch (_BindingFlags)
{
case "All":
bf = BindingFlags.Instance | BindingFlags.DeclaredOnly |
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static;
break;
case "Public Only":
bf = BindingFlags.Instance | BindingFlags.DeclaredOnly |
BindingFlags.Public;
break;
case "Public and Static":
bf = BindingFlags.Instance | BindingFlags.DeclaredOnly |
BindingFlags.Public | BindingFlags.Static;
break;
default :
bf = BindingFlags.Instance | BindingFlags.DeclaredOnly |
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static;
break;
}
//return the result
return bf;
}
}
/// <summary>
/// InputBox, returns user input string
/// </summary>
/// <param name="prompt">the prompt</param>
/// <param name="title">the form title</param>
/// <param name="defaultValue">the default value to use</param>
/// <returns>the string the user entered</returns>
public static string InputBox(string prompt,
string title, string defaultValue)
{
InputBoxDialog ib = new InputBoxDialog();
ib.FormPrompt = prompt;
ib.FormCaption = title;
ib.DefaultValue = defaultValue;
ib.ShowDialog();
string s = ib.InputResponse;
ib.Close();
return s;
}
/// <summary>
/// Gets a random number in the range 0.0 - upperLimit
/// </summary>
/// <param name="upperLimit">the random upper limit to return</param>
/// <returns>A random number in the range 0.0 - upperLimit</returns>
public static int GetRandom(int upperLimit)
{
return (int)rand.NextDouble() * upperLimit;
}
/// <summary>
/// Shows an error message within a MessageBox
/// </summary>
/// <param name="error">the error message</param>
public static void ErrorBox(string error)
{
MessageBox.Show(error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
/// <summary>
/// Shows an information message within a MessageBox
/// </summary>
/// <param name="error">the information message</param>
public static void InfoBox(string info)
{
MessageBox.Show(info, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
/// <summary>
/// Shows a Yes/No query within a MessageBox
/// </summary>
/// <param name="query">the query message</param>
/// <returns>DialogResult, which is the result of the Confirmation query</returns>
public static DialogResult YesNoBox(string query)
{
return MessageBox.Show(query,
"Confirmation", MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
}
#endregion
}
#endregion
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I currently hold the following qualifications (amongst others, I also studied Music Technology and Electronics, for my sins)
- MSc (Passed with distinctions), in Information Technology for E-Commerce
- BSc Hons (1st class) in Computer Science & Artificial Intelligence
Both of these at Sussex University UK.
Award(s)
I am lucky enough to have won a few awards for Zany Crazy code articles over the years
- Microsoft C# MVP 2016
- Codeproject MVP 2016
- Microsoft C# MVP 2015
- Codeproject MVP 2015
- Microsoft C# MVP 2014
- Codeproject MVP 2014
- Microsoft C# MVP 2013
- Codeproject MVP 2013
- Microsoft C# MVP 2012
- Codeproject MVP 2012
- Microsoft C# MVP 2011
- Codeproject MVP 2011
- Microsoft C# MVP 2010
- Codeproject MVP 2010
- Microsoft C# MVP 2009
- Codeproject MVP 2009
- Microsoft C# MVP 2008
- Codeproject MVP 2008
- And numerous codeproject awards which you can see over at my blog