1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-29 00:26:09 +03:00

save mvvmcross

This commit is contained in:
next-autumn 2021-05-14 19:07:19 +08:00
parent a6221c330a
commit 8d531a2930
41 changed files with 758 additions and 144 deletions

View File

@ -12,7 +12,7 @@ namespace ProxySuper.Core
{ {
public override void Initialize() public override void Initialize()
{ {
RegisterAppStart<MainViewModel>(); RegisterAppStart<HomeViewModel>();
} }
} }
} }

View File

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProxySuper.Core.Models.Hosts
{
public class Host
{
public Host()
{
Proxy = new LocalProxy();
}
public string Tag { get; set; }
public string Address { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public int Port { get; set; } = 22;
public string PrivateKeyPath { get; set; }
public LocalProxy Proxy { get; set; }
public LoginSecretType SecretType { get; set; }
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProxySuper.Core.Models.Hosts
{
public class LocalProxy
{
public string Address { get; set; } = "127.0.0.1";
public int Port { get; set; } = 1080;
public LocalProxyType Type { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProxySuper.Core.Models.Hosts
{
public enum LocalProxyType
{
None = 0,
//
// 摘要:
// A SOCKS4 proxy server.
Socks4 = 1,
//
// 摘要:
// A SOCKS5 proxy server.
Socks5 = 2,
//
// 摘要:
// A HTTP proxy server.
Http = 3
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProxySuper.Core.Models.Hosts
{
public enum LoginSecretType
{
Password = 0,
PrivateKey = 1
}
}

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ProxySuper.Core.Models namespace ProxySuper.Core.Models.Projects
{ {
public interface IProjectSettings public interface IProjectSettings
{ {
@ -22,5 +22,10 @@ namespace ProxySuper.Core.Models
/// 额外需要开放的端口 /// 额外需要开放的端口
/// </summary> /// </summary>
List<int> FreePorts { get; } List<int> FreePorts { get; }
/// <summary>
/// 类型
/// </summary>
ProjectType Type { get; set; }
} }
} }

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProxySuper.Core.Models.Projects
{
public enum ProjectType
{
Xray = 0,
TrojanGo = 1,
NaiveProxy = 2
}
}

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ProxySuper.Core.Models namespace ProxySuper.Core.Models.Projects
{ {
public class TrojanGoSettings : IProjectSettings public class TrojanGoSettings : IProjectSettings
{ {
@ -16,6 +16,8 @@ namespace ProxySuper.Core.Models
} }
} }
public ProjectType Type { get; set; } = ProjectType.TrojanGo;
/// <summary> /// <summary>
/// 域名 /// 域名
/// </summary> /// </summary>

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ProxySuper.Core.Models namespace ProxySuper.Core.Models.Projects
{ {
public partial class XraySettings : IProjectSettings public partial class XraySettings : IProjectSettings
{ {
@ -21,6 +21,8 @@ namespace ProxySuper.Core.Models
} }
} }
public ProjectType Type { get; set; } = ProjectType.Xray;
/// <summary> /// <summary>
/// UUID /// UUID
/// </summary> /// </summary>

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ProxySuper.Core.Models namespace ProxySuper.Core.Models.Projects
{ {
public partial class XraySettings public partial class XraySettings
{ {

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ProxySuper.Core.Models namespace ProxySuper.Core.Models.Projects
{ {
public partial class XraySettings public partial class XraySettings
{ {

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ProxySuper.Core.Models namespace ProxySuper.Core.Models.Projects
{ {
public partial class XraySettings public partial class XraySettings
{ {

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ProxySuper.Core.Models namespace ProxySuper.Core.Models.Projects
{ {
public partial class XraySettings public partial class XraySettings
{ {

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ProxySuper.Core.Models namespace ProxySuper.Core.Models.Projects
{ {
public enum XrayType public enum XrayType
{ {

View File

@ -0,0 +1,29 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using ProxySuper.Core.Models.Hosts;
using ProxySuper.Core.Models.Projects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProxySuper.Core.Models
{
public class Record
{
public Host Host { get; set; }
[JsonProperty("settings")]
public dynamic Settings { get; set; }
public string Type
{
get
{
return Settings.type ?? "Xray";
}
}
}
}

View File

@ -57,22 +57,28 @@
<ItemGroup> <ItemGroup>
<Compile Include="App.cs" /> <Compile Include="App.cs" />
<Compile Include="Helpers\DateTimeUtils.cs" /> <Compile Include="Helpers\DateTimeUtils.cs" />
<Compile Include="Models\IProjectSettings.cs" /> <Compile Include="Models\Hosts\Host.cs" />
<Compile Include="Models\TrojanGoSettings.cs" /> <Compile Include="Models\Hosts\LocalProxyType.cs" />
<Compile Include="Models\XraySettings_SS.cs" /> <Compile Include="Models\Hosts\LoginSecretType.cs" />
<Compile Include="Models\XraySettings_Trojan.cs" /> <Compile Include="Models\Projects\IProjectSettings.cs" />
<Compile Include="Models\XraySettings_VLESS.cs" /> <Compile Include="Models\Hosts\LocalProxy.cs" />
<Compile Include="Models\XraySettings.cs" /> <Compile Include="Models\Projects\ProjectType.cs" />
<Compile Include="Models\XraySettings_VMESS.cs" /> <Compile Include="Models\Projects\TrojanGoSettings.cs" />
<Compile Include="Models\XrayType.cs" /> <Compile Include="Models\Projects\XraySettings_SS.cs" />
<Compile Include="Models\Projects\XraySettings_Trojan.cs" />
<Compile Include="Models\Projects\XraySettings_VLESS.cs" />
<Compile Include="Models\Projects\XraySettings.cs" />
<Compile Include="Models\Projects\XraySettings_VMESS.cs" />
<Compile Include="Models\Projects\XrayType.cs" />
<Compile Include="Models\Record.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\ProjectBase.cs" /> <Compile Include="Services\ProjectBase.cs" />
<Compile Include="Services\TrojanGoConfigBuilder.cs" /> <Compile Include="Services\TrojanGoConfigBuilder.cs" />
<Compile Include="Services\TrojanGoProject.cs" /> <Compile Include="Services\TrojanGoProject.cs" />
<Compile Include="Services\XrayConfigBuilder.cs" /> <Compile Include="Services\XrayConfigBuilder.cs" />
<Compile Include="Services\XrayProject.cs" /> <Compile Include="Services\XrayProject.cs" />
<Compile Include="ViewModels\SecondViewModel.cs" /> <Compile Include="ViewModels\HomeViewModel.cs" />
<Compile Include="ViewModels\MainViewModel.cs" /> <Compile Include="ViewModels\XrayEditorViewModel.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />

View File

@ -1,5 +1,6 @@
using ProxySuper.Core.Helpers; using ProxySuper.Core.Helpers;
using ProxySuper.Core.Models; using ProxySuper.Core.Models;
using ProxySuper.Core.Models.Projects;
using Renci.SshNet; using Renci.SshNet;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,6 +1,7 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using ProxySuper.Core.Models; using ProxySuper.Core.Models;
using ProxySuper.Core.Models.Projects;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;

View File

@ -1,4 +1,5 @@
using ProxySuper.Core.Models; using ProxySuper.Core.Models;
using ProxySuper.Core.Models.Projects;
using Renci.SshNet; using Renci.SshNet;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,6 +1,7 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using ProxySuper.Core.Models; using ProxySuper.Core.Models;
using ProxySuper.Core.Models.Projects;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;

View File

@ -1,5 +1,6 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using ProxySuper.Core.Models; using ProxySuper.Core.Models;
using ProxySuper.Core.Models.Projects;
using Renci.SshNet; using Renci.SshNet;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -0,0 +1,39 @@
using MvvmCross.Navigation;
using MvvmCross.ViewModels;
using Newtonsoft.Json;
using ProxySuper.Core.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProxySuper.Core.ViewModels
{
public class HomeViewModel : MvxViewModel
{
private readonly IMvxNavigationService _navigationService;
public HomeViewModel(IMvxNavigationService navigationService)
{
_navigationService = navigationService;
ReadRecords();
}
private void ReadRecords()
{
var json = File.ReadAllText("Data/Record.json");
var records = JsonConvert.DeserializeObject<List<Record>>(json);
this.Records = new MvxObservableCollection<Record>();
records.ForEach(item =>
{
this.Records.Add(item);
});
}
public MvxObservableCollection<Record> Records { get; set; }
}
}

View File

@ -1,23 +0,0 @@
using MvvmCross.Commands;
using MvvmCross.Navigation;
using MvvmCross.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProxySuper.Core.ViewModels
{
public class MainViewModel : MvxViewModel
{
private readonly IMvxNavigationService _navigationService;
public MainViewModel(IMvxNavigationService navigationService)
{
_navigationService = navigationService;
}
}
}

View File

@ -1,30 +0,0 @@
using MvvmCross.Commands;
using MvvmCross.Navigation;
using MvvmCross.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProxySuper.Core.ViewModels
{
public class SecondViewModel : MvxViewModel
{
private readonly IMvxNavigationService _navigationService;
public SecondViewModel(IMvxNavigationService navigationService)
{
_navigationService = navigationService;
}
public string Message { get; set; } = "Hello world!";
public IMvxCommand BackCommand => new MvxCommand(Back);
public void Back()
{
_navigationService.Close(this);
}
}
}

View File

@ -0,0 +1,25 @@
using MvvmCross.ViewModels;
using ProxySuper.Core.Models;
using ProxySuper.Core.Models.Hosts;
using ProxySuper.Core.Models.Projects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProxySuper.Core.ViewModels
{
public class XrayEditorViewModel : MvxViewModel<Record>
{
public Host Host { get; set; }
public XraySettings Settings { get; set; }
public override void Prepare(Record parameter)
{
Host = parameter.Host;
Settings = parameter.Settings as XraySettings;
}
}
}

View File

@ -3,12 +3,26 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ProxySuper.WPF" xmlns:local="clr-namespace:ProxySuper.WPF"
xmlns:views="clr-namespace:MvvmCross.Platforms.Wpf.Views;assembly=MvvmCross.Platforms.Wpf" xmlns:views="clr-namespace:MvvmCross.Platforms.Wpf.Views;assembly=MvvmCross.Platforms.Wpf"
xmlns:ui="http://schemas.modernwpf.com/2019"
StartupUri="MainWindow.xaml"> StartupUri="MainWindow.xaml">
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<!--Languages--> <!--Languages-->
<ResourceDictionary Source="/Resources/Languages/zh_cn.xaml" /> <ResourceDictionary Source="/Resources/Languages/zh_cn.xaml" />
<!--components styles-->
<ResourceDictionary Source="/Resources/Styles/DataGridStyle.xaml" />
<ResourceDictionary>
<Style TargetType="{x:Type TextBox}">
<Setter Property="Padding" Value="5" />
</Style>
<Style TargetType="{x:Type Label}">
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>
</Application.Resources> </Application.Resources>

View File

@ -0,0 +1,32 @@
<UserControl x:Class="ProxySuper.WPF.Controls.HostControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ProxySuper.WPF.Controls"
mc:Ignorable="d">
<Grid>
<GroupBox Padding="10" Header="Host">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<Label Content="地址:" Grid.Row="0" Grid.Column="0" />
<TextBox Grid.Row="0" Grid.Column="1"
Width="200"
Text="{Binding Host.Address}"
VerticalContentAlignment="Center" />
</Grid>
</GroupBox>
</Grid>
</UserControl>

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace ProxySuper.WPF.Controls
{
/// <summary>
/// HostControl.xaml 的交互逻辑
/// </summary>
public partial class HostControl : UserControl
{
public HostControl()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,54 @@
[
{
"host": {
"tag": "123",
"address": "122.23.36.32",
"userName": null,
"password": null,
"port": 22,
"privateKeyPath": null,
"proxy": {
"address": "127.0.0.1",
"port": 1080,
"type": 0,
"userName": null,
"password": null
},
"secretType": 0
},
"settings": {
"port": 443,
"uuid": "ac082c52-0be1-4a20-a1ee-aa7e29ce2d1e",
"vlesS_WS_Path": "/vlessws",
"vlesS_H2_Path": "/vlessh2",
"vlesS_KCP_Seed": "ac082c52-0be1-4a20-a1ee-aa7e29ce2d1e",
"vlesS_KCP_Type": "none",
"vlesS_KCP_Port": 2001,
"vlesS_gRPC_ServiceName": "xray_gRPC",
"vlesS_gRPC_Port": 2002,
"vmesS_WS_Path": "/vmessws",
"vmesS_TCP_Path": "/vmesstcp",
"vmesS_H2_Path": "/vmessh2",
"vmesS_KCP_Seed": "ac082c52-0be1-4a20-a1ee-aa7e29ce2d1e",
"vmesS_KCP_Type": "none",
"vmesS_KCP_Port": 3001,
"trojanPassword": "ac082c52-0be1-4a20-a1ee-aa7e29ce2d1e",
"trojan_WS_Path": "/trojanws",
"shadowsocksPassword": "ac082c52-0be1-4a20-a1ee-aa7e29ce2d1e",
"shadowsocksMethod": "aes-128-gcm",
"shadowSocksPort": 4001,
"domain": "www.baodu.com",
"maskDomain": null,
"types": [
100,
101,
102,
104,
202,
204,
401,
301
]
}
}
]

View File

@ -1,15 +1,14 @@
<local:MvxWindow x:Class="ProxySuper.WPF.MainWindow" <views:MvxWindow x:Class="ProxySuper.WPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MvvmCross.Platforms.Wpf.Views;assembly=MvvmCross.Platforms.Wpf" xmlns:views="clr-namespace:MvvmCross.Platforms.Wpf.Views;assembly=MvvmCross.Platforms.Wpf"
xmlns:local="clr-namespace:ProxySuper.WPF"
mc:Ignorable="d" mc:Ignorable="d"
FontSize="14" WindowStartupLocation="CenterScreen"
Icon="/Resources/ProxySU.ico" Title="ProxySU" Height="600" Width="1000">
Title="主机列表" Height="600" Width="1000">
<Grid> <Grid>
</Grid> </Grid>
</local:MvxWindow> </views:MvxWindow>

View File

@ -11,7 +11,6 @@ using System.Windows.Documents;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
namespace ProxySuper.WPF namespace ProxySuper.WPF

View File

@ -50,6 +50,9 @@
<HintPath>..\packages\System.Console.4.3.1\lib\net46\System.Console.dll</HintPath> <HintPath>..\packages\System.Console.4.3.1\lib\net46\System.Console.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web" /> <Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" /> <Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
@ -70,19 +73,32 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Compile Include="Views\MainView.xaml.cs"> <Compile Include="Controls\HostControl.xaml.cs">
<DependentUpon>MainView.xaml</DependentUpon> <DependentUpon>HostControl.xaml</DependentUpon>
</Compile>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="MainWindow.xaml.cs"> <Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon> <DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Views\HomeView.xaml.cs">
<DependentUpon>HomeView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\XrayEditorView.xaml.cs">
<DependentUpon>XrayEditorView.xaml</DependentUpon>
</Compile>
<Page Include="Controls\HostControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\HomeView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Page Include="Resources\Languages\en.xaml"> <Page Include="Resources\Languages\en.xaml">
@ -95,7 +111,13 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Page> </Page>
<Page Include="Views\MainView.xaml"> <Page Include="Resources\Styles\DataGridStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Page>
<Page Include="Views\XrayEditorView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
</ItemGroup> </ItemGroup>
@ -117,6 +139,9 @@
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
<None Include="Data\Record.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
@ -137,8 +162,13 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource> </Resource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup />
<Folder Include="Resources\Styles\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\System.Runtime.WindowsRuntime.4.6.0\build\net461\System.Runtime.WindowsRuntime.targets" Condition="Exists('..\packages\System.Runtime.WindowsRuntime.4.6.0\build\net461\System.Runtime.WindowsRuntime.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\System.Runtime.WindowsRuntime.4.6.0\build\net461\System.Runtime.WindowsRuntime.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Runtime.WindowsRuntime.4.6.0\build\net461\System.Runtime.WindowsRuntime.targets'))" />
</Target>
</Project> </Project>

View File

@ -2,6 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"> xmlns:sys="clr-namespace:System;assembly=mscorlib">
<!--Main Menu-->
<sys:String x:Key="MainMenuAddHost">Add Host</sys:String> <sys:String x:Key="MainMenuAddHost">Add Host</sys:String>
<sys:String x:Key="MainMenuActions">Actions</sys:String> <sys:String x:Key="MainMenuActions">Actions</sys:String>
<sys:String x:Key="MainMenuActionsExportSettings">Export Settings</sys:String> <sys:String x:Key="MainMenuActionsExportSettings">Export Settings</sys:String>
@ -13,4 +14,16 @@
<sys:String x:Key="MainMenuHelper">Helper</sys:String> <sys:String x:Key="MainMenuHelper">Helper</sys:String>
<sys:String x:Key="MainMenuHelperGithub">Github</sys:String> <sys:String x:Key="MainMenuHelperGithub">Github</sys:String>
<!--Main DataGrid-->
<sys:String x:Key="MainDataGridColumnTag">Tag</sys:String>
<sys:String x:Key="MainDataGridColumnAddress">Address</sys:String>
<sys:String x:Key="MainDataGridColumnType">Type</sys:String>
<sys:String x:Key="MainDataGridColumnAction">Action</sys:String>
<sys:String x:Key="MainDataGridColumnActionInstall">Install</sys:String>
<sys:String x:Key="MainDataGridColumnActionEdit">Edit</sys:String>
<sys:String x:Key="MainDataGridColumnActionDelete">Delete</sys:String>
<!--Editor Window-->
</ResourceDictionary> </ResourceDictionary>

View File

@ -2,6 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"> xmlns:sys="clr-namespace:System;assembly=mscorlib">
<!--Main Menu-->
<sys:String x:Key="MainMenuAddHost">添加主机</sys:String> <sys:String x:Key="MainMenuAddHost">添加主机</sys:String>
<sys:String x:Key="MainMenuActions">操作</sys:String> <sys:String x:Key="MainMenuActions">操作</sys:String>
<sys:String x:Key="MainMenuActionsExportSettings">导出配置</sys:String> <sys:String x:Key="MainMenuActionsExportSettings">导出配置</sys:String>
@ -14,4 +15,12 @@
<sys:String x:Key="MainMenuHelperGithub">Github</sys:String> <sys:String x:Key="MainMenuHelperGithub">Github</sys:String>
<!--Main DataGrid-->
<sys:String x:Key="MainDataGridColumnTag">名称</sys:String>
<sys:String x:Key="MainDataGridColumnAddress">地址</sys:String>
<sys:String x:Key="MainDataGridColumnType">类型</sys:String>
<sys:String x:Key="MainDataGridColumnAction">操作</sys:String>
<sys:String x:Key="MainDataGridColumnActionInstall">安装</sys:String>
<sys:String x:Key="MainDataGridColumnActionEdit">编辑</sys:String>
<sys:String x:Key="MainDataGridColumnActionDelete">删除</sys:String>
</ResourceDictionary> </ResourceDictionary>

View File

@ -0,0 +1,158 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<sys:Double x:Key="DataGridRow.Height">33</sys:Double>
<!-- 表格外边框线粗细,一般不修改 -->
<Thickness x:Key="DataGrid.BorderThickness" Bottom="1" Left="1" Right="1" Top="1" />
<!-- 列头边框粗细,一般不修改 -->
<Thickness x:Key="ColumnHeader.BorderThickness" Bottom="0" Left="0" Right="1" Top="0" />
<!-- 行边框粗细,一般不修改 -->
<Thickness x:Key="DataGridRow.BorderThickness" Bottom="0" Left="0" Right="0" Top="1" />
<!-- 表格外边框颜色 -->
<SolidColorBrush x:Key="DataGrid.BorderBrush" Color="#E9ECF1" />
<!-- 列头背景色 -->
<SolidColorBrush x:Key="ColumnHeader.Background" Color="#F6F7FB" />
<!-- 列头边框颜色 -->
<SolidColorBrush x:Key="ColumnHeader.BorderBrush" Color="#E9ECF1" />
<!-- 行边框颜色 -->
<SolidColorBrush x:Key="DataGridRow.BorderBrush" Color="#E9ECF1" />
<!-- 行默认背景颜色 -->
<SolidColorBrush x:Key="DataGridRow.Normal.Background" Color="#FFFFFF" />
<!-- 行默认文字颜色 -->
<SolidColorBrush x:Key="DataGridRow.Normal.Foreground" Color="#000000" />
<!-- 行悬浮背景颜色 -->
<SolidColorBrush x:Key="DataGridRow.MouseOver.Background" Color="#F6F7FB" />
<!-- 行悬浮文字颜色 -->
<SolidColorBrush x:Key="DataGridRow.MouseOver.Foreground" Color="#000000" />
<!-- 行选中背景颜色 -->
<SolidColorBrush x:Key="DataGridRow.Selected.Background" Color="#F6F7FB" />
<!-- 行选中文字颜色 -->
<SolidColorBrush x:Key="DataGridRow.Selected.Foreground" Color="#000000" />
<Style TargetType="DataGrid">
<!-- 网格线颜色 -->
<Setter Property="RowHeaderWidth" Value="0" />
<Setter Property="BorderThickness" Value="{StaticResource DataGrid.BorderThickness}" />
<Setter Property="HeadersVisibility" Value="Column" />
<Setter Property="Background" Value="{StaticResource ColumnHeader.Background}" />
<Setter Property="BorderBrush" Value="{StaticResource DataGrid.BorderBrush}" />
<Setter Property="HorizontalGridLinesBrush" Value="#00E9ECF1" />
<Setter Property="VerticalGridLinesBrush" Value="#00E9ECF1" />
<Setter Property="UseLayoutRounding" Value="True" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="AutoGenerateColumns" Value="False" />
<Setter Property="CanUserAddRows" Value="False" />
<Setter Property="CanUserReorderColumns" Value="False" />
<Setter Property="CanUserResizeColumns" Value="False" />
<Setter Property="CanUserResizeRows" Value="False" />
<Setter Property="CanUserSortColumns" Value="False" />
<Setter Property="GridLinesVisibility" Value="None" />
<Setter Property="IsReadOnly" Value="True" />
<Setter Property="RowHeight" Value="{StaticResource DataGridRow.Height}" />
<Setter Property="SelectionMode" Value="Single" />
</Style>
<!--列头样式-->
<Style TargetType="DataGridColumnHeader">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Foreground" Value="#000000" />
<Setter Property="FontSize" Value="12" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Height" Value="28" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridColumnHeader">
<Border x:Name="BackgroundBorder" Width="Auto" Margin="-1,0"
BorderBrush="{StaticResource ColumnHeader.BorderBrush}"
BorderThickness="{StaticResource ColumnHeader.BorderThickness}"
SnapsToDevicePixels="True" UseLayoutRounding="True">
<ContentPresenter Margin="5,0" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- 行样式触发 背景色改变必须先设置cellStyle 因为cellStyle会覆盖rowStyle样式 -->
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Background" Value="{StaticResource DataGridRow.Normal.Background}" />
<Setter Property="Foreground" Value="{StaticResource DataGridRow.MouseOver.Foreground}" />
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="UseLayoutRounding" Value="True" />
<Setter Property="Validation.ErrorTemplate" Value="{x:Null}" />
<Setter Property="BorderThickness" Value="{StaticResource DataGridRow.BorderThickness}" />
<Setter Property="BorderBrush" Value="{StaticResource DataGridRow.BorderBrush}" />
<Setter Property="ValidationErrorTemplate">
<Setter.Value>
<ControlTemplate>
<TextBlock Margin="0,0,0,0" VerticalAlignment="Center" Foreground="Red" Text="!" />
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridRow}">
<Border x:Name="DGR_Border" Margin="0,0,0,-1"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="True" UseLayoutRounding="True">
<SelectiveScrollingGrid>
<SelectiveScrollingGrid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</SelectiveScrollingGrid.ColumnDefinitions>
<SelectiveScrollingGrid.RowDefinitions>
<RowDefinition Height="*" MinHeight="{StaticResource DataGridRow.Height}" />
<RowDefinition Height="Auto" />
</SelectiveScrollingGrid.RowDefinitions>
<DataGridCellsPresenter Grid.Column="1"
ItemsPanel="{TemplateBinding ItemsPanel}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<DataGridDetailsPresenter Grid.Row="1" Grid.Column="1"
SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen,
ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical},
Converter={x:Static DataGrid.RowDetailsScrollingConverter},
RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
Visibility="{TemplateBinding DetailsVisibility}" />
<DataGridRowHeader Grid.RowSpan="2" SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
Visibility="{Binding HeadersVisibility,
ConverterParameter={x:Static DataGridHeadersVisibility.Row},
Converter={x:Static DataGrid.HeadersVisibilityConverter},
RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
</SelectiveScrollingGrid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{StaticResource DataGridRow.MouseOver.Foreground}" />
<Setter Property="Background" Value="{StaticResource DataGridRow.MouseOver.Background}" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Foreground" Value="{StaticResource DataGridRow.Selected.Foreground}" />
<Setter Property="Background" Value="{StaticResource DataGridRow.Selected.Background}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- 单元格样式触发 -->
<Style TargetType="DataGridCell">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridCell">
<Border x:Name="Bg" Background="Transparent" UseLayoutRounding="True">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="#000000" />
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>

View File

@ -0,0 +1,92 @@
<views:MvxWpfView x:Class="ProxySuper.WPF.Views.HomeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ProxySuper.WPF.Views"
xmlns:views="clr-namespace:MvvmCross.Platforms.Wpf.Views;assembly=MvvmCross.Platforms.Wpf"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Menu Background="White" Grid.Row="0" BorderThickness="0,0,0,2" BorderBrush="#eee">
<MenuItem Header="{DynamicResource MainMenuAddHost}" Padding="10,3">
<MenuItem Padding="0,5" Header="Xray"></MenuItem>
<MenuItem Padding="0,5" Header="Trojan-Go"></MenuItem>
<MenuItem Padding="0,5" Header="NaiveProxy"></MenuItem>
</MenuItem>
<MenuItem Header="{DynamicResource MainMenuActions}" Padding="10,3">
<MenuItem Padding="0,5" Header="{DynamicResource MainMenuActionsExportSettings}"></MenuItem>
<MenuItem Padding="0,5" Header="{DynamicResource MainMenuActionsExportSubscribe}"></MenuItem>
</MenuItem>
<MenuItem Header="{DynamicResource MainMenuLanguage}" Padding="10,3">
<MenuItem Padding="0,5" Header="{DynamicResource MainMenuLanguageEn}"></MenuItem>
<MenuItem Padding="0,5" Header="{DynamicResource MainMenuLanguageCn}"></MenuItem>
</MenuItem>
<MenuItem Header="{DynamicResource MainMenuHelper}" Padding="10,3">
<MenuItem Padding="0,5" Header="{DynamicResource MainMenuHelperGithub}" Click="LaunchGitHubSite"></MenuItem>
</MenuItem>
</Menu>
<StackPanel Grid.Row="1" Margin="0,10">
<DataGrid AutoGenerateColumns="False"
ItemsSource="{Binding Records}"
VerticalContentAlignment="Bottom"
IsReadOnly="True"
SelectionUnit="Cell"
BorderBrush="#eee"
BorderThickness="1">
<DataGrid.Columns>
<DataGridTemplateColumn Width="40">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox ></CheckBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Binding="{Binding Host.Tag}"
Header="{DynamicResource MainDataGridColumnTag}"
Width="120" />
<DataGridTextColumn Binding="{Binding Host.Address}"
Header="{DynamicResource MainDataGridColumnAddress}"
Width="200" />
<DataGridTextColumn Binding="{Binding Type}"
Header="{DynamicResource MainDataGridColumnType}"
Width="200" />
<DataGridTemplateColumn Header="{DynamicResource MainDataGridColumnAction}">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button Padding="10,3"
Click="NavToEditor"
Margin="5,0"
Content="{DynamicResource MainDataGridColumnActionInstall}" />
<Button Padding="10,3"
Click="NavToEditor"
Margin="5,0"
Content="{DynamicResource MainDataGridColumnActionEdit}" />
<Button Padding="10,3"
Click="NavToEditor"
Margin="5,0"
Content="{DynamicResource MainDataGridColumnActionDelete}" />
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</StackPanel>
</Grid>
</views:MvxWpfView>

View File

@ -0,0 +1,34 @@
using MvvmCross;
using MvvmCross.Navigation;
using MvvmCross.Platforms.Wpf.Views;
using ProxySuper.Core.Models;
using ProxySuper.Core.ViewModels;
using System.Windows;
namespace ProxySuper.WPF.Views
{
/// <summary>
/// HomeView.xaml 的交互逻辑
/// </summary>
public partial class HomeView : MvxWpfView
{
public HomeView()
{
InitializeComponent();
}
private void LaunchGitHubSite(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process.Start("explorer.exe", "https://github.com/proxysu/ProxySU");
}
private void NavToEditor(object sender, RoutedEventArgs e)
{
var navSrv = Mvx.IoCProvider.Resolve<IMvxNavigationService>();
var vm = ViewModel as HomeViewModel;
navSrv.Navigate<XrayEditorViewModel, Record>(vm.Records[0]);
}
}
}

View File

@ -1,40 +0,0 @@
<views:MvxWpfView x:Class="ProxySuper.WPF.Views.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespace:MvvmCross.Platforms.Wpf.Views;assembly=MvvmCross.Platforms.Wpf"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Menu Background="White" Grid.Row="0" BorderThickness="0,0,0,2" BorderBrush="#eee">
<MenuItem Header="{DynamicResource MainMenuAddHost}" Padding="10,3">
<MenuItem Padding="0,5" Header="Xray"></MenuItem>
<MenuItem Padding="0,5" Header="Trojan-Go"></MenuItem>
<MenuItem Padding="0,5" Header="NaiveProxy"></MenuItem>
</MenuItem>
<MenuItem Header="{DynamicResource MainMenuActions}" Padding="10,3">
<MenuItem Padding="0,5" Header="{DynamicResource MainMenuActionsExportSettings}"></MenuItem>
<MenuItem Padding="0,5" Header="{DynamicResource MainMenuActionsExportSubscribe}"></MenuItem>
</MenuItem>
<MenuItem Header="{DynamicResource MainMenuLanguage}" Padding="10,3">
<MenuItem Padding="0,5" Header="{DynamicResource MainMenuLanguageEn}"></MenuItem>
<MenuItem Padding="0,5" Header="{DynamicResource MainMenuLanguageCn}"></MenuItem>
</MenuItem>
<MenuItem Header="{DynamicResource MainMenuHelper}" Padding="10,3">
<MenuItem Padding="0,5" Header="{DynamicResource MainMenuHelperGithub}" Click="LaunchGitHubSite"></MenuItem>
</MenuItem>
</Menu>
<StackPanel Grid.Row="1" Margin="0,10">
</StackPanel>
</Grid>
</views:MvxWpfView>

View File

@ -0,0 +1,21 @@
<views:MvxWindow x:Class="ProxySuper.WPF.Views.XrayEditorView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespace:MvvmCross.Platforms.Wpf.Views;assembly=MvvmCross.Platforms.Wpf"
xmlns:local="clr-namespace:ProxySuper.WPF.Views"
xmlns:ctrl="clr-namespace:ProxySuper.WPF.Controls"
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
Title="XrayEditorView" Height="600" Width="1000">
<Grid>
<GroupBox Header="Host" Margin="10" Padding="10">
<StackPanel>
<ctrl:HostControl />
</StackPanel>
</GroupBox>
</Grid>
</views:MvxWindow>

View File

@ -16,18 +16,13 @@ using System.Windows.Shapes;
namespace ProxySuper.WPF.Views namespace ProxySuper.WPF.Views
{ {
/// <summary> /// <summary>
/// MainView.xaml 的交互逻辑 /// XrayEditorView.xaml 的交互逻辑
/// </summary> /// </summary>
public partial class MainView : MvxWpfView public partial class XrayEditorView : MvxWindow
{ {
public MainView() public XrayEditorView()
{ {
InitializeComponent(); InitializeComponent();
} }
private void LaunchGitHubSite(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process.Start("explorer.exe", "https://github.com/proxysu/ProxySU");
}
} }
} }

View File

@ -3,4 +3,6 @@
<package id="MvvmCross" version="7.1.2" targetFramework="net461" /> <package id="MvvmCross" version="7.1.2" targetFramework="net461" />
<package id="MvvmCross.Platforms.Wpf" version="7.1.2" targetFramework="net461" /> <package id="MvvmCross.Platforms.Wpf" version="7.1.2" targetFramework="net461" />
<package id="System.Console" version="4.3.1" targetFramework="net461" /> <package id="System.Console" version="4.3.1" targetFramework="net461" />
<package id="System.Runtime.WindowsRuntime" version="4.6.0" targetFramework="net461" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net461" />
</packages> </packages>