• R/O
  • SSH
  • HTTPS

wheretrainbuild: コミット


コミットメタ情報

リビジョン16 (tree)
日時2019-01-16 21:55:51
作者dangerouswoo

ログメッセージ

(メッセージはありません)

変更サマリ

差分

--- WhereTrainBuild/MapForm.Designer.cs (revision 15)
+++ WhereTrainBuild/MapForm.Designer.cs (revision 16)
@@ -227,6 +227,7 @@
227227 //
228228 // MapForm
229229 //
230+ this.AllowDrop = true;
230231 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
231232 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
232233 this.ClientSize = new System.Drawing.Size(616, 429);
@@ -240,6 +241,8 @@
240241 this.Text = "WhereTrainBuild";
241242 this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MapForm_FormClosed);
242243 this.Load += new System.EventHandler(this.MapForm_Load);
244+ this.DragDrop += new System.Windows.Forms.DragEventHandler(this.MapForm_DragDrop);
245+ this.DragEnter += new System.Windows.Forms.DragEventHandler(this.MapForm_DragEnter);
243246 this.Resize += new System.EventHandler(this.MapForm_Resize);
244247 this.menuStrip1.ResumeLayout(false);
245248 this.menuStrip1.PerformLayout();
--- WhereTrainBuild/MapForm.cs (revision 15)
+++ WhereTrainBuild/MapForm.cs (revision 16)
@@ -333,17 +333,7 @@
333333 dlg.DefaultExt = "wtx";
334334 if (dlg.ShowDialog(this) == DialogResult.OK)
335335 {
336- m_filename = dlg.FileName;
337- Text = string.Format("WhereTrainBuild({0})", Path.GetFileNameWithoutExtension(m_filename));
338-
339- var factory = new PlaneFactory();
340-
341- var doc = new XmlDocument();
342- doc.Load(dlg.FileName);
343-
344- LoadFactory(factory, doc);
345-
346- InitializeFactory(factory);
336+ LoadFactory(dlg.FileName);
347337 }
348338 }
349339 }
@@ -351,10 +341,18 @@
351341 /// <summary>
352342 /// ファクトリロード
353343 /// </summary>
354- /// <param name="factory"></param>
355- /// <param name="doc"></param>
356- protected void LoadFactory( IFactory factory, XmlDocument doc )
344+ /// <param name="filename"></param>
345+ protected void LoadFactory( string filename )
357346 {
347+ m_filename = filename;
348+
349+ Text = string.Format("WhereTrainBuild({0})", Path.GetFileNameWithoutExtension(m_filename));
350+
351+ var factory = new PlaneFactory();
352+
353+ var doc = new XmlDocument();
354+ doc.Load(filename);
355+
358356 var rootnode = doc.DocumentElement;
359357
360358 foreach (XmlNode factorynode in rootnode.ChildNodes)
@@ -364,6 +362,8 @@
364362 break;
365363 }
366364 }
365+
366+ InitializeFactory(factory);
367367 }
368368
369369 /// <summary>
@@ -1321,5 +1321,54 @@
13211321 dlg.MainForm = this;
13221322 dlg.Show(this);
13231323 }
1324+
1325+ /// <summary>
1326+ /// ドラッグ侵入
1327+ /// </summary>
1328+ /// <param name="sender"></param>
1329+ /// <param name="e"></param>
1330+ private void MapForm_DragEnter(object sender, DragEventArgs e)
1331+ {
1332+ if (e.Data.GetDataPresent(DataFormats.FileDrop))
1333+ {
1334+ var drags = e.Data.GetData(DataFormats.FileDrop) as string[];
1335+ if (drags != null)
1336+ {
1337+ bool bWtx = false;
1338+ foreach (var file in drags)
1339+ {
1340+ if (Path.GetExtension(file).ToUpper() == ".WTX")
1341+ {
1342+ bWtx = true;
1343+ break;
1344+ }
1345+ }
1346+ if (bWtx == true)
1347+ e.Effect = DragDropEffects.Copy;
1348+ }
1349+ }
1350+ }
1351+
1352+ /// <summary>
1353+ /// ドラッグ完了
1354+ /// </summary>
1355+ /// <param name="sender"></param>
1356+ /// <param name="e"></param>
1357+ private void MapForm_DragDrop(object sender, DragEventArgs e)
1358+ {
1359+ var drags = e.Data.GetData(DataFormats.FileDrop) as string[];
1360+ if( drags != null )
1361+ {
1362+ foreach (var file in drags)
1363+ {
1364+ if (Path.GetExtension(file).ToUpper() == ".WTX")
1365+ {
1366+ LoadFactory(file);
1367+
1368+ break;
1369+ }
1370+ }
1371+ }
1372+ }
13241373 }
13251374 }
旧リポジトリブラウザで表示