Start getting design together

First and foremost are the Generate options, which are populated with functions similar to ListSystems and ListSources.
This commit is contained in:
Matt Nadareski
2016-03-29 21:23:22 -07:00
parent a33036b3e0
commit ac03051e04
7 changed files with 319 additions and 19 deletions

View File

@@ -52,7 +52,7 @@ namespace SabreTools
// Determine which switches are enabled (with values if necessary)
bool help = false, import = false, generate = false, convert = false,
listsys = false, listsrc = false, norename = false, old = false,
log = false, genall = false, add = false, rem = false;
log = false, genall = false, add = false, rem = false, skip = false;
string systems = "", sources = "", input = "", manu = "", url = "";
foreach (string arg in args)
{
@@ -71,6 +71,7 @@ namespace SabreTools
log = log || (arg == "-l" || arg == "--log");
old = old || (arg == "-old" || arg == "--romvault");
norename = norename || (arg == "-nr" || arg == "--no-rename");
skip = skip || (arg == "--skip");
// User input strings
systems = (arg.StartsWith("system=") && systems == "" ? arg.Split('=')[1] : systems);
@@ -89,6 +90,12 @@ namespace SabreTools
input == "" ? arg : input);
}
// If skip is set, it's being called from the UI so we just exit
if (skip)
{
return;
}
// If more than one switch is enabled or help is set, show the help screen
if (help || !(import ^ generate ^ listsys ^ listsrc ^ genall ^ add ^ rem))
{

View File

@@ -1,6 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v12.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite.EF6" />
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
<remove invariant="System.Data.SQLite" /><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /></DbProviderFactories>
</system.data>
</configuration>

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SabreToolsUI
namespace SabreTools
{
static class Program
{

View File

@@ -1,4 +1,4 @@
namespace SabreToolsUI
namespace SabreTools
{
partial class SabreToolsUI
{
@@ -30,10 +30,19 @@
{
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.quitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.quitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.checkedListBox1 = new System.Windows.Forms.CheckedListBox();
this.checkedListBox2 = new System.Windows.Forms.CheckedListBox();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
@@ -45,7 +54,7 @@
this.helpToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(575, 24);
this.menuStrip1.Size = new System.Drawing.Size(681, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
@@ -57,6 +66,14 @@
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
this.fileToolStripMenuItem.Text = "File";
//
// quitToolStripMenuItem
//
this.quitToolStripMenuItem.Name = "quitToolStripMenuItem";
this.quitToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.X)));
this.quitToolStripMenuItem.Size = new System.Drawing.Size(129, 22);
this.quitToolStripMenuItem.Text = "Exit";
this.quitToolStripMenuItem.Click += new System.EventHandler(this.quitToolStripMenuItem_Click);
//
// editToolStripMenuItem
//
this.editToolStripMenuItem.Name = "editToolStripMenuItem";
@@ -71,23 +88,111 @@
this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
this.helpToolStripMenuItem.Text = "Help";
//
// quitToolStripMenuItem
//
this.quitToolStripMenuItem.Name = "quitToolStripMenuItem";
this.quitToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.quitToolStripMenuItem.Text = "Exit";
//
// aboutToolStripMenuItem
//
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(107, 22);
this.aboutToolStripMenuItem.Text = "About";
this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(12, 34);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(112, 17);
this.label1.TabIndex = 1;
this.label1.Text = "Generate DAT";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(15, 65);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(0, 13);
this.label2.TabIndex = 2;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.Location = new System.Drawing.Point(15, 65);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 15);
this.label3.TabIndex = 3;
this.label3.Text = "Systems:";
//
// checkedListBox1
//
this.checkedListBox1.FormattingEnabled = true;
this.checkedListBox1.Items.AddRange(GetAllSystems());
this.checkedListBox1.Location = new System.Drawing.Point(77, 65);
this.checkedListBox1.Name = "checkedListBox1";
this.checkedListBox1.Size = new System.Drawing.Size(260, 34);
this.checkedListBox1.TabIndex = 4;
//
// checkedListBox2
//
this.checkedListBox2.FormattingEnabled = true;
this.checkedListBox2.Items.AddRange(GetAllSources());
this.checkedListBox2.Location = new System.Drawing.Point(415, 65);
this.checkedListBox2.Name = "checkedListBox2";
this.checkedListBox2.Size = new System.Drawing.Size(244, 34);
this.checkedListBox2.TabIndex = 7;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point(353, 65);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(55, 15);
this.label4.TabIndex = 6;
this.label4.Text = "Sources:";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(363, 65);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(0, 13);
this.label5.TabIndex = 5;
//
// button1
//
this.button1.Location = new System.Drawing.Point(18, 107);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 8;
this.button1.Text = "Generate";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(100, 107);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(97, 23);
this.button2.TabIndex = 9;
this.button2.Text = "Generate All";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// SabreToolsUI
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(575, 342);
this.ClientSize = new System.Drawing.Size(681, 477);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.checkedListBox2);
this.Controls.Add(this.label4);
this.Controls.Add(this.label5);
this.Controls.Add(this.checkedListBox1);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.Name = "SabreToolsUI";
@@ -107,6 +212,15 @@
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.CheckedListBox checkedListBox1;
private System.Windows.Forms.CheckedListBox checkedListBox2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
}
}

View File

@@ -2,19 +2,138 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SQLite;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SabreToolsUI
namespace SabreTools
{
public partial class SabreToolsUI : Form
{
private static string _dbName = "DATabase.sqlite";
private static string _connectionString = "Data Source=" + _dbName + ";Version = 3;";
public SabreToolsUI()
{
AllocConsole();
InitializeComponent();
}
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool AllocConsole();
private void quitToolStripMenuItem_Click(object sender, EventArgs e)
{
Environment.Exit(0);
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("SabreTools designed and coded by: Matt Nadareski (darksabre76)\nTested by: @tractivo", "About");
}
private static object[] GetAllSystems()
{
List<object> objs = new List<object>();
Process.Start("DATabase.exe", "--skip");
string query = @"
SELECT DISTINCT systems.id, systems.manufacturer, systems.system
FROM systems JOIN games ON systems.id=games.system
ORDER BY systems.manufacturer, systems.system";
using (SQLiteConnection dbc = new SQLiteConnection(_connectionString))
{
dbc.Open();
using (SQLiteCommand slc = new SQLiteCommand(query, dbc))
{
using (SQLiteDataReader sldr = slc.ExecuteReader())
{
// If nothing is found, tell the user and exit
if (sldr.HasRows)
{
while (sldr.Read())
{
objs.Add(sldr.GetString(1) + " - " + sldr.GetString(2) + " (" + sldr.GetInt32(0) + ")");
}
}
}
}
}
return objs.ToArray();
}
private static object[] GetAllSources()
{
List<object> objs = new List<object>();
Process.Start("DATabase.exe", "--skip");
string query = @"
SELECT DISTINCT sources.id, sources.name
FROM sources JOIN games on sources.id=games.source
ORDER BY sources.name COLLATE NOCASE";
using (SQLiteConnection dbc = new SQLiteConnection(_connectionString))
{
dbc.Open();
using (SQLiteCommand slc = new SQLiteCommand(query, dbc))
{
using (SQLiteDataReader sldr = slc.ExecuteReader())
{
// If nothing is found, tell the user and exit
if (sldr.HasRows)
{
while (sldr.Read())
{
objs.Add(sldr.GetString(1) + " (" + sldr.GetInt32(0) + ")");
}
}
}
}
}
return objs.ToArray();
}
private void button1_Click(object sender, EventArgs e)
{
string systems = "";
string sources = "";
CheckedListBox.CheckedItemCollection cil = this.checkedListBox1.CheckedItems;
Console.WriteLine(cil.Count);
foreach (object ci in cil)
{
string id = Regex.Match(ci.ToString(), @".*? \((.*?)\)").Groups[1].Value;
systems += (systems == "" ? id : ", " + id);
Console.WriteLine(systems);
}
cil = this.checkedListBox2.CheckedItems;
Console.WriteLine(cil.Count);
foreach (object ci in cil)
{
string id = Regex.Match(ci.ToString(), @".*? \((.*?)\)").Groups[1].Value;
sources += (sources == "" ? id : ", " + id);
Console.WriteLine(systems);
}
Process.Start("DATabase.exe", "-g" + (systems != "" ? " systems=" + systems : "") + (sources != "" ? " sources=" + sources : ""));
}
private void button2_Click(object sender, EventArgs e)
{
Process.Start("DATabase.exe", "-ga");
}
}
}

View File

@@ -12,13 +12,15 @@
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>..\..\Builds\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@@ -33,8 +35,29 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SQLite, Version=1.0.99.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.Core.1.0.99.0\lib\net451\System.Data.SQLite.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Data.SQLite.EF6, Version=1.0.99.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.EF6.1.0.99.0\lib\net451\System.Data.SQLite.EF6.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Data.SQLite.Linq, Version=1.0.99.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.Linq.1.0.99.0\lib\net451\System.Data.SQLite.Linq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@@ -66,6 +89,7 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -80,6 +104,13 @@
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\System.Data.SQLite.Core.1.0.99.0\build\net451\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.99.0\build\net451\System.Data.SQLite.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\System.Data.SQLite.Core.1.0.99.0\build\net451\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Data.SQLite.Core.1.0.99.0\build\net451\System.Data.SQLite.Core.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.0.0" targetFramework="net452" />
<package id="System.Data.SQLite" version="1.0.99.0" targetFramework="net452" />
<package id="System.Data.SQLite.Core" version="1.0.99.0" targetFramework="net452" />
<package id="System.Data.SQLite.EF6" version="1.0.99.0" targetFramework="net452" />
<package id="System.Data.SQLite.Linq" version="1.0.99.0" targetFramework="net452" />
</packages>