docx, xlsx, pptx の中に張り付けられた PNG ( BMP ) を JPEG へ変換して docx, xlsx, pptx のファイルサイズを削減する。
Revision | 8 (tree) |
---|---|
Time | 2017-09-30 21:39:56 |
Author | hor931101jp |
(empty log message)
@@ -1,63 +0,0 @@ | ||
1 | -'------------------------------------------------------------------------------ | |
2 | -' <auto-generated> | |
3 | -' このコードはツールによって生成されました。 | |
4 | -' ランタイム バージョン:4.0.30319.42000 | |
5 | -' | |
6 | -' このファイルへの変更は、以下の状況下で不正な動作の原因になったり、 | |
7 | -' コードが再生成されるときに損失したりします。 | |
8 | -' </auto-generated> | |
9 | -'------------------------------------------------------------------------------ | |
10 | - | |
11 | -Option Strict On | |
12 | -Option Explicit On | |
13 | - | |
14 | -Imports System | |
15 | - | |
16 | -Namespace My.Resources | |
17 | - | |
18 | - 'このクラスは StronglyTypedResourceBuilder クラスが ResGen | |
19 | - 'または Visual Studio のようなツールを使用して自動生成されました。 | |
20 | - 'メンバーを追加または削除するには、.ResX ファイルを編集して、/str オプションと共に | |
21 | - 'ResGen を実行し直すか、または VS プロジェクトをビルドし直します。 | |
22 | - '''<summary> | |
23 | - ''' ローカライズされた文字列などを検索するための、厳密に型指定されたリソース クラスです。 | |
24 | - '''</summary> | |
25 | - <Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _ | |
26 | - Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _ | |
27 | - Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _ | |
28 | - Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _ | |
29 | - Public Module Resources | |
30 | - | |
31 | - Private resourceMan As Global.System.Resources.ResourceManager | |
32 | - | |
33 | - Private resourceCulture As Global.System.Globalization.CultureInfo | |
34 | - | |
35 | - '''<summary> | |
36 | - ''' このクラスで使用されているキャッシュされた ResourceManager インスタンスを返します。 | |
37 | - '''</summary> | |
38 | - <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ | |
39 | - Public ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager | |
40 | - Get | |
41 | - If Object.ReferenceEquals(resourceMan, Nothing) Then | |
42 | - Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("OfficeImageReducer.Resources", GetType(Resources).Assembly) | |
43 | - resourceMan = temp | |
44 | - End If | |
45 | - Return resourceMan | |
46 | - End Get | |
47 | - End Property | |
48 | - | |
49 | - '''<summary> | |
50 | - ''' 厳密に型指定されたこのリソース クラスを使用して、すべての検索リソースに対し、 | |
51 | - ''' 現在のスレッドの CurrentUICulture プロパティをオーバーライドします。 | |
52 | - '''</summary> | |
53 | - <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ | |
54 | - Public Property Culture() As Global.System.Globalization.CultureInfo | |
55 | - Get | |
56 | - Return resourceCulture | |
57 | - End Get | |
58 | - Set | |
59 | - resourceCulture = value | |
60 | - End Set | |
61 | - End Property | |
62 | - End Module | |
63 | -End Namespace |
@@ -1,35 +0,0 @@ | ||
1 | -Imports System | |
2 | -Imports System.Reflection | |
3 | -Imports System.Runtime.InteropServices | |
4 | - | |
5 | -' アセンブリに関する一般情報は以下の属性セットをとおして制御されます。 | |
6 | -' アセンブリに関連付けられている情報を変更するには、 | |
7 | -' これらの属性値を変更してください。 | |
8 | - | |
9 | -' アセンブリ属性の値を確認します。 | |
10 | - | |
11 | -<Assembly: AssemblyTitle("")> | |
12 | -<Assembly: AssemblyDescription("")> | |
13 | -<Assembly: AssemblyCompany("")> | |
14 | -<Assembly: AssemblyProduct("")> | |
15 | -<Assembly: AssemblyCopyright("")> | |
16 | -<Assembly: AssemblyTrademark("")> | |
17 | - | |
18 | -<Assembly: ComVisible(False)> | |
19 | - | |
20 | -'このプロジェクトが COM に公開される場合、次の GUID がタイプ ライブラリの ID になります。 | |
21 | -<Assembly: Guid("1be446ae-e39f-46da-b27d-5cb47b36183c")> | |
22 | - | |
23 | -' アセンブリのバージョン情報は、以下の 4 つの値で構成されています: | |
24 | -' | |
25 | -' Major Version | |
26 | -' Minor Version | |
27 | -' Build Number | |
28 | -' Revision | |
29 | -' | |
30 | -' すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を | |
31 | -' 既定値にすることができます: | |
32 | -' <Assembly: AssemblyVersion("1.0.*")> | |
33 | - | |
34 | -<Assembly: AssemblyVersion("1.0.0.0")> | |
35 | -<Assembly: AssemblyFileVersion("1.0.0.0")> |
@@ -1,73 +0,0 @@ | ||
1 | -'------------------------------------------------------------------------------ | |
2 | -' <auto-generated> | |
3 | -' このコードはツールによって生成されました。 | |
4 | -' ランタイム バージョン:4.0.30319.42000 | |
5 | -' | |
6 | -' このファイルへの変更は、以下の状況下で不正な動作の原因になったり、 | |
7 | -' コードが再生成されるときに損失したりします。 | |
8 | -' </auto-generated> | |
9 | -'------------------------------------------------------------------------------ | |
10 | - | |
11 | -Option Strict On | |
12 | -Option Explicit On | |
13 | - | |
14 | - | |
15 | -Namespace My | |
16 | - | |
17 | - <Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _ | |
18 | - Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0"), _ | |
19 | - Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ | |
20 | - Partial Friend NotInheritable Class MySettings | |
21 | - Inherits Global.System.Configuration.ApplicationSettingsBase | |
22 | - | |
23 | - Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) | |
24 | - | |
25 | -#Region "My.Settings 自動保存機能" | |
26 | -#If _MyType = "WindowsForms" Then | |
27 | - Private Shared addedHandler As Boolean | |
28 | - | |
29 | - Private Shared addedHandlerLockObject As New Object | |
30 | - | |
31 | - <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ | |
32 | - Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) | |
33 | - If My.Application.SaveMySettingsOnExit Then | |
34 | - My.Settings.Save() | |
35 | - End If | |
36 | - End Sub | |
37 | -#End If | |
38 | -#End Region | |
39 | - | |
40 | - Public Shared ReadOnly Property [Default]() As MySettings | |
41 | - Get | |
42 | - | |
43 | -#If _MyType = "WindowsForms" Then | |
44 | - If Not addedHandler Then | |
45 | - SyncLock addedHandlerLockObject | |
46 | - If Not addedHandler Then | |
47 | - AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings | |
48 | - addedHandler = True | |
49 | - End If | |
50 | - End SyncLock | |
51 | - End If | |
52 | -#End If | |
53 | - Return defaultInstance | |
54 | - End Get | |
55 | - End Property | |
56 | - End Class | |
57 | -End Namespace | |
58 | - | |
59 | -Namespace My | |
60 | - | |
61 | - <Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _ | |
62 | - Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _ | |
63 | - Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _ | |
64 | - Friend Module MySettingsProperty | |
65 | - | |
66 | - <Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _ | |
67 | - Friend ReadOnly Property Settings() As Global.OfficeImageReducer.My.MySettings | |
68 | - Get | |
69 | - Return Global.OfficeImageReducer.My.MySettings.Default | |
70 | - End Get | |
71 | - End Property | |
72 | - End Module | |
73 | -End Namespace |
@@ -1,22 +0,0 @@ | ||
1 | -<?xml version="1.0" encoding="utf-8"?> | |
2 | -<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |
3 | - <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> | |
4 | - <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> | |
5 | - <security> | |
6 | - <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> | |
7 | - <!-- UAC マニフェスト オプション | |
8 | - Windows のユーザー アカウント制御のレベルを変更するには、 | |
9 | - requestedExecutionLevel ノードを以下のいずれかで置換します。 | |
10 | - | |
11 | - <requestedExecutionLevel level="asInvoker" uiAccess="false" /> | |
12 | - <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> | |
13 | - <requestedExecutionLevel level="highestAvailable" uiAccess="false" /> | |
14 | - | |
15 | - 下位互換性のためにファイルおよびレジストリの仮想化を | |
16 | - 利用する場合は、requestedExecutionLevel ノードを削除してください。 | |
17 | - --> | |
18 | - <requestedExecutionLevel level="asInvoker" uiAccess="false" /> | |
19 | - </requestedPrivileges> | |
20 | - </security> | |
21 | - </trustInfo> | |
22 | -</asmv1:assembly> |
@@ -1,38 +0,0 @@ | ||
1 | -'------------------------------------------------------------------------------ | |
2 | -' <auto-generated> | |
3 | -' このコードはツールによって生成されました。 | |
4 | -' ランタイム バージョン:4.0.30319.42000 | |
5 | -' | |
6 | -' このファイルへの変更は、以下の状況下で不正な動作の原因になったり、 | |
7 | -' コードが再生成されるときに損失したりします。 | |
8 | -' </auto-generated> | |
9 | -'------------------------------------------------------------------------------ | |
10 | - | |
11 | -Option Strict On | |
12 | -Option Explicit On | |
13 | - | |
14 | - | |
15 | -Namespace My | |
16 | - | |
17 | - 'メモ:このファイルは自動生成されました。直接変更しないでください。変更したり、 | |
18 | - ' ビルド エラーが発生した場合は、プロジェクト デザイナー へ移動し (プロジェクト | |
19 | - ' プロパティに移動するか、またはソリューション エクスプローラーのマイ プロジェクト | |
20 | - ' ノード上でダブルクリック)、アプリケーション タブ上で変更を行います。 | |
21 | - ' | |
22 | - Partial Friend Class MyApplication | |
23 | - | |
24 | - <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _ | |
25 | - Public Sub New() | |
26 | - MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) | |
27 | - Me.IsSingleInstance = false | |
28 | - Me.EnableVisualStyles = true | |
29 | - Me.SaveMySettingsOnExit = true | |
30 | - Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses | |
31 | - End Sub | |
32 | - | |
33 | - <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _ | |
34 | - Protected Overrides Sub OnCreateMainForm() | |
35 | - Me.MainForm = Global.OfficeImageReducer.FormMain | |
36 | - End Sub | |
37 | - End Class | |
38 | -End Namespace |
@@ -1,139 +0,0 @@ | ||
1 | -Imports OfficeImageReducer.ClassMyCommon ''ClassMyCoomonのプロパティ・メソッドを参照するためのImportsステートメント | |
2 | - | |
3 | -''' <summary>ログ管理クラス</summary> | |
4 | -Public Class ClassLog | |
5 | - | |
6 | - ''' <summary>フルパスでのログファイル名</summary> | |
7 | - Private LogFileName As String | |
8 | - | |
9 | - ''' <summary>ログファイル保存用の裏バッファ</summary> | |
10 | - Private _ShadowBuf As String | |
11 | - | |
12 | - ''' <summary>フォーム上のログ表示用テキストボックス</summary> | |
13 | - Private _LogTextBox As TextBox | |
14 | - | |
15 | - ''' <summary>コンストラクタ</summary> | |
16 | - ''' <param name="LogTextBox">フォーム上のログ表示用テキストボックス</param> | |
17 | - Public Sub New(ByVal LogTextBox As TextBox) | |
18 | - _LogTextBox = LogTextBox | |
19 | - _LogTextBox.Text = "" | |
20 | - _ShadowBuf = "" | |
21 | - LogFileName = AppPath() + "Log" + Now.ToString("yyMM") + ".txt" | |
22 | - End Sub | |
23 | - | |
24 | - ''' <summary>Delegate ログの追加</summary> | |
25 | - ''' <param name="stradd">ログ追加文字列</param> | |
26 | - Delegate Sub Add_Callback(ByVal stradd As String) | |
27 | - | |
28 | - ''' <summary>ログの追加</summary> | |
29 | - ''' <param name="stradd">ログ追加文字列</param> | |
30 | - ''' <remarks>ログの最下行へのスクロール・表示更新は行わない</remarks> | |
31 | - Public Sub Add(ByVal stradd As String) | |
32 | - Dim SplitBuf() As String | |
33 | - Dim i As Integer | |
34 | - Dim TempText As String | |
35 | - | |
36 | - ''別スレッドか判定 | |
37 | - If _LogTextBox.InvokeRequired Then | |
38 | - ''別スレッドからの場合コールバック処理をして終了 | |
39 | - Dim d As New Add_Callback(AddressOf Add) | |
40 | - _LogTextBox.Invoke(d, New Object() {stradd}) | |
41 | - Exit Sub | |
42 | - End If | |
43 | - | |
44 | - If Len(stradd) = 0 Then Exit Sub | |
45 | - | |
46 | - If InStr(stradd, vbCrLf) = 0 Then stradd &= vbCrLf | |
47 | - | |
48 | - SplitBuf = Split(stradd, vbCrLf) | |
49 | - If UBound(SplitBuf) > 0 Then | |
50 | - For i = 0 To UBound(SplitBuf) - 1 | |
51 | - 'TempText = Format(Now, "yy/MM/dd HH:mm:ss") & " : " & SplitBuf(i) & vbCrLf | |
52 | - TempText = Format(Now, "MM/dd HH:mm:ss") & " : " & SplitBuf(i) & vbCrLf | |
53 | - _LogTextBox.Text += TempText | |
54 | - _ShadowBuf += TempText | |
55 | - Next i | |
56 | - End If | |
57 | - | |
58 | - End Sub | |
59 | - | |
60 | - ''' <summary>Delegate ログの追加と表示の更新</summary> | |
61 | - ''' <param name="stradd">ログ追加文字列</param> | |
62 | - Delegate Sub Put_Callback(ByVal stradd As String) | |
63 | - | |
64 | - ''' <summary>ログの最終行を表示する。</summary> | |
65 | - Public Sub Put() | |
66 | - ''カレット位置を末尾に移動 | |
67 | - _LogTextBox.SelectionStart = _LogTextBox.Text.Length | |
68 | - ''カレット位置までスクロール | |
69 | - _LogTextBox.ScrollToCaret() | |
70 | - End Sub | |
71 | - | |
72 | - ''' <summary>ログの追加と最下行へのスクロール・表示更新</summary> | |
73 | - ''' <param name="stradd">ログ追加文字列</param> | |
74 | - Public Sub Put(ByVal stradd As String) | |
75 | - | |
76 | - ''別スレッドか判定 | |
77 | - If _LogTextBox.InvokeRequired Then | |
78 | - ''別スレッドからの場合コールバック処理をして終了 | |
79 | - Dim d As New Put_Callback(AddressOf Put) | |
80 | - _LogTextBox.Invoke(d, New Object() {stradd}) | |
81 | - Exit Sub | |
82 | - End If | |
83 | - | |
84 | - ''古いログを廃棄する | |
85 | - DeleteOld() | |
86 | - | |
87 | - ''ログ追加処理 | |
88 | - Add(stradd) | |
89 | - | |
90 | - ''最新ログまでスクロール | |
91 | - Put() | |
92 | - | |
93 | - End Sub | |
94 | - | |
95 | - ''' <summary>デバッグログの追加と最下行へのスクロール・表示更新</summary> | |
96 | - ''' <param name="stradd">デバッグログ追加文字列</param> | |
97 | - Public Sub DebugPut(ByVal stradd As String) | |
98 | - | |
99 | -#If 0 Then | |
100 | - Put(stradd) | |
101 | -#End If | |
102 | - | |
103 | - End Sub | |
104 | - | |
105 | - ''' <summary>ログをファイルへ保存する</summary> | |
106 | - Public Sub Save() | |
107 | - If _ShadowBuf.Length = 0 Then Exit Sub | |
108 | - | |
109 | -#If 0 Then 'このプログラムでは保存機能は封印する。 | |
110 | - ''追記モードでShift-JISファイルを開く | |
111 | - Using Writer As New System.IO.StreamWriter(LogFileName, True, System.Text.Encoding.GetEncoding("shift-jis")) | |
112 | - Writer.Write(_ShadowBuf) | |
113 | - End Using | |
114 | -#End If | |
115 | - _ShadowBuf = "" | |
116 | - End Sub | |
117 | - | |
118 | - ''' <summary>古いログ表示を破棄する</summary> | |
119 | - Private Sub DeleteOld() | |
120 | - Dim SplitBuf() As String | |
121 | - | |
122 | - ''ログ表示量が MaxLength -1024 より小さくなるまで破棄する。 | |
123 | - While Len(_LogTextBox.Text) > (_LogTextBox.MaxLength - 1024) | |
124 | - SplitBuf = Split(_LogTextBox.Text, vbLf, 2) | |
125 | - If UBound(SplitBuf) > 0 Then | |
126 | - _LogTextBox.Text = SplitBuf(1) | |
127 | - Else | |
128 | - _LogTextBox.Text = "" | |
129 | - End If | |
130 | - End While | |
131 | - End Sub | |
132 | - | |
133 | - ''' <summary>ログ表示を消去する。</summary> | |
134 | - ''' <remarks >ファイル保存用の裏バッファはクリアしない</remarks> | |
135 | - Public Sub Clear() | |
136 | - _LogTextBox.Text = "" | |
137 | - End Sub | |
138 | - | |
139 | -End Class |
@@ -1,99 +0,0 @@ | ||
1 | -<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ | |
2 | -Partial Class FormMain | |
3 | - Inherits System.Windows.Forms.Form | |
4 | - | |
5 | - 'フォームがコンポーネントの一覧をクリーンアップするために dispose をオーバーライドします。 | |
6 | - <System.Diagnostics.DebuggerNonUserCode()> _ | |
7 | - Protected Overrides Sub Dispose(ByVal disposing As Boolean) | |
8 | - Try | |
9 | - If disposing AndAlso components IsNot Nothing Then | |
10 | - components.Dispose() | |
11 | - End If | |
12 | - Finally | |
13 | - MyBase.Dispose(disposing) | |
14 | - End Try | |
15 | - End Sub | |
16 | - | |
17 | - 'Windows フォーム デザイナで必要です。 | |
18 | - Private components As System.ComponentModel.IContainer | |
19 | - | |
20 | - 'メモ: 以下のプロシージャは Windows フォーム デザイナで必要です。 | |
21 | - 'Windows フォーム デザイナを使用して変更できます。 | |
22 | - 'コード エディタを使って変更しないでください。 | |
23 | - <System.Diagnostics.DebuggerStepThrough()> _ | |
24 | - Private Sub InitializeComponent() | |
25 | - Me.Button4 = New System.Windows.Forms.Button() | |
26 | - Me.Button5 = New System.Windows.Forms.Button() | |
27 | - Me.Button6 = New System.Windows.Forms.Button() | |
28 | - Me.TextBox4 = New System.Windows.Forms.TextBox() | |
29 | - Me.SuspendLayout() | |
30 | - ' | |
31 | - 'Button4 | |
32 | - ' | |
33 | - Me.Button4.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) | |
34 | - Me.Button4.Location = New System.Drawing.Point(15, 251) | |
35 | - Me.Button4.Name = "Button4" | |
36 | - Me.Button4.Size = New System.Drawing.Size(148, 29) | |
37 | - Me.Button4.TabIndex = 2 | |
38 | - Me.Button4.Text = "このプログラムについて" | |
39 | - Me.Button4.UseVisualStyleBackColor = True | |
40 | - ' | |
41 | - 'Button5 | |
42 | - ' | |
43 | - Me.Button5.Anchor = CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _ | |
44 | - Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) | |
45 | - Me.Button5.Location = New System.Drawing.Point(169, 251) | |
46 | - Me.Button5.Name = "Button5" | |
47 | - Me.Button5.Size = New System.Drawing.Size(251, 29) | |
48 | - Me.Button5.TabIndex = 3 | |
49 | - Me.Button5.Text = "ログ表示クリア" | |
50 | - Me.Button5.UseVisualStyleBackColor = True | |
51 | - ' | |
52 | - 'Button6 | |
53 | - ' | |
54 | - Me.Button6.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) | |
55 | - Me.Button6.Location = New System.Drawing.Point(426, 251) | |
56 | - Me.Button6.Name = "Button6" | |
57 | - Me.Button6.Size = New System.Drawing.Size(146, 29) | |
58 | - Me.Button6.TabIndex = 4 | |
59 | - Me.Button6.Text = "終了" | |
60 | - Me.Button6.UseVisualStyleBackColor = True | |
61 | - ' | |
62 | - 'TextBox4 | |
63 | - ' | |
64 | - Me.TextBox4.AllowDrop = True | |
65 | - Me.TextBox4.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ | |
66 | - Or System.Windows.Forms.AnchorStyles.Left) _ | |
67 | - Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) | |
68 | - Me.TextBox4.Location = New System.Drawing.Point(15, 12) | |
69 | - Me.TextBox4.MaxLength = 327670 | |
70 | - Me.TextBox4.Multiline = True | |
71 | - Me.TextBox4.Name = "TextBox4" | |
72 | - Me.TextBox4.ScrollBars = System.Windows.Forms.ScrollBars.Both | |
73 | - Me.TextBox4.Size = New System.Drawing.Size(557, 223) | |
74 | - Me.TextBox4.TabIndex = 1 | |
75 | - Me.TextBox4.WordWrap = False | |
76 | - ' | |
77 | - 'FormMain | |
78 | - ' | |
79 | - Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!) | |
80 | - Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font | |
81 | - Me.ClientSize = New System.Drawing.Size(584, 292) | |
82 | - Me.Controls.Add(Me.TextBox4) | |
83 | - Me.Controls.Add(Me.Button5) | |
84 | - Me.Controls.Add(Me.Button4) | |
85 | - Me.Controls.Add(Me.Button6) | |
86 | - Me.MinimumSize = New System.Drawing.Size(500, 330) | |
87 | - Me.Name = "FormMain" | |
88 | - Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen | |
89 | - Me.Text = "XLSXPack" | |
90 | - Me.ResumeLayout(False) | |
91 | - Me.PerformLayout() | |
92 | - | |
93 | - End Sub | |
94 | - Friend WithEvents Button4 As System.Windows.Forms.Button | |
95 | - Friend WithEvents Button5 As System.Windows.Forms.Button | |
96 | - Friend WithEvents Button6 As System.Windows.Forms.Button | |
97 | - Friend WithEvents TextBox4 As System.Windows.Forms.TextBox | |
98 | - | |
99 | -End Class |
@@ -1,376 +0,0 @@ | ||
1 | -Imports OfficeImageReducer.ClassMyCommon ''ClassMyConmonのプロパティ・メソッドを参照するためのImportsステートメント | |
2 | -Imports System.IO | |
3 | -Imports System.IO.Compression | |
4 | - | |
5 | -''' <summary>メイン(スタートアップ)フォーム</summary> | |
6 | -Public Class FormMain | |
7 | - | |
8 | - Private Sub FormMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing | |
9 | - On Error Resume Next | |
10 | - | |
11 | - Log.Put("終了" + vbCrLf) | |
12 | - Log.Save() | |
13 | - | |
14 | - End Sub | |
15 | - | |
16 | - ''' <summary>メイン(スタートアップ)フォームのロード</summary> | |
17 | - ''' <param name="sender">イベントを発生させたオブジェクト</param> | |
18 | - ''' <param name="e">イベントオプション</param> | |
19 | - Private Sub FormMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load | |
20 | - | |
21 | -#If 0 Then | |
22 | - ''多重起動チェック | |
23 | - 'Process.GetProcessesByName メソッド | |
24 | - '指定したプロセス名を共有するリモートコンピュータ上の | |
25 | - 'すべてのプロセスリソースに関連付けます。 | |
26 | - Dim pn As String = Process.GetCurrentProcess.ProcessName 'Process.ProcessName プロパティ(プロセスの名前を取得します) | |
27 | - If Process.GetProcessesByName(pn).GetUpperBound(0) > 0 Then | |
28 | - ''多重起動しているならばエラーメッセージ表示して終了。 | |
29 | - MessageBox.Show("すでに起動しています。", TITLE + " エラーメッセージ", _ | |
30 | - MessageBoxButtons.OK, _ | |
31 | - MessageBoxIcon.Error) | |
32 | - End | |
33 | - End If | |
34 | -#End If | |
35 | - frmMain = Me | |
36 | - | |
37 | - FormControlBoxCustomize(Me) | |
38 | - | |
39 | - Me.Text = TITLE + " " + VERSION | |
40 | - | |
41 | - Log = New ClassLog(Me.TextBox4) | |
42 | - | |
43 | - Log.DebugPut("起動しました。" + vbCrLf) | |
44 | - | |
45 | - Button4.PerformClick() | |
46 | - | |
47 | - '起動時は最前面にもってくる | |
48 | - Me.Show() | |
49 | - Me.TopMost = True | |
50 | - WaitTickCount(500) | |
51 | - Me.TopMost = False | |
52 | - | |
53 | - | |
54 | - End Sub | |
55 | - | |
56 | - ''' <summary>「このプログラムについて」のボタンを押された時の処理</summary> | |
57 | - Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click | |
58 | - Log.Add("--------------------------------------------------------------------------" + vbCrLf) | |
59 | - Log.Add(TITLE + " " + VERSION + vbCrLf) | |
60 | - Log.Add(OPENING_MSG) | |
61 | - Log.Add(vbCrLf) | |
62 | - Log.Add("--------------------------------------------------------------------------" + vbCrLf) | |
63 | - Log.Put() | |
64 | - End Sub | |
65 | - | |
66 | - ''' <summary>ログの表示クリアを行う</summary> | |
67 | - Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click | |
68 | - Log.Clear() | |
69 | - End Sub | |
70 | - | |
71 | - ''' <summary>プログラムの終了ボタンを押された。</summary> | |
72 | - Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click | |
73 | - | |
74 | - 'ここで closingイベントが発生。 | |
75 | - Me.Close() | |
76 | - End | |
77 | - | |
78 | - End Sub | |
79 | - | |
80 | - Public Sub New() | |
81 | - | |
82 | - ' この呼び出しはデザイナーで必要です。 | |
83 | - InitializeComponent() | |
84 | - | |
85 | - ' InitializeComponent() 呼び出しの後で初期化を追加します。 | |
86 | - | |
87 | - End Sub | |
88 | - | |
89 | - Private Sub TextBox4_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TextBox4.DragEnter | |
90 | - | |
91 | - 'ファイル形式の場合のみ、ドラッグを受け付けます。 | |
92 | - If e.Data.GetDataPresent(DataFormats.FileDrop) = True Then | |
93 | - e.Effect = DragDropEffects.Copy | |
94 | - Else | |
95 | - e.Effect = DragDropEffects.None | |
96 | - End If | |
97 | - | |
98 | - End Sub | |
99 | - | |
100 | - Private Sub TextBox4_DragDrop(sender As Object, e As DragEventArgs) Handles TextBox4.DragDrop | |
101 | - | |
102 | - ' 読み込んだ結果をすべて格納するための変数を宣言する | |
103 | - Dim Result As String | |
104 | - Dim StrArray() As String | |
105 | - | |
106 | - 'ドラッグされたファイル・フォルダのパスを格納します。 | |
107 | - Dim strFileName As String() = CType(e.Data.GetData(DataFormats.FileDrop, False), String()) | |
108 | - Dim OrgFileName As String | |
109 | - | |
110 | - OrgFileName = strFileName(0).ToString() | |
111 | - | |
112 | - If OrgFileName.Substring(OrgFileName.Length - 5).ToLower <> ".xlsx" And _ | |
113 | - OrgFileName.Substring(OrgFileName.Length - 5).ToLower <> ".xlsm" And _ | |
114 | - OrgFileName.Substring(OrgFileName.Length - 5).ToLower <> ".pptx" And _ | |
115 | - OrgFileName.Substring(OrgFileName.Length - 5).ToLower <> ".pptm" And _ | |
116 | - OrgFileName.Substring(OrgFileName.Length - 5).ToLower <> ".docx" And _ | |
117 | - OrgFileName.Substring(OrgFileName.Length - 5).ToLower <> ".docm" Then | |
118 | - Log.Put("office2007 ファイル以外には対応していません。") | |
119 | - Exit Sub | |
120 | - End If | |
121 | - | |
122 | - Dim FileExtension As String = OrgFileName.Substring(OrgFileName.Length - 4).ToLower | |
123 | - | |
124 | - 'ファイルの存在確認を行い、ある場合にのみ、 | |
125 | - 'テキストボックスにパスを表示します。 | |
126 | - '(この処理でフォルダを対象外にしています。) | |
127 | - If System.IO.File.Exists(OrgFileName) = True Then | |
128 | - Log.Put("Drop : " + OrgFileName) | |
129 | - Application.DoEvents() | |
130 | - Else | |
131 | - Exit Sub | |
132 | - End If | |
133 | - | |
134 | - Log.Put("解析中です。") | |
135 | - Application.DoEvents() | |
136 | - | |
137 | - Dim ZipFileName As String = Path.GetDirectoryName(OrgFileName) + "\~OfficeJPGconvTemp.zip" | |
138 | - Dim ExtractPath As String = Path.GetDirectoryName(OrgFileName) + "\~OfficeJPGconvExtract" | |
139 | - Dim CurrentTypesFileName As String = ExtractPath + "\[Content_Types].xml" | |
140 | - | |
141 | - Try | |
142 | - | |
143 | - File.Delete(ZipFileName) | |
144 | - File.Copy(OrgFileName, ZipFileName) | |
145 | - | |
146 | - '解凍先フォルダ (ディレクトリ) が存在しているかどうか確認して削除 | |
147 | - '存在の有無を確認しないとExceptionが発生する | |
148 | - If Directory.Exists(ExtractPath) Then | |
149 | - Log.DebugPut("作業用フォルダが存在します。削除します。") | |
150 | - Directory.Delete(ExtractPath, True) | |
151 | - Else | |
152 | - Log.DebugPut("作業用フォルダが存在しません。") | |
153 | - End If | |
154 | - | |
155 | - Try | |
156 | - Directory.CreateDirectory(ExtractPath) | |
157 | - Catch | |
158 | - Log.Put("作業用フォルダの作成に失敗しました。") | |
159 | - Exit Sub | |
160 | - End Try | |
161 | - | |
162 | - Application.DoEvents() | |
163 | - | |
164 | - 'ZIP書庫を展開する | |
165 | - Compression.ZipFile.ExtractToDirectory( _ | |
166 | - ZipFileName, ExtractPath, | |
167 | - System.Text.Encoding.GetEncoding("shift_jis")) | |
168 | - | |
169 | - Application.DoEvents() | |
170 | - | |
171 | - '解凍したZIPの中に [Content_Types].xml があるかどうか確認する。 | |
172 | - If File.Exists(CurrentTypesFileName) Then | |
173 | - '存在するのなら正常。次の処理へ | |
174 | - Else | |
175 | - '存在しないなら異常。作業中断 | |
176 | - Try | |
177 | - File.Delete(ZipFileName) | |
178 | - Directory.Delete(ExtractPath, True) | |
179 | - Catch | |
180 | - End Try | |
181 | - Log.Put("対象ファイルの解析ができません。") | |
182 | - Log.Put("作業を終了します。") | |
183 | - Exit Sub | |
184 | - End If | |
185 | - | |
186 | - 'MediaPath = <ExtractPath>\xl\media | |
187 | - 'MediaPath = <ExtractPath>\ppt\media | |
188 | - 'PNGファイルのリストアップ | |
189 | - Dim MediaPath As String | |
190 | - Dim MediaFileNames() As String | |
191 | - If System.IO.Directory.Exists(ExtractPath + "\xl\media\") Then | |
192 | - MediaPath = ExtractPath + "\xl\media" | |
193 | - MediaFileNames = Directory.GetFiles(MediaPath, "*.png") | |
194 | - ElseIf System.IO.Directory.Exists(ExtractPath + "\ppt\media\") Then | |
195 | - MediaPath = ExtractPath + "\ppt\media" | |
196 | - MediaFileNames = Directory.GetFiles(MediaPath, "*.png") | |
197 | - ElseIf System.IO.Directory.Exists(ExtractPath + "\word\media\") Then | |
198 | - MediaPath = ExtractPath + "\word\media" | |
199 | - MediaFileNames = Directory.GetFiles(MediaPath, "*.png") | |
200 | - Else | |
201 | - Try | |
202 | - File.Delete(ZipFileName) | |
203 | - Directory.Delete(ExtractPath, True) | |
204 | - Catch | |
205 | - | |
206 | - End Try | |
207 | - Log.Put("対象ファイルの中にPNGファイルがありません。") | |
208 | - Log.Put("作業を終了します。") | |
209 | - Exit Sub | |
210 | - End If | |
211 | -#If 0 Then | |
212 | - For Each MediaFileName As String In MediaFileNames | |
213 | - Log.Put(MediaFileName) | |
214 | - Next | |
215 | -#End If | |
216 | - 'relsファイルのリストアップ | |
217 | - Dim RelsFileNames() As String = System.IO.Directory.GetFiles(ExtractPath, "*.rels", System.IO.SearchOption.AllDirectories) | |
218 | -#If 0 Then | |
219 | - For Each RelsFileName As String In RelsFileNames | |
220 | - Log.Put(RelsFileName) | |
221 | - Next | |
222 | -#End If | |
223 | - | |
224 | - '取得したメディアファイルの処理をする | |
225 | - For Each MediaFileName As String In MediaFileNames | |
226 | - | |
227 | - 'ファイルのサイズを取得し小さいサイズのものはスキップ | |
228 | - Dim Medialen As Long = New FileInfo(MediaFileName).Length | |
229 | - If Medialen < 1024 Then | |
230 | - Continue For | |
231 | - End If | |
232 | - | |
233 | - '取得したファイル名を表示する | |
234 | - Log.DebugPut(MediaFileName) | |
235 | - Log.DebugPut(Medialen.ToString) | |
236 | - | |
237 | - Dim TmpJpgFileName As String = MediaPath + "~OfficeJPGConvtemp.jpg" | |
238 | - | |
239 | - 'PNGファイルを開く | |
240 | - Try | |
241 | - '前回の作業ファイルが残っていれば削除する | |
242 | - File.Delete(TmpJpgFileName) | |
243 | - | |
244 | - ' Bitmapファイルオープン | |
245 | - Using bmp As New Bitmap(MediaFileName) | |
246 | - | |
247 | - 'JPEG形式で保存する() | |
248 | - bmp.Save(TmpJpgFileName, System.Drawing.Imaging.ImageFormat.Jpeg) | |
249 | - | |
250 | - 'Bitmapファイルをクローズ | |
251 | - bmp.Dispose() | |
252 | - End Using | |
253 | - Catch | |
254 | - '不正なBMP/PNGであれば例外が発生する。 | |
255 | - File.Delete(TmpJpgFileName) | |
256 | - '次のPNGファイルの処理へ | |
257 | - Continue For | |
258 | - End Try | |
259 | - | |
260 | - Dim Jpglen As Long = New FileInfo(TmpJpgFileName).Length | |
261 | - If Jpglen <= (Medialen * 0.8) Then | |
262 | - File.Delete(MediaFileName) | |
263 | - Dim NewMediaFileName As String = "" | |
264 | - For j = 0 To 9999 | |
265 | - If j = 0 Then | |
266 | - NewMediaFileName = MediaFileName.Substring(0, MediaFileName.Length - 4) + ".jpeg" | |
267 | - Else | |
268 | - NewMediaFileName = MediaFileName.Substring(0, MediaFileName.Length - 4) + "(" + (j - 1).ToString + ").jpeg" | |
269 | - End If | |
270 | - | |
271 | - Try | |
272 | - File.Move(TmpJpgFileName, NewMediaFileName) | |
273 | - Exit For | |
274 | - Catch | |
275 | - End Try | |
276 | - Next j | |
277 | - | |
278 | - StrArray = Split(MediaFileName, "\") | |
279 | - Dim SplitMediaFileName As String = StrArray(StrArray.Length - 1) | |
280 | - StrArray = Split(NewMediaFileName, "\") | |
281 | - Dim SplitNewMediaFileName As String = StrArray(StrArray.Length - 1) | |
282 | - | |
283 | - Log.Put(SplitMediaFileName + " -> " + SplitNewMediaFileName) | |
284 | - Application.DoEvents() 'ログ表示更新の為 | |
285 | - | |
286 | - '取得したリレーションファイルの処理をする | |
287 | - For Each RelsFileName As String In RelsFileNames | |
288 | - 'Shift-JISファイルを開く | |
289 | - Result = String.Empty | |
290 | - Using Reader As New System.IO.StreamReader(RelsFileName, System.Text.Encoding.GetEncoding("shift-jis")) | |
291 | - Result = Reader.ReadToEnd | |
292 | - 'Log.Put(Result) | |
293 | - End Using | |
294 | - | |
295 | - If InStr(Result, SplitMediaFileName) Then | |
296 | - 'Log.Put(Result) | |
297 | - Result = Replace(Result, SplitMediaFileName, SplitNewMediaFileName) | |
298 | - '上書モードでShift-JISファイルを開く | |
299 | - Using Writer As New System.IO.StreamWriter(RelsFileName, False, System.Text.Encoding.GetEncoding("shift-jis")) | |
300 | - Writer.Write(Result) | |
301 | - 'Log.Put(Result) | |
302 | - End Using | |
303 | - | |
304 | - End If | |
305 | - Next | |
306 | - | |
307 | - File.Delete(TmpJpgFileName) | |
308 | - | |
309 | - Else | |
310 | - 'JPGファイルにしてもサイズがちいさくならなかった。 | |
311 | - File.Delete(TmpJpgFileName) | |
312 | - End If | |
313 | - | |
314 | - Next | |
315 | - | |
316 | - ' ExtractPath + "\[Content_Types].xml の中を修正する | |
317 | - Result = String.Empty | |
318 | - Using Reader As New System.IO.StreamReader(CurrentTypesFileName, System.Text.Encoding.GetEncoding("shift-jis")) | |
319 | - Result = Reader.ReadToEnd | |
320 | - End Using | |
321 | - | |
322 | - '追加 <Default Extension="jpeg" ContentType="application/jpeg"/> | |
323 | - If InStr(Result.ToLower, "default extension=""jpeg""") Then | |
324 | - '変更不要 | |
325 | - Else | |
326 | - Result = Replace(Result, _ | |
327 | - "<Default Extension=""xml"" ContentType=""application/xml""/>", _ | |
328 | - "<Default Extension=""xml"" ContentType=""application/xml""/><Default Extension=""jpeg"" ContentType=""application/jpeg""/>") | |
329 | - '上書モードでShift-JISファイルを開く | |
330 | - Using Writer As New System.IO.StreamWriter(CurrentTypesFileName, False, System.Text.Encoding.GetEncoding("shift-jis")) | |
331 | - Writer.Write(Result) | |
332 | - 'Log.Put(Result) | |
333 | - End Using | |
334 | - End If | |
335 | - | |
336 | - 'ZIP書庫を作成する | |
337 | - File.Delete(ZipFileName) | |
338 | - Compression.ZipFile.CreateFromDirectory( _ | |
339 | - ExtractPath, ZipFileName, | |
340 | - Compression.CompressionLevel.Optimal, _ | |
341 | - False, _ | |
342 | - System.Text.Encoding.GetEncoding("shift_jis")) | |
343 | - | |
344 | - 'オリジナルファイルをリネームする | |
345 | - For i = 0 To 1000 | |
346 | - Dim NewOrgFileName As String _ | |
347 | - = OrgFileName.Substring(0, OrgFileName.Length - 5) + "(" + i.ToString + ")" + OrgFileName.Substring(OrgFileName.Length - 5) | |
348 | - Try | |
349 | - File.Move(OrgFileName, NewOrgFileName) | |
350 | - Catch | |
351 | - Continue For | |
352 | - End Try | |
353 | - Exit For | |
354 | - Next | |
355 | - | |
356 | - File.Move(ZipFileName, OrgFileName) | |
357 | - | |
358 | - Log.Put("作業終了しました。") | |
359 | - | |
360 | - Catch | |
361 | - Log.Put("対象ファイルの解析作業ができませんでした。") | |
362 | - Log.Put("作業を強制終了します。") | |
363 | - End Try | |
364 | - | |
365 | - '作業ファイルとフォルダを削除 | |
366 | - Try | |
367 | - File.Delete(ZipFileName) | |
368 | - Catch | |
369 | - End Try | |
370 | - Try | |
371 | - Directory.Delete(ExtractPath, True) | |
372 | - Catch | |
373 | - End Try | |
374 | - | |
375 | - End Sub | |
376 | -End Class |
@@ -1,83 +0,0 @@ | ||
1 | -''' <summary>共通クラス</summary> | |
2 | -''' <remarks>Public Const/Shared 宣言用クラス。グローバルな変数、メソッドなどを定義する</remarks> | |
3 | -Public Class ClassMyCommon | |
4 | - | |
5 | - ''' <summary>プログラムタイトル</summary> | |
6 | - Public Const TITLE As String = "Office Image Reducer" | |
7 | - | |
8 | - ''' <summary>バージョン</summary> | |
9 | - Public Const VERSION As String = "01.01-170928" | |
10 | - | |
11 | - ''' <summary>メッセージ</summary> | |
12 | - ''' <remarks>改行はvbCrLf</remarks> | |
13 | - Public Const OPENING_MSG As String _ | |
14 | - = "Programmed by S.Hori" + vbCrLf _ | |
15 | - + vbCrLf _ | |
16 | - + "下記のWEBサーバから最新版を入手できます。" + vbCrLf _ | |
17 | - + "https://osdn.net/users/hor931101jp/pf/01/files" + vbCrLf _ | |
18 | - + "下記のSVNリポジトリからソースコードをチェックアウトできます。" + vbCrLf _ | |
19 | - + "svn://svn.pf.osdn.jp/h/ho/hor931101jp/01/tags" + vbCrLf _ | |
20 | - + vbCrLf _ | |
21 | - + "ここに docx xlsx pptx ファイルを1つずつドラックアンドドロップしてください。" + vbCrLf | |
22 | - | |
23 | - ''' <summary>メインフォームインスタンス宣言</summary> | |
24 | - Public Shared frmMain As FormMain | |
25 | - | |
26 | - ''' <summary>ログの管理インスタンス宣言</summary> | |
27 | - Public Shared Log As ClassLog | |
28 | - | |
29 | - ''' <summary>ミリ秒指定で待機する。</summary> | |
30 | - ''' <param name="WaitTime">待機時間[ms]</param> | |
31 | - ''' <remarks>引数を 50 以下にしても Windows の都合で 50ms 以上待機してしまうこともおこりうる</remarks> | |
32 | - Public Shared Sub WaitTickCount(ByVal WaitTime As Int32) | |
33 | - Dim StartTickCount As Int32 = Environment.TickCount And Int32.MaxValue | |
34 | - Dim NowTickCount As Int32 | |
35 | - Do | |
36 | - Application.DoEvents() | |
37 | - System.Threading.Thread.Sleep(1) | |
38 | - NowTickCount = Environment.TickCount And Int32.MaxValue | |
39 | - Loop Until ((NowTickCount - StartTickCount) >= WaitTime) | |
40 | - End Sub | |
41 | - | |
42 | - ''' <summary>システムメニューを取得するAPI</summary> | |
43 | - Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Integer, ByVal bRevert As Integer) As Integer | |
44 | - | |
45 | - ''' <summary>システムメニューの項目を削除するAPI</summary> | |
46 | - Private Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Integer, ByVal nPosition As Integer, ByVal wFlags As Integer) As Integer | |
47 | - | |
48 | - ''' <summary>メニューバーを再描画するAPI</summary> | |
49 | - Private Declare Function DrawMenuBar Lib "user32.dll" (ByVal hWnd As Integer) As Integer | |
50 | - | |
51 | - ''' <summary>フォームの「右上コントロールボックス」と「左上アイコンのシステムメニュー」のカスタマイズを行う。</summary> | |
52 | - ''' <param name="f">対象とするフォーム</param> | |
53 | - Public Shared Sub FormControlBoxCustomize(ByVal f As Form) | |
54 | - 'Const SC_SIZE = &HF000& 'システムメニューの「サイズ変更」 | |
55 | - 'Const SC_MOVE = &HF010& 'システムメニューの「移動」 | |
56 | - 'Const SC_MINIMIZE = &HF020& 'システムメニューの「最小化」 | |
57 | - 'Const SC_MAXIMIZE = &HF030& 'システムメニューの「最大化」 | |
58 | - Const SC_CLOSE = &HF060& 'システムメニューの「閉じる」 | |
59 | - 'Const SC_RESTORE = &HF120 'システムメニューの「元のサイズに戻す」 | |
60 | - Const MF_BYCOMMAND = &H0& 'メニュー項目指定 | |
61 | - Const MF_BYPOSITION = &H400& 'ポジション指定 | |
62 | - 'Const MF_ENABLED = &H0& '有効化 | |
63 | - 'Const MF_GRAYED = &H1& '無効化 | |
64 | - 'Const MF_DISABLED = &H2& '半無効化(見かけ上有効) | |
65 | - Dim DUMMY As Integer | |
66 | - | |
67 | - ''「区切り線」の削除 | |
68 | - DUMMY = DeleteMenu(GetSystemMenu(f.Handle, 0), 5, MF_BYPOSITION) | |
69 | - ''「閉じる」の削除 + xボタンの無効化 | |
70 | - DUMMY = DeleteMenu(GetSystemMenu(f.Handle, 0), SC_CLOSE, MF_BYCOMMAND) | |
71 | - ''描画 (変更を反映) | |
72 | - DUMMY = DrawMenuBar(f.Handle) | |
73 | - | |
74 | - End Sub | |
75 | - | |
76 | - ''' <summary>本体のEXEファイルのあるフォルダをフルパスで返す</summary> | |
77 | - ''' <returns>フォルダのフルパス。最後に\がつく。例) C:\MyFolder\ </returns> | |
78 | - Public Shared Function AppPath() As String | |
79 | - Return System.IO.Path.GetDirectoryName( _ | |
80 | - System.Reflection.Assembly.GetExecutingAssembly().Location) + "\" | |
81 | - End Function | |
82 | - | |
83 | -End Class |
@@ -0,0 +1,83 @@ | ||
1 | +''' <summary>共通クラス</summary> | |
2 | +''' <remarks>Public Const/Shared 宣言用クラス。グローバルな変数、メソッドなどを定義する</remarks> | |
3 | +Public Class ClassMyCommon | |
4 | + | |
5 | + ''' <summary>プログラムタイトル</summary> | |
6 | + Public Const TITLE As String = "Office Image Reducer" | |
7 | + | |
8 | + ''' <summary>バージョン</summary> | |
9 | + Public Const VERSION As String = "01.01-170928" | |
10 | + | |
11 | + ''' <summary>メッセージ</summary> | |
12 | + ''' <remarks>改行はvbCrLf</remarks> | |
13 | + Public Const OPENING_MSG As String _ | |
14 | + = "Programmed by S.Hori" + vbCrLf _ | |
15 | + + vbCrLf _ | |
16 | + + "下記のWEBサーバから最新版を入手できます。" + vbCrLf _ | |
17 | + + "https://osdn.net/users/hor931101jp/pf/01/files" + vbCrLf _ | |
18 | + + "下記のSVNリポジトリからソースコードをチェックアウトできます。" + vbCrLf _ | |
19 | + + "svn://svn.pf.osdn.jp/h/ho/hor931101jp/01/tags" + vbCrLf _ | |
20 | + + vbCrLf _ | |
21 | + + "ここに docx xlsx pptx ファイルを1つずつドラックアンドドロップしてください。" + vbCrLf | |
22 | + | |
23 | + ''' <summary>メインフォームインスタンス宣言</summary> | |
24 | + Public Shared frmMain As FormMain | |
25 | + | |
26 | + ''' <summary>ログの管理インスタンス宣言</summary> | |
27 | + Public Shared Log As ClassLog | |
28 | + | |
29 | + ''' <summary>ミリ秒指定で待機する。</summary> | |
30 | + ''' <param name="WaitTime">待機時間[ms]</param> | |
31 | + ''' <remarks>引数を 50 以下にしても Windows の都合で 50ms 以上待機してしまうこともおこりうる</remarks> | |
32 | + Public Shared Sub WaitTickCount(ByVal WaitTime As Int32) | |
33 | + Dim StartTickCount As Int32 = Environment.TickCount And Int32.MaxValue | |
34 | + Dim NowTickCount As Int32 | |
35 | + Do | |
36 | + Application.DoEvents() | |
37 | + System.Threading.Thread.Sleep(1) | |
38 | + NowTickCount = Environment.TickCount And Int32.MaxValue | |
39 | + Loop Until ((NowTickCount - StartTickCount) >= WaitTime) | |
40 | + End Sub | |
41 | + | |
42 | + ''' <summary>システムメニューを取得するAPI</summary> | |
43 | + Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Integer, ByVal bRevert As Integer) As Integer | |
44 | + | |
45 | + ''' <summary>システムメニューの項目を削除するAPI</summary> | |
46 | + Private Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Integer, ByVal nPosition As Integer, ByVal wFlags As Integer) As Integer | |
47 | + | |
48 | + ''' <summary>メニューバーを再描画するAPI</summary> | |
49 | + Private Declare Function DrawMenuBar Lib "user32.dll" (ByVal hWnd As Integer) As Integer | |
50 | + | |
51 | + ''' <summary>フォームの「右上コントロールボックス」と「左上アイコンのシステムメニュー」のカスタマイズを行う。</summary> | |
52 | + ''' <param name="f">対象とするフォーム</param> | |
53 | + Public Shared Sub FormControlBoxCustomize(ByVal f As Form) | |
54 | + 'Const SC_SIZE = &HF000& 'システムメニューの「サイズ変更」 | |
55 | + 'Const SC_MOVE = &HF010& 'システムメニューの「移動」 | |
56 | + 'Const SC_MINIMIZE = &HF020& 'システムメニューの「最小化」 | |
57 | + 'Const SC_MAXIMIZE = &HF030& 'システムメニューの「最大化」 | |
58 | + Const SC_CLOSE = &HF060& 'システムメニューの「閉じる」 | |
59 | + 'Const SC_RESTORE = &HF120 'システムメニューの「元のサイズに戻す」 | |
60 | + Const MF_BYCOMMAND = &H0& 'メニュー項目指定 | |
61 | + Const MF_BYPOSITION = &H400& 'ポジション指定 | |
62 | + 'Const MF_ENABLED = &H0& '有効化 | |
63 | + 'Const MF_GRAYED = &H1& '無効化 | |
64 | + 'Const MF_DISABLED = &H2& '半無効化(見かけ上有効) | |
65 | + Dim DUMMY As Integer | |
66 | + | |
67 | + ''「区切り線」の削除 | |
68 | + DUMMY = DeleteMenu(GetSystemMenu(f.Handle, 0), 5, MF_BYPOSITION) | |
69 | + ''「閉じる」の削除 + xボタンの無効化 | |
70 | + DUMMY = DeleteMenu(GetSystemMenu(f.Handle, 0), SC_CLOSE, MF_BYCOMMAND) | |
71 | + ''描画 (変更を反映) | |
72 | + DUMMY = DrawMenuBar(f.Handle) | |
73 | + | |
74 | + End Sub | |
75 | + | |
76 | + ''' <summary>本体のEXEファイルのあるフォルダをフルパスで返す</summary> | |
77 | + ''' <returns>フォルダのフルパス。最後に\がつく。例) C:\MyFolder\ </returns> | |
78 | + Public Shared Function AppPath() As String | |
79 | + Return System.IO.Path.GetDirectoryName( _ | |
80 | + System.Reflection.Assembly.GetExecutingAssembly().Location) + "\" | |
81 | + End Function | |
82 | + | |
83 | +End Class |
@@ -0,0 +1,38 @@ | ||
1 | +'------------------------------------------------------------------------------ | |
2 | +' <auto-generated> | |
3 | +' このコードはツールによって生成されました。 | |
4 | +' ランタイム バージョン:4.0.30319.42000 | |
5 | +' | |
6 | +' このファイルへの変更は、以下の状況下で不正な動作の原因になったり、 | |
7 | +' コードが再生成されるときに損失したりします。 | |
8 | +' </auto-generated> | |
9 | +'------------------------------------------------------------------------------ | |
10 | + | |
11 | +Option Strict On | |
12 | +Option Explicit On | |
13 | + | |
14 | + | |
15 | +Namespace My | |
16 | + | |
17 | + 'メモ:このファイルは自動生成されました。直接変更しないでください。変更したり、 | |
18 | + ' ビルド エラーが発生した場合は、プロジェクト デザイナー へ移動し (プロジェクト | |
19 | + ' プロパティに移動するか、またはソリューション エクスプローラーのマイ プロジェクト | |
20 | + ' ノード上でダブルクリック)、アプリケーション タブ上で変更を行います。 | |
21 | + ' | |
22 | + Partial Friend Class MyApplication | |
23 | + | |
24 | + <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _ | |
25 | + Public Sub New() | |
26 | + MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) | |
27 | + Me.IsSingleInstance = false | |
28 | + Me.EnableVisualStyles = true | |
29 | + Me.SaveMySettingsOnExit = true | |
30 | + Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses | |
31 | + End Sub | |
32 | + | |
33 | + <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _ | |
34 | + Protected Overrides Sub OnCreateMainForm() | |
35 | + Me.MainForm = Global.OfficeImageReducer.FormMain | |
36 | + End Sub | |
37 | + End Class | |
38 | +End Namespace |
@@ -0,0 +1,73 @@ | ||
1 | +'------------------------------------------------------------------------------ | |
2 | +' <auto-generated> | |
3 | +' このコードはツールによって生成されました。 | |
4 | +' ランタイム バージョン:4.0.30319.42000 | |
5 | +' | |
6 | +' このファイルへの変更は、以下の状況下で不正な動作の原因になったり、 | |
7 | +' コードが再生成されるときに損失したりします。 | |
8 | +' </auto-generated> | |
9 | +'------------------------------------------------------------------------------ | |
10 | + | |
11 | +Option Strict On | |
12 | +Option Explicit On | |
13 | + | |
14 | + | |
15 | +Namespace My | |
16 | + | |
17 | + <Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _ | |
18 | + Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0"), _ | |
19 | + Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ | |
20 | + Partial Friend NotInheritable Class MySettings | |
21 | + Inherits Global.System.Configuration.ApplicationSettingsBase | |
22 | + | |
23 | + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) | |
24 | + | |
25 | +#Region "My.Settings 自動保存機能" | |
26 | +#If _MyType = "WindowsForms" Then | |
27 | + Private Shared addedHandler As Boolean | |
28 | + | |
29 | + Private Shared addedHandlerLockObject As New Object | |
30 | + | |
31 | + <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ | |
32 | + Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) | |
33 | + If My.Application.SaveMySettingsOnExit Then | |
34 | + My.Settings.Save() | |
35 | + End If | |
36 | + End Sub | |
37 | +#End If | |
38 | +#End Region | |
39 | + | |
40 | + Public Shared ReadOnly Property [Default]() As MySettings | |
41 | + Get | |
42 | + | |
43 | +#If _MyType = "WindowsForms" Then | |
44 | + If Not addedHandler Then | |
45 | + SyncLock addedHandlerLockObject | |
46 | + If Not addedHandler Then | |
47 | + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings | |
48 | + addedHandler = True | |
49 | + End If | |
50 | + End SyncLock | |
51 | + End If | |
52 | +#End If | |
53 | + Return defaultInstance | |
54 | + End Get | |
55 | + End Property | |
56 | + End Class | |
57 | +End Namespace | |
58 | + | |
59 | +Namespace My | |
60 | + | |
61 | + <Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _ | |
62 | + Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _ | |
63 | + Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _ | |
64 | + Friend Module MySettingsProperty | |
65 | + | |
66 | + <Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _ | |
67 | + Friend ReadOnly Property Settings() As Global.OfficeImageReducer.My.MySettings | |
68 | + Get | |
69 | + Return Global.OfficeImageReducer.My.MySettings.Default | |
70 | + End Get | |
71 | + End Property | |
72 | + End Module | |
73 | +End Namespace |
@@ -0,0 +1,35 @@ | ||
1 | +Imports System | |
2 | +Imports System.Reflection | |
3 | +Imports System.Runtime.InteropServices | |
4 | + | |
5 | +' アセンブリに関する一般情報は以下の属性セットをとおして制御されます。 | |
6 | +' アセンブリに関連付けられている情報を変更するには、 | |
7 | +' これらの属性値を変更してください。 | |
8 | + | |
9 | +' アセンブリ属性の値を確認します。 | |
10 | + | |
11 | +<Assembly: AssemblyTitle("")> | |
12 | +<Assembly: AssemblyDescription("")> | |
13 | +<Assembly: AssemblyCompany("")> | |
14 | +<Assembly: AssemblyProduct("")> | |
15 | +<Assembly: AssemblyCopyright("")> | |
16 | +<Assembly: AssemblyTrademark("")> | |
17 | + | |
18 | +<Assembly: ComVisible(False)> | |
19 | + | |
20 | +'このプロジェクトが COM に公開される場合、次の GUID がタイプ ライブラリの ID になります。 | |
21 | +<Assembly: Guid("1be446ae-e39f-46da-b27d-5cb47b36183c")> | |
22 | + | |
23 | +' アセンブリのバージョン情報は、以下の 4 つの値で構成されています: | |
24 | +' | |
25 | +' Major Version | |
26 | +' Minor Version | |
27 | +' Build Number | |
28 | +' Revision | |
29 | +' | |
30 | +' すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を | |
31 | +' 既定値にすることができます: | |
32 | +' <Assembly: AssemblyVersion("1.0.*")> | |
33 | + | |
34 | +<Assembly: AssemblyVersion("1.0.0.0")> | |
35 | +<Assembly: AssemblyFileVersion("1.0.0.0")> |
@@ -0,0 +1,63 @@ | ||
1 | +'------------------------------------------------------------------------------ | |
2 | +' <auto-generated> | |
3 | +' このコードはツールによって生成されました。 | |
4 | +' ランタイム バージョン:4.0.30319.42000 | |
5 | +' | |
6 | +' このファイルへの変更は、以下の状況下で不正な動作の原因になったり、 | |
7 | +' コードが再生成されるときに損失したりします。 | |
8 | +' </auto-generated> | |
9 | +'------------------------------------------------------------------------------ | |
10 | + | |
11 | +Option Strict On | |
12 | +Option Explicit On | |
13 | + | |
14 | +Imports System | |
15 | + | |
16 | +Namespace My.Resources | |
17 | + | |
18 | + 'このクラスは StronglyTypedResourceBuilder クラスが ResGen | |
19 | + 'または Visual Studio のようなツールを使用して自動生成されました。 | |
20 | + 'メンバーを追加または削除するには、.ResX ファイルを編集して、/str オプションと共に | |
21 | + 'ResGen を実行し直すか、または VS プロジェクトをビルドし直します。 | |
22 | + '''<summary> | |
23 | + ''' ローカライズされた文字列などを検索するための、厳密に型指定されたリソース クラスです。 | |
24 | + '''</summary> | |
25 | + <Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _ | |
26 | + Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _ | |
27 | + Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _ | |
28 | + Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _ | |
29 | + Public Module Resources | |
30 | + | |
31 | + Private resourceMan As Global.System.Resources.ResourceManager | |
32 | + | |
33 | + Private resourceCulture As Global.System.Globalization.CultureInfo | |
34 | + | |
35 | + '''<summary> | |
36 | + ''' このクラスで使用されているキャッシュされた ResourceManager インスタンスを返します。 | |
37 | + '''</summary> | |
38 | + <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ | |
39 | + Public ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager | |
40 | + Get | |
41 | + If Object.ReferenceEquals(resourceMan, Nothing) Then | |
42 | + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("OfficeImageReducer.Resources", GetType(Resources).Assembly) | |
43 | + resourceMan = temp | |
44 | + End If | |
45 | + Return resourceMan | |
46 | + End Get | |
47 | + End Property | |
48 | + | |
49 | + '''<summary> | |
50 | + ''' 厳密に型指定されたこのリソース クラスを使用して、すべての検索リソースに対し、 | |
51 | + ''' 現在のスレッドの CurrentUICulture プロパティをオーバーライドします。 | |
52 | + '''</summary> | |
53 | + <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ | |
54 | + Public Property Culture() As Global.System.Globalization.CultureInfo | |
55 | + Get | |
56 | + Return resourceCulture | |
57 | + End Get | |
58 | + Set | |
59 | + resourceCulture = value | |
60 | + End Set | |
61 | + End Property | |
62 | + End Module | |
63 | +End Namespace |
@@ -0,0 +1,22 @@ | ||
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |
3 | + <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> | |
4 | + <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> | |
5 | + <security> | |
6 | + <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> | |
7 | + <!-- UAC マニフェスト オプション | |
8 | + Windows のユーザー アカウント制御のレベルを変更するには、 | |
9 | + requestedExecutionLevel ノードを以下のいずれかで置換します。 | |
10 | + | |
11 | + <requestedExecutionLevel level="asInvoker" uiAccess="false" /> | |
12 | + <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> | |
13 | + <requestedExecutionLevel level="highestAvailable" uiAccess="false" /> | |
14 | + | |
15 | + 下位互換性のためにファイルおよびレジストリの仮想化を | |
16 | + 利用する場合は、requestedExecutionLevel ノードを削除してください。 | |
17 | + --> | |
18 | + <requestedExecutionLevel level="asInvoker" uiAccess="false" /> | |
19 | + </requestedPrivileges> | |
20 | + </security> | |
21 | + </trustInfo> | |
22 | +</asmv1:assembly> |
@@ -0,0 +1,139 @@ | ||
1 | +Imports OfficeImageReducer.ClassMyCommon ''ClassMyCoomonのプロパティ・メソッドを参照するためのImportsステートメント | |
2 | + | |
3 | +''' <summary>ログ管理クラス</summary> | |
4 | +Public Class ClassLog | |
5 | + | |
6 | + ''' <summary>フルパスでのログファイル名</summary> | |
7 | + Private LogFileName As String | |
8 | + | |
9 | + ''' <summary>ログファイル保存用の裏バッファ</summary> | |
10 | + Private _ShadowBuf As String | |
11 | + | |
12 | + ''' <summary>フォーム上のログ表示用テキストボックス</summary> | |
13 | + Private _LogTextBox As TextBox | |
14 | + | |
15 | + ''' <summary>コンストラクタ</summary> | |
16 | + ''' <param name="LogTextBox">フォーム上のログ表示用テキストボックス</param> | |
17 | + Public Sub New(ByVal LogTextBox As TextBox) | |
18 | + _LogTextBox = LogTextBox | |
19 | + _LogTextBox.Text = "" | |
20 | + _ShadowBuf = "" | |
21 | + LogFileName = AppPath() + "Log" + Now.ToString("yyMM") + ".txt" | |
22 | + End Sub | |
23 | + | |
24 | + ''' <summary>Delegate ログの追加</summary> | |
25 | + ''' <param name="stradd">ログ追加文字列</param> | |
26 | + Delegate Sub Add_Callback(ByVal stradd As String) | |
27 | + | |
28 | + ''' <summary>ログの追加</summary> | |
29 | + ''' <param name="stradd">ログ追加文字列</param> | |
30 | + ''' <remarks>ログの最下行へのスクロール・表示更新は行わない</remarks> | |
31 | + Public Sub Add(ByVal stradd As String) | |
32 | + Dim SplitBuf() As String | |
33 | + Dim i As Integer | |
34 | + Dim TempText As String | |
35 | + | |
36 | + ''別スレッドか判定 | |
37 | + If _LogTextBox.InvokeRequired Then | |
38 | + ''別スレッドからの場合コールバック処理をして終了 | |
39 | + Dim d As New Add_Callback(AddressOf Add) | |
40 | + _LogTextBox.Invoke(d, New Object() {stradd}) | |
41 | + Exit Sub | |
42 | + End If | |
43 | + | |
44 | + If Len(stradd) = 0 Then Exit Sub | |
45 | + | |
46 | + If InStr(stradd, vbCrLf) = 0 Then stradd &= vbCrLf | |
47 | + | |
48 | + SplitBuf = Split(stradd, vbCrLf) | |
49 | + If UBound(SplitBuf) > 0 Then | |
50 | + For i = 0 To UBound(SplitBuf) - 1 | |
51 | + 'TempText = Format(Now, "yy/MM/dd HH:mm:ss") & " : " & SplitBuf(i) & vbCrLf | |
52 | + TempText = Format(Now, "MM/dd HH:mm:ss") & " : " & SplitBuf(i) & vbCrLf | |
53 | + _LogTextBox.Text += TempText | |
54 | + _ShadowBuf += TempText | |
55 | + Next i | |
56 | + End If | |
57 | + | |
58 | + End Sub | |
59 | + | |
60 | + ''' <summary>Delegate ログの追加と表示の更新</summary> | |
61 | + ''' <param name="stradd">ログ追加文字列</param> | |
62 | + Delegate Sub Put_Callback(ByVal stradd As String) | |
63 | + | |
64 | + ''' <summary>ログの最終行を表示する。</summary> | |
65 | + Public Sub Put() | |
66 | + ''カレット位置を末尾に移動 | |
67 | + _LogTextBox.SelectionStart = _LogTextBox.Text.Length | |
68 | + ''カレット位置までスクロール | |
69 | + _LogTextBox.ScrollToCaret() | |
70 | + End Sub | |
71 | + | |
72 | + ''' <summary>ログの追加と最下行へのスクロール・表示更新</summary> | |
73 | + ''' <param name="stradd">ログ追加文字列</param> | |
74 | + Public Sub Put(ByVal stradd As String) | |
75 | + | |
76 | + ''別スレッドか判定 | |
77 | + If _LogTextBox.InvokeRequired Then | |
78 | + ''別スレッドからの場合コールバック処理をして終了 | |
79 | + Dim d As New Put_Callback(AddressOf Put) | |
80 | + _LogTextBox.Invoke(d, New Object() {stradd}) | |
81 | + Exit Sub | |
82 | + End If | |
83 | + | |
84 | + ''古いログを廃棄する | |
85 | + DeleteOld() | |
86 | + | |
87 | + ''ログ追加処理 | |
88 | + Add(stradd) | |
89 | + | |
90 | + ''最新ログまでスクロール | |
91 | + Put() | |
92 | + | |
93 | + End Sub | |
94 | + | |
95 | + ''' <summary>デバッグログの追加と最下行へのスクロール・表示更新</summary> | |
96 | + ''' <param name="stradd">デバッグログ追加文字列</param> | |
97 | + Public Sub DebugPut(ByVal stradd As String) | |
98 | + | |
99 | +#If 0 Then | |
100 | + Put(stradd) | |
101 | +#End If | |
102 | + | |
103 | + End Sub | |
104 | + | |
105 | + ''' <summary>ログをファイルへ保存する</summary> | |
106 | + Public Sub Save() | |
107 | + If _ShadowBuf.Length = 0 Then Exit Sub | |
108 | + | |
109 | +#If 0 Then 'このプログラムでは保存機能は封印する。 | |
110 | + ''追記モードでShift-JISファイルを開く | |
111 | + Using Writer As New System.IO.StreamWriter(LogFileName, True, System.Text.Encoding.GetEncoding("shift-jis")) | |
112 | + Writer.Write(_ShadowBuf) | |
113 | + End Using | |
114 | +#End If | |
115 | + _ShadowBuf = "" | |
116 | + End Sub | |
117 | + | |
118 | + ''' <summary>古いログ表示を破棄する</summary> | |
119 | + Private Sub DeleteOld() | |
120 | + Dim SplitBuf() As String | |
121 | + | |
122 | + ''ログ表示量が MaxLength -1024 より小さくなるまで破棄する。 | |
123 | + While Len(_LogTextBox.Text) > (_LogTextBox.MaxLength - 1024) | |
124 | + SplitBuf = Split(_LogTextBox.Text, vbLf, 2) | |
125 | + If UBound(SplitBuf) > 0 Then | |
126 | + _LogTextBox.Text = SplitBuf(1) | |
127 | + Else | |
128 | + _LogTextBox.Text = "" | |
129 | + End If | |
130 | + End While | |
131 | + End Sub | |
132 | + | |
133 | + ''' <summary>ログ表示を消去する。</summary> | |
134 | + ''' <remarks >ファイル保存用の裏バッファはクリアしない</remarks> | |
135 | + Public Sub Clear() | |
136 | + _LogTextBox.Text = "" | |
137 | + End Sub | |
138 | + | |
139 | +End Class |
@@ -0,0 +1,99 @@ | ||
1 | +<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ | |
2 | +Partial Class FormMain | |
3 | + Inherits System.Windows.Forms.Form | |
4 | + | |
5 | + 'フォームがコンポーネントの一覧をクリーンアップするために dispose をオーバーライドします。 | |
6 | + <System.Diagnostics.DebuggerNonUserCode()> _ | |
7 | + Protected Overrides Sub Dispose(ByVal disposing As Boolean) | |
8 | + Try | |
9 | + If disposing AndAlso components IsNot Nothing Then | |
10 | + components.Dispose() | |
11 | + End If | |
12 | + Finally | |
13 | + MyBase.Dispose(disposing) | |
14 | + End Try | |
15 | + End Sub | |
16 | + | |
17 | + 'Windows フォーム デザイナで必要です。 | |
18 | + Private components As System.ComponentModel.IContainer | |
19 | + | |
20 | + 'メモ: 以下のプロシージャは Windows フォーム デザイナで必要です。 | |
21 | + 'Windows フォーム デザイナを使用して変更できます。 | |
22 | + 'コード エディタを使って変更しないでください。 | |
23 | + <System.Diagnostics.DebuggerStepThrough()> _ | |
24 | + Private Sub InitializeComponent() | |
25 | + Me.Button4 = New System.Windows.Forms.Button() | |
26 | + Me.Button5 = New System.Windows.Forms.Button() | |
27 | + Me.Button6 = New System.Windows.Forms.Button() | |
28 | + Me.TextBox4 = New System.Windows.Forms.TextBox() | |
29 | + Me.SuspendLayout() | |
30 | + ' | |
31 | + 'Button4 | |
32 | + ' | |
33 | + Me.Button4.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) | |
34 | + Me.Button4.Location = New System.Drawing.Point(15, 251) | |
35 | + Me.Button4.Name = "Button4" | |
36 | + Me.Button4.Size = New System.Drawing.Size(148, 29) | |
37 | + Me.Button4.TabIndex = 2 | |
38 | + Me.Button4.Text = "このプログラムについて" | |
39 | + Me.Button4.UseVisualStyleBackColor = True | |
40 | + ' | |
41 | + 'Button5 | |
42 | + ' | |
43 | + Me.Button5.Anchor = CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _ | |
44 | + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) | |
45 | + Me.Button5.Location = New System.Drawing.Point(169, 251) | |
46 | + Me.Button5.Name = "Button5" | |
47 | + Me.Button5.Size = New System.Drawing.Size(251, 29) | |
48 | + Me.Button5.TabIndex = 3 | |
49 | + Me.Button5.Text = "ログ表示クリア" | |
50 | + Me.Button5.UseVisualStyleBackColor = True | |
51 | + ' | |
52 | + 'Button6 | |
53 | + ' | |
54 | + Me.Button6.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) | |
55 | + Me.Button6.Location = New System.Drawing.Point(426, 251) | |
56 | + Me.Button6.Name = "Button6" | |
57 | + Me.Button6.Size = New System.Drawing.Size(146, 29) | |
58 | + Me.Button6.TabIndex = 4 | |
59 | + Me.Button6.Text = "終了" | |
60 | + Me.Button6.UseVisualStyleBackColor = True | |
61 | + ' | |
62 | + 'TextBox4 | |
63 | + ' | |
64 | + Me.TextBox4.AllowDrop = True | |
65 | + Me.TextBox4.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ | |
66 | + Or System.Windows.Forms.AnchorStyles.Left) _ | |
67 | + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) | |
68 | + Me.TextBox4.Location = New System.Drawing.Point(15, 12) | |
69 | + Me.TextBox4.MaxLength = 327670 | |
70 | + Me.TextBox4.Multiline = True | |
71 | + Me.TextBox4.Name = "TextBox4" | |
72 | + Me.TextBox4.ScrollBars = System.Windows.Forms.ScrollBars.Both | |
73 | + Me.TextBox4.Size = New System.Drawing.Size(557, 223) | |
74 | + Me.TextBox4.TabIndex = 1 | |
75 | + Me.TextBox4.WordWrap = False | |
76 | + ' | |
77 | + 'FormMain | |
78 | + ' | |
79 | + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!) | |
80 | + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font | |
81 | + Me.ClientSize = New System.Drawing.Size(584, 292) | |
82 | + Me.Controls.Add(Me.TextBox4) | |
83 | + Me.Controls.Add(Me.Button5) | |
84 | + Me.Controls.Add(Me.Button4) | |
85 | + Me.Controls.Add(Me.Button6) | |
86 | + Me.MinimumSize = New System.Drawing.Size(500, 330) | |
87 | + Me.Name = "FormMain" | |
88 | + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen | |
89 | + Me.Text = "XLSXPack" | |
90 | + Me.ResumeLayout(False) | |
91 | + Me.PerformLayout() | |
92 | + | |
93 | + End Sub | |
94 | + Friend WithEvents Button4 As System.Windows.Forms.Button | |
95 | + Friend WithEvents Button5 As System.Windows.Forms.Button | |
96 | + Friend WithEvents Button6 As System.Windows.Forms.Button | |
97 | + Friend WithEvents TextBox4 As System.Windows.Forms.TextBox | |
98 | + | |
99 | +End Class |
@@ -0,0 +1,376 @@ | ||
1 | +Imports OfficeImageReducer.ClassMyCommon ''ClassMyConmonのプロパティ・メソッドを参照するためのImportsステートメント | |
2 | +Imports System.IO | |
3 | +Imports System.IO.Compression | |
4 | + | |
5 | +''' <summary>メイン(スタートアップ)フォーム</summary> | |
6 | +Public Class FormMain | |
7 | + | |
8 | + Private Sub FormMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing | |
9 | + On Error Resume Next | |
10 | + | |
11 | + Log.Put("終了" + vbCrLf) | |
12 | + Log.Save() | |
13 | + | |
14 | + End Sub | |
15 | + | |
16 | + ''' <summary>メイン(スタートアップ)フォームのロード</summary> | |
17 | + ''' <param name="sender">イベントを発生させたオブジェクト</param> | |
18 | + ''' <param name="e">イベントオプション</param> | |
19 | + Private Sub FormMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load | |
20 | + | |
21 | +#If 0 Then | |
22 | + ''多重起動チェック | |
23 | + 'Process.GetProcessesByName メソッド | |
24 | + '指定したプロセス名を共有するリモートコンピュータ上の | |
25 | + 'すべてのプロセスリソースに関連付けます。 | |
26 | + Dim pn As String = Process.GetCurrentProcess.ProcessName 'Process.ProcessName プロパティ(プロセスの名前を取得します) | |
27 | + If Process.GetProcessesByName(pn).GetUpperBound(0) > 0 Then | |
28 | + ''多重起動しているならばエラーメッセージ表示して終了。 | |
29 | + MessageBox.Show("すでに起動しています。", TITLE + " エラーメッセージ", _ | |
30 | + MessageBoxButtons.OK, _ | |
31 | + MessageBoxIcon.Error) | |
32 | + End | |
33 | + End If | |
34 | +#End If | |
35 | + frmMain = Me | |
36 | + | |
37 | + FormControlBoxCustomize(Me) | |
38 | + | |
39 | + Me.Text = TITLE + " " + VERSION | |
40 | + | |
41 | + Log = New ClassLog(Me.TextBox4) | |
42 | + | |
43 | + Log.DebugPut("起動しました。" + vbCrLf) | |
44 | + | |
45 | + Button4.PerformClick() | |
46 | + | |
47 | + '起動時は最前面にもってくる | |
48 | + Me.Show() | |
49 | + Me.TopMost = True | |
50 | + WaitTickCount(500) | |
51 | + Me.TopMost = False | |
52 | + | |
53 | + | |
54 | + End Sub | |
55 | + | |
56 | + ''' <summary>「このプログラムについて」のボタンを押された時の処理</summary> | |
57 | + Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click | |
58 | + Log.Add("--------------------------------------------------------------------------" + vbCrLf) | |
59 | + Log.Add(TITLE + " " + VERSION + vbCrLf) | |
60 | + Log.Add(OPENING_MSG) | |
61 | + Log.Add(vbCrLf) | |
62 | + Log.Add("--------------------------------------------------------------------------" + vbCrLf) | |
63 | + Log.Put() | |
64 | + End Sub | |
65 | + | |
66 | + ''' <summary>ログの表示クリアを行う</summary> | |
67 | + Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click | |
68 | + Log.Clear() | |
69 | + End Sub | |
70 | + | |
71 | + ''' <summary>プログラムの終了ボタンを押された。</summary> | |
72 | + Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click | |
73 | + | |
74 | + 'ここで closingイベントが発生。 | |
75 | + Me.Close() | |
76 | + End | |
77 | + | |
78 | + End Sub | |
79 | + | |
80 | + Public Sub New() | |
81 | + | |
82 | + ' この呼び出しはデザイナーで必要です。 | |
83 | + InitializeComponent() | |
84 | + | |
85 | + ' InitializeComponent() 呼び出しの後で初期化を追加します。 | |
86 | + | |
87 | + End Sub | |
88 | + | |
89 | + Private Sub TextBox4_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TextBox4.DragEnter | |
90 | + | |
91 | + 'ファイル形式の場合のみ、ドラッグを受け付けます。 | |
92 | + If e.Data.GetDataPresent(DataFormats.FileDrop) = True Then | |
93 | + e.Effect = DragDropEffects.Copy | |
94 | + Else | |
95 | + e.Effect = DragDropEffects.None | |
96 | + End If | |
97 | + | |
98 | + End Sub | |
99 | + | |
100 | + Private Sub TextBox4_DragDrop(sender As Object, e As DragEventArgs) Handles TextBox4.DragDrop | |
101 | + | |
102 | + ' 読み込んだ結果をすべて格納するための変数を宣言する | |
103 | + Dim Result As String | |
104 | + Dim StrArray() As String | |
105 | + | |
106 | + 'ドラッグされたファイル・フォルダのパスを格納します。 | |
107 | + Dim strFileName As String() = CType(e.Data.GetData(DataFormats.FileDrop, False), String()) | |
108 | + Dim OrgFileName As String | |
109 | + | |
110 | + OrgFileName = strFileName(0).ToString() | |
111 | + | |
112 | + If OrgFileName.Substring(OrgFileName.Length - 5).ToLower <> ".xlsx" And _ | |
113 | + OrgFileName.Substring(OrgFileName.Length - 5).ToLower <> ".xlsm" And _ | |
114 | + OrgFileName.Substring(OrgFileName.Length - 5).ToLower <> ".pptx" And _ | |
115 | + OrgFileName.Substring(OrgFileName.Length - 5).ToLower <> ".pptm" And _ | |
116 | + OrgFileName.Substring(OrgFileName.Length - 5).ToLower <> ".docx" And _ | |
117 | + OrgFileName.Substring(OrgFileName.Length - 5).ToLower <> ".docm" Then | |
118 | + Log.Put("office2007 ファイル以外には対応していません。") | |
119 | + Exit Sub | |
120 | + End If | |
121 | + | |
122 | + Dim FileExtension As String = OrgFileName.Substring(OrgFileName.Length - 4).ToLower | |
123 | + | |
124 | + 'ファイルの存在確認を行い、ある場合にのみ、 | |
125 | + 'テキストボックスにパスを表示します。 | |
126 | + '(この処理でフォルダを対象外にしています。) | |
127 | + If System.IO.File.Exists(OrgFileName) = True Then | |
128 | + Log.Put("Drop : " + OrgFileName) | |
129 | + Application.DoEvents() | |
130 | + Else | |
131 | + Exit Sub | |
132 | + End If | |
133 | + | |
134 | + Log.Put("解析中です。") | |
135 | + Application.DoEvents() | |
136 | + | |
137 | + Dim ZipFileName As String = Path.GetDirectoryName(OrgFileName) + "\~OfficeJPGconvTemp.zip" | |
138 | + Dim ExtractPath As String = Path.GetDirectoryName(OrgFileName) + "\~OfficeJPGconvExtract" | |
139 | + Dim CurrentTypesFileName As String = ExtractPath + "\[Content_Types].xml" | |
140 | + | |
141 | + Try | |
142 | + | |
143 | + File.Delete(ZipFileName) | |
144 | + File.Copy(OrgFileName, ZipFileName) | |
145 | + | |
146 | + '解凍先フォルダ (ディレクトリ) が存在しているかどうか確認して削除 | |
147 | + '存在の有無を確認しないとExceptionが発生する | |
148 | + If Directory.Exists(ExtractPath) Then | |
149 | + Log.DebugPut("作業用フォルダが存在します。削除します。") | |
150 | + Directory.Delete(ExtractPath, True) | |
151 | + Else | |
152 | + Log.DebugPut("作業用フォルダが存在しません。") | |
153 | + End If | |
154 | + | |
155 | + Try | |
156 | + Directory.CreateDirectory(ExtractPath) | |
157 | + Catch | |
158 | + Log.Put("作業用フォルダの作成に失敗しました。") | |
159 | + Exit Sub | |
160 | + End Try | |
161 | + | |
162 | + Application.DoEvents() | |
163 | + | |
164 | + 'ZIP書庫を展開する | |
165 | + Compression.ZipFile.ExtractToDirectory( _ | |
166 | + ZipFileName, ExtractPath, | |
167 | + System.Text.Encoding.GetEncoding("shift_jis")) | |
168 | + | |
169 | + Application.DoEvents() | |
170 | + | |
171 | + '解凍したZIPの中に [Content_Types].xml があるかどうか確認する。 | |
172 | + If File.Exists(CurrentTypesFileName) Then | |
173 | + '存在するのなら正常。次の処理へ | |
174 | + Else | |
175 | + '存在しないなら異常。作業中断 | |
176 | + Try | |
177 | + File.Delete(ZipFileName) | |
178 | + Directory.Delete(ExtractPath, True) | |
179 | + Catch | |
180 | + End Try | |
181 | + Log.Put("対象ファイルの解析ができません。") | |
182 | + Log.Put("作業を終了します。") | |
183 | + Exit Sub | |
184 | + End If | |
185 | + | |
186 | + 'MediaPath = <ExtractPath>\xl\media | |
187 | + 'MediaPath = <ExtractPath>\ppt\media | |
188 | + 'PNGファイルのリストアップ | |
189 | + Dim MediaPath As String | |
190 | + Dim MediaFileNames() As String | |
191 | + If System.IO.Directory.Exists(ExtractPath + "\xl\media\") Then | |
192 | + MediaPath = ExtractPath + "\xl\media" | |
193 | + MediaFileNames = Directory.GetFiles(MediaPath, "*.png") | |
194 | + ElseIf System.IO.Directory.Exists(ExtractPath + "\ppt\media\") Then | |
195 | + MediaPath = ExtractPath + "\ppt\media" | |
196 | + MediaFileNames = Directory.GetFiles(MediaPath, "*.png") | |
197 | + ElseIf System.IO.Directory.Exists(ExtractPath + "\word\media\") Then | |
198 | + MediaPath = ExtractPath + "\word\media" | |
199 | + MediaFileNames = Directory.GetFiles(MediaPath, "*.png") | |
200 | + Else | |
201 | + Try | |
202 | + File.Delete(ZipFileName) | |
203 | + Directory.Delete(ExtractPath, True) | |
204 | + Catch | |
205 | + | |
206 | + End Try | |
207 | + Log.Put("対象ファイルの中にPNGファイルがありません。") | |
208 | + Log.Put("作業を終了します。") | |
209 | + Exit Sub | |
210 | + End If | |
211 | +#If 0 Then | |
212 | + For Each MediaFileName As String In MediaFileNames | |
213 | + Log.Put(MediaFileName) | |
214 | + Next | |
215 | +#End If | |
216 | + 'relsファイルのリストアップ | |
217 | + Dim RelsFileNames() As String = System.IO.Directory.GetFiles(ExtractPath, "*.rels", System.IO.SearchOption.AllDirectories) | |
218 | +#If 0 Then | |
219 | + For Each RelsFileName As String In RelsFileNames | |
220 | + Log.Put(RelsFileName) | |
221 | + Next | |
222 | +#End If | |
223 | + | |
224 | + '取得したメディアファイルの処理をする | |
225 | + For Each MediaFileName As String In MediaFileNames | |
226 | + | |
227 | + 'ファイルのサイズを取得し小さいサイズのものはスキップ | |
228 | + Dim Medialen As Long = New FileInfo(MediaFileName).Length | |
229 | + If Medialen < 1024 Then | |
230 | + Continue For | |
231 | + End If | |
232 | + | |
233 | + '取得したファイル名を表示する | |
234 | + Log.DebugPut(MediaFileName) | |
235 | + Log.DebugPut(Medialen.ToString) | |
236 | + | |
237 | + Dim TmpJpgFileName As String = MediaPath + "~OfficeJPGConvtemp.jpg" | |
238 | + | |
239 | + 'PNGファイルを開く | |
240 | + Try | |
241 | + '前回の作業ファイルが残っていれば削除する | |
242 | + File.Delete(TmpJpgFileName) | |
243 | + | |
244 | + ' Bitmapファイルオープン | |
245 | + Using bmp As New Bitmap(MediaFileName) | |
246 | + | |
247 | + 'JPEG形式で保存する() | |
248 | + bmp.Save(TmpJpgFileName, System.Drawing.Imaging.ImageFormat.Jpeg) | |
249 | + | |
250 | + 'Bitmapファイルをクローズ | |
251 | + bmp.Dispose() | |
252 | + End Using | |
253 | + Catch | |
254 | + '不正なBMP/PNGであれば例外が発生する。 | |
255 | + File.Delete(TmpJpgFileName) | |
256 | + '次のPNGファイルの処理へ | |
257 | + Continue For | |
258 | + End Try | |
259 | + | |
260 | + Dim Jpglen As Long = New FileInfo(TmpJpgFileName).Length | |
261 | + If Jpglen <= (Medialen * 0.8) Then | |
262 | + File.Delete(MediaFileName) | |
263 | + Dim NewMediaFileName As String = "" | |
264 | + For j = 0 To 9999 | |
265 | + If j = 0 Then | |
266 | + NewMediaFileName = MediaFileName.Substring(0, MediaFileName.Length - 4) + ".jpeg" | |
267 | + Else | |
268 | + NewMediaFileName = MediaFileName.Substring(0, MediaFileName.Length - 4) + "(" + (j - 1).ToString + ").jpeg" | |
269 | + End If | |
270 | + | |
271 | + Try | |
272 | + File.Move(TmpJpgFileName, NewMediaFileName) | |
273 | + Exit For | |
274 | + Catch | |
275 | + End Try | |
276 | + Next j | |
277 | + | |
278 | + StrArray = Split(MediaFileName, "\") | |
279 | + Dim SplitMediaFileName As String = StrArray(StrArray.Length - 1) | |
280 | + StrArray = Split(NewMediaFileName, "\") | |
281 | + Dim SplitNewMediaFileName As String = StrArray(StrArray.Length - 1) | |
282 | + | |
283 | + Log.Put(SplitMediaFileName + " -> " + SplitNewMediaFileName) | |
284 | + Application.DoEvents() 'ログ表示更新の為 | |
285 | + | |
286 | + '取得したリレーションファイルの処理をする | |
287 | + For Each RelsFileName As String In RelsFileNames | |
288 | + 'Shift-JISファイルを開く | |
289 | + Result = String.Empty | |
290 | + Using Reader As New System.IO.StreamReader(RelsFileName, System.Text.Encoding.GetEncoding("shift-jis")) | |
291 | + Result = Reader.ReadToEnd | |
292 | + 'Log.Put(Result) | |
293 | + End Using | |
294 | + | |
295 | + If InStr(Result, SplitMediaFileName) Then | |
296 | + 'Log.Put(Result) | |
297 | + Result = Replace(Result, SplitMediaFileName, SplitNewMediaFileName) | |
298 | + '上書モードでShift-JISファイルを開く | |
299 | + Using Writer As New System.IO.StreamWriter(RelsFileName, False, System.Text.Encoding.GetEncoding("shift-jis")) | |
300 | + Writer.Write(Result) | |
301 | + 'Log.Put(Result) | |
302 | + End Using | |
303 | + | |
304 | + End If | |
305 | + Next | |
306 | + | |
307 | + File.Delete(TmpJpgFileName) | |
308 | + | |
309 | + Else | |
310 | + 'JPGファイルにしてもサイズがちいさくならなかった。 | |
311 | + File.Delete(TmpJpgFileName) | |
312 | + End If | |
313 | + | |
314 | + Next | |
315 | + | |
316 | + ' ExtractPath + "\[Content_Types].xml の中を修正する | |
317 | + Result = String.Empty | |
318 | + Using Reader As New System.IO.StreamReader(CurrentTypesFileName, System.Text.Encoding.GetEncoding("shift-jis")) | |
319 | + Result = Reader.ReadToEnd | |
320 | + End Using | |
321 | + | |
322 | + '追加 <Default Extension="jpeg" ContentType="application/jpeg"/> | |
323 | + If InStr(Result.ToLower, "default extension=""jpeg""") Then | |
324 | + '変更不要 | |
325 | + Else | |
326 | + Result = Replace(Result, _ | |
327 | + "<Default Extension=""xml"" ContentType=""application/xml""/>", _ | |
328 | + "<Default Extension=""xml"" ContentType=""application/xml""/><Default Extension=""jpeg"" ContentType=""application/jpeg""/>") | |
329 | + '上書モードでShift-JISファイルを開く | |
330 | + Using Writer As New System.IO.StreamWriter(CurrentTypesFileName, False, System.Text.Encoding.GetEncoding("shift-jis")) | |
331 | + Writer.Write(Result) | |
332 | + 'Log.Put(Result) | |
333 | + End Using | |
334 | + End If | |
335 | + | |
336 | + 'ZIP書庫を作成する | |
337 | + File.Delete(ZipFileName) | |
338 | + Compression.ZipFile.CreateFromDirectory( _ | |
339 | + ExtractPath, ZipFileName, | |
340 | + Compression.CompressionLevel.Optimal, _ | |
341 | + False, _ | |
342 | + System.Text.Encoding.GetEncoding("shift_jis")) | |
343 | + | |
344 | + 'オリジナルファイルをリネームする | |
345 | + For i = 0 To 1000 | |
346 | + Dim NewOrgFileName As String _ | |
347 | + = OrgFileName.Substring(0, OrgFileName.Length - 5) + "(" + i.ToString + ")" + OrgFileName.Substring(OrgFileName.Length - 5) | |
348 | + Try | |
349 | + File.Move(OrgFileName, NewOrgFileName) | |
350 | + Catch | |
351 | + Continue For | |
352 | + End Try | |
353 | + Exit For | |
354 | + Next | |
355 | + | |
356 | + File.Move(ZipFileName, OrgFileName) | |
357 | + | |
358 | + Log.Put("作業終了しました。") | |
359 | + | |
360 | + Catch | |
361 | + Log.Put("対象ファイルの解析作業ができませんでした。") | |
362 | + Log.Put("作業を強制終了します。") | |
363 | + End Try | |
364 | + | |
365 | + '作業ファイルとフォルダを削除 | |
366 | + Try | |
367 | + File.Delete(ZipFileName) | |
368 | + Catch | |
369 | + End Try | |
370 | + Try | |
371 | + Directory.Delete(ExtractPath, True) | |
372 | + Catch | |
373 | + End Try | |
374 | + | |
375 | + End Sub | |
376 | +End Class |