Skip to content

Commit 71154cc

Browse files
committed
feat: Support MySQL database so you can share serves between different devices or within your team members #282
refactor: [WIP] working on multi credentials #301
1 parent 33ad3d6 commit 71154cc

File tree

12 files changed

+108
-235
lines changed

12 files changed

+108
-235
lines changed

Installer/Installer.wapproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
3232
<PackageCertificateKeyFile>Installer_TemporaryKey.pfx</PackageCertificateKeyFile>
3333
<EntryPointProjectUniqueName>..\Ui\Ui.csproj</EntryPointProjectUniqueName>
34+
<PackageCertificateThumbprint>4F04B56408BCE349E462DD18B2DEC3E21AAFF55C</PackageCertificateThumbprint>
3435
</PropertyGroup>
3536
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='StoreRelease|AnyCPU'">
3637
<DefaultLanguage>en-US</DefaultLanguage>
@@ -87,7 +88,6 @@
8788
<Content Include="Images\Square44x44Logo.targetsize-32.png" />
8889
<Content Include="Images\Square44x44Logo.targetsize-48.png" />
8990
<None Include="Installer_TemporaryKey.pfx" />
90-
<None Include="Shawn_Microsoft_Store_Installer_Key_20220107.pfx" />
9191
<None Include="Package.StoreAssociation.xml" />
9292
</ItemGroup>
9393
<ItemGroup>

Ui/Bootstrapper.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,10 @@ protected override void OnLaunch()
128128
{
129129
#if FOR_MICROSOFT_STORE_ONLY
130130
MsAppCenterHelper.TraceAppStatus(true, true);
131+
MsAppCenterHelper.TraceSpecial("Distributor", $"{Assert.APP_NAME} MS Store");
131132
#else
132133
MsAppCenterHelper.TraceAppStatus(true, false);
134+
MsAppCenterHelper.TraceSpecial("Distributor", $"{Assert.APP_NAME} Exe");
133135
#endif
134136
// Step4
135137
// This is called just after the root ViewModel has been launched

Ui/Model/Protocol/Base/ProtocolBase.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
34
using System.Diagnostics;
45
using System.IO;
56
using System.Linq;
@@ -274,9 +275,22 @@ public virtual string ToJsonString()
274275
/// </summary>
275276
public ProtocolBase Clone()
276277
{
278+
// TODO 使用 json 序列化来实现深拷贝
277279
var clone = this.MemberwiseClone() as ProtocolBase;
278280
Debug.Assert(clone != null);
279281
clone.Tags = new List<string>(this.Tags);
282+
if (this is ProtocolBaseWithAddressPortUserPwd p
283+
&& clone is ProtocolBaseWithAddressPortUserPwd c)
284+
{
285+
if (p.Credentials != null)
286+
{
287+
c.Credentials = new ObservableCollection<CredentialWithAddressPortUserPwd>(p.Credentials.Select(x => x.Clone() as CredentialWithAddressPortUserPwd));
288+
}
289+
else
290+
{
291+
c.Credentials = null;
292+
}
293+
}
280294
return clone;
281295
}
282296

Ui/Service/TaskTrayService.cs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using _1RM.Model;
88
using _1RM.Utils;
99
using _1RM.View;
10+
using Dragablz.Dockablz;
1011
using Shawn.Utils.Interface;
1112
using Shawn.Utils.Wpf;
1213
using Shawn.Utils.Wpf.Controls;
@@ -96,10 +97,10 @@ private void ReloadTaskTrayContextMenu()
9697
// rebuild TaskTrayContextMenu while language changed
9798
if (_taskTrayIcon == null) return;
9899

99-
var title = new System.Windows.Forms.ToolStripMenuItem(IoC.Get<LanguageService>().Translate("About") + $" {Assert.APP_DISPLAY_NAME}");
100-
title.Click += (sender, args) =>
100+
var about = new System.Windows.Forms.ToolStripMenuItem(IoC.Get<LanguageService>().Translate("About") + $" {Assert.APP_DISPLAY_NAME}");
101+
about.Click += (sender, args) =>
101102
{
102-
HyperlinkHelper.OpenUriBySystem("https://github.com/1Remote/1Remote");
103+
//HyperlinkHelper.OpenUriBySystem("https://github.com/1Remote/1Remote");
103104
IoC.Get<MainWindowViewModel>().ShowMe(true);
104105
IoC.Get<MainWindowViewModel>().CmdGoAboutPage.Execute();
105106
};
@@ -145,27 +146,11 @@ private void ReloadTaskTrayContextMenu()
145146
button.Click += (sender, args) => { GlobalEventHelper.OnRequestServerConnect?.Invoke(protocolBaseViewModel.Id, via: "Tray"); };
146147
_taskTrayIcon.ContextMenuStrip.Items.Add(button);
147148
}
148-
149-
_taskTrayIcon.ContextMenuStrip.Items.Add("-");
150-
151-
152-
var item = new System.Windows.Forms.ToolStripMenuItem(IoC.Get<LanguageService>().Translate("Hide recently used"));
153-
item.Click += (sender, args) =>
154-
{
155-
IoC.Get<ConfigurationService>().General.ShowRecentlySessionInTray = false;
156-
IoC.Get<ConfigurationService>().Save();
157-
ReloadTaskTrayContextMenu();
158-
MsAppCenterHelper.TraceSpecial("Tray recently", "Hide");
159-
};
160-
_taskTrayIcon.ContextMenuStrip.Items.Add(item);
161-
_taskTrayIcon.ContextMenuStrip.Items.Add("-");
162149
}
163150
}
164151

165152

166153

167-
_taskTrayIcon.ContextMenuStrip.Items.Add(title);
168-
_taskTrayIcon.ContextMenuStrip.Items.Add("-");
169154

170155
if (IoC.Get<ConfigurationService>().General.ShowRecentlySessionInTray == false)
171156
{
@@ -179,9 +164,25 @@ private void ReloadTaskTrayContextMenu()
179164
};
180165
_taskTrayIcon.ContextMenuStrip.Items.Add(item);
181166
}
167+
else
168+
{
169+
if (_taskTrayIcon.ContextMenuStrip.Items.Count > 0)
170+
_taskTrayIcon.ContextMenuStrip.Items.Add("-");
171+
172+
var item = new System.Windows.Forms.ToolStripMenuItem(IoC.Get<LanguageService>().Translate("Hide recently used"));
173+
item.Click += (sender, args) =>
174+
{
175+
IoC.Get<ConfigurationService>().General.ShowRecentlySessionInTray = false;
176+
IoC.Get<ConfigurationService>().Save();
177+
ReloadTaskTrayContextMenu();
178+
MsAppCenterHelper.TraceSpecial("Tray recently", "Hide");
179+
};
180+
_taskTrayIcon.ContextMenuStrip.Items.Add(item);
181+
}
182182

183183
//_taskTrayIcon.ContextMenuStrip.Items.Add(linkHowToUse);
184184
_taskTrayIcon.ContextMenuStrip.Items.Add(linkFeedback);
185+
_taskTrayIcon.ContextMenuStrip.Items.Add(about);
185186
_taskTrayIcon.ContextMenuStrip.Items.Add(exit);
186187

187188
// After startup and initializing our application and when closing our window and minimize the application to tray we free memory with the following line:

Ui/Utils/MsAppCenterHelper.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ public static void Error(Exception e, IDictionary<string, string>? properties =
4949
private static void Trace(EventName eventName, Dictionary<string, string> properties)
5050
{
5151
if (_isStarted == false) { return; }
52+
#if DEBUG
53+
Analytics.TrackEvent(eventName.ToString() + "_Debug", properties);
54+
#else
5255
Analytics.TrackEvent(eventName.ToString(), properties);
56+
#endif
5357
}
5458

5559

Ui/View/Editor/Forms/Credential/CredentialEditView.xaml renamed to Ui/View/Editor/Forms/AlternativeCredential/AlternativeCredentialEditView.xaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
<styles:WindowChromeBase x:Class="_1RM.View.Editor.Forms.Credential.CredentialEditView"
1+
<styles:WindowChromeBase x:Class="_1RM.View.Editor.Forms.AlternativeCredential.AlternativeCredentialEditView"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:settings="clr-namespace:_1RM.View.Settings"
77
xmlns:styles="clr-namespace:Shawn.Utils.WpfResources.Theme.Styles;assembly=Shawn.Utils.WpfResources"
88
xmlns:s="https://github.com/canton7/Stylet"
9-
xmlns:local="clr-namespace:_1RM.View.Editor.Forms.Credential"
9+
xmlns:local="clr-namespace:_1RM.View.Editor.Forms.AlternativeCredential"
1010
xmlns:attachProperty="clr-namespace:Shawn.Utils.WpfResources.Theme.AttachProperty;assembly=Shawn.Utils.WpfResources"
11+
xmlns:alternativeCredential="clr-namespace:_1RM.View.Editor.Forms.AlternativeCredential"
1112
mc:Ignorable="d"
1213
ShowInTaskbar="False"
1314
SizeToContent="WidthAndHeight"
1415
WindowStyle="None"
1516
Background="Transparent"
1617
AllowsTransparency="True"
17-
d:DataContext="{d:DesignInstance local:CredentialEditViewModel}">
18+
d:DataContext="{d:DesignInstance alternativeCredential:AlternativeCredentialEditViewModel}">
1819
<Window.Resources>
1920
<Style TargetType="TextBlock">
2021
<Setter Property="Foreground" Value="{DynamicResource BackgroundTextBrush}"></Setter>

Ui/View/Editor/Forms/Credential/CredentialEditViewModel.cs renamed to Ui/View/Editor/Forms/AlternativeCredential/AlternativeCredentialEditViewModel.cs

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,18 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.ComponentModel;
4-
using System.Diagnostics;
5-
using System.IO;
62
using System.Linq;
7-
using System.Text;
8-
using System.Threading;
9-
using System.Threading.Tasks;
10-
using System.Windows;
11-
using _1RM.Model;
12-
using _1RM.Model.DAO;
13-
using _1RM.Model.DAO.Dapper;
143
using _1RM.Model.Protocol.Base;
15-
using _1RM.Service;
16-
using _1RM.Service.DataSource;
17-
using _1RM.Service.DataSource.Model;
184
using _1RM.Utils;
19-
using _1RM.View.Settings.DataSource;
20-
using com.github.xiangyuecn.rsacsharp;
21-
using Shawn.Utils;
225
using Shawn.Utils.Interface;
236
using Shawn.Utils.Wpf;
24-
using Shawn.Utils.Wpf.FileSystem;
25-
using Stylet;
267

27-
namespace _1RM.View.Editor.Forms.Credential
8+
namespace _1RM.View.Editor.Forms.AlternativeCredential
289
{
29-
public class CredentialEditViewModel : NotifyPropertyChangedBaseScreen
10+
public class AlternativeCredentialEditViewModel : NotifyPropertyChangedBaseScreen
3011
{
3112
public CredentialWithAddressPortUserPwd? Org { get; } = null;
3213
public CredentialWithAddressPortUserPwd New { get; }= new CredentialWithAddressPortUserPwd();
3314
private readonly ProtocolBaseWithAddressPortUserPwd _protocol;
34-
public CredentialEditViewModel(ProtocolBaseWithAddressPortUserPwd protocol, CredentialWithAddressPortUserPwd? org = null)
15+
public AlternativeCredentialEditViewModel(ProtocolBaseWithAddressPortUserPwd protocol, CredentialWithAddressPortUserPwd? org = null)
3516
{
3617
_protocol = protocol;
3718
Org = org;
@@ -44,26 +25,25 @@ public CredentialEditViewModel(ProtocolBaseWithAddressPortUserPwd protocol, Cred
4425
}
4526

4627

47-
private string _name = "";
4828
public string Name
4929
{
50-
get => _name;
30+
get => New.Name;
5131
set
5232
{
53-
if (_name != value)
33+
if (New.Name != value)
5434
{
55-
if (string.IsNullOrWhiteSpace(_name))
35+
if (string.IsNullOrWhiteSpace(value))
5636
{
57-
_name = "";
37+
New.Name = "";
5838
RaisePropertyChanged();
5939
throw new ArgumentException(IoC.Get<ILanguageService>().Translate("Can not be empty!"));
6040
}
6141

62-
if (true == _protocol.Credentials?.Any(x => x != Org && string.Equals(x.Name, _name, StringComparison.CurrentCultureIgnoreCase)))
42+
if (true == _protocol.Credentials?.Any(x => x != Org && string.Equals(x.Name, value, StringComparison.CurrentCultureIgnoreCase)))
6343
{
64-
_name = "";
44+
New.Name = "";
6545
RaisePropertyChanged();
66-
throw new ArgumentException(IoC.Get<ILanguageService>().Translate("{0} is existed!", _name));
46+
throw new ArgumentException(IoC.Get<ILanguageService>().Translate("{0} is existed!", value));
6747
}
6848

6949
New.Name = value;
@@ -81,8 +61,8 @@ public RelayCommand CmdSave
8161
{
8262
return _cmdSave ??= new RelayCommand((o) =>
8363
{
84-
if (string.IsNullOrWhiteSpace(_name)
85-
|| true == _protocol.Credentials?.Any(x => x != Org && string.Equals(x.Name, _name, StringComparison.CurrentCultureIgnoreCase)))
64+
if (string.IsNullOrWhiteSpace(Name)
65+
|| true == _protocol.Credentials?.Any(x => x != Org && string.Equals(x.Name, Name, StringComparison.CurrentCultureIgnoreCase)))
8666
return;
8767
RequestClose(true);
8868

0 commit comments

Comments
 (0)