Skip to content

Commit a5b98ab

Browse files
committed
Removed the ForceBindIP Path selection because it's now included with the release.
1 parent 0e1fa29 commit a5b98ab

8 files changed

Lines changed: 84 additions & 129 deletions

File tree

ForceBindIP GUI/App.config

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<configuration>
33
<configSections>
4-
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
5-
<section name="ForceBindIP_GUI.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
6-
</sectionGroup>
74
</configSections>
85
<startup>
96
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
107
</startup>
11-
<userSettings>
12-
<ForceBindIP_GUI.Properties.Settings>
13-
<setting name="FBIPath" serializeAs="String">
14-
<value />
15-
</setting>
16-
</ForceBindIP_GUI.Properties.Settings>
17-
</userSettings>
188
</configuration>

ForceBindIP GUI/ForceBindIP GUI.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
<Compile Include="NetworkAdapterInfo.cs" />
100100
<Compile Include="Program.cs" />
101101
<Compile Include="Properties\AssemblyInfo.cs" />
102+
<Compile Include="Settings.cs" />
102103
<EmbeddedResource Include="frmMain.resx">
103104
<DependentUpon>frmMain.cs</DependentUpon>
104105
</EmbeddedResource>

ForceBindIP GUI/Properties/AssemblyInfo.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
77
// associées à un assembly.
88
[assembly: AssemblyTitle("ForceBindIP GUI")]
9-
[assembly: AssemblyDescription("")]
9+
[assembly: AssemblyDescription("ForceBindIP GUI")]
1010
[assembly: AssemblyConfiguration("")]
11-
[assembly: AssemblyCompany("")]
11+
[assembly: AssemblyCompany("Unreal852")]
1212
[assembly: AssemblyProduct("ForceBindIP GUI")]
13-
[assembly: AssemblyCopyright("Copyright © 2017")]
13+
[assembly: AssemblyCopyright("Copyright © Unreal852 2017")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
1616

1717
// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
1818
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
1919
// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
20-
[assembly: ComVisible(false)]
20+
[assembly: ComVisible(true)]
2121

2222
// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
2323
[assembly: Guid("2aa41a9a-fe12-4176-bf14-1c91e721dd5b")]

ForceBindIP GUI/Properties/Settings.Designer.cs

Lines changed: 1 addition & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<?xml version='1.0' encoding='utf-8'?>
2-
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="ForceBindIP_GUI.Properties" GeneratedClassName="Settings">
2+
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
33
<Profiles />
4-
<Settings>
5-
<Setting Name="FBIPath" Type="System.String" Scope="User">
6-
<Value Profile="(Default)" />
7-
</Setting>
8-
</Settings>
4+
<Settings />
95
</SettingsFile>

ForceBindIP GUI/Settings.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
namespace ForceBindIP_GUI.Properties {
2+
3+
4+
// Cette classe vous permet de gérer des événements spécifiques dans la classe de paramètres :
5+
// L'événement SettingChanging est déclenché avant la modification d'une valeur de paramètre.
6+
// L'événement PropertyChanged est déclenché après la modification d'une valeur de paramètre.
7+
// L'événement SettingsLoaded est déclenché après le chargement des valeurs de paramètre.
8+
// L'événement SettingsSaving est déclenché avant l'enregistrement des valeurs de paramètre.
9+
internal sealed partial class Settings {
10+
11+
public Settings() {
12+
// // Pour ajouter des gestionnaires d'événements afin d'enregistrer et de modifier les paramètres, supprimez les marques de commentaire des lignes ci-dessous :
13+
//
14+
// this.SettingChanging += this.SettingChangingEventHandler;
15+
//
16+
// this.SettingsSaving += this.SettingsSavingEventHandler;
17+
//
18+
}
19+
20+
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
21+
// Ajouter du code pour gérer l'événement SettingChangingEvent ici.
22+
}
23+
24+
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
25+
// Ajouter du code pour gérer l'événement SettingsSaving ici.
26+
}
27+
}
28+
}

ForceBindIP GUI/frmMain.Designer.cs

Lines changed: 8 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ForceBindIP GUI/frmMain.cs

Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,65 +8,43 @@ namespace ForceBindIP_GUI
88
{
99
public partial class frmMain : Form
1010
{
11-
private Properties.Settings m_settings = Properties.Settings.Default;
11+
private readonly string[] RequieredFiles = new string[] {"BindIP.dll", "BindIP64.dll", "ForceBindIP.exe", "ForceBindIP64.exe"};
1212

1313
public frmMain()
1414
{
1515
InitializeComponent();
1616

17-
btnSelectFBIPath.Click += OnSelectFBIPathClicked;
18-
btnOpenTargetApplication.Click += OnOpenAppClicked;
19-
btnLaunch.Click += OnLaunchClicked;
17+
CheckRequieredFiles();
2018

21-
ForceBindIPPath = AppSettings.FBIPath;
22-
23-
LoadAvailableNetworkAdapters();
19+
btnOpenTargetApplication.Click += (sender, e) => OpenAppSelector();
20+
btnLaunch.Click += (sender , e) => LaunchApp();
21+
cmbNetworkAdapter.DropDown += (sender, e) => LoadAvailableNetworkAdapters();
2422
}
2523

26-
private Properties.Settings AppSettings => m_settings;
24+
private string ForceBindIPPath => Environment.CurrentDirectory;
25+
26+
private string ForceBindExe => chk64b.Checked ? "ForceBindIP64.exe" : "ForceBindIP.exe";
2727

28-
public string ForceBindIPPath
28+
/// <summary>
29+
/// Check if all ForceBindIP files are in the directory
30+
/// </summary>
31+
private void CheckRequieredFiles()
2932
{
30-
get { return txtFBIPath.Text; }
31-
set
33+
string curDir = Environment.CurrentDirectory;
34+
foreach(string s in RequieredFiles)
3235
{
33-
if (Directory.Exists(value) && txtFBIPath.Text != value)
36+
if(!File.Exists(Path.Combine(curDir, s)))
3437
{
35-
txtFBIPath.Text = value;
36-
if (AppSettings.FBIPath != value)
37-
{
38-
AppSettings.FBIPath = value;
39-
AppSettings.Save();
40-
AppSettings.Reload();
41-
}
38+
MessageBox.Show("Couldn't find ForceBindIP files", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
39+
Environment.Exit(-1);
4240
}
4341
}
4442
}
4543

46-
public string ForceBindExe => chk64b.Checked ? "ForceBindIP64.exe" : "ForceBindIP.exe";
47-
48-
private void OnSelectFBIPathClicked(object sender, EventArgs e)
49-
{
50-
FolderBrowserDialog diag = new FolderBrowserDialog();
51-
if (!String.IsNullOrEmpty(ForceBindIPPath) && ForceBindIPPath.Length > 0)
52-
diag.SelectedPath = ForceBindIPPath;
53-
diag.Description = "Choose the ForceBindIP install path";
54-
diag.ShowNewFolderButton = false;
55-
if(diag.ShowDialog() == DialogResult.OK)
56-
ForceBindIPPath = diag.SelectedPath;
57-
}
58-
59-
private void OnOpenAppClicked(object sender, EventArgs e)
60-
{
61-
OpenFileDialog diag = new OpenFileDialog();
62-
diag.Filter = "Application (*.exe)|*.exe";
63-
diag.Multiselect = false;
64-
diag.Title = "Select a application to open";
65-
if (diag.ShowDialog() == DialogResult.OK)
66-
txtTargetApp.Text = diag.FileName;
67-
}
68-
69-
private void OnLaunchClicked(object sender, EventArgs e)
44+
/// <summary>
45+
/// Launch the selected app on the given network adapter
46+
/// </summary>
47+
private void LaunchApp()
7048
{
7149
try
7250
{
@@ -78,17 +56,31 @@ private void OnLaunchClicked(object sender, EventArgs e)
7856
psi.WorkingDirectory = Path.GetDirectoryName(txtTargetApp.Text);
7957
Process.Start(psi);
8058
}
81-
catch(Exception ex)
59+
catch (Exception ex)
8260
{
8361
MessageBox.Show(ex.Message);
8462
}
8563
}
8664

65+
/// <summary>
66+
/// Open the application selector
67+
/// </summary>
68+
private void OpenAppSelector()
69+
{
70+
OpenFileDialog diag = new OpenFileDialog();
71+
diag.Filter = "Application (*.exe)|*.exe";
72+
diag.Multiselect = false;
73+
diag.Title = "Select a application to open";
74+
if (diag.ShowDialog() == DialogResult.OK)
75+
txtTargetApp.Text = diag.FileName;
76+
}
77+
8778
/// <summary>
8879
/// Get all available network adapters
8980
/// </summary>
9081
private void LoadAvailableNetworkAdapters()
9182
{
83+
cmbNetworkAdapter.Items.Clear();
9284
foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
9385
{
9486
if (ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 || ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
@@ -102,5 +94,9 @@ private void LoadAvailableNetworkAdapters()
10294
}
10395
}
10496

97+
private void CmbNetworkAdapter_DropDown(object sender, EventArgs e)
98+
{
99+
LoadAvailableNetworkAdapters();
100+
}
105101
}
106102
}

0 commit comments

Comments
 (0)