@@ -387,7 +387,26 @@ namespace Shadowsocks.View | |||||
var success = controller.AddServerBySSURL(result.Text); | var success = controller.AddServerBySSURL(result.Text); | ||||
if (success) | if (success) | ||||
{ | { | ||||
ShowConfigForm(); | |||||
float minX = Int32.MaxValue, minY = Int32.MaxValue, maxX = 0, maxY = 0; | |||||
foreach (ResultPoint point in result.ResultPoints) | |||||
{ | |||||
minX = Math.Min(minX, point.X); | |||||
minY = Math.Min(minY, point.Y); | |||||
maxX = Math.Max(maxX, point.X); | |||||
maxY = Math.Max(maxY, point.Y); | |||||
} | |||||
// make it 20% larger | |||||
float margin = (maxX - minX) * 0.20f; | |||||
minX -= margin; | |||||
maxX += margin; | |||||
minY -= margin; | |||||
maxY += margin; | |||||
QRCodeSplashForm splash = new QRCodeSplashForm(); | |||||
splash.FormClosed += splash_FormClosed; | |||||
splash.Location = new Point((int)minX, (int)minY); | |||||
splash.Size = new Size((int)maxX - (int)minX, (int)maxY - (int)minY); | |||||
splash.Show(); | |||||
return; | return; | ||||
} | } | ||||
} | } | ||||
@@ -395,6 +414,11 @@ namespace Shadowsocks.View | |||||
} | } | ||||
} | } | ||||
void splash_FormClosed(object sender, FormClosedEventArgs e) | |||||
{ | |||||
ShowConfigForm(); | |||||
} | |||||
private void AutoStartupItem_Click(object sender, EventArgs e) { | private void AutoStartupItem_Click(object sender, EventArgs e) { | ||||
AutoStartupItem.Checked = !AutoStartupItem.Checked; | AutoStartupItem.Checked = !AutoStartupItem.Checked; | ||||
if (!AutoStartup.Set(AutoStartupItem.Checked)) { | if (!AutoStartup.Set(AutoStartupItem.Checked)) { | ||||
@@ -34,10 +34,10 @@ | |||||
// | // | ||||
// pictureBox1 | // pictureBox1 | ||||
// | // | ||||
this.pictureBox1.Location = new System.Drawing.Point(9, 9); | |||||
this.pictureBox1.Location = new System.Drawing.Point(10, 10); | |||||
this.pictureBox1.Margin = new System.Windows.Forms.Padding(0); | this.pictureBox1.Margin = new System.Windows.Forms.Padding(0); | ||||
this.pictureBox1.Name = "pictureBox1"; | this.pictureBox1.Name = "pictureBox1"; | ||||
this.pictureBox1.Size = new System.Drawing.Size(210, 210); | |||||
this.pictureBox1.Size = new System.Drawing.Size(240, 240); | |||||
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; | this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; | ||||
this.pictureBox1.TabIndex = 1; | this.pictureBox1.TabIndex = 1; | ||||
this.pictureBox1.TabStop = false; | this.pictureBox1.TabStop = false; | ||||
@@ -55,7 +55,7 @@ | |||||
this.MaximizeBox = false; | this.MaximizeBox = false; | ||||
this.MinimizeBox = false; | this.MinimizeBox = false; | ||||
this.Name = "QRCodeForm"; | this.Name = "QRCodeForm"; | ||||
this.Padding = new System.Windows.Forms.Padding(9); | |||||
this.Padding = new System.Windows.Forms.Padding(10); | |||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; | ||||
this.Text = "QRCode"; | this.Text = "QRCode"; | ||||
this.Load += new System.EventHandler(this.QRCodeForm_Load); | this.Load += new System.EventHandler(this.QRCodeForm_Load); | ||||
@@ -30,7 +30,7 @@ namespace Shadowsocks.View | |||||
string qrText = ssconfig; | string qrText = ssconfig; | ||||
QRCode code = ZXing.QrCode.Internal.Encoder.encode(qrText, ErrorCorrectionLevel.M); | QRCode code = ZXing.QrCode.Internal.Encoder.encode(qrText, ErrorCorrectionLevel.M); | ||||
ByteMatrix m = code.Matrix; | ByteMatrix m = code.Matrix; | ||||
int blockSize = Math.Max(200 / m.Height, 1); | |||||
int blockSize = Math.Max(pictureBox1.Height / m.Height, 1); | |||||
Bitmap drawArea = new Bitmap((m.Width * blockSize), (m.Height * blockSize)); | Bitmap drawArea = new Bitmap((m.Width * blockSize), (m.Height * blockSize)); | ||||
using (Graphics g = Graphics.FromImage(drawArea)) | using (Graphics g = Graphics.FromImage(drawArea)) | ||||
{ | { | ||||
@@ -183,6 +183,12 @@ | |||||
<Compile Include="View\QRCodeForm.Designer.cs"> | <Compile Include="View\QRCodeForm.Designer.cs"> | ||||
<DependentUpon>QRCodeForm.cs</DependentUpon> | <DependentUpon>QRCodeForm.cs</DependentUpon> | ||||
</Compile> | </Compile> | ||||
<Compile Include="View\QRCodeSplashForm.cs"> | |||||
<SubType>Form</SubType> | |||||
</Compile> | |||||
<Compile Include="View\QRCodeSplashForm.Designer.cs"> | |||||
<DependentUpon>QRCodeSplashForm.cs</DependentUpon> | |||||
</Compile> | |||||
<EmbeddedResource Include="View\ConfigForm.resx"> | <EmbeddedResource Include="View\ConfigForm.resx"> | ||||
<DependentUpon>ConfigForm.cs</DependentUpon> | <DependentUpon>ConfigForm.cs</DependentUpon> | ||||
<SubType>Designer</SubType> | <SubType>Designer</SubType> | ||||
@@ -195,6 +201,9 @@ | |||||
<EmbeddedResource Include="View\QRCodeForm.resx"> | <EmbeddedResource Include="View\QRCodeForm.resx"> | ||||
<DependentUpon>QRCodeForm.cs</DependentUpon> | <DependentUpon>QRCodeForm.cs</DependentUpon> | ||||
</EmbeddedResource> | </EmbeddedResource> | ||||
<EmbeddedResource Include="View\QRCodeSplashForm.resx"> | |||||
<DependentUpon>QRCodeSplashForm.cs</DependentUpon> | |||||
</EmbeddedResource> | |||||
<None Include="app.config" /> | <None Include="app.config" /> | ||||
<None Include="app.manifest"> | <None Include="app.manifest"> | ||||
<SubType>Designer</SubType> | <SubType>Designer</SubType> | ||||