Skip to content

Commit f00f625

Browse files
committed
feat: show datasource name in launcher, close #741
1 parent ed6665c commit f00f625

File tree

7 files changed

+53
-6
lines changed

7 files changed

+53
-6
lines changed

Ui/Model/GlobalData.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ public Result AddServer(ProtocolBase protocolServer, DataSourceBase dataSource)
181181
if (ret.IsSuccess)
182182
{
183183
var @new = new ProtocolBaseViewModel(protocolServer);
184+
@new.DataSourceNameForLauncher = _sourceService?.AdditionalSources.Any() == true ? protocolServer?.DataSource?.DataSourceName ?? "" : "";
184185
if (needReload == false)
185186
{
186187
VmItemList.Add(@new);
@@ -241,6 +242,7 @@ public Result UpdateServer(ProtocolBase protocolServer)
241242
if (old != null)
242243
{
243244
old.Server = protocolServer;
245+
old.DataSourceNameForLauncher = _sourceService?.AdditionalSources.Any() == true ? old.DataSourceName : "";
244246
}
245247
ReadTagsFromServers();
246248
IoC.Get<ServerListPageViewModel>().ClearSelection();
@@ -288,7 +290,9 @@ public Result UpdateServer(IEnumerable<ProtocolBase> protocolServers, bool reloa
288290
var old = GetItemById(source.DataSourceName, protocolServer.Id);
289291
// invoke main list ui change & invoke launcher ui change
290292
if (old != null)
293+
{
291294
old.Server = protocolServer;
295+
old.DataSourceNameForLauncher = _sourceService?.AdditionalSources.Any() == true ? old.DataSourceName : ""; }
292296
}
293297
}
294298

Ui/Service/DataSource/DataSourceService.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ public List<ProtocolBaseViewModel> GetServers(bool force)
4444
try
4545
{
4646
var pbs = dataSource.Value.GetServers(force);
47+
foreach (var pb in pbs)
48+
{
49+
pb.DataSourceNameForLauncher = AdditionalSources.Any() ? pb.DataSourceName : "";
50+
}
4751
ret.AddRange(pbs);
4852
}
4953
catch (Exception e)

Ui/Ui.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
3737
<RunPostBuildEvent>Always</RunPostBuildEvent>
3838
<XamlDebuggingInformation>True</XamlDebuggingInformation>
39+
40+
<CsWinRTAotOptimizerEnabled>false</CsWinRTAotOptimizerEnabled> <!-- 20241030 fix https://github.com/dotnet/sdk/issues/43680 -->
3941
</PropertyGroup>
4042

4143
<PropertyGroup Condition="'$(TargetFramework)'!='net48'">
@@ -73,7 +75,7 @@
7375
</PropertyGroup>
7476

7577
<PropertyGroup>
76-
<AssemblyVersion>1.0.1.41007</AssemblyVersion>
78+
<AssemblyVersion>1.0.1.41030</AssemblyVersion>
7779
<FileVersion>$(AssemblyVersion)</FileVersion>
7880
<Version>$(AssemblyVersion)</Version>
7981
<Authors>Shawn</Authors>

Ui/View/Launcher/ServerSelectionsView.xaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
</ContentControl.Resources>
120120
</ContentControl>
121121

122-
<Grid Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="4">
122+
<Grid Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="4">
123123

124124
<Grid.ColumnDefinitions>
125125
<ColumnDefinition Width="*"></ColumnDefinition>
@@ -158,6 +158,15 @@
158158
</Grid>
159159

160160

161+
<!--data source-->
162+
<TextBlock Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="4"
163+
HorizontalAlignment="Right"
164+
VerticalAlignment="Top"
165+
Text="{Binding DataSourceNameForLauncher}"
166+
Style="{StaticResource TextBlockTagStringStyle}"
167+
Opacity="0.15"
168+
>
169+
</TextBlock>
161170

162171

163172

Ui/View/ProtocolBaseViewModel.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ public class ProtocolBaseViewModel : NotifyPropertyChangedBase
2020
{
2121
public DataSourceBase? DataSource => Server.DataSource;
2222
public string DataSourceName => DataSource?.DataSourceName ?? "";
23+
private string _dataSourceNameForLauncher = "";
24+
public string DataSourceNameForLauncher
25+
{
26+
get => _dataSourceNameForLauncher;
27+
set => SetAndNotifyIfChanged(ref _dataSourceNameForLauncher, value);
28+
}
2329

2430
/// <summary>
2531
/// Order in Main window list view

Ui/View/Settings/DataSource/DataSourceViewModel.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using _1RM.Utils;
1010
using _1RM.View.Utils;
1111
using Shawn.Utils;
12-
using Shawn.Utils.Interface;
1312
using Shawn.Utils.Wpf;
1413
using Shawn.Utils.Wpf.FileSystem;
1514

@@ -102,7 +101,11 @@ public RelayCommand CmdAdd
102101
{
103102
try
104103
{
105-
_dataSourceService.AddOrUpdateDataSource(dataSource);
104+
var ret = _dataSourceService.AddOrUpdateDataSource(dataSource);
105+
if (ret.Status != EnumDatabaseStatus.OK)
106+
{
107+
MessageBoxHelper.ErrorAlert(ret.GetErrorMessage);
108+
}
106109
}
107110
finally
108111
{
@@ -143,7 +146,11 @@ public RelayCommand CmdEdit
143146
{
144147
try
145148
{
146-
_dataSourceService.AddOrUpdateDataSource(dataSource);
149+
var ret = _dataSourceService.AddOrUpdateDataSource(dataSource);
150+
if (ret.Status != EnumDatabaseStatus.OK)
151+
{
152+
MessageBoxHelper.ErrorAlert(ret.GetErrorMessage);
153+
}
147154
}
148155
finally
149156
{
@@ -213,7 +220,11 @@ public RelayCommand CmdRefreshDataSource
213220
{
214221
try
215222
{
216-
_dataSourceService.AddOrUpdateDataSource(dataSource);
223+
var ret = _dataSourceService.AddOrUpdateDataSource(dataSource);
224+
if (ret.Status != EnumDatabaseStatus.OK)
225+
{
226+
MessageBoxHelper.ErrorAlert(ret.GetErrorMessage);
227+
}
217228
}
218229
finally
219230
{

Ui/View/Settings/SettingsPageViewModel.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,17 @@ public RelayCommand CmdSaveAndGoBack
152152
return;
153153
}
154154

155+
foreach (var additionalSource in _dataSourceService.AdditionalSources)
156+
{
157+
var status = additionalSource.Value.Database_SelfCheck();
158+
if (status.Status != EnumDatabaseStatus.OK)
159+
{
160+
ShowPage(EnumMainWindowPage.SettingsData);
161+
MessageBoxHelper.ErrorAlert(status.GetErrorMessage);
162+
return;
163+
}
164+
}
165+
155166
if (_configurationService.Launcher.LauncherEnabled != IoC.TryGet<LauncherWindowViewModel>()?.SetHotKey(_configurationService.Launcher.LauncherEnabled, _configurationService.Launcher.HotKeyModifiers, _configurationService.Launcher.HotKeyKey))
156167
{
157168
ShowPage(EnumMainWindowPage.SettingsLauncher);

0 commit comments

Comments
 (0)