Skip to content

Commit 449f0a7

Browse files
bitboundJared Goodwin
authored and
Jared Goodwin
committed
Create main window viewmodel.
1 parent fe6ba8e commit 449f0a7

13 files changed

+352
-9
lines changed

Agent.Installer.Win/Agent.Installer.Win.csproj

+6-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<WarningLevel>4</WarningLevel>
3939
</PropertyGroup>
4040
<PropertyGroup>
41-
<ApplicationIcon>favicon.ico</ApplicationIcon>
41+
<ApplicationIcon>Assets\favicon.ico</ApplicationIcon>
4242
</PropertyGroup>
4343
<PropertyGroup>
4444
<ApplicationManifest>app.manifest</ApplicationManifest>
@@ -76,6 +76,7 @@
7676
<Compile Include="Services\InstallerService.cs" />
7777
<Compile Include="Services\Logger.cs" />
7878
<Compile Include="ViewModels\MainWindowViewModel.cs" />
79+
<Compile Include="ViewModels\ViewModelBase.cs" />
7980
<Page Include="MainWindow.xaml">
8081
<Generator>MSBuild:Compile</Generator>
8182
<SubType>Designer</SubType>
@@ -118,9 +119,11 @@
118119
<None Include="App.config" />
119120
</ItemGroup>
120121
<ItemGroup>
121-
<Resource Include="favicon.ico" />
122+
<Resource Include="Assets\favicon.ico" />
123+
</ItemGroup>
124+
<ItemGroup>
125+
<Resource Include="Assets\Remotely_Icon.png" />
122126
</ItemGroup>
123-
<ItemGroup />
124127
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
125128
<Import Project="..\packages\Fody.6.1.0\build\Fody.targets" Condition="Exists('..\packages\Fody.6.1.0\build\Fody.targets')" />
126129
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

Agent.Installer.Win/App.xaml

+22-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,27 @@
44
xmlns:local="clr-namespace:Remotely.Agent.Installer.Win"
55
StartupUri="MainWindow.xaml">
66
<Application.Resources>
7-
7+
<Style x:Key="TitlebarButton" TargetType="Button">
8+
<Setter Property="Background" Value="#FF464646"></Setter>
9+
<Setter Property="DockPanel.Dock" Value="Right"></Setter>
10+
<Setter Property="HorizontalAlignment" Value="Right"></Setter>
11+
<Setter Property="BorderBrush" Value="{x:Null}"></Setter>
12+
<Setter Property="Foreground" Value="White"></Setter>
13+
<Setter Property="FontWeight" Value="Bold"></Setter>
14+
<Setter Property="Height" Value="30"></Setter>
15+
<Setter Property="Width" Value="30"></Setter>
16+
<Setter Property="Cursor" Value="Hand"></Setter>
17+
<Setter Property="Margin" Value="5,0,5,0"></Setter>
18+
</Style>
19+
<Style x:Key="SectionHeader" TargetType="TextBlock">
20+
<Setter Property="FontWeight" Value="Bold"></Setter>
21+
<Setter Property="FontSize" Value="18"></Setter>
22+
</Style>
23+
<Style x:Key="NormalButton" TargetType="Button">
24+
<Setter Property="Background" Value="White"></Setter>
25+
<Setter Property="BorderThickness" Value="1"></Setter>
26+
<Setter Property="BorderBrush" Value="Black"></Setter>
27+
<Setter Property="Padding" Value="6,4"></Setter>
28+
</Style>
829
</Application.Resources>
930
</Application>
File renamed without changes.

Agent.Installer.Win/FodyWeavers.xml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
2+
<Costura />
3+
</Weavers>

Agent.Installer.Win/FodyWeavers.xsd

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
3+
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
4+
<xs:element name="Weavers">
5+
<xs:complexType>
6+
<xs:all>
7+
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
8+
<xs:complexType>
9+
<xs:all>
10+
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string">
11+
<xs:annotation>
12+
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
13+
</xs:annotation>
14+
</xs:element>
15+
<xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string">
16+
<xs:annotation>
17+
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
18+
</xs:annotation>
19+
</xs:element>
20+
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
21+
<xs:annotation>
22+
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation>
23+
</xs:annotation>
24+
</xs:element>
25+
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string">
26+
<xs:annotation>
27+
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with line breaks.</xs:documentation>
28+
</xs:annotation>
29+
</xs:element>
30+
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string">
31+
<xs:annotation>
32+
<xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation>
33+
</xs:annotation>
34+
</xs:element>
35+
</xs:all>
36+
<xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean">
37+
<xs:annotation>
38+
<xs:documentation>This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.</xs:documentation>
39+
</xs:annotation>
40+
</xs:attribute>
41+
<xs:attribute name="IncludeDebugSymbols" type="xs:boolean">
42+
<xs:annotation>
43+
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
44+
</xs:annotation>
45+
</xs:attribute>
46+
<xs:attribute name="DisableCompression" type="xs:boolean">
47+
<xs:annotation>
48+
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
49+
</xs:annotation>
50+
</xs:attribute>
51+
<xs:attribute name="DisableCleanup" type="xs:boolean">
52+
<xs:annotation>
53+
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation>
54+
</xs:annotation>
55+
</xs:attribute>
56+
<xs:attribute name="LoadAtModuleInit" type="xs:boolean">
57+
<xs:annotation>
58+
<xs:documentation>Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.</xs:documentation>
59+
</xs:annotation>
60+
</xs:attribute>
61+
<xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean">
62+
<xs:annotation>
63+
<xs:documentation>Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.</xs:documentation>
64+
</xs:annotation>
65+
</xs:attribute>
66+
<xs:attribute name="ExcludeAssemblies" type="xs:string">
67+
<xs:annotation>
68+
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
69+
</xs:annotation>
70+
</xs:attribute>
71+
<xs:attribute name="IncludeAssemblies" type="xs:string">
72+
<xs:annotation>
73+
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
74+
</xs:annotation>
75+
</xs:attribute>
76+
<xs:attribute name="Unmanaged32Assemblies" type="xs:string">
77+
<xs:annotation>
78+
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation>
79+
</xs:annotation>
80+
</xs:attribute>
81+
<xs:attribute name="Unmanaged64Assemblies" type="xs:string">
82+
<xs:annotation>
83+
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with |.</xs:documentation>
84+
</xs:annotation>
85+
</xs:attribute>
86+
<xs:attribute name="PreloadOrder" type="xs:string">
87+
<xs:annotation>
88+
<xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation>
89+
</xs:annotation>
90+
</xs:attribute>
91+
</xs:complexType>
92+
</xs:element>
93+
</xs:all>
94+
<xs:attribute name="VerifyAssembly" type="xs:boolean">
95+
<xs:annotation>
96+
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
97+
</xs:annotation>
98+
</xs:attribute>
99+
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
100+
<xs:annotation>
101+
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
102+
</xs:annotation>
103+
</xs:attribute>
104+
<xs:attribute name="GenerateXsd" type="xs:boolean">
105+
<xs:annotation>
106+
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
107+
</xs:annotation>
108+
</xs:attribute>
109+
</xs:complexType>
110+
</xs:element>
111+
</xs:schema>

Agent.Installer.Win/MainWindow.xaml

+79-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,88 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
55
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:ViewModels="clr-namespace:Remotely.Agent.Installer.Win.ViewModels"
67
xmlns:local="clr-namespace:Remotely.Agent.Installer.Win"
78
mc:Ignorable="d"
8-
Title="MainWindow" Height="450" Width="800" Icon="favicon.ico">
9+
WindowStyle="None"
10+
ResizeMode="NoResize"
11+
MouseLeftButtonDown="Window_MouseLeftButtonDown"
12+
Loaded="Window_Loaded"
13+
Title="Remotely Installer" Height="350" Width="500" Icon="Assets/favicon.ico">
14+
<Window.Resources>
15+
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
16+
</Window.Resources>
17+
<Window.DataContext>
18+
<ViewModels:MainWindowViewModel/>
19+
</Window.DataContext>
920
<Grid>
21+
<Grid.RowDefinitions>
22+
<RowDefinition Height="Auto" />
23+
<RowDefinition />
24+
<RowDefinition Height="Auto" />
25+
</Grid.RowDefinitions>
1026

27+
<Border Grid.Row="0" Height="50" Background="#FF464646" VerticalAlignment="Top">
28+
<DockPanel Margin="10,0,0,0">
29+
<Image Height="50" Width="50" Source="Assets/Remotely_Icon.png" Margin="0,0,10,0"></Image>
30+
<TextBlock Foreground="DeepSkyBlue" FontWeight="Bold" FontSize="20" VerticalAlignment="Center">Remotely Installer</TextBlock>
31+
<Button Style="{StaticResource TitlebarButton}" Click="CloseButton_Click" Content="X" />
32+
<Button Style="{StaticResource TitlebarButton}" Click="MinimizeButton_Click" Content="_"/>
33+
</DockPanel>
34+
</Border>
35+
<Grid Grid.Row="1" Margin="10,15,10,0">
36+
37+
<StackPanel Visibility="{Binding IsServiceMissing, Converter={StaticResource BooleanToVisibilityConverter}}">
38+
<TextBlock Style="{StaticResource SectionHeader}" Text="{Binding HeaderMessage}"></TextBlock>
39+
<TextBlock TextWrapping="Wrap" Margin="25,5,0,0">
40+
<Run>Organization: </Run>
41+
<Run Text="{Binding OrganizationName}"></Run>
42+
</TextBlock>
43+
<TextBlock TextWrapping="Wrap" Margin="25,5,0,0">
44+
<Run>Server URL: </Run>
45+
<Run Text="{Binding ServerUrl}"></Run>
46+
</TextBlock>
47+
<TextBlock TextWrapping="Wrap" Margin="0,15,0,0" Text="{Binding SubMessage}"></TextBlock>
48+
<ProgressBar Height="25" Margin="0,25,0,0" Value="{Binding Progress}"></ProgressBar>
49+
<TextBlock TextWrapping="Wrap" Margin="0,15,0,0" Text="{Binding StatusMessage}"></TextBlock>
50+
</StackPanel>
51+
52+
<StackPanel Visibility="{Binding IsServiceInstalled, Converter={StaticResource BooleanToVisibilityConverter}}">
53+
<TextBlock Style="{StaticResource SectionHeader}" Text="{Binding HeaderMessage}"></TextBlock>
54+
<TextBlock TextWrapping="Wrap" Margin="25,5,0,0" Visibility="{Binding IsServiceMissing, Converter={StaticResource BooleanToVisibilityConverter}}">
55+
<Run>Organization: </Run>
56+
<Run Text="{Binding OrganizationName}"></Run>
57+
</TextBlock>
58+
<TextBlock TextWrapping="Wrap" Margin="25,5,0,0" Visibility="{Binding IsServiceMissing, Converter={StaticResource BooleanToVisibilityConverter}}">
59+
<Run>Server URL: </Run>
60+
<Run Text="{Binding ServerUrl}"></Run>
61+
</TextBlock>
62+
<TextBlock TextWrapping="Wrap" Margin="0,15,0,0" Text="{Binding SubMessage}"></TextBlock>
63+
</StackPanel>
64+
65+
</Grid>
66+
67+
<DockPanel Margin="10" Grid.Row="2">
68+
<Button DockPanel.Dock="Right"
69+
HorizontalAlignment="Right"
70+
Style="{StaticResource NormalButton}"
71+
Margin="5,0,0,0">
72+
Close
73+
</Button>
74+
<Button DockPanel.Dock="Right"
75+
HorizontalAlignment="Right"
76+
Style="{StaticResource NormalButton}"
77+
Margin="5,0,0,0"
78+
Visibility="{Binding IsServiceMissing, Converter={StaticResource BooleanToVisibilityConverter}}">
79+
Install
80+
</Button>
81+
<Button DockPanel.Dock="Right"
82+
HorizontalAlignment="Right"
83+
Style="{StaticResource NormalButton}"
84+
Margin="5,0,0,0"
85+
Visibility="{Binding IsServiceInstalled, Converter={StaticResource BooleanToVisibilityConverter}}">
86+
Uninstall
87+
</Button>
88+
</DockPanel>
1189
</Grid>
1290
</Window>

Agent.Installer.Win/MainWindow.xaml.cs

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using Remotely.Agent.Installer.Win.ViewModels;
2+
using System;
23
using System.Collections.Generic;
34
using System.Linq;
45
using System.Text;
@@ -24,5 +25,25 @@ public MainWindow()
2425
{
2526
InitializeComponent();
2627
}
28+
29+
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
30+
{
31+
DragMove();
32+
}
33+
34+
private async void Window_Loaded(object sender, RoutedEventArgs e)
35+
{
36+
await (DataContext as MainWindowViewModel).Init();
37+
}
38+
39+
private void CloseButton_Click(object sender, RoutedEventArgs e)
40+
{
41+
App.Current.Shutdown();
42+
}
43+
44+
private void MinimizeButton_Click(object sender, RoutedEventArgs e)
45+
{
46+
this.WindowState = WindowState.Minimized;
47+
}
2748
}
2849
}

Agent.Installer.Win/ViewModels/MainWindowViewModel.cs

+89-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,96 @@
99

1010
namespace Remotely.Agent.Installer.Win.ViewModels
1111
{
12-
public class MainWindowViewModel
12+
public class MainWindowViewModel : ViewModelBase
1313
{
14+
private string headerMessage = "Install the Remotely service.";
15+
private bool isServiceInstalled;
16+
private bool isServiceMissing = true;
17+
private string subMessage = "Installing the Remotely service will allow remote access by the above service provider.";
18+
private string statusMessage;
19+
private int progress = 50;
20+
21+
public string HeaderMessage
22+
{
23+
get
24+
{
25+
return headerMessage;
26+
}
27+
set
28+
{
29+
headerMessage = value;
30+
FirePropertyChanged(nameof(HeaderMessage));
31+
}
32+
}
33+
34+
35+
public int Progress
36+
{
37+
get
38+
{
39+
return progress;
40+
}
41+
set
42+
{
43+
progress = value;
44+
FirePropertyChanged(nameof(Progress));
45+
}
46+
}
47+
48+
public bool IsServiceInstalled
49+
{
50+
get
51+
{
52+
return isServiceInstalled;
53+
}
54+
set
55+
{
56+
isServiceInstalled = value;
57+
FirePropertyChanged(nameof(IsServiceInstalled));
58+
}
59+
}
60+
public bool IsServiceMissing
61+
{
62+
get
63+
{
64+
return isServiceMissing;
65+
}
66+
set
67+
{
68+
isServiceMissing = value;
69+
FirePropertyChanged(nameof(IsServiceMissing));
70+
}
71+
}
72+
public string SubMessage
73+
{
74+
get
75+
{
76+
return subMessage;
77+
}
78+
set
79+
{
80+
subMessage = value;
81+
FirePropertyChanged(nameof(SubMessage));
82+
}
83+
}
84+
85+
public string StatusMessage
86+
{
87+
get
88+
{
89+
return statusMessage;
90+
}
91+
set
92+
{
93+
statusMessage = value;
94+
FirePropertyChanged(nameof(StatusMessage));
95+
}
96+
}
97+
public async Task Init()
98+
{
99+
100+
}
101+
14102
public InstallerSettings ReadInstallerSettings()
15103
{
16104
try

0 commit comments

Comments
 (0)