Skip to content

Commit 9b22ea4

Browse files
committed
zipperの超最適化
1 parent b5347da commit 9b22ea4

File tree

8 files changed

+422
-103
lines changed

8 files changed

+422
-103
lines changed

ConsoleApp1/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
5+
</startup>
6+
</configuration>

ConsoleApp1/ConsoleApp1.csproj

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{8EB29F44-4542-4989-943C-7207588297CE}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>ConsoleApp1</RootNamespace>
10+
<AssemblyName>ConsoleApp1</AssemblyName>
11+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Net.Http" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="Program.cs" />
47+
<Compile Include="Properties\AssemblyInfo.cs" />
48+
</ItemGroup>
49+
<ItemGroup>
50+
<None Include="App.config" />
51+
</ItemGroup>
52+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
53+
</Project>

ConsoleApp1/Program.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace ConsoleApp1 {
8+
class Program {
9+
static void Main(string[] args) {
10+
}
11+
static void kansuu() {
12+
app
13+
}
14+
}
15+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
6+
// 制御されます。アセンブリに関連付けられている情報を変更するには、
7+
// これらの属性値を変更します。
8+
[assembly: AssemblyTitle("ConsoleApp1")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("ConsoleApp1")]
13+
[assembly: AssemblyCopyright("Copyright © 2021")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// ComVisible を false に設定すると、このアセンブリ内の型は COM コンポーネントから
18+
// 参照できなくなります。COM からこのアセンブリ内の型にアクセスする必要がある場合は、
19+
// その型の ComVisible 属性を true に設定します。
20+
[assembly: ComVisible(false)]
21+
22+
// このプロジェクトが COM に公開される場合、次の GUID が typelib の ID になります
23+
[assembly: Guid("8eb29f44-4542-4989-943c-7207588297ce")]
24+
25+
// アセンブリのバージョン情報は次の 4 つの値で構成されています:
26+
//
27+
// メジャー バージョン
28+
// マイナー バージョン
29+
// ビルド番号
30+
// リビジョン
31+
//
32+
// すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます
33+
// 既定値にすることができます:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

MABProcessAtWait/Program.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
namespace MABProcessAtWait {
2626
static class Program {
27-
private static Logger logger = new Logger("Zipper");
27+
private static Logger logger = new Logger("MABProcess");
2828
/// <summary>
2929
/// アプリケーションのメイン エントリ ポイントです。
3030
/// </summary>
@@ -73,7 +73,7 @@ static void Main() {
7373
}
7474

7575
public partial class Form1 :Form {
76-
private static Logger logger = new Logger("Zipper");
76+
private static Logger logger = new Logger("MABProcess");
7777
private System.Windows.Forms.Timer timer;
7878
private string backupDataPath;
7979
private NotifyIcon notifyIcon;
@@ -92,6 +92,7 @@ public Form1() {
9292
};
9393
timer.Interval = 1000;
9494
timer.Tick += new EventHandler(Timer_Tick);
95+
notifyIcon = new NotifyIcon();
9596

9697
SetNotifyIconWait();
9798
}
@@ -129,6 +130,7 @@ private void Timer_Tick(object sender, EventArgs e) {
129130
logger.Info("isRunningがfalseに設定されていました");
130131

131132
SetNotifyIconBackuping();
133+
132134
backupTask = Task.Run(() => {
133135
DoBackupProcess();
134136
});
@@ -140,16 +142,21 @@ private void Timer_Tick(object sender, EventArgs e) {
140142
}
141143
}
142144

143-
private void bootMainForm_Click(object sender, EventArgs e) {
144-
logger.Info(System.Environment.CurrentDirectory);
145-
145+
private void BootMainForm_Click(object sender, EventArgs e) {
146146
var mainForm = new ProcessStartInfo();
147147
mainForm.FileName = ".\\Minecraft Auto Backup.exe";
148148
mainForm.UseShellExecute = true;
149149
mainForm.WorkingDirectory = ".\\";
150150
Process.Start(mainForm);
151151
}
152152

153+
private void DoBackup_Click (object sender, EventArgs e) {
154+
SetNotifyIconBackuping();
155+
backupTask = Task.Run(() => {
156+
DoBackupProcess();
157+
});
158+
}
159+
153160
private void DoBackupProcess() {
154161
logger.Info("バックアッププロセスを始めます");
155162
//zipperが起動している場合はバックアップを保留にする
@@ -267,7 +274,6 @@ private void DoBackup(string path, string Time) {
267274
}
268275

269276
private void SetNotifyIconWait() {
270-
notifyIcon = new NotifyIcon();
271277
notifyIcon.Icon = new Icon(".\\Image\\app_sub.ico");
272278
notifyIcon.Text = "MAB待機モジュール";
273279
notifyIcon.Visible = true;
@@ -278,15 +284,17 @@ private void SetNotifyIconWait() {
278284
menu.Items.Add(exit);
279285
ToolStripMenuItem bootMainForm = new ToolStripMenuItem();
280286
bootMainForm.Text = "バックアップの設定を編集する";
281-
bootMainForm.Click += new EventHandler(bootMainForm_Click);
287+
bootMainForm.Click += new EventHandler(BootMainForm_Click);
282288
menu.Items.Add(bootMainForm);
289+
ToolStripMenuItem doBackup = new ToolStripMenuItem();
290+
doBackup.Text = "バックアップを手動でする";
291+
doBackup.Click += new EventHandler(DoBackup_Click);
292+
menu.Items.Add(doBackup);
283293
notifyIcon.ContextMenuStrip = menu;
284294
}
285295

286296
private void SetNotifyIconBackuping() {
287-
notifyIcon = new NotifyIcon();
288297
notifyIcon.Icon = new Icon(".\\Image\\app_sub_doing.ico");
289-
notifyIcon.Text = "MAB待機モジュール(バックアップ中)";
290298
notifyIcon.Visible = true;
291299
ContextMenuStrip menu = new ContextMenuStrip();
292300
ToolStripMenuItem exit = new ToolStripMenuItem();

MainForms/AppConfigForm.cs

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//ちょっとFormの書き方変えてみたやつ
1212
//結局メリットはよくわからなかった
1313
internal class AppConfigForm :Form {
14+
private FormWindowState preWindowState;
1415
private Logger logger = new Logger("MainForm", ".\\logs\\MainForm.log", 3);
1516
private TabControl tab = new TabControl();
1617
private TabPage backupTab = new TabPage();
@@ -41,6 +42,14 @@ internal class AppConfigForm :Form {
4142
private FlowLayoutPanel startupTabF = new FlowLayoutPanel();
4243
private CheckBox addStartup = new CheckBox();
4344
public AppConfigForm() {
45+
//初期化
46+
if (this.WindowState == FormWindowState.Minimized) {
47+
this.preWindowState = FormWindowState.Normal;
48+
}
49+
else {
50+
this.preWindowState = this.WindowState;
51+
}
52+
this.SizeChanged += new EventHandler(AppConfigForm_SizeChanged);
4453

4554
//controls追加(ほかのフォームと比べ先に追加している。メリットは忘れた)
4655
backupPathPanel.Controls.AddRange(new Control[] { backupPathInput, refe });
@@ -76,9 +85,9 @@ public AppConfigForm() {
7685
okCanselFlowPanel.Height = 40;
7786
okCanselFlowPanel.FlowDirection = FlowDirection.RightToLeft;
7887

79-
backupTab.Text = "バックアップ";
80-
fontTab.Text = "フォント";
81-
startupTab.Text = "スタートアップに追加";
88+
backupTab.Text = "バックアップ";
89+
fontTab.Text = "フォント";
90+
startupTab.Text = "スタートアップに追加";
8291

8392
backupPath.Text = "バックアップの保存先";
8493
backupPath.AutoSize = true;
@@ -165,7 +174,20 @@ public AppConfigForm() {
165174

166175

167176
}
177+
//SizeChangedイベントハンドラ
178+
private void AppConfigForm_SizeChanged(object sender, EventArgs e) {
179+
//最小化された以外の時に、状態を覚えておく
180+
if (this.WindowState != FormWindowState.Minimized) {
181+
this.preWindowState = this.WindowState;
182+
}
183+
}
168184

185+
//フォームが最小化されている時、元の状態に戻す
186+
public void RestoreMinimizedWindow() {
187+
if (this.WindowState == FormWindowState.Minimized) {
188+
this.WindowState = this.preWindowState;
189+
}
190+
}
169191
private void addGameDir_Click(object sender, EventArgs e) {
170192
List<World> worlds = new List<World>();
171193
CommonOpenFileDialog copd = new CommonOpenFileDialog();
@@ -249,7 +271,13 @@ private void ok_Click(object sender, EventArgs e) {
249271
p.StartInfo = Decompression;
250272
logger.Info($"Zipper {command} {_args}");
251273
p.Start();
274+
this.Enabled = false;
275+
this.WindowState = FormWindowState.Minimized;
252276
p.WaitForExit();
277+
this.Enabled = true;
278+
this.WindowState = FormWindowState.Normal;
279+
RestoreMinimizedWindow();
280+
((WorldListForm)this.Owner).WindowState = FormWindowState.Normal;
253281
}
254282
}
255283
}
@@ -270,8 +298,12 @@ private void ok_Click(object sender, EventArgs e) {
270298
logger.Info($"Zipper {command} {_args}");
271299
p.Start();
272300
this.Enabled = false;
301+
this.WindowState = FormWindowState.Minimized;
273302
p.WaitForExit();
274303
this.Enabled = true;
304+
this.WindowState = FormWindowState.Normal;
305+
RestoreMinimizedWindow();
306+
((WorldListForm)this.Owner).WindowState = FormWindowState.Normal;
275307
}
276308
}
277309
}

MainForms/BackupDataListView.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ private void DeleteBackup_Click(object sender , EventArgs e) {
171171
// バックアップがzipだった場合
172172
backupPath = $"{AppConfig.BackupPath}\\{selectedItem.SubItems[2].Text}\\{selectedItem.World.WorldName}\\{fileName}.zip";
173173
FileSystem.DeleteFile(backupPath);
174-
175174
}
176175
else {
177176
// バックアップがzipじゃなかった場合
@@ -183,4 +182,4 @@ private void DeleteBackup_Click(object sender , EventArgs e) {
183182
}
184183

185184
}
186-
#endregion
185+
#endregion

0 commit comments

Comments
 (0)