Code (csharp) Select
/// <summary>
/// Exit tool strip menu item click.
/// </summary>
private void ExitToolStripMenuItem_Click(object sender, EventArgs e)
{
// Close
Close();
}
/// <summary>
/// Launches web browser to BetSelection.cc
/// </summary>
void LlWeb_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
// Launch site
Process.Start("http://betselection.cc");
}
/// <summary>
/// Add module
/// </summary>
private void BAdd_Click(object sender, EventArgs e)
{
// Set listbox
ListBox lb = null;
switch (((Button)sender).Tag.ToString())
{
// Utilities
case "nUtilities":
lb = lbUtilities;
break;
// Input
case "nInput":
lb = lbInput;
break;
// Bet selection
case "nBS":
lb = lbBS;
break;
// Money management
case "nMM":
lb = lbMM;
break;
// Display
case "nDisplay":
lb = lbDisplay;
break;
// Output
case "nOutput":
lb = lbOutput;
break;
}
// Check there's something to add
if (lb.SelectedIndex > -1)
{
// Declare string for item text
String itemText;
// Iterate selected items
foreach (Object sel in lb.SelectedItems)
{
// Make string
itemText = sel as String;
// Check if it's unique
if (!tvLaunch.Nodes[((Button)sender).Tag.ToString()].Nodes.ContainsKey(itemText))
{
// Add to TreeView
tvLaunch.Nodes[((Button)sender).Tag.ToString()].Nodes.Add(itemText, itemText);
}
}
}
// Change status text
tsslStatus.Text = "2) Set launch order, then click 'Launch'";
// Enable
tvLaunch.Enabled = true;
bUp.Enabled = true;
bDown.Enabled = true;
bDelete.Enabled = true;
bLaunch.Enabled = true;
// Expand all nodes
tvLaunch.ExpandAll();
}
/// <summary>
/// Moves selected module up in TreeView
/// </summary>
void BUp_Click(object sender, EventArgs e)
{
// Check it isn't null
if (tvLaunch.SelectedNode != null && tvLaunch.SelectedNode.Parent != null && tvLaunch.SelectedNode.Index > 0)
{
// Suspend redraws
tvLaunch.SuspendLayout();
// Save selected node
TreeNode node = tvLaunch.SelectedNode;
// Set parent
TreeNode parent = tvLaunch.SelectedNode.Parent;
// Set index
int index = tvLaunch.SelectedNode.Index;
// Remove it
parent.Nodes.RemoveAt(index);
// Insert it again
parent.Nodes.Insert(index - 1, node);
//select the node
tvLaunch.SelectedNode = parent.Nodes[index - 1];
// Resume redrawing
tvLaunch.ResumeLayout();
// Refresh
tvLaunch.Refresh();
}
// Focus treeview
tvLaunch.Focus();
}
/// <summary>
/// Moves selected module down in TreeView
/// </summary>
void BDown_Click(object sender, EventArgs e)
{
// Check it isn't null
if (tvLaunch.SelectedNode != null && tvLaunch.SelectedNode.Parent != null && tvLaunch.SelectedNode.Index < tvLaunch.SelectedNode.Parent.Nodes.Count - 1)
{
// Suspend redraws
tvLaunch.SuspendLayout();
// Save selected node
TreeNode node = tvLaunch.SelectedNode;
// Set parent
TreeNode parent = tvLaunch.SelectedNode.Parent;
// Set index
int index = tvLaunch.SelectedNode.Index;
// Remove it
parent.Nodes.RemoveAt(index);
// Insert it again
parent.Nodes.Insert(index + 1, node);
//select the node
tvLaunch.SelectedNode = tvLaunch.SelectedNode.Parent.Nodes[index + 1];
// Resume redrawing
tvLaunch.ResumeLayout();
// Refresh
tvLaunch.Refresh();
}
// Focus treeview
tvLaunch.Focus();
}
/// <summary>
/// Launch button
/// </summary>
private void BLaunch_Click(object sender, EventArgs e)
{
// Namespace string
string nSpace = string.Empty;
/* Assign */
/* Utilities */
foreach (TreeNode tn in tvLaunch.Nodes["nUtilities"].Nodes)
{
// Set namespace
nSpace = DisplayNameToNameSpace(tn.Text);
// Load assembly
Assembly asm = Assembly.LoadFile(GetDllPath(tn.Text, "Utilities", tags["Utilities"][nSpace]));
// Add to Utilities dict
Modules.Utilities.Dict.Add(nSpace, asm);
// Add to Utilities list
Modules.Utilities.List.Add(nSpace);
// Utilities module
Modules.Utilities.Dict[nSpace].GetType(nSpace + ".Comm").GetMethod("Init", BindingFlags.Static | BindingFlags.Public).Invoke(null, new object[] { Data.NameSpace });
}
/* Input */
foreach (TreeNode tn in tvLaunch.Nodes["nInput"].Nodes)
{
// Set namespace
nSpace = DisplayNameToNameSpace(tn.Text);
// Load assembly
Assembly asm = Assembly.LoadFile(GetDllPath(tn.Text, "Input", tags["Input"][nSpace]));
// Add to input dict
Modules.Input.Dict.Add(nSpace, asm);
// Add to input list
Modules.Input.List.Add(nSpace);
// Init module
Modules.Input.Dict[nSpace].GetType(nSpace + ".Comm").GetMethod("Init", BindingFlags.Static | BindingFlags.Public).Invoke(null, new object[] { Data.NameSpace });
}
/* Bet Selection */
foreach (TreeNode tn in tvLaunch.Nodes["nBS"].Nodes)
{
// Set namespace
nSpace = DisplayNameToNameSpace(tn.Text);
// Load assembly
Assembly asm = Assembly.LoadFile(GetDllPath(tn.Text, "BetSelection", tags["BetSelection"][nSpace]));
// Add to Bet Selection dict
Modules.BS.Dict.Add(nSpace, asm);
// Add to Bet Selection list
Modules.BS.List.Add(nSpace);
// Init module
Modules.BS.Dict[nSpace].GetType(nSpace + ".Comm").GetMethod("Init", BindingFlags.Static | BindingFlags.Public).Invoke(null, new object[] { Data.NameSpace });
}
/* Money Management */
foreach (TreeNode tn in tvLaunch.Nodes["nMM"].Nodes)
{
// Set namespace
nSpace = DisplayNameToNameSpace(tn.Text);
// Load assembly
Assembly asm = Assembly.LoadFile(GetDllPath(tn.Text, "MoneyManagement", tags["MoneyManagement"][nSpace]));
// Add to Money Management dict
Modules.MM.Dict.Add(nSpace, asm);
// Add to Money Management list
Modules.MM.List.Add(nSpace);
// Init module
Modules.MM.Dict[nSpace].GetType(nSpace + ".Comm").GetMethod("Init", BindingFlags.Static | BindingFlags.Public).Invoke(null, new object[] { Data.NameSpace });
}
/* Display */
foreach (TreeNode tn in tvLaunch.Nodes["nDisplay"].Nodes)
{
// Set namespace
nSpace = DisplayNameToNameSpace(tn.Text);
// Load assembly
Assembly asm = Assembly.LoadFile(GetDllPath(tn.Text, "Display", tags["Display"][nSpace]));
// Add to display dict
Modules.Display.Dict.Add(nSpace, asm);
// Add to display list
Modules.Display.List.Add(nSpace);
// Init module
Modules.Display.Dict[nSpace].GetType(nSpace + ".Comm").GetMethod("Init", BindingFlags.Static | BindingFlags.Public).Invoke(null, new object[] { Data.NameSpace });
}
/* Output */
foreach (TreeNode tn in tvLaunch.Nodes["nOutput"].Nodes)
{
// Set namespace
nSpace = DisplayNameToNameSpace(tn.Text);
// Load assembly
Assembly asm = Assembly.LoadFile(GetDllPath(tn.Text, "Output", tags["Output"][nSpace]));
// Add to Output dict
Modules.Output.Dict.Add(nSpace, asm);
// Add to Output list
Modules.Output.List.Add(nSpace);
// Init module
Modules.Output.Dict[nSpace].GetType(nSpace + ".Comm").GetMethod("Init", BindingFlags.Static | BindingFlags.Public).Invoke(null, new object[] { Data.NameSpace });
}
/* Re-enable (a bit more efficient than comparing on every iteration) */
// Enable link
llWeb.Enabled = true;
// Change color
lWeb.ForeColor = Color.Red;
// Enable web label
lWeb.Enabled = true;
// Enabe status label
ss.Enabled = true;
// Set status label
tsslStatus.Text = "3) Close program when finished. --Or visit our web!";
}
/// <summary>
/// Remove currently selected module from tree
/// </summary>
private void BDelete_Click(object sender, EventArgs e)
{
// Check it isn't null
if (tvLaunch.SelectedNode != null && tvLaunch.SelectedNode.Parent != null)
{
// Delete node
tvLaunch.SelectedNode.Remove();
}
}
/// <summary>
/// Changes a display name to its .dll representation
/// </summary>
private string GetDllPath(string displayName, string folder)
{
return string.Empty;
}
/// <summary>
/// Changes a display name to its .dll representation
/// </summary>
private string GetDllPath(string displayName, string folder, string subfolder)
{
// Check strings are there
if (displayName.Length > 0 && folder.Length > 0)
{
// Replace and return
return appDir + folder + Path.DirectorySeparatorChar + subfolder + Path.DirectorySeparatorChar + DisplayNameToNameSpace(displayName) + ".dll";
}
// Return empty string by default
return String.Empty;
}
/// <summary>
/// Load event for main form
/// </summary>
void MainForm_Load(object sender, EventArgs e)
{
// Select tpInput
tcMain.SelectedTab = tpInput;
/* Handle options */
// Always on top
if (alwaysOntopToolStripMenuItem.Checked)
{
// On top
this.TopMost = true;
}
/* Event handlers */
// Buttons
Button[] buttons = new Button[] { bAddBS, bAddDisplay, bAddInput, bAddMM, bAddOut, bAddUtilities };
// Handler
foreach (Button b in buttons)
{
// Attach
b.Click += new EventHandler(BAdd_Click);
}
// Load modules
LoadModules(false);
}
/// <summary>
/// Handles form closing
/// </summary>
void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
// Check if must ask
if (askOnExitToolStripMenuItem.Checked)
{
// Ask
if (MessageBox.Show("Would you like to exit now?", "Confirm exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes)
{
// Cancel form close
e.Cancel = true;
// Exit procedure
return;
}
}
/* Save XML */
// Instantiate XmlTextWriter
XmlTextWriter writer = new XmlTextWriter(xmlFile, null);
// Set formatting
writer.Formatting = Formatting.Indented;
writer.Indentation = 4;
// Document start
writer.WriteStartDocument();
// Root start
writer.WriteStartElement("BetSoftware");
// Options start
writer.WriteStartElement("Options");
// Write options
foreach (ToolStripMenuItem tsmi in optionsToolStripMenuItem.DropDownItems)
{
// Save checked status
writer.WriteElementString(tsmi.Name.Replace("ToolStripMenuItem", ""), tsmi.CheckState.ToString());
}
// Options end
writer.WriteEndElement();
// Root start
writer.WriteEndElement();
// Document end
writer.WriteEndDocument();
// Close writer
writer.Close();
}
/// <summary>
/// Generic event handler for ToolStripMenuItem
/// </summary>
void ToolStripMenuItem_Click(object sender, EventArgs e)
{
// Toggle
((ToolStripMenuItem)sender).Checked = !((ToolStripMenuItem)sender).Checked;
}
/// <summary>
/// Shows about form
/// </summary>
void AboutToolStripMenuItem_Click(object sender, EventArgs e)
{
// Display about msg
MessageBox.Show("Coded by Victor/VLS for BetSelection.cc" + Environment.NewLine + Environment.NewLine + "(2014-04-02 / Version 0.1)", "About BetSoftware", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
/// <summary>
/// Sets TopMost
/// </summary>
void alwaysOntopToolStripMenuItem_Click(object sender, EventArgs e)
{
// Set
this.TopMost = !alwaysOntopToolStripMenuItem.Checked;
// Toggle
ToolStripMenuItem_Click(sender, e);
}
/// <summary>
/// Check/creates directories and loads modules
/// </summary>
private void LoadModules(bool init)
{
// Temporary string array
string[] tempSA;
// List of string to hold modules
List<string> mods = new List<string>();
// Prepare or clear tags
SetTags();
/* Clear listboxes */
lbUtilities.Items.Clear();
lbInput.Items.Clear();
lbBS.Items.Clear();
lbMM.Items.Clear();
lbDisplay.Items.Clear();
lbOutput.Items.Clear();
/* Utilities */
// Check for an existent directory
if (!Directory.Exists(appDir + "Utilities"))
{
// Not present, create it
Directory.CreateDirectory(appDir + "Utilities");
// Create subdirectories for games
Directory.CreateDirectory(appDir + "Utilities" + Path.DirectorySeparatorChar + "Roulette");
Directory.CreateDirectory(appDir + "Utilities" + Path.DirectorySeparatorChar + "Baccarat");
}
else if (!init)
{
/* Add modules to Utilities list */
// Append current game modules to list
if (Directory.Exists(appDir + "Utilities" + Path.DirectorySeparatorChar + UpperFirst(Data.Game)))
{
// Current game
tempSA = Directory.GetFiles(appDir + "Utilities" + Path.DirectorySeparatorChar + UpperFirst(Data.Game), "*.dll");
// Populate
for (int i = 0; i < tempSA.Length; i++)
{
// Add current module to list
mods.Add(tempSA[i]);
// Set matching current module tag
tags["Utilities"].Add(DisplayNameToNameSpace(GetDisplayNameFromPath(tempSA[i])), UpperFirst(Data.Game));
}
}
// Iterate mods
foreach (string mod in mods)
{
// Get file name
lbUtilities.Items.Add(GetDisplayNameFromPath(mod));
}
// Set module counter
if (lbUtilities.Items.Count > 0)
{
// Display count
tpUtilities.Text = "Util. (" + lbUtilities.Items.Count + ")";
}
else
{
// Initial label
tpUtilities.Text = "Utilities";
}
}
/* Input */
// Check for an existent directory
if (!Directory.Exists(appDir + "Input"))
{
// Not present, create it
Directory.CreateDirectory(appDir + "Input");
// Create subdirectories for games
Directory.CreateDirectory(appDir + "Input" + Path.DirectorySeparatorChar + "Roulette");
Directory.CreateDirectory(appDir + "Input" + Path.DirectorySeparatorChar + "Baccarat");
}
else if (!init)
{
/* Add modules to input list */
// Clear list
mods.Clear();
// Append current game modules to list
if (Directory.Exists(appDir + "Input" + Path.DirectorySeparatorChar + UpperFirst(Data.Game)))
{
// Current game
tempSA = Directory.GetFiles(appDir + "Input" + Path.DirectorySeparatorChar + UpperFirst(Data.Game), "*.dll");
// Populate
for (int i = 0; i < tempSA.Length; i++)
{
// Add current module to list
mods.Add(tempSA[i]);
// Set matching current module tag
tags["Input"].Add(DisplayNameToNameSpace(GetDisplayNameFromPath(tempSA[i])), UpperFirst(Data.Game));
}
}
// Iterate
foreach (string mod in mods)
{
// Get file name
lbInput.Items.Add(GetDisplayNameFromPath(mod));
}
// Set module counter
if (lbInput.Items.Count > 0)
{
// Display count
tpInput.Text = "Input (" + lbInput.Items.Count + ")";
}
else
{
// Initial label
tpInput.Text = "Input";
}
}
/* BetSelection */
// Check for an existent directory
if (!Directory.Exists(appDir + "BetSelection"))
{
// Not present, create it
Directory.CreateDirectory(appDir + "BetSelection");
// Create subdirectories for games
Directory.CreateDirectory(appDir + "BetSelection" + Path.DirectorySeparatorChar + "Roulette");
Directory.CreateDirectory(appDir + "BetSelection" + Path.DirectorySeparatorChar + "Baccarat");
}
else if (!init)
{
/* Add modules to BetSelection list */
// Clear list
mods.Clear();
// Append current game modules to list
if (Directory.Exists(appDir + "BetSelection" + Path.DirectorySeparatorChar + UpperFirst(Data.Game)))
{
// Current game
tempSA = Directory.GetFiles(appDir + "BetSelection" + Path.DirectorySeparatorChar + UpperFirst(Data.Game), "*.dll");
// Populate
for (int i = 0; i < tempSA.Length; i++)
{
// Add current module to list
mods.Add(tempSA[i]);
// Set matching current module tag
tags["BetSelection"].Add(DisplayNameToNameSpace(GetDisplayNameFromPath(tempSA[i])), UpperFirst(Data.Game));
}
}
// Iterate mods
foreach (string mod in mods)
{
// Get file name
lbBS.Items.Add(GetDisplayNameFromPath(mod));
}
// Set module counter
if (lbBS.Items.Count > 0)
{
// Display count
tpBS.Text = "Bet S. (" + lbBS.Items.Count + ")";
}
else
{
// Initial label
tpBS.Text = "Bet S.";
}
}
/* MoneyManagement */
// Check for an existent directory
if (!Directory.Exists(appDir + "MoneyManagement"))
{
// Not present, create it
Directory.CreateDirectory(appDir + "MoneyManagement");
// Create subdirectories for games
Directory.CreateDirectory(appDir + "MoneyManagement" + Path.DirectorySeparatorChar + "Roulette");
Directory.CreateDirectory(appDir + "MoneyManagement" + Path.DirectorySeparatorChar + "Baccarat");
}
else if (!init)
{
/* Add modules to MoneyManagement list */
// Clear list
mods.Clear();
// Append current game modules to list
if (Directory.Exists(appDir + "MoneyManagement" + Path.DirectorySeparatorChar + UpperFirst(Data.Game)))
{
// Current game
tempSA = Directory.GetFiles(appDir + "MoneyManagement" + Path.DirectorySeparatorChar + UpperFirst(Data.Game), "*.dll");
// Populate
for (int i = 0; i < tempSA.Length; i++)
{
// Add current module to list
mods.Add(tempSA[i]);
// Set matching current module tag
tags["MoneyManagement"].Add(DisplayNameToNameSpace(GetDisplayNameFromPath(tempSA[i])), UpperFirst(Data.Game));
}
}
// Iterate mods
foreach (string mod in mods)
{
// Get file name
lbMM.Items.Add(GetDisplayNameFromPath(mod));
}
// Set module counter
if (lbMM.Items.Count > 0)
{
// Display count
tpMM.Text = "Mon. M. (" + lbMM.Items.Count + ")";
}
else
{
// Initial label
tpMM.Text = "Mon. M.";
}
}
/* Display */
// Check for an existent directory
if (!Directory.Exists(appDir + "Display"))
{
// Not present, create it
Directory.CreateDirectory(appDir + "Display");
// Create subdirectories for games
Directory.CreateDirectory(appDir + "Display" + Path.DirectorySeparatorChar + "Roulette");
Directory.CreateDirectory(appDir + "Display" + Path.DirectorySeparatorChar + "Baccarat");
}
else if (!init)
{
/* Add modules to Display list */
// Clear list
mods.Clear();
// Append current game modules to list
if (Directory.Exists(appDir + "Display" + Path.DirectorySeparatorChar + UpperFirst(Data.Game)))
{
// Current game
tempSA = Directory.GetFiles(appDir + "Display" + Path.DirectorySeparatorChar + UpperFirst(Data.Game), "*.dll");
// Populate
for (int i = 0; i < tempSA.Length; i++)
{
// Add current module to list
mods.Add(tempSA[i]);
// Set matching current module tag
tags["Display"].Add(DisplayNameToNameSpace(GetDisplayNameFromPath(tempSA[i])), UpperFirst(Data.Game));
}
}
// Iterate mods
foreach (string mod in mods)
{
// Get file name
lbDisplay.Items.Add(GetDisplayNameFromPath(mod));
}
// Set module counter
if (lbDisplay.Items.Count > 0)
{
// Display count
tpDisplay.Text = "Disp. (" + lbDisplay.Items.Count + ")";
}
else
{
// Initial label
tpDisplay.Text = "Display";
}
}
/* Output */
// Check for an existent directory
if (!Directory.Exists(appDir + "Output"))
{
// Not present, create it
Directory.CreateDirectory(appDir + "Output");
// Create subdirectories for games
Directory.CreateDirectory(appDir + "Output" + Path.DirectorySeparatorChar + "Roulette");
Directory.CreateDirectory(appDir + "Output" + Path.DirectorySeparatorChar + "Baccarat");
}
else if (!init)
{
/* Add modules to Output list */
// Clear list
mods.Clear();
// Append current game modules to list
if (Directory.Exists(appDir + "Output" + Path.DirectorySeparatorChar + UpperFirst(Data.Game)))
{
// Current game
tempSA = Directory.GetFiles(appDir + "Output" + Path.DirectorySeparatorChar + UpperFirst(Data.Game), "*.dll");
// Populate
for (int i = 0; i < tempSA.Length; i++)
{
// Add current module to list
mods.Add(tempSA[i]);
// Set matching current module tag
tags["Output"].Add(DisplayNameToNameSpace(GetDisplayNameFromPath(tempSA[i])), UpperFirst(Data.Game));
}
}
// Iterate mods
foreach (string mod in mods)
{
// Get file name
lbOutput.Items.Add(GetDisplayNameFromPath(mod));
}
// Set module counter
if (lbOutput.Items.Count > 0)
{
// Display count
tpOutput.Text = "Output (" + lbOutput.Items.Count + ")";
}
else
{
// Initial label
tpOutput.Text = "Output";
}
}
}
/// <summary>
/// Prepares tags dictionary
/// </summary>
private void SetTags()
{
// Check if there's something
if (tags.Count > 0)
{
// Clear 'em
tags.Clear();
}
// Populate base
tags.Add("Utilities", new Dictionary<string, string>());
tags.Add("Input", new Dictionary<string, string>());
tags.Add("BetSelection", new Dictionary<string, string>());
tags.Add("MoneyManagement", new Dictionary<string, string>());
tags.Add("Display", new Dictionary<string, string>());
tags.Add("Output", new Dictionary<string, string>());
}
/// <summary>
/// Changes a path to its display name representation
/// </summary>
private string GetDisplayNameFromPath(string filePath)
{
// Check there's something to act upon
if (filePath.Length > 0)
{
// File name without extension
string FileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath);
// Make replacements
string displayName = NameSpaceToDisplayName(FileNameWithoutExtension);
// Return proper Display Name
return displayName;
}
// Return empty string by default
return String.Empty;
}
/// <summary>
/// Changes a display name to namespace
/// </summary>
private string DisplayNameToNameSpace(string displayName)
{
// Check strings are there
if (displayName.Length > 0)
{
// Match with regular expression
MatchCollection matches = Regex.Matches(displayName, @"[^a-zA-Z0-9_]");
// Walk reversed
for (int i = matches.Count - 1; i >= 0; i--)
{
// Handle space
if (matches[i].Value == " ")
{
// Remove original
displayName = displayName.Remove(matches[i].Index, 1);
// Insert replacement
displayName = displayName.Insert(matches[i].Index, "__");
// Next iteration
continue;
}
// Set encoding
UTF32Encoding encoding = new UTF32Encoding();
// Get current bytes
byte[] bytes = encoding.GetBytes(matches[i].Value.ToCharArray());
// Remove original
displayName = displayName.Remove(matches[i].Index, 1);
// Insert replacement
displayName = displayName.Insert(matches[i].Index, "_" + BitConverter.ToInt32(bytes, 0).ToString() + "_");
}
// Return processed display name
return displayName;
}
// Return empty string by default
return String.Empty;
}
/// <summary>
/// Changes namespace to display name by naming convention
/// </summary>
/// <param name="nameSpace">string Passed namespace</param>
/// <returns>String with replacements</returns>
private string NameSpaceToDisplayName(string nameSpace)
{
// Match with regular expression
MatchCollection matches = Regex.Matches(nameSpace, @"_[0-9]+_");
// Walk reversed
for (int i = matches.Count - 1; i >= 0; i--)
{
/* Validate odd underscores */
// Counter
int count = 0;
// Get underscores
for (int j = matches[i].Index; j >= 0; j--)
{
// Check for non-underscore
if (nameSpace[j].ToString() != "_")
{
// Halt flow
break;
}
// Rise counter
count++;
}
// Check for odd
if ((count % 2) == 0)
{
// Move to next iteration
continue;
}
// Convert
try
{
// Declare
Int32 int32Val;
// Parse from string
if (Int32.TryParse(matches[i].Value.Replace("_", ""), NumberStyles.Integer, null, out int32Val))
{
// Remove original
nameSpace = nameSpace.Remove(matches[i].Index, matches[i].Length);
// Insert replacement
nameSpace = nameSpace.Insert(matches[i].Index, char.ConvertFromUtf32(int32Val).ToString());
}
}
catch (Exception e)
{
// Let is fall through
}
}
// Replace double-space with single
nameSpace = nameSpace.Replace("__", " ");
// Processed namespace back
return nameSpace;
}
/// <summary>
/// Converts passed string's first letter to uppercase
/// </summary>
/// <param name="text">String to work with</param>
/// <returns>String with first letter in uppercase and the rest in lowercase</returns>
private string UpperFirst(string text)
{
// Check there's something to work with
if (text.Length > 1)
{
// Make title case
text = text[0].ToString().ToUpper() + text.Substring(1).ToLower();
}
// Return
return text;
}
/// <summary>
/// The entry point of the program, where the program control starts and ends.
/// </summary>
[STAThread]
public static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
}