Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit88a4a97

Browse files
authored
feat: integrate the tray app with RPC (#19)
- Modularizes the tray window to use multiple Pages for the threedifferent states: signed out, disconnected from RPC, normal- Adds the two new aforementioned pages- Adds a CredentialManager service for storing credentials in WindowsCredential Manager- Adds a RpcController service for managing the connection to thebackend service and reporting state changes to the ViewModel- Switches to using separate ViewModels in the Views- Switches to using Dependency Injection for instantiating Views,ViewModels and Services- Integrates the tray window into the new RpcController on Start/Stopinteractions. Workspace agent updates will be handled in a separate PRRelates to#5 (I will do agent updates immediately after this)
1 parent4c6d2bd commit88a4a97

File tree

51 files changed

+1677
-454
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1677
-454
lines changed

‎.idea/.idea.Coder.Desktop/.idea/codeStyles/Project.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎.idea/.idea.Coder.Desktop/.idea/codeStyles/codeStyleConfig.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎App/App.csproj

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
<Nullable>enable</Nullable>
1313
<EnableMsixTooling>true</EnableMsixTooling>
1414
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
15+
<!-- To use CommunityToolkit.Mvvm.ComponentModel.ObservablePropertyAttribute:-->
16+
<LangVersion>preview</LangVersion>
1517
</PropertyGroup>
1618

1719
<ItemGroup>
@@ -37,22 +39,11 @@
3739
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3840
</PackageReference>
3941
<PackageReferenceInclude="H.NotifyIcon.WinUI"Version="2.2.0" />
42+
<PackageReferenceInclude="Microsoft.Extensions.DependencyInjection"Version="9.0.1" />
4043
<PackageReferenceInclude="Microsoft.Windows.SDK.BuildTools"Version="10.0.26100.1742" />
4144
<PackageReferenceInclude="Microsoft.WindowsAppSDK"Version="1.6.250108002" />
4245
</ItemGroup>
4346

44-
<ItemGroup>
45-
<PageUpdate="TrayIcon.xaml">
46-
<Generator>MSBuild:Compile</Generator>
47-
</Page>
48-
</ItemGroup>
49-
50-
<ItemGroup>
51-
<PageUpdate="HorizontalRule.xaml">
52-
<Generator>MSBuild:Compile</Generator>
53-
</Page>
54-
</ItemGroup>
55-
5647
<!--
5748
Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging
5849
Tools extension to be activated for this project even if the Windows App SDK Nuget
@@ -61,6 +52,11 @@
6152
<ItemGroupCondition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
6253
<ProjectCapabilityInclude="Msix" />
6354
</ItemGroup>
55+
<ItemGroup>
56+
<ProjectReferenceInclude="..\CoderSdk\CoderSdk.csproj" />
57+
<ProjectReferenceInclude="..\Vpn.Proto\Vpn.Proto.csproj" />
58+
<ProjectReferenceInclude="..\Vpn\Vpn.csproj" />
59+
</ItemGroup>
6460

6561
<!--
6662
Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution

‎App/App.xaml.cs

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,55 @@
1+
usingSystem;
2+
usingSystem.Diagnostics;
3+
usingCoder.Desktop.App.Services;
4+
usingCoder.Desktop.App.ViewModels;
5+
usingCoder.Desktop.App.Views;
6+
usingCoder.Desktop.App.Views.Pages;
7+
usingMicrosoft.Extensions.DependencyInjection;
18
usingMicrosoft.UI.Xaml;
29

310
namespaceCoder.Desktop.App;
411

512
publicpartialclassApp:Application
613
{
7-
privateTrayWindow?TrayWindow;
14+
privatereadonlyIServiceProvider_services;
15+
privateTrayWindow?_trayWindow;
16+
privatereadonlybool_handleClosedEvents=true;
817

918
publicApp()
1019
{
20+
varservices=newServiceCollection();
21+
services.AddSingleton<ICredentialManager,CredentialManager>();
22+
services.AddSingleton<IRpcController,RpcController>();
23+
24+
services.AddTransient<TrayWindowDisconnectedViewModel>();
25+
services.AddTransient<TrayWindowDisconnectedPage>();
26+
services.AddTransient<TrayWindowLoginRequiredViewModel>();
27+
services.AddTransient<TrayWindowLoginRequiredPage>();
28+
services.AddTransient<TrayWindowLoginRequiredViewModel>();
29+
services.AddTransient<TrayWindowLoginRequiredPage>();
30+
services.AddTransient<TrayWindowViewModel>();
31+
services.AddTransient<TrayWindowMainPage>();
32+
services.AddTransient<TrayWindow>();
33+
34+
_services=services.BuildServiceProvider();
35+
36+
#ifDEBUG
37+
UnhandledException+=(_,e)=>{Debug.WriteLine(e.Exception.ToString());};
38+
#endif
39+
1140
InitializeComponent();
1241
}
1342

14-
privateboolHandleClosedEvents{get;}=true;
15-
1643
protectedoverridevoidOnLaunched(LaunchActivatedEventArgsargs)
1744
{
18-
TrayWindow=newTrayWindow();
19-
TrayWindow.Closed+=(sender,args)=>
45+
_trayWindow=_services.GetRequiredService<TrayWindow>();
46+
_trayWindow.Closed+=(sender,args)=>
2047
{
2148
// TODO: wire up HandleClosedEvents properly
22-
if(HandleClosedEvents)
49+
if(_handleClosedEvents)
2350
{
2451
args.Handled=true;
25-
TrayWindow.AppWindow.Hide();
52+
_trayWindow.AppWindow.Hide();
2653
}
2754
};
2855
}

‎App/HorizontalRule.xamlrenamed to‎App/Controls/HorizontalRule.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22

33
<UserControl
4-
x:Class="Coder.Desktop.App.HorizontalRule"
4+
x:Class="Coder.Desktop.App.Controls.HorizontalRule"
55
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
66
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
77
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

‎App/HorizontalRule.xaml.csrenamed to‎App/Controls/HorizontalRule.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
usingMicrosoft.UI.Xaml.Controls;
22

3-
namespaceCoder.Desktop.App;
3+
namespaceCoder.Desktop.App.Controls;
44

55
publicsealedpartialclassHorizontalRule:UserControl
66
{

‎App/TrayIcon.xamlrenamed to‎App/Controls/TrayIcon.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22

33
<UserControl
4-
x:Class="Coder.Desktop.App.TrayIcon"
4+
x:Class="Coder.Desktop.App.Controls.TrayIcon"
55
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
66
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
77
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

‎App/TrayIcon.xaml.csrenamed to‎App/Controls/TrayIcon.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
usingMicrosoft.UI.Xaml.Controls;
77
usingMicrosoft.UI.Xaml.Media.Imaging;
88

9-
namespaceCoder.Desktop.App;
9+
namespaceCoder.Desktop.App.Controls;
1010

1111
[DependencyProperty<ICommand>("OpenCommand")]
1212
[DependencyProperty<ICommand>("ExitCommand")]
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
usingSystem;
2+
usingWindows.UI;
3+
usingCoder.Desktop.App.ViewModels;
4+
usingMicrosoft.UI.Xaml.Data;
5+
usingMicrosoft.UI.Xaml.Media;
6+
7+
namespaceCoder.Desktop.App.Converters;
8+
9+
publicclassAgentStatusToColorConverter:IValueConverter
10+
{
11+
privatestaticreadonlySolidColorBrushGreen=new(Color.FromArgb(255,52,199,89));
12+
privatestaticreadonlySolidColorBrushRed=new(Color.FromArgb(255,255,59,48));
13+
privatestaticreadonlySolidColorBrushGray=new(Color.FromArgb(255,142,142,147));
14+
15+
publicobjectConvert(objectvalue,TypetargetType,objectparameter,stringlanguage)
16+
{
17+
if(valueis notAgentConnectionStatusstatus)returnGray;
18+
19+
returnstatusswitch
20+
{
21+
AgentConnectionStatus.Green=>Green,
22+
AgentConnectionStatus.Red=>Red,
23+
_=>Gray,
24+
};
25+
}
26+
27+
publicobjectConvertBack(objectvalue,TypetargetType,objectparameter,stringlanguage)
28+
{
29+
thrownewNotImplementedException();
30+
}
31+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
usingSystem;
2+
usingDependencyPropertyGenerator;
3+
usingMicrosoft.UI.Xaml;
4+
usingMicrosoft.UI.Xaml.Data;
5+
6+
namespaceCoder.Desktop.App.Converters;
7+
8+
[DependencyProperty<object>("TrueValue",DefaultValue=true)]
9+
[DependencyProperty<object>("FalseValue",DefaultValue=true)]
10+
publicpartialclassBoolToObjectConverter:DependencyObject,IValueConverter
11+
{
12+
publicobjectConvert(objectvalue,TypetargetType,objectparameter,stringlanguage)
13+
{
14+
returnvalueistrue?TrueValue:FalseValue;
15+
}
16+
17+
publicobjectConvertBack(objectvalue,TypetargetType,objectparameter,stringlanguage)
18+
{
19+
thrownewNotImplementedException();
20+
}
21+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
usingMicrosoft.UI.Xaml;
2+
3+
namespaceCoder.Desktop.App.Converters;
4+
5+
publicpartialclassBoolToVisibilityConverter:BoolToObjectConverter
6+
{
7+
publicBoolToVisibilityConverter()
8+
{
9+
TrueValue=Visibility.Visible;
10+
FalseValue=Visibility.Collapsed;
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
usingMicrosoft.UI.Xaml;
2+
3+
namespaceCoder.Desktop.App.Converters;
4+
5+
publicpartialclassInverseBoolToVisibilityConverter:BoolToObjectConverter
6+
{
7+
publicInverseBoolToVisibilityConverter()
8+
{
9+
TrueValue=Visibility.Collapsed;
10+
FalseValue=Visibility.Visible;
11+
}
12+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
usingSystem;
2+
usingCoder.Desktop.App.Models;
3+
usingDependencyPropertyGenerator;
4+
usingMicrosoft.UI.Xaml;
5+
usingMicrosoft.UI.Xaml.Data;
6+
7+
namespaceCoder.Desktop.App.Converters;
8+
9+
[DependencyProperty<bool>("Starting",DefaultValue=false)]
10+
[DependencyProperty<bool>("Started",DefaultValue=false)]
11+
[DependencyProperty<bool>("Stopping",DefaultValue=false)]
12+
[DependencyProperty<bool>("Stopped",DefaultValue=false)]
13+
publicpartialclassVpnLifecycleToBoolConverter:DependencyObject,IValueConverter
14+
{
15+
publicobjectConvert(objectvalue,TypetargetType,objectparameter,stringlanguage)
16+
{
17+
if(valueis notVpnLifecyclelifecycle)returnStopped;
18+
19+
returnlifecycleswitch
20+
{
21+
VpnLifecycle.Starting=>Starting,
22+
VpnLifecycle.Started=>Started,
23+
VpnLifecycle.Stopping=>Stopping,
24+
VpnLifecycle.Stopped=>Stopped,
25+
_=>Visibility.Collapsed,
26+
};
27+
}
28+
29+
publicobjectConvertBack(objectvalue,TypetargetType,objectparameter,stringlanguage)
30+
{
31+
thrownewNotImplementedException();
32+
}
33+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
usingSystem;
2+
usingMicrosoft.UI.Xaml;
3+
usingMicrosoft.UI.Xaml.Data;
4+
5+
namespaceCoder.Desktop.App.Converters;
6+
7+
publicpartialclassVpnLifecycleToVisibilityConverter:VpnLifecycleToBoolConverter,IValueConverter
8+
{
9+
publicnewobjectConvert(objectvalue,TypetargetType,objectparameter,stringlanguage)
10+
{
11+
varboolValue=base.Convert(value,targetType,parameter,language);
12+
returnboolValueistrue?Visibility.Visible:Visibility.Collapsed;
13+
}
14+
}

‎App/Models/CredentialModel.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
namespaceCoder.Desktop.App.Models;
2+
3+
publicenumCredentialState
4+
{
5+
Invalid,
6+
Valid,
7+
}
8+
9+
publicclassCredentialModel
10+
{
11+
publicCredentialStateState{get;set;}=CredentialState.Invalid;
12+
13+
publicstring?CoderUrl{get;set;}
14+
publicstring?ApiToken{get;set;}
15+
16+
publicCredentialModelClone()
17+
{
18+
returnnewCredentialModel
19+
{
20+
State=State,
21+
CoderUrl=CoderUrl,
22+
ApiToken=ApiToken,
23+
};
24+
}
25+
}

‎App/Models/RpcModel.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
usingSystem.Collections.Generic;
2+
3+
namespaceCoder.Desktop.App.Models;
4+
5+
publicenumRpcLifecycle
6+
{
7+
Disconnected,
8+
Connecting,
9+
Connected,
10+
}
11+
12+
publicenumVpnLifecycle
13+
{
14+
Stopped,
15+
Starting,
16+
Started,
17+
Stopping,
18+
}
19+
20+
publicclassRpcModel
21+
{
22+
publicRpcLifecycleRpcLifecycle{get;set;}=RpcLifecycle.Disconnected;
23+
24+
publicVpnLifecycleVpnLifecycle{get;set;}=VpnLifecycle.Stopped;
25+
26+
publicList<object>Agents{get;set;}=[];
27+
28+
publicRpcModelClone()
29+
{
30+
returnnewRpcModel
31+
{
32+
RpcLifecycle=RpcLifecycle,
33+
VpnLifecycle=VpnLifecycle,
34+
Agents=Agents,
35+
};
36+
}
37+
}

‎App/Package.appxmanifest

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
<Identity
1111
Name="925b49fc-4648-4967-b4e6-b5473061ee62"
1212
Publisher="CN=Coder Technologies Inc."
13-
Version="1.0.0.0"/>
13+
Version="1.0.0.0"/>
1414

1515
<mp:PhoneIdentityPhoneProductId="925b49fc-4648-4967-b4e6-b5473061ee62"
16-
PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
16+
PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
1717

1818
<Properties>
1919
<DisplayName>Coder Desktop (Package)</DisplayName>
@@ -22,12 +22,12 @@
2222
</Properties>
2323

2424
<Dependencies>
25-
<TargetDeviceFamilyName="Windows.Universal"MinVersion="10.0.17763.0"MaxVersionTested="10.0.19041.0"/>
26-
<TargetDeviceFamilyName="Windows.Desktop"MinVersion="10.0.17763.0"MaxVersionTested="10.0.19041.0"/>
25+
<TargetDeviceFamilyName="Windows.Universal"MinVersion="10.0.17763.0"MaxVersionTested="10.0.19041.0"/>
26+
<TargetDeviceFamilyName="Windows.Desktop"MinVersion="10.0.17763.0"MaxVersionTested="10.0.19041.0"/>
2727
</Dependencies>
2828

2929
<Resources>
30-
<ResourceLanguage="x-generate"/>
30+
<ResourceLanguage="x-generate"/>
3131
</Resources>
3232

3333
<Applications>
@@ -40,13 +40,13 @@
4040
BackgroundColor="transparent"
4141
Square150x150Logo="Images\Square150x150Logo.png"
4242
Square44x44Logo="Images\Square44x44Logo.png">
43-
<uap:DefaultTileWide310x150Logo="Images\Wide310x150Logo.png"/>
44-
<uap:SplashScreenImage="Images\SplashScreen.png"/>
43+
<uap:DefaultTileWide310x150Logo="Images\Wide310x150Logo.png"/>
44+
<uap:SplashScreenImage="Images\SplashScreen.png"/>
4545
</uap:VisualElements>
4646
</Application>
4747
</Applications>
4848

4949
<Capabilities>
50-
<rescap:CapabilityName="runFullTrust"/>
50+
<rescap:CapabilityName="runFullTrust"/>
5151
</Capabilities>
5252
</Package>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp