diff --git a/Enigma.sln b/Enigma.sln index b4cd551..7734ff9 100644 --- a/Enigma.sln +++ b/Enigma.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Enigma", "Enigma\Enigma.csproj", "{64F7824B-48B9-40FE-BAD7-B2DF49BFCEA8}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EnigmaX", "EnigmaX\EnigmaX.csproj", "{9C277A65-39FE-466D-8AE9-4B3A12A5E61E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {64F7824B-48B9-40FE-BAD7-B2DF49BFCEA8}.Debug|Any CPU.Build.0 = Debug|Any CPU {64F7824B-48B9-40FE-BAD7-B2DF49BFCEA8}.Release|Any CPU.ActiveCfg = Release|Any CPU {64F7824B-48B9-40FE-BAD7-B2DF49BFCEA8}.Release|Any CPU.Build.0 = Release|Any CPU + {9C277A65-39FE-466D-8AE9-4B3A12A5E61E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9C277A65-39FE-466D-8AE9-4B3A12A5E61E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9C277A65-39FE-466D-8AE9-4B3A12A5E61E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9C277A65-39FE-466D-8AE9-4B3A12A5E61E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Enigma/App.config b/Enigma/App.config index 88fa402..0fac5cd 100644 --- a/Enigma/App.config +++ b/Enigma/App.config @@ -1,6 +1,11 @@ - + - \ No newline at end of file + + + + + + \ No newline at end of file diff --git a/Enigma/Form1.Designer.cs b/Enigma/DebugForm.Designer.cs similarity index 91% rename from Enigma/Form1.Designer.cs rename to Enigma/DebugForm.Designer.cs index efefc70..0a5d856 100644 --- a/Enigma/Form1.Designer.cs +++ b/Enigma/DebugForm.Designer.cs @@ -1,6 +1,6 @@ namespace Enigma { - partial class Form1 + partial class DebugForm { /// /// Required designer variable. @@ -30,13 +30,13 @@ { this.SuspendLayout(); // - // Form1 + // DebugForm // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1094, 652); - this.Name = "Form1"; - this.Text = "Form template thing"; + this.Name = "DebugForm"; + this.Text = "Debug Form"; this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false); diff --git a/Enigma/Form1.cs b/Enigma/DebugForm.cs similarity index 84% rename from Enigma/Form1.cs rename to Enigma/DebugForm.cs index 2897817..942f47b 100644 --- a/Enigma/Form1.cs +++ b/Enigma/DebugForm.cs @@ -11,9 +11,9 @@ using MetroFramework.Forms; namespace Enigma { - public partial class Form1 : MetroForm + public partial class DebugForm : MetroForm { - public Form1() + public DebugForm() { InitializeComponent(); } diff --git a/Enigma/Form1.resx b/Enigma/DebugForm.resx similarity index 100% rename from Enigma/Form1.resx rename to Enigma/DebugForm.resx diff --git a/Enigma/Enigma.csproj b/Enigma/Enigma.csproj index a787220..5640412 100644 --- a/Enigma/Enigma.csproj +++ b/Enigma/Enigma.csproj @@ -45,6 +45,10 @@ ..\packages\MetroModernUI.1.4.0.0\lib\net\MetroFramework.Fonts.dll True + + ..\packages\MySql.ConnectorNET.Data.6.8.3.2\lib\net45\MySql.Data.dll + True + @@ -58,16 +62,16 @@ - + Form - - Form1.cs + + DebugForm.cs - - Form1.cs + + DebugForm.cs ResXFileCodeGenerator diff --git a/Enigma/Program.cs b/Enigma/Program.cs index 52308df..c866293 100644 --- a/Enigma/Program.cs +++ b/Enigma/Program.cs @@ -17,7 +17,7 @@ namespace Enigma { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Form1()); + Application.Run(new DebugForm()); } } } diff --git a/Enigma/packages.config b/Enigma/packages.config index bad4c3f..ee93edb 100644 --- a/Enigma/packages.config +++ b/Enigma/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file diff --git a/EnigmaX/Classes/DBConnect.cs b/EnigmaX/Classes/DBConnect.cs new file mode 100644 index 0000000..4b2a0fd --- /dev/null +++ b/EnigmaX/Classes/DBConnect.cs @@ -0,0 +1,150 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using MySql.Data.MySqlClient; + +namespace EnigmaX +{ + public class DBConnect + { + + private MySqlConnection connection; + + public DBConnect() + { + Initialize(); + } + + private void Initialize() + { + connection = new MySqlConnection("Server=4156.hostgator.com; database=ttech_enigma; UID=ttech_enigma; password=JaQE7eKrY4Rr"); + } + + private bool OpenConnection() + { + + try + { + connection.Open(); + return true; + } + catch (MySqlException ex) + { + //When handling errors, you can your application's response based + //on the error number. + //The two most common error numbers when connecting are as follows: + //0: Cannot connect to server. + //1045: Invalid user name and/or password. + switch (ex.Number) + { + case 0: + //GlobalFunctions.showDialog("Database Error", "Couldn't connect to the Database.", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); + break; + + case 1045: + // GlobalFunctions.showDialog("Database Error", "Database Credentials are Incorrect", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); + break; + } + return false; + } + + } + + private bool CloseConnection() + { + + try + { + connection.Close(); + return true; + } + catch (MySqlException ex) + { + // GlobalFunctions.showDialog("Database Error", ex.ToString(), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); + return false; + } + + } + + public void WriteCommand(string str) + { + + if (this.OpenConnection() == true) + { + //create command and assign the query and connection from the constructor + MySqlCommand cmd = new MySqlCommand(str, connection); + + //Execute command + cmd.ExecuteNonQuery(); + + //close connection + this.CloseConnection(); + } + + } + + public List> ReadCommand(string str, params string[] collect) + { + + List> total = new List>(); + + if (this.OpenConnection() == true) + { + //Create Command + MySqlCommand cmd = new MySqlCommand(str, connection); + //Create a data reader and Execute the command + MySqlDataReader dataReader = cmd.ExecuteReader(); + + //Read the data and store them in the list + while (dataReader.Read()) + { + Dictionary tmp = new Dictionary(); + foreach (string t in collect) + { + tmp.Add(t, dataReader[t] + ""); + } + total.Add(tmp); + } + + //close Data Reader + dataReader.Close(); + + //close Connection + this.CloseConnection(); + + //return list to be displayed + return total; + } + else + { + return total; + } + + } + + /*public string ReadSingleCommand(string str) { + + if (this.OpenConnection() == true) + { + //Create Mysql Command + MySqlCommand cmd = new MySqlCommand(str, connection); + + //ExecuteScalar will return one value + Count = int.Parse(cmd.ExecuteScalar() + ""); + + //close Connection + this.CloseConnection(); + + return Count; + } + else + { + return Count; + } + + }*/ + + } + } diff --git a/EnigmaX/Classes/XMessageBox.cs b/EnigmaX/Classes/XMessageBox.cs new file mode 100644 index 0000000..4f5e370 --- /dev/null +++ b/EnigmaX/Classes/XMessageBox.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EnigmaX.Classes +{ + public class XMessageBox + { + private string _title = ""; + private string _message = ""; + private string[] _buttons; + + public XMessageBox(string title, string message, string leftButton, string rightButton = "") { + + _title = title; + _message = message; + _buttons = new string[] { leftButton, rightButton }; + + } + + public int showMessage() { + XMessageBoxForm window = new XMessageBoxForm(_title, _message, _buttons[0], _buttons[1]); + var dialog = window.ShowDialog(); + if (dialog == System.Windows.Forms.DialogResult.OK) + { + if (window.returnValue.Equals("primary")) + { + return 0; + } + else + { + return 1; + } + } + else { + return -1; + } + } + + + } +} diff --git a/EnigmaX/EnigmaX.csproj b/EnigmaX/EnigmaX.csproj new file mode 100644 index 0000000..3a98211 --- /dev/null +++ b/EnigmaX/EnigmaX.csproj @@ -0,0 +1,88 @@ + + + + + Debug + AnyCPU + {9C277A65-39FE-466D-8AE9-4B3A12A5E61E} + Library + Properties + EnigmaX + EnigmaX + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\MetroModernUI.1.4.0.0\lib\net\MetroFramework.dll + True + + + ..\packages\MetroModernUI.1.4.0.0\lib\net\MetroFramework.Design.dll + True + + + ..\packages\MetroModernUI.1.4.0.0\lib\net\MetroFramework.Fonts.dll + True + + + ..\packages\MySql.ConnectorNET.Data.6.8.3.2\lib\net45\MySql.Data.dll + True + + + + + + + + + + + + + + + + + + Form + + + XMessageBoxForm.cs + + + + + + + + + XMessageBoxForm.cs + + + + + \ No newline at end of file diff --git a/EnigmaX/Forms/XMessageBoxForm.Designer.cs b/EnigmaX/Forms/XMessageBoxForm.Designer.cs new file mode 100644 index 0000000..b9055d3 --- /dev/null +++ b/EnigmaX/Forms/XMessageBoxForm.Designer.cs @@ -0,0 +1,90 @@ +namespace EnigmaX +{ + partial class XMessageBoxForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.primaryButton = new MetroFramework.Controls.MetroButton(); + this.secondaryButton = new MetroFramework.Controls.MetroButton(); + this.message_text = new MetroFramework.Controls.MetroLabel(); + this.SuspendLayout(); + // + // primaryButton + // + this.primaryButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.primaryButton.Location = new System.Drawing.Point(550, 272); + this.primaryButton.Name = "primaryButton"; + this.primaryButton.Size = new System.Drawing.Size(193, 29); + this.primaryButton.TabIndex = 0; + this.primaryButton.Text = "metroButton1"; + this.primaryButton.UseSelectable = true; + this.primaryButton.Click += new System.EventHandler(this.primaryButton_Click); + // + // secondaryButton + // + this.secondaryButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.secondaryButton.Location = new System.Drawing.Point(351, 272); + this.secondaryButton.Name = "secondaryButton"; + this.secondaryButton.Size = new System.Drawing.Size(193, 29); + this.secondaryButton.TabIndex = 1; + this.secondaryButton.Text = "metroButton2"; + this.secondaryButton.UseSelectable = true; + this.secondaryButton.Click += new System.EventHandler(this.secondaryButton_Click); + // + // message_text + // + this.message_text.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.message_text.Location = new System.Drawing.Point(23, 60); + this.message_text.Name = "message_text"; + this.message_text.Size = new System.Drawing.Size(720, 209); + this.message_text.TabIndex = 2; + this.message_text.Text = "metroLabel1"; + // + // XMessageBox + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(766, 324); + this.Controls.Add(this.message_text); + this.Controls.Add(this.secondaryButton); + this.Controls.Add(this.primaryButton); + this.Name = "XMessageBox"; + this.Text = "XMessageBox"; + this.Load += new System.EventHandler(this.XMessageBox_Load); + this.ResumeLayout(false); + + } + + #endregion + + private MetroFramework.Controls.MetroButton primaryButton; + private MetroFramework.Controls.MetroButton secondaryButton; + private MetroFramework.Controls.MetroLabel message_text; + } +} \ No newline at end of file diff --git a/EnigmaX/Forms/XMessageBoxForm.cs b/EnigmaX/Forms/XMessageBoxForm.cs new file mode 100644 index 0000000..76bb209 --- /dev/null +++ b/EnigmaX/Forms/XMessageBoxForm.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using MetroFramework.Forms; + +namespace EnigmaX +{ + public partial class XMessageBoxForm : MetroForm + { + private string _title; + private string _message; + private string _primary; + private string _secondary; + public string returnValue { get; set; } + + public XMessageBoxForm(string Title, string Message, string Primary, string Secondary) + { + InitializeComponent(); + _title = Title; + _message = Message; + _primary = Primary; + _secondary = Secondary; + } + + private void XMessageBox_Load(object sender, EventArgs e) + { + this.Text = _title; + this.message_text.Text = _message; + this.primaryButton.Text = _primary; + this.secondaryButton.Text = _secondary; + if (_secondary.Equals("")) { + secondaryButton.Visible = false; + secondaryButton.Enabled = false; + } + } + + private void primaryButton_Click(object sender, EventArgs e) + { + returnValue = "primary"; + this.Close(); + } + + private void secondaryButton_Click(object sender, EventArgs e) + { + returnValue = "secondary"; + this.Close(); + } + } +} diff --git a/EnigmaX/Forms/XMessageBoxForm.resx b/EnigmaX/Forms/XMessageBoxForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/EnigmaX/Forms/XMessageBoxForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/EnigmaX/Properties/AssemblyInfo.cs b/EnigmaX/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..3a6a53d --- /dev/null +++ b/EnigmaX/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("EnigmaX")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("EnigmaX")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("9c277a65-39fe-466d-8ae9-4b3a12a5e61e")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/EnigmaX/app.config b/EnigmaX/app.config new file mode 100644 index 0000000..2a504c1 --- /dev/null +++ b/EnigmaX/app.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/EnigmaX/packages.config b/EnigmaX/packages.config new file mode 100644 index 0000000..ee93edb --- /dev/null +++ b/EnigmaX/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file