Skip to content

Commit a4409e0

Browse files
committed
Fixed IpPort so it can be set externally. Also updated csproj to be ready for nuget release
1 parent 6fc95e3 commit a4409e0

File tree

9 files changed

+41
-15
lines changed

9 files changed

+41
-15
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ publish/
143143
*.publishproj
144144

145145
# NuGet Packages
146-
# *.nupkg
146+
*.nupkg
147147
# The packages folder can be ignored because of Package Restore
148148
**/packages/*
149149
# except build/, which is used as an MSBuild target.

IPUserControls/Extensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
namespace IPUserControls
44
{
55
/// <summary>
6-
/// string extensions for validating if a string is a number and to
7-
/// remove chars like whitespace, leading zeros etc.
6+
/// string extensions
87
/// </summary>
98
public static class Extensions
109
{

IPUserControls/IPUserControls.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
44
<PropertyGroup>
5-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
66
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
77
<ProjectGuid>{96C79F86-B591-49C2-A3AA-98FA9C29A126}</ProjectGuid>
88
<OutputType>library</OutputType>
@@ -28,12 +28,13 @@
2828
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2929
<DebugType>pdbonly</DebugType>
3030
<Optimize>true</Optimize>
31-
<OutputPath>bin\Release\net48\</OutputPath>
31+
<OutputPath>bin\Release\</OutputPath>
3232
<DefineConstants>TRACE</DefineConstants>
3333
<ErrorReport>prompt</ErrorReport>
3434
<WarningLevel>1</WarningLevel>
35-
<PlatformTarget>x64</PlatformTarget>
35+
<PlatformTarget>AnyCPU</PlatformTarget>
3636
<Prefer32Bit>false</Prefer32Bit>
37+
<DocumentationFile>bin\Release\IPUserControls.xml</DocumentationFile>
3738
</PropertyGroup>
3839
<PropertyGroup>
3940
<ApplicationIcon>Images\IPUserControls.ico</ApplicationIcon>

IPUserControls/IpPort.xaml.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,34 @@ public IpPort()
2222
public ushort PortNumber
2323
{
2424
get => (ushort)GetValue(PortNumberProperty);
25-
private set
25+
set
2626
{
2727
SetValue(PortNumberProperty, value);
2828
OnPropertyChanged();
2929
}
3030
}
3131

32-
public static readonly DependencyProperty PortNumberProperty =
33-
DependencyProperty.Register("PortNumber", typeof(ushort), typeof(IpPort), new FrameworkPropertyMetadata(ushort.MinValue){BindsTwoWayByDefault = true});
32+
public static readonly DependencyProperty PortNumberProperty = DependencyProperty.Register
33+
(
34+
"PortNumber",
35+
typeof(ushort),
36+
typeof(IpPort),
37+
new FrameworkPropertyMetadata
38+
(
39+
ushort.MinValue,
40+
new PropertyChangedCallback(PortNumberChangedCallback)
41+
)
42+
{BindsTwoWayByDefault = true});
43+
3444

3545
// Event Handlers
3646
// --------------------------------------
47+
private static void PortNumberChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
48+
{
49+
var Uc = (IpPort) d;
50+
Uc.PortNumber = (ushort)e.NewValue;
51+
}
52+
3753
private void PortNumber_TextChanged(object sender, TextChangedEventArgs e)
3854
{
3955
if (PortNrTextBox.Text == PortNumber.ToString()) return;
-94 KB
Binary file not shown.
-1.35 MB
Binary file not shown.

IPUserControls/Properties/AssemblyInfo.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
// General Information about an assembly is controlled through the following
88
// set of attributes. Change these attribute values to modify the information
99
// associated with an assembly.
10-
[assembly: AssemblyTitle("WPF IP Address Field, Port and Status")]
11-
[assembly: AssemblyDescription("WPF User Controls with IP address field, IP port field and IP connection status icon.")]
10+
[assembly: AssemblyTitle("IPUserControls")]
11+
[assembly: AssemblyDescription("IP address and IP port text box, that only accept valid IP address and port values, as well as an IP connection status icon that changes its color and text based on the passed in connection status.")]
1212
[assembly: AssemblyConfiguration("")]
1313
[assembly: AssemblyCompany("Marius C. K.")]
1414
[assembly: AssemblyProduct("IPUserControls")]
15-
[assembly: AssemblyCopyright("Copyright © 2021")]
15+
[assembly: AssemblyCopyright("Marius C. K. Copyright © 2021")]
1616
[assembly: AssemblyTrademark("")]
1717
[assembly: AssemblyCulture("")]
1818

@@ -51,6 +51,6 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("0.0.0.1")]
55-
[assembly: AssemblyFileVersion("0.0.0.1")]
54+
[assembly: AssemblyVersion("1.1.0.0")]
55+
[assembly: AssemblyFileVersion("1.1.0.0")]
5656
[assembly: NeutralResourcesLanguage("en")]

Prototyping Prism/ViewModels/MainWindowViewModel.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public MainWindowViewModel()
1212
{
1313
ButtonClickCommand = new DelegateCommand(ButtonClick);
1414
ButtonIpChangeCommand = new DelegateCommand(IpChangeButtonClick);
15+
IpAddress = "192.168.0.175";
1516
}
1617

1718

@@ -39,7 +40,7 @@ public string IpAddress
3940
}
4041
}
4142

42-
private ConnectionStatus _connectionStatus;
43+
private ConnectionStatus _connectionStatus = ConnectionStatus.Disconnected;
4344
public ConnectionStatus ConnectionStatus
4445
{
4546
get => _connectionStatus;
@@ -64,4 +65,12 @@ private void ButtonClick()
6465

6566
}
6667
}
68+
69+
public enum SomeOtherConnectionStatus
70+
{
71+
Connected,
72+
Disconnected,
73+
Connecting,
74+
Error
75+
}
6776
}

Prototyping Prism/Views/MainWindow.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<Button Content="Change IP" Command="{Binding ButtonIpChangeCommand}"/>
1414
<ip:IpStatus ConnectionStatus="{Binding ConnectionStatus}"/>
1515
<Button Content="Change Status" Command="{Binding ButtonClickCommand}"/>
16+
<ip:IpPort PortNumber="500"/>
1617
</StackPanel>
1718
</StackPanel>
1819
</Grid>

0 commit comments

Comments
 (0)