Browse Source

Use WPF window instead of WinForms ElementHost

tags/4.2.1.0
database64128 4 years ago
parent
commit
1c2ac2978c
8 changed files with 61 additions and 235 deletions
  1. +11
    -0
      shadowsocks-csharp/ServerSharingWindow.xaml
  2. +27
    -0
      shadowsocks-csharp/ServerSharingWindow.xaml.cs
  3. +14
    -4
      shadowsocks-csharp/View/MenuViewController.cs
  4. +0
    -66
      shadowsocks-csharp/View/QRCodeForm.Designer.cs
  5. +0
    -35
      shadowsocks-csharp/View/QRCodeForm.cs
  6. +0
    -120
      shadowsocks-csharp/View/QRCodeForm.resx
  7. +1
    -1
      shadowsocks-csharp/Views/ServerSharingView.xaml
  8. +8
    -9
      shadowsocks-csharp/shadowsocks-csharp.csproj

+ 11
- 0
shadowsocks-csharp/ServerSharingWindow.xaml View File

@@ -0,0 +1,11 @@
<Window x:Class="Shadowsocks.ServerSharingWindow"
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:local="clr-namespace:Shadowsocks"
xmlns:views="clr-namespace:Shadowsocks.Views"
mc:Ignorable="d"
Title="Server Sharing" Height="400" Width="660">
<views:ServerSharingView />
</Window>

+ 27
- 0
shadowsocks-csharp/ServerSharingWindow.xaml.cs View File

@@ -0,0 +1,27 @@
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.Shapes;

namespace Shadowsocks
{
/// <summary>
/// Interaction logic for ServerSharingWindow.xaml
/// </summary>
public partial class ServerSharingWindow : Window
{
public ServerSharingWindow()
{
InitializeComponent();
}
}
}

+ 14
- 4
shadowsocks-csharp/View/MenuViewController.cs View File

@@ -65,6 +65,8 @@ namespace Shadowsocks.View
private HotkeySettingsForm hotkeySettingsForm;
private OnlineConfigForm onlineConfigForm;
private ServerSharingWindow serverSharingWindow;
// color definition for icon color transformation
private readonly Color colorMaskBlue = Color.FromArgb(255, 25, 125, 191);
private readonly Color colorMaskDarkSilver = Color.FromArgb(128, 192, 192, 192);
@@ -741,10 +743,18 @@ namespace Shadowsocks.View
private void QRCodeItem_Click(object sender, EventArgs e)
{
QRCodeForm qrCodeForm = new QRCodeForm(controller.GetServerURLForCurrentServer());
//qrCodeForm.Icon = this.Icon;
// TODO
qrCodeForm.Show();
if (serverSharingWindow == null)
{
serverSharingWindow = new ServerSharingWindow();
serverSharingWindow.Closed += ServerSharingWindow_Closed;
serverSharingWindow.Show();
}
serverSharingWindow.Activate();
}
private void ServerSharingWindow_Closed(object sender, EventArgs e)
{
serverSharingWindow = null;
}
private void ScanQRCodeItem_Click(object sender, EventArgs e)


+ 0
- 66
shadowsocks-csharp/View/QRCodeForm.Designer.cs View File

@@ -1,66 +0,0 @@
namespace Shadowsocks.View
{
partial class QRCodeForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.elementHost1 = new System.Windows.Forms.Integration.ElementHost();
this.serverSharingView1 = new Shadowsocks.Views.ServerSharingView();
this.SuspendLayout();
//
// elementHost1
//
this.elementHost1.Dock = System.Windows.Forms.DockStyle.Fill;
this.elementHost1.Location = new System.Drawing.Point(0, 0);
this.elementHost1.Margin = new System.Windows.Forms.Padding(0);
this.elementHost1.Name = "elementHost1";
this.elementHost1.Size = new System.Drawing.Size(600, 340);
this.elementHost1.TabIndex = 0;
this.elementHost1.Text = "elementHost1";
this.elementHost1.Child = this.serverSharingView1;
//
// QRCodeForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(600, 340);
this.Controls.Add(this.elementHost1);
this.Margin = new System.Windows.Forms.Padding(8);
this.Name = "QRCodeForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "QRCode and URL";
this.Load += new System.EventHandler(this.QRCodeForm_Load);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Integration.ElementHost elementHost1;
private Views.ServerSharingView serverSharingView1;
}
}

+ 0
- 35
shadowsocks-csharp/View/QRCodeForm.cs View File

@@ -1,35 +0,0 @@
using ZXing.QrCode.Internal;
using Shadowsocks.Controller;
using Shadowsocks.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Shadowsocks.Model;
namespace Shadowsocks.View
{
public partial class QRCodeForm : Form
{
private string code;
public QRCodeForm(string code)
{
this.code = code;
InitializeComponent();
this.Icon = Icon.FromHandle(Resources.ssw128.GetHicon());
this.Text = I18N.GetString("QRCode and URL");
}
private void QRCodeForm_Load(object sender, EventArgs e)
{
}
}
}

+ 0
- 120
shadowsocks-csharp/View/QRCodeForm.resx View File

@@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

+ 1
- 1
shadowsocks-csharp/Views/ServerSharingView.xaml View File

@@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Shadowsocks.Views"
mc:Ignorable="d"
d:DesignHeight="320" d:DesignWidth="600">
d:DesignHeight="400" d:DesignWidth="660">
<Grid Margin="8">
<Grid.RowDefinitions>
<RowDefinition Height="*" />


+ 8
- 9
shadowsocks-csharp/shadowsocks-csharp.csproj View File

@@ -41,6 +41,7 @@
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<ProjectTypeGuids>{60DC8134-EBA5-43B8-BCC9-BB4BC16C2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
@@ -256,6 +257,9 @@
<Compile Include="Controller\Strategy\IStrategy.cs" />
<Compile Include="Controller\Service\Sip003Plugin.cs" />
<Compile Include="Proxy\Socks5Proxy.cs" />
<Compile Include="ServerSharingWindow.xaml.cs">
<DependentUpon>ServerSharingWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Settings.cs" />
<Compile Include="Controller\System\Hotkeys\Hotkeys.cs" />
<Compile Include="StringEx.cs" />
@@ -312,12 +316,6 @@
<Compile Include="View\ProxyForm.Designer.cs">
<DependentUpon>ProxyForm.cs</DependentUpon>
</Compile>
<Compile Include="View\QRCodeForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="View\QRCodeForm.Designer.cs">
<DependentUpon>QRCodeForm.cs</DependentUpon>
</Compile>
<Compile Include="View\QRCodeSplashForm.cs">
<SubType>Form</SubType>
</Compile>
@@ -354,9 +352,6 @@
<EmbeddedResource Include="View\ProxyForm.resx">
<DependentUpon>ProxyForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="View\QRCodeForm.resx">
<DependentUpon>QRCodeForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="View\StatisticsStrategyConfigurationForm.resx">
<DependentUpon>StatisticsStrategyConfigurationForm.cs</DependentUpon>
</EmbeddedResource>
@@ -421,6 +416,10 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Page Include="ServerSharingWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ServerSharingView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>


Loading…
Cancel
Save