Skip to content
This repository has been archived by the owner on Nov 26, 2017. It is now read-only.

Commit

Permalink
7.0.0
Browse files Browse the repository at this point in the history
View Resources\changelog.txt for changes
  • Loading branch information
abluescarab committed Mar 1, 2014
1 parent fa2ef3b commit 5e8854c
Show file tree
Hide file tree
Showing 59 changed files with 3,808 additions and 2,150 deletions.
Binary file added AMD64/sqlceca40.dll
Binary file not shown.
Binary file added AMD64/sqlcecompact40.dll
Binary file not shown.
Binary file added AMD64/sqlceer40EN.dll
Binary file not shown.
Binary file added AMD64/sqlceme40.dll
Binary file not shown.
Binary file added AMD64/sqlceoledb40.dll
Binary file not shown.
Binary file added AMD64/sqlceqp40.dll
Binary file not shown.
Binary file added AMD64/sqlcese40.dll
Binary file not shown.
22 changes: 9 additions & 13 deletions App.config
Expand Up @@ -6,7 +6,9 @@
</sectionGroup>
</configSections>
<connectionStrings>
<add name="Switchex.Properties.Settings.WoWServerConnectionString" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\WoWServer.accdb" providerName="System.Data.OleDb"/>
<add name="Switchex.Properties.Settings.switchexConnectionString"
connectionString="Data Source=|DataDirectory|\switchex.sdf"
providerName="Microsoft.SqlServerCe.Client.4.0" />
</connectionStrings>
<startup>

Expand All @@ -16,28 +18,22 @@
<setting name="updatesOnStartup" serializeAs="String">
<value>True</value>
</setting>
<setting name="gamePath" serializeAs="String">
<value/>
</setting>
<setting name="realmPath" serializeAs="String">
<value/>
</setting>
<setting name="windowSize" serializeAs="String">
<value>914 410</value>
<value>983,417</value>
</setting>
<setting name="firstRun" serializeAs="String">
<value>True</value>
</setting>
<setting name="columnWidths" serializeAs="String">
<value>41 133 133 133 39 65 133</value>
</setting>
<setting name="installType" serializeAs="String">
<value/>
<value>43,133,100,133,60,63,133,133</value>
</setting>
<setting name="openWow" serializeAs="String">
<value>False</value>
</setting>
<setting name="bit64" serializeAs="String">
<setting name="currentProfile" serializeAs="String">
<value>Main</value>
</setting>
<setting name="deleteServersAfterProfile" serializeAs="String">
<value>False</value>
</setting>
</Switchex.Properties.Settings>
Expand Down
152 changes: 152 additions & 0 deletions Globals.cs
@@ -0,0 +1,152 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlServerCe;
using System.Diagnostics;
using System.IO;
//using System.Linq;
//using System.Security.Policy;
//using System.Security.Principal;
//using System.Security.AccessControl;
using System.Security;
using System.Security.Permissions;
//using System.Text;
//using System.Windows.Forms;

namespace Switchex {
public class Globals {
public static frmError frmError = new frmError();

public static List<Profile> profiles = new List<Profile>();

public enum FileAction {
CreateFolder,
DeleteFolder,
CreateFile,
WriteFile,
CopyFile,
DeleteFile,
CreateBoth
};

public static bool blnUpdates = false,
resetSettings = false;
public static int rowCount = 0;
public static string
downloadVersion = null,
selectedID = null,
selectedName = null,
selectedIP = null,
selectedWebsite = null,
selectedPatch = null,
selectedRating = null,
selectedNotes = null,
selectedProfile = null,
currentProfile = null,
changelogFile = System.Windows.Forms.Application.StartupPath + "\\Resources\\changelog.txt",
helpFile = System.Windows.Forms.Application.StartupPath + "\\Resources\\Switchex Help.html";

public static int RunActionsExecutable(FileAction action, string[] args) {
Process p = new Process();
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.FileName = "fileactions.exe";
p.StartInfo.UseShellExecute = true;

try {
switch(action) {
case FileAction.WriteFile:
// args: change "path\to\file" "text to write"
// note: can only be a text file (any extension)
p.StartInfo.Arguments = "write \"" + args[0] + "\" \"\"" + args[1] + "\"\"";
break;
case FileAction.CreateBoth:
// args: create both "path\to\folder" "path\to\file" ["text to write"]
p.StartInfo.Arguments = "create both \"" + args[0] + "\" \"" + args[1] + "\"";

if(args.Length > 2 && args[2] != null) {
p.StartInfo.Arguments += " \"\"" + args[2] + "\"\"";
}
break;
case FileAction.CreateFile:
// args: create file "path\to\file" ["text to write"]
// note: ["text to write"] is for text files (any extension)
p.StartInfo.Arguments = "create file \"" + args[0] + "\"";

if(args.Length > 1 && args[1] != null) {
p.StartInfo.Arguments += " \"\"" + args[1] + "\"\"";
}
break;
case FileAction.CreateFolder:
// args: create folder "path\to\create"
p.StartInfo.Arguments = "create folder \"" + args[0] + "\"";
break;
case FileAction.DeleteFile:
// args: delete file "path\to\file"
p.StartInfo.Arguments = "delete file \"" + args[0] + "\"";
break;
case FileAction.DeleteFolder:
// args: delete folder "path\to\delete"
p.StartInfo.Arguments = "delete folder \"" + args[0] + "\"";
break;
case FileAction.CopyFile:
// args: copy "true/false" (delete source file) "file\to\copy" "path\to\new\location"
p.StartInfo.Arguments = "copy " + args[0] + " \"" + args[1] + "\" \"" + args[2] + "\"";
break;
}

p.Start();
p.WaitForExit();

if(p.ExitCode == 1) {
p.StartInfo.Verb = "runas";
p.Start();
p.WaitForExit();

if(p.ExitCode != 0) {
return -1;
}
}

return p.ExitCode;
}
catch(Exception ex) {
if(ex.Message.Contains("canceled by the user")) {
return 5;
}

return -1;
}
}

/// <summary>
/// Get all profiles and add them to a global list.
/// </summary>
public static void GetProfiles() {
profiles.Clear();

try {
using(SqlCeConnection conn = new SqlCeConnection(Properties.Settings.Default.switchexConnectionString)) {
using(SqlCeCommand cmd = new SqlCeCommand("SELECT * FROM Profiles", conn)) {
using(DataSet ds = new DataSet()) {
using(SqlCeDataAdapter adapter = new SqlCeDataAdapter(cmd)) {
adapter.SelectCommand = cmd;

adapter.Fill(ds);

foreach(DataRow row in ds.Tables[0].Rows) {
profiles.Add(new Profile(false, Convert.ToInt32(row.ItemArray[0])));
}

Globals.profiles.Sort((x, y) => x.ProfileName.CompareTo(y.ProfileName));
}
}
}
}
}
catch(Exception ex) {
Globals.frmError.ShowDialog(ex);
}
}
}
}
136 changes: 136 additions & 0 deletions Profile.cs
@@ -0,0 +1,136 @@
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlServerCe;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Switchex {
public class Profile {
public static int newProfileID { get; set; }

public string ProfileName { get; set; }
public string ProfilePath { get; set; }
public string ProfileDesc { get; set; }
public int ProfileType { get; set; }
public bool ProfileDefault { get; set; }
public int ProfileID { get; set; }

public Profile(bool isNew, int id) {
try {
using(SqlCeConnection conn = new SqlCeConnection(Properties.Settings.Default.switchexConnectionString)) {
using(SqlCeCommand cmd = new SqlCeCommand("", conn)) {
if(isNew) {
int nextNew = 1;

conn.Open();

foreach(Profile profile in Globals.profiles) {
if(profile.ProfileName.Contains("New Profile ") && profile.ProfileName.Length >= 13) {
if(Convert.ToInt32(profile.ProfileName.Substring(12)) == nextNew) {
nextNew = Convert.ToInt32(profile.ProfileName.Substring(12)) + 1;
}
}
}

ProfileName = "New Profile " + nextNew;
ProfilePath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
ProfileDesc = "A blank profile.";
ProfileType = 32;

cmd.CommandText = "INSERT INTO Profiles (ProfileName, ProfilePath, ProfileDescription, ProfileType) " +
"VALUES (@name, @path, @desc, @type)";

cmd.Parameters.AddWithValue("@name", ProfileName);
cmd.Parameters.AddWithValue("@path", ProfilePath);
cmd.Parameters.AddWithValue("@desc", ProfileDesc);
cmd.Parameters.AddWithValue("@type", ProfileType);
cmd.ExecuteNonQuery();

cmd.CommandText = "SELECT @@IDENTITY";
ProfileID = Convert.ToInt32(cmd.ExecuteScalar());
}
else {
cmd.CommandText = "SELECT * FROM Profiles WHERE ID=@id";
cmd.Parameters.AddWithValue("@id", id);

using(DataSet ds = new DataSet()) {
using(SqlCeDataAdapter adapter = new SqlCeDataAdapter(cmd)) {
adapter.SelectCommand = cmd;

adapter.Fill(ds);

foreach(DataRow row in ds.Tables[0].Rows) {
ProfileID = Convert.ToInt32(row.ItemArray[0]);
ProfileName = row.ItemArray[1].ToString();
ProfilePath = row.ItemArray[2].ToString();
ProfileDesc = row.ItemArray[3].ToString();
ProfileType = Convert.ToInt32(row.ItemArray[4]);
ProfileDefault = (bool)row.ItemArray[5];
}
}
}
}
}
}
}
catch(Exception ex) {
Globals.frmError.ShowDialog(ex);
}
}

/// <summary>
/// Edit the profile.
/// </summary>
/// <param name="id">The ID of the profile</param>
/// <param name="name">The name of the profile (Optional)</param>
/// <param name="path">The path of the profile (Optional)</param>
/// <param name="desc">The description of the profile (Optional)</param>
/// <param name="type">The type of profile (Optional)</param>
/// <param name="isDefault">If the profile is the default or not (Optional)</param>
public void EditProfile(int id, string name = null, string path = null, string desc = null, int type = 0, bool isDefault = false) {
string oldName = null;

if(name != null) {
oldName = ProfileName;
ProfileName = name;
}
if(path != null)
ProfilePath = path;
if(desc != null)
ProfileDesc = desc;
if(type != 0)
ProfileType = type;
ProfileDefault = isDefault;

try {
using(SqlCeConnection conn = new SqlCeConnection(Properties.Settings.Default.switchexConnectionString)) {
using(SqlCeCommand cmd = new SqlCeCommand("UPDATE Profiles SET ProfileName=@name, ProfilePath=@path, ProfileDescription=@desc, " +
"ProfileType=@type, ProfileDefault=@default WHERE ID=@id", conn)) {
cmd.Parameters.AddWithValue("@name", ProfileName);
cmd.Parameters.AddWithValue("@path", ProfilePath);
cmd.Parameters.AddWithValue("@desc", ProfileDesc);
cmd.Parameters.AddWithValue("@type", ProfileType);
cmd.Parameters.AddWithValue("@default", (ProfileDefault ? 1 : 0));
cmd.Parameters.AddWithValue("@id", id);

conn.Open();
cmd.ExecuteNonQuery();

if(name != null && oldName != null) {
cmd.CommandText = "UPDATE Servers SET ServerProfile=@name WHERE ServerProfile=@old";
cmd.Parameters.AddWithValue("@old", oldName);

cmd.ExecuteNonQuery();
}
}
}
}
catch(Exception ex) {
Globals.frmError.ShowDialog(ex);
}
}
}
}
10 changes: 9 additions & 1 deletion Program.cs
@@ -1,19 +1,27 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Switchex {
static class Program {
public static bool keepRunning { get; set; }

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmMain());

keepRunning = true;
while(keepRunning) {
keepRunning = false;
Application.Run(new frmMain());
}
}
}
}
6 changes: 3 additions & 3 deletions Properties/AssemblyInfo.cs
Expand Up @@ -11,7 +11,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Abluescarab Designs")]
[assembly: AssemblyProduct("Switchex")]
[assembly: AssemblyCopyright("Copyright © 2008-2013 Abluescarab Designs")]
[assembly: AssemblyCopyright("Copyright © 2008-2014 Abluescarab Designs")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -33,6 +33,6 @@
// 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("6.1.0")]
[assembly: AssemblyFileVersion("6.1.0")]
[assembly: AssemblyVersion("7.0.0")]
[assembly: AssemblyFileVersion("7.0.0")]
[assembly: NeutralResourcesLanguageAttribute("en-US")]

0 comments on commit 5e8854c

Please sign in to comment.