Browse Source

add visual feedback

tags/2.3
clowwindy 9 years ago
parent
commit
de0f752cc8
4 changed files with 38 additions and 5 deletions
  1. +25
    -1
      shadowsocks-csharp/View/MenuViewController.cs
  2. +3
    -3
      shadowsocks-csharp/View/QRCodeForm.Designer.cs
  3. +1
    -1
      shadowsocks-csharp/View/QRCodeForm.cs
  4. +9
    -0
      shadowsocks-csharp/shadowsocks-csharp.csproj

+ 25
- 1
shadowsocks-csharp/View/MenuViewController.cs View File

@@ -387,7 +387,26 @@ namespace Shadowsocks.View
var success = controller.AddServerBySSURL(result.Text);
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;
}
}
@@ -395,6 +414,11 @@ namespace Shadowsocks.View
}
}
void splash_FormClosed(object sender, FormClosedEventArgs e)
{
ShowConfigForm();
}
private void AutoStartupItem_Click(object sender, EventArgs e) {
AutoStartupItem.Checked = !AutoStartupItem.Checked;
if (!AutoStartup.Set(AutoStartupItem.Checked)) {


+ 3
- 3
shadowsocks-csharp/View/QRCodeForm.Designer.cs View File

@@ -34,10 +34,10 @@
//
// 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.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.TabIndex = 1;
this.pictureBox1.TabStop = false;
@@ -55,7 +55,7 @@
this.MaximizeBox = false;
this.MinimizeBox = false;
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.Text = "QRCode";
this.Load += new System.EventHandler(this.QRCodeForm_Load);


+ 1
- 1
shadowsocks-csharp/View/QRCodeForm.cs View File

@@ -30,7 +30,7 @@ namespace Shadowsocks.View
string qrText = ssconfig;
QRCode code = ZXing.QrCode.Internal.Encoder.encode(qrText, ErrorCorrectionLevel.M);
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));
using (Graphics g = Graphics.FromImage(drawArea))
{


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

@@ -183,6 +183,12 @@
<Compile Include="View\QRCodeForm.Designer.cs">
<DependentUpon>QRCodeForm.cs</DependentUpon>
</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">
<DependentUpon>ConfigForm.cs</DependentUpon>
<SubType>Designer</SubType>
@@ -195,6 +201,9 @@
<EmbeddedResource Include="View\QRCodeForm.resx">
<DependentUpon>QRCodeForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="View\QRCodeSplashForm.resx">
<DependentUpon>QRCodeSplashForm.cs</DependentUpon>
</EmbeddedResource>
<None Include="app.config" />
<None Include="app.manifest">
<SubType>Designer</SubType>


Loading…
Cancel
Save