Skip to content
This repository has been archived by the owner on Sep 5, 2019. It is now read-only.

Commit

Permalink
Added custom ASF path setting. v0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
alvr committed Jun 20, 2016
1 parent a9e2af5 commit ee79cf6
Show file tree
Hide file tree
Showing 12 changed files with 401 additions and 8 deletions.
15 changes: 14 additions & 1 deletion ASFui/ASFui.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 19 additions & 4 deletions ASFui/ASFui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,20 @@ public partial class ASFui : Form

public ASFui()
{
if (!Util.CheckBinary())
while (!Util.CheckBinary())
{
MessageBox.Show("ASF binary should be in the same folder as ASFui.",
"ASF binary not found.", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(-1);
DialogResult result = MessageBox.Show("ASF binary setting not configured. Configure now?",
"ASF binary not found.", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
if (result == DialogResult.Yes)
{
Properties.Settings.Default.ASFBinary = "Setting not configured.";
SettingsForm Settings = new SettingsForm();
Settings.ShowDialog();
}
else
{
Environment.Exit(-1);
}
}

if (Util.CheckIfASFIsRunning())
Expand Down Expand Up @@ -120,6 +129,12 @@ private void btnReloadBots_Click(object sender, EventArgs e)
EnableElements();
tsslCommandOutput.Text = "Updated Bot list.";
}

private void btnASFuiSettings_Click(object sender, EventArgs e)
{
SettingsForm Settings = new SettingsForm();
Settings.ShowDialog();
}
#endregion

#region Cards Buttons
Expand Down
19 changes: 19 additions & 0 deletions ASFui/ASFui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@
<Compile Include="Client.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="Settings.cs" />
<Compile Include="SettingsForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SettingsForm.Designer.cs">
<DependentUpon>SettingsForm.cs</DependentUpon>
</Compile>
<Compile Include="Util.cs" />
<EmbeddedResource Include="ASFui.resx">
<DependentUpon>ASFui.cs</DependentUpon>
Expand All @@ -118,8 +130,15 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="SettingsForm.resx">
<DependentUpon>SettingsForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<None Include="Resources\ASFui.ico" />
</ItemGroup>
<ItemGroup>
Expand Down
12 changes: 12 additions & 0 deletions ASFui/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="ASFui.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
<userSettings>
<ASFui.Properties.Settings>
<setting name="ASFBinary" serializeAs="String">
<value>Setting not configured.</value>
</setting>
</ASFui.Properties.Settings>
</userSettings>
</configuration>
4 changes: 2 additions & 2 deletions ASFui/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
// Puede especificar todos los valores o usar los valores predeterminados de número de compilación y de revisión
// mediante el carácter '*', como se muestra a continuación:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.0.0")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyVersion("0.2.0.0")]
[assembly: AssemblyFileVersion("0.2.0.0")]
38 changes: 38 additions & 0 deletions ASFui/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions ASFui/Properties/Settings.settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="ASFui.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="ASFBinary" Type="System.String" Scope="User">
<Value Profile="(Default)">Setting not configured.</Value>
</Setting>
</Settings>
</SettingsFile>
28 changes: 28 additions & 0 deletions ASFui/Settings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace ASFui.Properties {


// Esta clase le permite controlar eventos específicos en la clase de configuración:
// El evento SettingChanging se desencadena antes de cambiar un valor de configuración.
// El evento PropertyChanged se desencadena después de cambiar el valor de configuración.
// El evento SettingsLoaded se desencadena después de cargar los valores de configuración.
// El evento SettingsSaving se desencadena antes de guardar los valores de configuración.
internal sealed partial class Settings {

public Settings() {
// // Para agregar los controladores de eventos para guardar y cambiar la configuración, quite la marca de comentario de las líneas:
//
// this.SettingChanging += this.SettingChangingEventHandler;
//
// this.SettingsSaving += this.SettingsSavingEventHandler;
//
}

private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
// Agregar código para administrar aquí el evento SettingChangingEvent.
}

private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
// Agregar código para administrar aquí el evento SettingsSaving.
}
}
}
102 changes: 102 additions & 0 deletions ASFui/SettingsForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions ASFui/SettingsForm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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;

namespace ASFui
{
public partial class SettingsForm : Form
{
public SettingsForm()
{
InitializeComponent();
lbPath.Text = Properties.Settings.Default.ASFBinary;
}

private void btnSearch_Click(object sender, EventArgs e)
{
ofdBinarySearch.ShowDialog();
Properties.Settings.Default.ASFBinary = ofdBinarySearch.FileName;
lbPath.Text = Properties.Settings.Default.ASFBinary;
Properties.Settings.Default.Save();
}

private void SettingsForm_FormClosing(object sender, FormClosingEventArgs e)
{
Dispose();
}
}
}
Loading

0 comments on commit ee79cf6

Please sign in to comment.