• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythonwindowsphpgamebathyscapheguic翻訳omegattwitterframeworkbtronvb.net計画中(planning stage)testdomarduinodirectxpreviewerゲームエンジン

誰にでも使えるメモ帳を目指してます。


Commit MetaInfo

Révision8add1427905f6625675e02223bad952ba550fcd9 (tree)
l'heure2013-10-29 14:42:54
AuteurTakayuki Kamiyama <karuma.reason@gmai...>
CommiterTakayuki Kamiyama

Message de Log

上書き保存機能を追加しました。

Change Summary

Modification

--- a/.hg/cache/branchheads-served
+++ b/.hg/cache/branchheads-served
@@ -1,2 +1,2 @@
1-978177d2025cb049422ae70723e937f4d2faa60a 1
2-978177d2025cb049422ae70723e937f4d2faa60a default
1+3b003640495da7f75940276412be9ba16b743005 2
2+3b003640495da7f75940276412be9ba16b743005 default
--- a/.hg/cache/tags
+++ b/.hg/cache/tags
@@ -1,2 +1,2 @@
1-0 05b6645fe7aff3ddf238bfb3fa40e3a64e92240a
1+1 978177d2025cb049422ae70723e937f4d2faa60a
22
Binary files a/.hg/dirstate and b/.hg/dirstate differ
--- a/.hg/last-message.txt
+++ b/.hg/last-message.txt
@@ -1 +1 @@
1-build version 1.0.1 changed.
\ No newline at end of file
1+上書き保存機能を追加しました。
\ No newline at end of file
Binary files a/.hg/store/00changelog.i and b/.hg/store/00changelog.i differ
Binary files a/.hg/store/00manifest.i and b/.hg/store/00manifest.i differ
Binary files a/.hg/store/data/_u_k_editor/_form1._designer.cs.i and b/.hg/store/data/_u_k_editor/_form1._designer.cs.i differ
Binary files a/.hg/store/data/_u_k_editor/_form1.cs.i and b/.hg/store/data/_u_k_editor/_form1.cs.i differ
Binary files a/.hg/store/data/_u_k_editor/_form1.resx.d and b/.hg/store/data/_u_k_editor/_form1.resx.d differ
Binary files a/.hg/store/data/_u_k_editor/_form1.resx.i and b/.hg/store/data/_u_k_editor/_form1.resx.i differ
Binary files a/.hg/store/undo and b/.hg/store/undo differ
--- a/.hg/thgstatus
+++ b/.hg/thgstatus
@@ -1 +0,0 @@
1-r
--- a/.hg/undo.desc
+++ b/.hg/undo.desc
@@ -1,2 +1,2 @@
1-1
1+2
22 commit
Binary files a/.hg/undo.dirstate and b/.hg/undo.dirstate differ
Binary files a/UKEditor.suo and b/UKEditor.suo differ
--- a/UKEditor/Form1.Designer.cs
+++ b/UKEditor/Form1.Designer.cs
@@ -37,6 +37,7 @@
3737 this.保存ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
3838 this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
3939 this.閉じるToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
40+ this.menuSave = new System.Windows.Forms.ToolStripMenuItem();
4041 this.編集ToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
4142 this.コピーToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
4243 this.切り取りToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -59,6 +60,7 @@
5960 this.printDialog1 = new System.Windows.Forms.PrintDialog();
6061 this.printPreviewDialog1 = new System.Windows.Forms.PrintPreviewDialog();
6162 this.fontDialog1 = new System.Windows.Forms.FontDialog();
63+ this.statusStrip1 = new System.Windows.Forms.StatusStrip();
6264 this.menuStrip1.SuspendLayout();
6365 this.SuspendLayout();
6466 //
@@ -83,6 +85,7 @@
8385 this.toolStripSeparator2,
8486 this.新規作成ToolStripMenuItem,
8587 this.開くToolStripMenuItem,
88+ this.menuSave,
8689 this.保存ToolStripMenuItem,
8790 this.toolStripSeparator1,
8891 this.閉じるToolStripMenuItem});
@@ -93,13 +96,13 @@
9396 // toolStripSeparator2
9497 //
9598 this.toolStripSeparator2.Name = "toolStripSeparator2";
96- this.toolStripSeparator2.Size = new System.Drawing.Size(165, 6);
99+ this.toolStripSeparator2.Size = new System.Drawing.Size(174, 6);
97100 //
98101 // 新規作成ToolStripMenuItem
99102 //
100103 this.新規作成ToolStripMenuItem.Name = "新規作成ToolStripMenuItem";
101104 this.新規作成ToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A)));
102- this.新規作成ToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
105+ this.新規作成ToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
103106 this.新規作成ToolStripMenuItem.Text = "新規作成";
104107 this.新規作成ToolStripMenuItem.Click += new System.EventHandler(this.新規作成ToolStripMenuItem_Click);
105108 //
@@ -107,31 +110,40 @@
107110 //
108111 this.開くToolStripMenuItem.Name = "開くToolStripMenuItem";
109112 this.開くToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.B)));
110- this.開くToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
113+ this.開くToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
111114 this.開くToolStripMenuItem.Text = "開く";
112115 this.開くToolStripMenuItem.Click += new System.EventHandler(this.開くToolStripMenuItem_Click);
113116 //
114117 // 保存ToolStripMenuItem
115118 //
116119 this.保存ToolStripMenuItem.Name = "保存ToolStripMenuItem";
117- this.保存ToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
118- this.保存ToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
120+ this.保存ToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.S)));
121+ this.保存ToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
119122 this.保存ToolStripMenuItem.Text = "保存";
120123 this.保存ToolStripMenuItem.Click += new System.EventHandler(this.保存ToolStripMenuItem_Click);
121124 //
122125 // toolStripSeparator1
123126 //
124127 this.toolStripSeparator1.Name = "toolStripSeparator1";
125- this.toolStripSeparator1.Size = new System.Drawing.Size(165, 6);
128+ this.toolStripSeparator1.Size = new System.Drawing.Size(174, 6);
126129 //
127130 // 閉じるToolStripMenuItem
128131 //
129132 this.閉じるToolStripMenuItem.Name = "閉じるToolStripMenuItem";
130133 this.閉じるToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E)));
131- this.閉じるToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
134+ this.閉じるToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
132135 this.閉じるToolStripMenuItem.Text = "閉じる";
133136 this.閉じるToolStripMenuItem.Click += new System.EventHandler(this.閉じるToolStripMenuItem_Click);
134137 //
138+ // menuSave
139+ //
140+ this.menuSave.Enabled = false;
141+ this.menuSave.Name = "menuSave";
142+ this.menuSave.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
143+ this.menuSave.Size = new System.Drawing.Size(177, 22);
144+ this.menuSave.Text = "上書き保存";
145+ this.menuSave.Click += new System.EventHandler(this.menuSave_Click);
146+ //
135147 // 編集ToolStripMenuItem1
136148 //
137149 this.編集ToolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -304,11 +316,20 @@
304316 //
305317 this.fontDialog1.ShowColor = true;
306318 //
319+ // statusStrip1
320+ //
321+ this.statusStrip1.Location = new System.Drawing.Point(0, 473);
322+ this.statusStrip1.Name = "statusStrip1";
323+ this.statusStrip1.Size = new System.Drawing.Size(883, 22);
324+ this.statusStrip1.TabIndex = 3;
325+ this.statusStrip1.Text = "statusStrip1";
326+ //
307327 // Form1
308328 //
309329 this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
310330 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
311331 this.ClientSize = new System.Drawing.Size(883, 495);
332+ this.Controls.Add(this.statusStrip1);
312333 this.Controls.Add(this.textBox1);
313334 this.Controls.Add(this.menuStrip1);
314335 this.Font = new System.Drawing.Font("MS UI Gothic", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
@@ -357,6 +378,8 @@
357378 private System.Windows.Forms.ToolStripMenuItem その他ToolStripMenuItem;
358379 private System.Windows.Forms.ToolStripMenuItem ストップウオッチToolStripMenuItem;
359380 private System.Windows.Forms.ToolStripMenuItem デジタルタイマーToolStripMenuItem;
381+ private System.Windows.Forms.ToolStripMenuItem menuSave;
382+ private System.Windows.Forms.StatusStrip statusStrip1;
360383 }
361384 }
362385
--- a/UKEditor/Form1.cs
+++ b/UKEditor/Form1.cs
@@ -15,12 +15,25 @@ namespace UKEditor
1515 {
1616 private string StrPrint;
1717 private PageSettings PageSetting = new PageSettings();
18+ private bool dirtyFlag = false;   //ダーティーフラグ
19+ private bool readOnlyFlag = false; //読み取り専用フラグ
20+ private string editFilePath = ""; //編集中のファイルのパス
1821
1922 public Form1()
2023 {
2124 InitializeComponent();
2225 }
2326
27+ //ダーティーフラグの設定
28+ private void setDirty(bool flag)
29+ {
30+ dirtyFlag = flag;
31+ //読み取り専用でファイルがオープンされている場合、新規作成の場合
32+ //[上書き(&S)] メニューアイテムは常に無効
33+ menuSave.Enabled = (readOnlyFlag || editFilePath == "") ? false : flag;
34+ }
35+
36+
2437 private void 閉じるToolStripMenuItem_Click(object sender, EventArgs e)
2538 {
2639 this.閉じるToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E;
@@ -283,5 +296,33 @@ namespace UKEditor
283296 d.ShowDialog(this);
284297 d.Dispose();
285298 }
299+
300+ private void menuSave_Click(object sender, EventArgs e)
301+ {
302+ const string MSGBOX_TITLE = "ファイルの上書き保存";
303+
304+ //保存先のファイルが存在するかチェック
305+ if (File.Exists(editFilePath))
306+ {
307+ try
308+ {
309+ //テキストボックスの内容をファイルに書き込み
310+ File.WriteAllText(editFilePath, textBox1.Text, Encoding.Default);
311+ setDirty(false);
312+
313+ }
314+ catch (Exception ex)
315+ {
316+ //ファイルの書き込みでエラーが発生した場合に Exception の内容を表示
317+ MessageBox.Show(this, ex.Message, MSGBOX_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
318+ }
319+ }
320+ else
321+ {
322+ string MSG_BOX_STRING = "ファイル\"" + editFilePath
323+ + "\" のパスは正しくありません。\n\nディレクトリが存在するか確認してください。";
324+ MessageBox.Show(MSG_BOX_STRING, MSGBOX_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
325+ }
326+ }
286327 }
287328 }
--- a/UKEditor/Form1.resx
+++ b/UKEditor/Form1.resx
@@ -118,19 +118,19 @@
118118 <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119 </resheader>
120120 <metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121- <value>17, 17</value>
121+ <value>141, 17</value>
122122 </metadata>
123123 <metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
124- <value>139, 17</value>
124+ <value>263, 17</value>
125125 </metadata>
126126 <metadata name="saveFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
127- <value>286, 17</value>
127+ <value>410, 17</value>
128128 </metadata>
129129 <metadata name="printDocument1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
130- <value>431, 17</value>
130+ <value>555, 17</value>
131131 </metadata>
132132 <metadata name="printDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
133- <value>580, 17</value>
133+ <value>704, 17</value>
134134 </metadata>
135135 <metadata name="printPreviewDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
136136 <value>17, 55</value>
@@ -312,6 +312,9 @@
312312 <metadata name="fontDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
313313 <value>189, 55</value>
314314 </metadata>
315+ <metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
316+ <value>17, 17</value>
317+ </metadata>
315318 <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
316319 <value>
317320 AAABABUAAAAQAAEABACtJQAAVgEAAICAEAABAAQAaCgAAAMnAABgYBAAAQAEAOgWAABrTwAAMDAQAAEA
Binary files a/UKEditor/bin/Debug/UKEditor.exe and b/UKEditor/bin/Debug/UKEditor.exe differ
Binary files a/UKEditor/bin/Debug/UKEditor.pdb and b/UKEditor/bin/Debug/UKEditor.pdb differ
--- a/UKEditor/obj/x86/Debug/UKEditor.csproj.FileListAbsolute.txt
+++ b/UKEditor/obj/x86/Debug/UKEditor.csproj.FileListAbsolute.txt
@@ -9,6 +9,3 @@ H:\C#\UKEditor\UKEditor\obj\x86\Debug\UKEditor.AboutBox1.resources
99 H:\C#\UKEditor\UKEditor\obj\x86\Debug\UKEditor.Form2.resources
1010 H:\C#\UKEditor\UKEditor\obj\x86\Debug\UKEditor.Form3.resources
1111 H:\C#\UKEditor\UKEditor\obj\x86\Debug\UKEditor.Form4.resources
12-H:\C#\UKEditor\UKEditor\obj\x86\Debug\UKEditor.csprojResolveAssemblyReference.cache
13-H:\sourceforge\UKEditor\UKEditor\obj\x86\Debug\UKEditor.exe
14-H:\sourceforge\UKEditor\UKEditor\obj\x86\Debug\UKEditor.pdb
Binary files a/UKEditor/obj/x86/Debug/UKEditor.csproj.GenerateResource.Cache and b/UKEditor/obj/x86/Debug/UKEditor.csproj.GenerateResource.Cache differ
Binary files a/UKEditor/obj/x86/Debug/UKEditor.exe and b/UKEditor/obj/x86/Debug/UKEditor.exe differ
Binary files a/UKEditor/obj/x86/Debug/UKEditor.pdb and b/UKEditor/obj/x86/Debug/UKEditor.pdb differ