Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 30 enhance sample app v2 #56

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
269 changes: 160 additions & 109 deletions WindowsFirewallHelper.Sample/AddPortForm.Designer.cs

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

46 changes: 46 additions & 0 deletions WindowsFirewallHelper.Sample/AddPortForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ public AddPortForm()
cb_protocol.SelectedIndex = 0;
}

public AddPortForm(
FirewallProfiles currentProfile,
string defaultRuleName)
: this()
{
textBoxRuleName.Text = defaultRuleName;

for (int index = 0; index < checkedListBoxProfiles.Items.Count; index++)
{
if (checkedListBoxProfiles.Items[index].ToString() == currentProfile.ToString())
{
checkedListBoxProfiles.SetItemChecked(index, true);
}
}
}
public FirewallProtocol FirewallProtocol
{
get => cb_protocol.SelectedItem as FirewallProtocol;
Expand All @@ -23,5 +38,36 @@ public ushort PortNumber
{
get => (ushort) nud_port.Value;
}

public string RuleName
{
get => textBoxRuleName.Text;
}

public FirewallProfiles Profiles
{
get
{
FirewallProfiles profiles = (FirewallProfiles) 0;

foreach (object checkedItem in checkedListBoxProfiles.CheckedItems)
{
switch (checkedItem.ToString())
{
case "Domain":
profiles |= FirewallProfiles.Domain;
break;
case "Private":
profiles |= FirewallProfiles.Private;
break;
case "Public":
profiles |= FirewallProfiles.Public;
break;
}
}

return profiles;
}
}
}
}
Loading