Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit e9aacc9

Browse files
authored
Merge pull request #86 from ShahriyarB/master
Code cleanup
2 parents 630d387 + 1968662 commit e9aacc9

File tree

65 files changed

+7748
-7097
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+7748
-7097
lines changed

Deploy/SpeditUpdater/Program.cs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
62
using System.Threading;
73
using System.Diagnostics;
8-
using System.Windows;
94
using System.Windows.Forms;
105
using System.IO;
116
using System.IO.Compression;
@@ -17,61 +12,66 @@ public static class Program
1712
[STAThread]
1813
public static void Main()
1914
{
20-
Process[] p = Process.GetProcessesByName("Spedit.exe");
21-
if (p.Length > 0)
15+
var process = Process.GetProcessesByName("Spedit.exe");
16+
17+
if (process.Length > 0)
2218
{
23-
for (int i = 0; i < p.Length; ++i)
24-
{
19+
foreach (var p in process)
2520
try
2621
{
27-
p[i].WaitForExit();
22+
p.WaitForExit();
23+
}
24+
catch (Exception)
25+
{
26+
// ignored
2827
}
29-
catch (Exception) { }
30-
}
3128
}
29+
3230
Application.EnableVisualStyles();
3331
Application.SetCompatibleTextRenderingDefault(true);
34-
UpdateMarquee um = new UpdateMarquee();
32+
33+
var um = new UpdateMarquee();
3534
um.Show();
36-
Application.DoEvents(); //execute Visual
37-
Thread t = new Thread(new ParameterizedThreadStart(Worker));
35+
36+
Application.DoEvents();
37+
38+
var t = new Thread(Worker);
3839
t.Start(um);
40+
3941
Application.Run(um);
4042
}
4143

4244
private static void Worker(object arg)
4345
{
44-
UpdateMarquee um = (UpdateMarquee)arg;
45-
string zipFile = Path.Combine(Environment.CurrentDirectory, "updateZipFile.zip");
46-
47-
byte[] zipFileContent = SpeditUpdater.Properties.Resources.spedit1_2_0_1Update;
46+
var um = (UpdateMarquee) arg;
47+
var zipFile = Path.Combine(Environment.CurrentDirectory, "updateZipFile.zip");
48+
var zipFileContent = Properties.Resources.spedit1_2_0_1Update;
4849

4950
File.WriteAllBytes(zipFile, zipFileContent);
5051

51-
FileInfo zipInfo = new FileInfo(zipFile);
52+
var zipInfo = new FileInfo(zipFile);
53+
var extractPath = Environment.CurrentDirectory;
5254

53-
string extractPath = Environment.CurrentDirectory;
54-
using (ZipArchive archieve = ZipFile.OpenRead(zipInfo.FullName))
55+
using (var archieve = ZipFile.OpenRead(zipInfo.FullName))
5556
{
5657
var entries = archieve.Entries;
58+
5759
foreach (var entry in entries)
5860
{
59-
string full = Path.Combine(extractPath, entry.FullName);
60-
FileInfo fInfo = new FileInfo(full);
61+
var full = Path.Combine(extractPath, entry.FullName);
62+
var fInfo = new FileInfo(full);
63+
6164
if (!Directory.Exists(fInfo.DirectoryName))
62-
{
63-
Directory.CreateDirectory(fInfo.DirectoryName);
64-
}
65+
if (fInfo.DirectoryName != null)
66+
Directory.CreateDirectory(fInfo.DirectoryName);
67+
6568
entry.ExtractToFile(fInfo.FullName, true);
6669
}
6770
}
6871

6972
zipInfo.Delete();
7073

71-
um.Invoke((InvokeDel)(() =>
72-
{
73-
um.SetToReadyState();
74-
}));
74+
um.Invoke((InvokeDel) (() => { um.SetToReadyState(); }));
7575
}
7676

7777
public delegate void InvokeDel();
Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.ComponentModel;
4-
using System.Data;
5-
using System.Drawing;
6-
using System.Linq;
7-
using System.Text;
8-
using System.Threading.Tasks;
92
using System.Windows.Forms;
103

114
namespace SpeditUpdater
@@ -15,21 +8,21 @@ public partial class UpdateMarquee : Form
158
public UpdateMarquee()
169
{
1710
InitializeComponent();
18-
Bitmap bmp = SpeditUpdater.Properties.Resources.IconPng;
19-
pictureBox1.Image = (Image)bmp;
11+
12+
pictureBox1.Image = Properties.Resources.IconPng;
2013
}
2114

2215
public void SetToReadyState()
2316
{
24-
label1.Text = "SPEdit got updated!";
17+
label1.Text = @"SPEdit got updated!";
2518
progressBar1.Visible = false;
2619
button1.Visible = true;
27-
this.UseWaitCursor = false;
20+
UseWaitCursor = false;
2821
}
2922

3023
private void button1_Click(object sender, EventArgs e)
3124
{
32-
this.Close();
25+
Close();
3326
}
3427
}
3528
}

0 commit comments

Comments
 (0)