This repository has been archived by the owner on Aug 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9990991
commit ae9773e
Showing
37 changed files
with
14,902 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.27130.2003 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IP Configuration Profiles", "IP Configuration Profiles\IP Configuration Profiles.csproj", "{4038B258-4703-407A-8112-91EFE983E45D}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Debug|Default = Debug|Default | ||
Release|Any CPU = Release|Any CPU | ||
Release|Default = Release|Default | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{4038B258-4703-407A-8112-91EFE983E45D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4038B258-4703-407A-8112-91EFE983E45D}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4038B258-4703-407A-8112-91EFE983E45D}.Debug|Default.ActiveCfg = Debug|Any CPU | ||
{4038B258-4703-407A-8112-91EFE983E45D}.Debug|Default.Build.0 = Debug|Any CPU | ||
{4038B258-4703-407A-8112-91EFE983E45D}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4038B258-4703-407A-8112-91EFE983E45D}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{4038B258-4703-407A-8112-91EFE983E45D}.Release|Default.ActiveCfg = Release|Any CPU | ||
{4038B258-4703-407A-8112-91EFE983E45D}.Release|Default.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {5B14326B-3E17-4599-B350-ED4BADE8CB34} | ||
EndGlobalSection | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Debug|Default = Debug|Default | ||
Release|Any CPU = Release|Any CPU | ||
Release|Default = Release|Default | ||
EndGlobalSection | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Debug|Default = Debug|Default | ||
Release|Any CPU = Release|Any CPU | ||
Release|Default = Release|Default | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> | ||
</startup> | ||
</configuration> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Data; | ||
using System.Diagnostics; | ||
using System.Drawing; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Net.NetworkInformation; | ||
using System.Runtime.Serialization.Formatters.Binary; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
using IPAddressControlLib; | ||
|
||
namespace IP_Configuration_Profiles | ||
{ | ||
public partial class FormEdit : Form | ||
{ | ||
string interfaceName, profileName, ipAddress, netmask, gateway, dns1, dns2; | ||
|
||
bool editProfile; | ||
|
||
List<object> formInputs; | ||
|
||
NetworkProfile profileToEdit; | ||
|
||
FormMain main; | ||
|
||
public FormEdit(bool edit, FormMain _main) | ||
{ | ||
InitializeComponent(); | ||
editProfile = edit; | ||
main = _main; | ||
} | ||
|
||
public FormEdit(bool edit, object toEdit, FormMain _main) | ||
{ | ||
InitializeComponent(); | ||
editProfile = edit; | ||
profileToEdit = (NetworkProfile)toEdit; | ||
main = _main; | ||
} | ||
|
||
public void FormEdit_Load(object sender, EventArgs e) | ||
{ | ||
formInputs = new List<object>() { tbName, tbIpAddress, tbNetmask, tbGateway, tbDns1, tbDns2}; | ||
LoadInterfaces(); | ||
|
||
if (editProfile) | ||
{ | ||
LoadProfileValues(); | ||
} | ||
} | ||
|
||
public void LoadProfileValues() | ||
{ | ||
foreach (object o in formInputs) | ||
{ | ||
if (o is TextBox) | ||
{ | ||
TextBox tb = (TextBox)o; | ||
tb.Text = GetPropValue(profileToEdit, tb.Tag.ToString()).ToString(); | ||
} | ||
else | ||
{ | ||
IPAddressControl ip = (IPAddressControl)o; | ||
if (GetPropValue(profileToEdit, ip.Tag.ToString()) != null) // ci vuole sennò esplode | ||
ip.Text = GetPropValue(profileToEdit, ip.Tag.ToString()).ToString(); | ||
} | ||
} | ||
|
||
cbIntefaces.Text = profileToEdit.Interface; | ||
} | ||
|
||
// ritorna il valore della proprietà cercata | ||
public static object GetPropValue(object src, string propName) | ||
{ | ||
return src.GetType().GetProperty(propName).GetValue(src, null); | ||
} | ||
|
||
private void buttonCancel_Click(object sender, EventArgs e) | ||
{ | ||
this.Close(); | ||
} | ||
|
||
// aggiunge le schede di reta alla combobox | ||
public void LoadInterfaces() | ||
{ | ||
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces(); | ||
foreach (NetworkInterface nic in nics) | ||
{ | ||
cbIntefaces.Items.Add(nic.Name); | ||
} | ||
} | ||
|
||
public void InterfaceSelected(object sender, EventArgs e) | ||
{ | ||
interfaceName = cbIntefaces.SelectedItem.ToString(); | ||
} | ||
|
||
private void buttonEdit_Click(object sender, EventArgs e) | ||
{ | ||
profileName = tbName.Text; | ||
ipAddress = tbIpAddress.Text; | ||
netmask = tbNetmask.Text; | ||
gateway = tbGateway.Text; | ||
dns1 = tbDns1.Text; | ||
dns2 = tbDns2.Text; | ||
|
||
if (editProfile) | ||
{ | ||
EditProfile(); | ||
} | ||
else | ||
{ | ||
NewProfile(); | ||
} | ||
} | ||
|
||
public void EditProfile() | ||
{ | ||
ProfilesCollection.RemoveProfile(profileToEdit); | ||
NewProfile(); | ||
} | ||
|
||
public void NewProfile() | ||
{ | ||
NetworkProfile profile; | ||
|
||
if (rdbDhcp.Checked) | ||
{ | ||
profile = new NetworkProfile( | ||
profileName, | ||
interfaceName); | ||
} | ||
else | ||
{ | ||
profile = new NetworkProfile( | ||
profileName, | ||
interfaceName, | ||
ipAddress, | ||
netmask, | ||
gateway, | ||
dns1, | ||
dns2); | ||
} | ||
|
||
ProfilesCollection.AddProfile(profile); | ||
|
||
main.UpdateForm(); // refresh dei profili nel main | ||
this.Close(); | ||
} | ||
|
||
public void ConfigurationModeChanged(object sender, EventArgs e) | ||
{ | ||
if (rdbDhcp.Checked) | ||
{ | ||
groupBoxIp.Visible = false; | ||
groupBoxDns.Visible = false; | ||
} | ||
else | ||
{ | ||
groupBoxIp.Visible = true; | ||
groupBoxDns.Visible = true; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.