// リストアイテムが選択された. private void listBoxMainListBox_SelectedIndexChanged(object sender, EventArgs e) { if (TDCGExplorer.BusyTest()==true) return; try { int index = listBoxMainListBox.SelectedIndex; if (index >= 0) { if (index == lastSelectedListBoxIndex) return; lastSelectedListBoxIndex = index; LbGenItem item = listBoxMainListBox.Items[index] as LbGenItem; if (item != null) { item.DoClick(); listBoxMainListBox.Focus(); } } } catch (Exception exception) { TDCGExplorer.SetToolTips(TextResource.Error + ":" + exception.Message); Debug.WriteLine(exception.Message); } }
// ZIPファイルを展開する private void extractZipToolStripMenuItem_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; try { GenericZipTreeNode node = (GenericZipTreeNode)lastSelectTreeNode; if (TDCGExplorer.InstallZipFile(node)) { MessageBox.Show(TextResource.ExtractSuccess, TextResource.ExtractSuccessCaption, MessageBoxButtons.OK); } else { MessageBox.Show(TextResource.ExtractFailure,TextResource.ExtractFailureCaption, MessageBoxButtons.OK); } } catch (System.InvalidCastException ex) { MessageBox.Show(TextResource.ZipFileOnly, TextResource.Error, MessageBoxButtons.OK); Debug.WriteLine(ex.Message); } catch (Exception exception) { TDCGExplorer.SetToolTips(TextResource.Error+ ":" + exception.Message); Debug.WriteLine(exception.Message); } Cursor.Current = Cursors.Default; }
public static bool DownloadFile(string uri, string localfile) { try { HttpWebRequest request = WebRequest.Create(uri) as HttpWebRequest; SetRequestHeaders(request); HttpWebResponse response = request.GetResponse() as HttpWebResponse; Stream dataStream = response.GetResponseStream(); //File.Delete(localfile); TDCGExplorer.FileDelete(localfile); Stream fileStream = File.Create(localfile); BufferedStream bufferedDataStream = new BufferedStream(dataStream); BufferedStream bufferedFileStream = new BufferedStream(fileStream); byte[] buf = new byte[1024]; int len; while ((len = bufferedDataStream.Read(buf, 0, buf.Length)) > 0) { bufferedFileStream.Write(buf, 0, len); } bufferedFileStream.Flush(); bufferedFileStream.Close(); bufferedDataStream.Close(); response.Close(); return(true); } catch (Exception e) { TDCGExplorer.SetToolTips("Error DownloadFile : " + e.Message); } return(false); }
public void SetBitmap(Bitmap bitmap) { if (PictureBox.Image != null) { PictureBox.Image.Dispose(); PictureBox.Image = null; } #if false PictureBox.Image = new Bitmap(bitmap); PictureBox.Width = bitmap.Width; PictureBox.Height = bitmap.Height; #endif try { // 全部読み出す. using (MemoryStream basebmp = new MemoryStream()) { bitmap.Save(basebmp, System.Drawing.Imaging.ImageFormat.Bmp); Bitmap newbmp = new Bitmap(basebmp); PictureBox.Image = (Image)newbmp; PictureBox.Width = newbmp.Width; PictureBox.Height = newbmp.Height; } } catch (Exception e) { Bitmap noimage = new Bitmap(1, 1); PictureBox.Image = noimage; PictureBox.Width = 0; PictureBox.Height = 0; ; TDCGExplorer.SetToolTips("error: " + e.Message); } }
// 関連情報を取得する. private void downloadLatestDBZipToolStripMenuItem_Click_1(object sender, EventArgs e) { if (threadCheck() == true) return; if (TDCGExplorer.DownloadArcNamesZipFromServer() == true) { TDCGExplorer.GetArcNamesZipInfo(); } else { MessageBox.Show(TextResource.HttpError, TextResource.DownloadCaption, MessageBoxButtons.OK); return; } if (TDCGExplorer.DownloadTagNamesZipFromServer() == true) { TDCGExplorer.GetTagNamesZipInfo(); DisplayDB(); } else { MessageBox.Show(TextResource.HttpError, TextResource.DownloadCaption, MessageBoxButtons.OK); return; } DisplayDB(); MessageBox.Show(TextResource.SuccessModRefServer, TextResource.DownloadCaption, MessageBoxButtons.OK); }
private void toolStripMenuItemTouchAll_Click(object sender, EventArgs e) { if (TDCGExplorer.BusyTest() == true) return; try { SimpleTextDialog dialog = new SimpleTextDialog(); dialog.Owner = TDCGExplorer.MainFormWindow; dialog.dialogtext = TextResource.TouchDialogText; dialog.labeltext = TextResource.DateTime; dialog.textfield = DateTime.Now.ToString(); if (dialog.ShowDialog() == DialogResult.OK) { DateTime newtime = DateTime.Parse(dialog.textfield); foreach (Object itemobject in ListBoxMainView.Items) { LbSaveFileItem item = itemobject as LbSaveFileItem; if (item != null) { item.SetDate(newtime); } } } } catch (Exception) { } }
// 起動時処理. private void MainForm_Load(object sender, EventArgs e) { TDCGExplorer.IfReadyDbDisplayArcsDB(); // この処理がWindows x64ではたまに失敗するらしい. try { string windowRect = TDCGExplorer.SystemDB.window_rectangle; string[] rect = windowRect.Split(','); Left = int.Parse(rect[0]); Top = int.Parse(rect[1]); Size = new Size(int.Parse(rect[2]), int.Parse(rect[3])); normalsize = new Rectangle(Location, Size); string splitterDistance = TDCGExplorer.SystemDB.splitter_distance; string[] distance = splitterDistance.Split(','); splitContainerV.SplitterDistance = int.Parse(distance[0]); splitContainerH.SplitterDistance = int.Parse(distance[1]); splitContainerWithView.SplitterDistance = int.Parse(distance[2]); } catch (Exception) { } viewer = null; listBoxMainListBox.HorizontalScrollbar = true; }
// zipファイルの場合はDBを調べる. public override void DoExploreNode() { ArcsZipArcEntry zip = TDCGExplorer.ArcsDB.GetZip(zipid); string fullpath = Path.Combine(TDCGExplorer.SystemDB.zips_path, zip.path); TDCGExplorer.ExplorerSelectPath(fullpath); }
public static void ArcsDumpTahFilesEntries(ArcsDatabase db, ArcsTahEntry entry, TAHFile tah) { string source = Path.Combine(TDCGExplorer.SystemDB.arcs_path, entry.path); int tahentry = 0; foreach (TAHEntry ent in tah.EntrySet.Entries) { if (ent.FileName == null) { TDCGExplorer.SetToolTips("Dump " + ent.Hash.ToString("x8") + " file"); } else { TDCGExplorer.SetToolTips("Dump " + ent.FileName + " file"); } ArcsTahFilesEntry fileentry = new ArcsTahFilesEntry(); fileentry.id = 0; fileentry.tahid = entry.id; fileentry.tahentry = tahentry++; fileentry.path = ent.FileName; if (entry.path == null) { entry.path = ""; } fileentry.hash = (int)ent.Hash; fileentry.length = (int)ent.Length; db.SetTahFilesPath(fileentry); } }
public static void ZipsDumpTAHEntries(ArcsDatabase db, string zipname) { string ext = Path.GetExtension(zipname).ToLower(); if (ext == ".zip" || ext == ".lzh" || ext == ".rar") { TDCGExplorer.SetToolTips("Processing " + Path.GetFileName(zipname)); Regex filter = new Regex(zipcoderegexp); Match match = filter.Match(Path.GetFileName(zipname)); if (match.Success) { DateTime datetime = File.GetLastWriteTime(zipname); ArcsZipArcEntry entry = new ArcsZipArcEntry(); entry.id = 0; entry.path = zipname.Substring(zipspath.Length + 1); entry.code = match.Groups[1].ToString(); entry.exist = 1; entry.datetime = datetime; entry.id = db.SetZipEntry(entry); ZipDumpArcEntries(db, entry); } else { DateTime datetime = File.GetLastWriteTime(zipname); ArcsZipArcEntry entry = new ArcsZipArcEntry(); entry.id = 0; entry.path = zipname.Substring(zipspath.Length + 1); entry.code = Path.GetFileNameWithoutExtension(zipname); entry.exist = 1; entry.datetime = datetime; entry.id = db.SetZipEntry(entry); ZipDumpArcEntries(db, entry); } } }
// 検索 private void FindItemToolStripMenuItem_Click(object sender, EventArgs e) { SimpleTextDialog dialog = new SimpleTextDialog(); dialog.Owner = this; dialog.dialogtext = "検索"; dialog.labeltext = "検索文字列"; if (dialog.ShowDialog() == DialogResult.OK) { string text = dialog.textfield; Cursor.Current = Cursors.WaitCursor; foreach (TreeNode node in treeViewArcs.Nodes) TDCGExplorer.FindTreeNode(node, text); foreach (TreeNode node in treeViewZips.Nodes) TDCGExplorer.FindTreeNode(node, text); foreach (TreeNode node in treeViewInstalled.Nodes) TDCGExplorer.FindTreeNode(node, text); foreach (TreeNode node in treeViewCollision.Nodes) TDCGExplorer.FindTreeNode(node, text); foreach (TreeNode node in treeViewTag.Nodes) TDCGExplorer.FindTreeNode(node, text); foreach (TreeNode node in treeViewSaveFile.Nodes) TDCGExplorer.FindTreeNode(node, text); Cursor.Current = Cursors.Default; } }
public void ExtractFile() { if (info.zipid != -1) { ArcsZipArcEntry zipEntry = TDCGExplorer.GetArcsDatabase().GetZip(info.zipid); string zipsource = Path.Combine(TDCGExplorer.GetSystemDatabase().zips_path, zipEntry.path); switch (Path.GetExtension(zipEntry.path.ToLower())) { case ".zip": using (IArchive arc = new ZipArchive()) { ExtractFile(arc, zipsource); } break; case ".rar": using (IArchive arc = new RarArchive()) { ExtractFile(arc, zipsource); } break; case ".lzh": using (IArchive arc = new LzhArchive()) { ExtractFile(arc, zipsource); } break; default: break; } } }
public void Dispose() { foreach (PNGPoseFigureData figure in figures) { figure.Dispose(); } TDCGExplorer.GcCopact(); }
// ファイルをドラッグドロップされた→TAHページを作成してTAH梱包の準備をする. private void MainForm_DragDrop(object sender, DragEventArgs e) { if (TDCGExplorer.BusyTest()) return; string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); if (files.Length == 0) return; TDCGExplorer.FileDrop(files); }
private void ShowVersionToolStripMenuItem_Click(object sender, EventArgs e) { string cr = "\n"; string appVersion = "TDCGExplorer Version " + TDCGExplorer.CONST_APPVERSION; string sysDbVersion = "System.db Version " + TDCGExplorer.SystemDB.appversion; string arcsDbVersion = "Arcs.db Version " + TDCGExplorer.ArcsDB["version"]; string directXVersion = "DirectX Version " + TDCGExplorer.GetDirectXVersion(); string copyright = TDCGExplorer.CONST_COPYRIGHT; MessageBox.Show(appVersion+cr+sysDbVersion+cr+arcsDbVersion+cr+directXVersion+cr+cr+copyright , "Version", MessageBoxButtons.OK); }
// TSOビューワをリセットする private void resetTSOViewerToolStripMenuItem_Click(object sender, EventArgs e) { if (viewer!=null) { viewer.ClearFigureList(); viewer.Render(); viewer.Dispose(); viewer = null; TDCGExplorer.ResetDefaultPose(); // ポーズをデフォルトに戻す. // TDCGExplorer.FigureLoad = false; } }
// ツリーを展開する. private void expandAllToolStripMenuItem1_Click(object sender, EventArgs e) { try { TreeNode node = (TreeNode)lastSelectTreeNode; node.ExpandAll(); } catch (Exception exception) { TDCGExplorer.SetToolTips("error:" + exception.Message); Debug.WriteLine(exception.Message); } }
public static void ArcsDumpDirEntries(string dir, ArcsDatabase db) { bool skipflag = false; string[] shortnames = dir.Split('\\'); foreach (string shortname in shortnames) { if (shortname[0] == '!') { skipflag = true; } } if (skipflag) { return; // !で始まるディレクトリはスキップ } string[] tah_files = Directory.GetFiles(dir, "*.TAH"); foreach (string file in tah_files) { // 既にdb上にエントリがあるか調べる. //string tahid = db.GetTahID(file.Substring(arcspath.Length + 1)); ArcsTahEntry tah = db.GetTah(file.Substring(arcspath.Length + 1)); if (tah != null) { // 日付が一致するか? DateTime datetime = File.GetLastWriteTime(file); if (tah.datetime.ToString() == datetime.ToString()) { // 該当するエントリの存在フラグを立てる. TDCGExplorer.SetToolTips("Update " + Path.GetFileName(file)); db.UpdateTahExistUp(tah.id); continue; } else { // dbから一旦削除する. db.DeleteTah(tah.id); } } TDCGExplorer.LastAccessFile = file; using (FileStream source = File.OpenRead(file)) { ArcsDumpTAHEntries(source, db, file); } } string[] entries = Directory.GetDirectories(dir); foreach (string entry in entries) { ArcsDumpDirEntries(entry, db); } }
public static void ArcsDumpDirEntriesMain(string dir, ArcsDatabase db) { arcspath = dir; if (Directory.Exists(dir) == true) { // 存在フラグを全て落とす. TDCGExplorer.SetToolTips("Setup database"); db.UpdateTahExistDown(); ArcsDumpDirEntries(dir, db); // 存在しないtahファイルは消去する. TDCGExplorer.SetToolTips("Deleting orphan records"); db.DeleteNoExistentTah(); } }
//ファイルシステムをスキャンしてZIP情報を集める. public static void ZipsDumpDirEntriesMain(string dir, ArcsDatabase db) { zipspath = dir; if (Directory.Exists(dir) == true) { zipcoderegexp = TDCGExplorer.SystemDB.zip_regexp; // 存在フラグを全て落とす. TDCGExplorer.SetToolTips("Setup database"); db.UpdateZipExistDown(); ZipsDumpDirEntries(dir, db); // 存在しないtahファイルは消去する. TDCGExplorer.SetToolTips("Deleting orphan records"); db.DeleteNoExistentZip(); } }
public override void DoDecrypt() { // TAHファイル内容に関するフォームを追加する. switch (Path.GetExtension(entry.shortname)) { case ".tah": TDCGExplorer.TAHDecrypt(new GenericZipsTahInfo(entry)); break; default: //MessageBox.Show("TAHファイル以外は展開できません.", "TAHDecrypt", MessageBoxButtons.OK); MessageBox.Show(TextResource.OnlyTAHFile, TextResource.Error, MessageBoxButtons.OK); break; } }
//rename public void Rename() { string directory = Path.GetDirectoryName(path); SimpleTextDialog dialog = new SimpleTextDialog(); dialog.Owner = TDCGExplorer.MainFormWindow; dialog.dialogtext = TextResource.Rename; //"ファイル名の変更"; dialog.labeltext = TextResource.Filename; //"ファイル名"; dialog.textfield = Path.GetFileName(path); if (dialog.ShowDialog() == DialogResult.OK) { File.Move(path, Path.Combine(directory, dialog.textfield)); TDCGExplorer.DeleteFileTree(path); TDCGExplorer.AddFileTree(Path.Combine(directory, dialog.textfield)); } }
// tagnames.zipをサーバからダウンロードする. public bool DownloadTagNamesZipFromServer() { bool status = false; try { string uri = TDCGExplorer.SystemDB.tagnames_server; string localfile = zipTagLocalName(); // サーバからダウンロードする. HttpUtil.DownloadFile(uri, localfile); status = true; } catch (Exception e) { TDCGExplorer.SetToolTips("Error DownloadTagNamesZipFromServer : " + e.Message); } return(status); }
private void toolStripMenuItemTouch_Click(object sender, EventArgs e) { if (TDCGExplorer.BusyTest() == true) return; try { int index = listBoxMainListBox.SelectedIndex; if (index >= 0) { LbSaveFileItem item = listBoxMainListBox.Items[index] as LbSaveFileItem; if (item != null) { item.Touch(); } } } catch (Exception) { } }
// アノテーションを編集. private void EditAnnotationToolStripMenuItem_Click(object sender, EventArgs e) { try { GenericZipTreeNode node = lastSelectTreeNode as GenericZipTreeNode; if (node != null) { node.DoEditAnnotation(); } else { MessageBox.Show(TextResource.ZipFileOnly,TextResource.Error, MessageBoxButtons.OK); } } catch (Exception exception) { TDCGExplorer.SetToolTips("error:" + exception.Message); Debug.WriteLine(exception.Message); } }
// 前提zipファイルを展開する. private void ExtractPreferZipToolStripMenuItem_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; try { GenericZipTreeNode node = lastSelectTreeNode as GenericZipTreeNode; if (node != null) { TDCGExplorer.InstallPreferZip(node); } else { MessageBox.Show(TextResource.ZipFileOnly, TextResource.Error, MessageBoxButtons.OK); } } catch (Exception exception) { TDCGExplorer.SetToolTips("error:" + exception.Message); Debug.WriteLine(exception.Message); } Cursor.Current = Cursors.Default; }
private void LookupMODRefToolStripMenuItem_Click(object sender, EventArgs e) { if (TDCGExplorer.BusyTest()) return; try { GenericZipTreeNode node = lastSelectTreeNode as GenericZipTreeNode; if (node != null) { AssignTagPageControl(new MODRefPage(node.Entry)); } else { MessageBox.Show(TextResource.ZipFileOnly, TextResource.Error, MessageBoxButtons.OK); } } catch (Exception exception) { TDCGExplorer.SetToolTips(TextResource.Error + ":" + exception.Message); Debug.WriteLine(exception.Message); } }
private void OpenAllTAHToolStripMenuItem_Click(object sender, EventArgs e) { try { GenericFilesTreeNode node = lastSelectTreeNode as GenericFilesTreeNode; if (node != null) { //node.DoEditAnnotation(); string startwith = node.FullPath.Substring(TDCGExplorer.SystemDB.arcs_path.Length+1); TDCGExplorer.TAHCompaction(startwith); } else { MessageBox.Show(TextResource.OnlyTAHDirectory, TextResource.Error, MessageBoxButtons.OK); } } catch (Exception exception) { TDCGExplorer.SetToolTips(TextResource.Error + ":" + exception.Message); Debug.WriteLine(exception.Message); } }
private void TahDecryptToolStripMenuItem_Click(object sender, EventArgs e) { if (TDCGExplorer.BusyTest()) return; try { int index = listBoxMainListBox.SelectedIndex; if (index >= 0) { LbGenItem item = listBoxMainListBox.Items[index] as LbGenItem; if (item != null) { item.DoTahEdit(); listBoxMainListBox.Focus(); } } } catch (Exception exception) { MessageBox.Show(TextResource.ExtractFailure + ":" + exception.Message, TextResource.ExtractFailureCaption, MessageBoxButtons.OK); } }
// データベースのツリー表示を構築する. public void DisplayDB() { try { ClearTreeBox(); TDCGExplorer.MakeArcsTreeView(treeViewArcs); TDCGExplorer.MakeZipsTreeView(treeViewZips); TDCGExplorer.MakeCollisionTreeView(treeViewCollision); TDCGExplorer.MakeInstalledArcsTreeView(treeViewInstalled); TDCGExplorer.MakeTagTreeView(treeViewTag); TDCGExplorer.MakeSavefileTreeView(treeViewSaveFile); // 初期表示に戻す tabControlTreeView.SelectTab(0); treeViewArcs.Focus(); treeViewArcs.SelectedNode = treeViewArcs.Nodes[0]; TreeView_AfterSelect(treeViewArcs, null); } catch (Exception) { } }