// ファイルから直接読み出す. public PoseFilePage(string path) { Cursor.Current = Cursors.WaitCursor; try { InitializeComponent(); Text = Path.GetFileName(path); filename = Path.GetFileName(path); TDCGExplorer.TDCGExplorer.LastAccessFile = path; using (FileStream fs = File.OpenRead(path)) { using (MemoryStream ms = new MemoryStream()) { ZipFileUtil.CopyStream(fs, ms); BindingStream(ms); ms.Close(); } fs.Close(); } TDCGExplorer.TDCGExplorer.SetToolTips(Text); } catch (System.InvalidCastException ex) { Debug.WriteLine(ex.Message); } Cursor.Current = Cursors.Default; }
// ファイルから直接読み出す. public SaveFilePage(string path) { Cursor.Current = Cursors.WaitCursor; try { InitializeComponent(); Text = Path.GetFileName(path); TDCGExplorer.TDCGExplorer.LastAccessFile = path; using (FileStream fs = File.OpenRead(path)) { using (MemoryStream ms = new MemoryStream()) { ZipFileUtil.CopyStream(fs, ms); BindingStream(ms); ms.Close(); } fs.Close(); } dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dataGridView.ReadOnly = true; dataGridView.MultiSelect = false; dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridView.AllowUserToAddRows = false; TDCGExplorer.TDCGExplorer.SetToolTips(Text + " : " + TextResource.SearchComplete); } catch (System.InvalidCastException ex) { Debug.WriteLine(ex.Message); } Cursor.Current = Cursors.Default; filename = Path.GetFileName(path); }
public override void BindingStream(MemoryStream ms) { // データの複製を作る. streamdata = new MemoryStream(); ZipFileUtil.CopyStream(ms, streamdata); ms.Seek(0, SeekOrigin.Begin); Bitmap savefilebitmap = new Bitmap(ms); posestream = new PNGPOSEStream(); ms.Seek(0, SeekOrigin.Begin); posedata = posestream.LoadStream(ms); #if false TDCGExplorer.TDCGExplorer.MainFormWindow.PictureBox.Image = savefilebitmap; TDCGExplorer.TDCGExplorer.MainFormWindow.PictureBox.Width = savefilebitmap.Width; TDCGExplorer.TDCGExplorer.MainFormWindow.PictureBox.Height = savefilebitmap.Height; #else TDCGExplorer.TDCGExplorer.MainFormWindow.SetBitmap(savefilebitmap); #endif #if false TDCG.Viewer viewer = TDCGExplorer.TDCGExplorer.MainFormWindow.Viewer; if (posedata.scene == false) { // キャラが無い時はデフォ子 if (TDCGExplorer.TDCGExplorer.FigureLoad == false) { viewer.AddFigureFromPNGFile("default.tdcgsav.png", false); TDCGExplorer.TDCGExplorer.FigureLoad = true; } using (MemoryStream tmo = new MemoryStream(posedata.figures[0].tmo.data)) { viewer.LoadTMOFile(tmo); } } else { // 全部ロードする. ms.Seek(0, SeekOrigin.Begin); viewer.AddFigureFromPNGStream(ms, false); TDCGExplorer.TDCGExplorer.FigureLoad = false; } List <float> camera = posedata.GetCamera(); Vector3 eye = new Vector3(camera[0], camera[1], camera[2]); Vector3 ypr = new Vector3(camera[5], camera[4], camera[6]); Matrix m = Matrix.RotationYawPitchRoll(ypr.Y, ypr.X, ypr.Z) * Matrix.Translation(eye.X, eye.Y, eye.Z); viewer.Camera.Reset(); viewer.Camera.Translation = new Vector3(-m.M41, -m.M42, m.M43); viewer.Camera.Angle = ypr; TDCGExplorer.TDCGExplorer.MainFormWindow.setNeedCameraReset(); #endif // データ階層ツリーを構築する. MakeTreeView(); }
private void assembleTsoData() { foreach (LoadTsoInfo tsoload in loadtsoinfo) { GenericTahInfo info = tsoload.info; ArcsTahFilesEntry file = tsoload.file; int id = tsoload.id; try { // tso名を取得する. string tsoname; using (GenericTAHStream tahstream = new GenericTAHStream(info, file)) { using (MemoryStream memorystream = new MemoryStream()) { ZipFileUtil.CopyStream(tahstream.stream, memorystream); tsoname = TDCGTbnUtil.GetTsoName(memorystream.ToArray()); } } GenericTahInfo tsoinfo = null; ArcsTahFilesEntry tso = null; if (info.zipid < 0) {// Arcsの場合 int pastVersion = -1; ArcsTahEntry tahinfo = null; List <ArcsTahFilesEntry> tsos = TDCGExplorer.TDCGExplorer.ArcsDB.GetTahFilesEntry(TAHUtil.CalcHash(tsoname)); foreach (ArcsTahFilesEntry subfile in tsos) { ArcsTahEntry subtah = TDCGExplorer.TDCGExplorer.ArcsDB.GetTah(subfile.tahid); if (subtah.version > pastVersion) { tso = subfile; tahinfo = subtah; pastVersion = subtah.version; } } tsoinfo = new GenericArcsTahInfo(tahinfo); } else {// zipの場合 int pastVersion = -1; ArcsZipTahEntry tahinfo = null; List <ArcsTahFilesEntry> tsos = TDCGExplorer.TDCGExplorer.ArcsDB.GetZipTahFilesEntries(TAHUtil.CalcHash(tsoname)); foreach (ArcsTahFilesEntry subfile in tsos) { ArcsZipTahEntry subtah = TDCGExplorer.TDCGExplorer.ArcsDB.GetZipTah(subfile.tahid); if (subtah.version > pastVersion) { tso = subfile; tahinfo = subtah; pastVersion = subtah.version; } } tsoinfo = new GenericZipsTahInfo(tahinfo); } if (tsoinfo != null && tso != null) { // TSOを読み込む using (GenericTAHStream tahstream = new GenericTAHStream(tsoinfo, tso)) { using (MemoryStream memorystream = new MemoryStream()) { ZipFileUtil.CopyStream(tahstream.stream, memorystream); PNGTsoData tsodata = new PNGTsoData(); tsodata.tsoID = (uint)id; tsodata.tsodata = memorystream.ToArray(); tsoDataList.Add(tsodata); } } } } catch (Exception) { } } }
public override void BindingStream(MemoryStream ms) { ms.Seek(0, SeekOrigin.Begin); savefilebitmap = new Bitmap(ms); ms.Seek(0, SeekOrigin.Begin); savefile = new TDCGSaveFileInfo((Stream)ms); // セーブデータのコピーを保持する savedata = new MemoryStream(); ZipFileUtil.CopyStream(ms, savedata); #if false TDCGExplorer.TDCGExplorer.MainFormWindow.PictureBox.Image = savefilebitmap; TDCGExplorer.TDCGExplorer.MainFormWindow.PictureBox.Width = savefilebitmap.Width; TDCGExplorer.TDCGExplorer.MainFormWindow.PictureBox.Height = savefilebitmap.Height; #else TDCGExplorer.TDCGExplorer.MainFormWindow.SetBitmap(savefilebitmap); #endif DataTable data = new DataTable(); data.Columns.Add(TextResource.Parts, Type.GetType("System.String")); data.Columns.Add(TextResource.Category, Type.GetType("System.String")); data.Columns.Add(TextResource.TAHFile, Type.GetType("System.String")); for (int i = 0; i < TDCGSaveFileStatic.PARTS_SIZE; ++i) { string[] partfile = { savefile.GetPartsName(i), savefile.GetPartsFileName(i), "" }; // TAHファイルを検索する string partsname = savefile.GetPartsFileName(i); if (partsname.StartsWith("items/") == true) { if (TDCGExplorer.TDCGExplorer.SystemDB.findziplevel == false) { string partname = FindFromArcsTahs(partsname, i); if (partname != "") { partfile[2] = "arcs : " + partname; } } if (partfile[2] == "") { string partname = FindFromZipTahs(partsname, i); if (partname != "") { partfile[2] = "zips : " + partname; } } if (TDCGExplorer.TDCGExplorer.SystemDB.findziplevel == true && partfile[2] == "") { string partname = FindFromArcsTahs(partsname, i); if (partname != "") { partfile[2] = "arcs : " + partname; } } } DataRow row = data.NewRow(); row.ItemArray = partfile; data.Rows.Add(row); } for (int i = 0; i < TDCGSaveFileStatic.SLIDER_SIZE; ++i) { string[] partfile = { savefile.GetSliderName(i), savefile.GetSliderValue(i), "" }; DataRow row = data.NewRow(); row.ItemArray = partfile; data.Rows.Add(row); } dataGridView.DataSource = data; }
// This function is invoked from Ux public static BizRulesValidationResult ValidateBizRules(string userName, string homeOrg, ZipArchive zipArchive, BizRuleCertMetadata bizRuleCertMetadata, IDalManager dalManager) { if (zipArchive == null) { throw new ArgumentNullException("zipArchive", "zipFile cannot be empty"); } if (bizRuleCertMetadata == null) { throw new ArgumentNullException("bizRuleCertMetadata", "bizRuleCertMetadata cannot be empty"); } if (dalManager == null) { throw new ArgumentNullException("dalManager", "dalManager cannot be null"); } #region DummyCode if (GCValidatorHelper.AddDummyDataForInstanceValidation) { List <BizRuleInfo> ruleInfo1 = new List <BizRuleInfo>(); ruleInfo1.Add(new BizRuleInfo() { FileName = "Delphi Corp - Spec Cert - 810 - Send.dat", SegmentPath = "BIG->BIG03", Value = "1/2/2014" }); ruleInfo1.Add(new BizRuleInfo() { FileName = "Delphi Corporation - Spec Cert - 4010 - 856 - receive - Comments.dat", SegmentPath = "PRF->PRF04", Value = "1/3/2014" }); ruleInfo1.Add(new BizRuleInfo() { FileName = "Delphi Corporation - Spec Cert - 4010 - 850 - send - Comments.dat", SegmentPath = "BEG->BEG05", Value = "1/2/2014" }); List <BizRuleInfo> ruleInfo2 = new List <BizRuleInfo>(); ruleInfo2.Add(new BizRuleInfo() { FileName = "Delphi Corp - Spec Cert - 810 - Send", SegmentPath = "BIG->BIG04", Value = "122014" }); ruleInfo2.Add(new BizRuleInfo() { FileName = "Delphi Corporation - Spec Cert - 4010 - 856 - receive - Comments.dat", SegmentPath = "PRF->PRF01", Value = "122014" }); ruleInfo2.Add(new BizRuleInfo() { FileName = "Delphi Corporation - Spec Cert - 4010 - 850 - send - Comments.dat", SegmentPath = "BEG->BEG03", Value = "122014" }); List <BizRuleInfo> ruleInfo3 = new List <BizRuleInfo>(); ruleInfo3.Add(new BizRuleInfo() { FileName = "Delphi Corp - Spec Cert - 810 - Send.dat", SegmentPath = "IT1->IT101", Value = "123" }); ruleInfo3.Add(new BizRuleInfo() { FileName = "Delphi Corporation - Spec Cert - 4010 - 856 - receive - Comments.dat", SegmentPath = "LIN->LIN01", Value = "234" }); ruleInfo3.Add(new BizRuleInfo() { FileName = "Delphi Corporation - Spec Cert - 4010 - 850 - send - Comments.dat", SegmentPath = "PO1->PO1O1", Value = "345" }); BizRulesValidationResult bizRulesValidationResultDummy = new BizRulesValidationResult() { BizRuleCertName = "3M - Biz Rule - X12 810-856-850" }; bizRulesValidationResultDummy.BizRuleValidationResults = new List <BizRuleValidationResult>(); bizRulesValidationResultDummy.BizRuleValidationResults.Add(new BizRuleValidationResult() { RuleName = "Purchase Order Date", Type = ResultType.Error, RuleInfo = ruleInfo1 }); bizRulesValidationResultDummy.BizRuleValidationResults.Add(new BizRuleValidationResult() { RuleName = "Purchase Order Number", Type = ResultType.Success, RuleInfo = ruleInfo2 }); bizRulesValidationResultDummy.BizRuleValidationResults.Add(new BizRuleValidationResult() { RuleName = "Assigned Identification", Type = ResultType.Warning, RuleInfo = ruleInfo3 }); bizRulesValidationResultDummy.EdiValidationResults = new List <EDIValidationResult>(); List <SegmentValidationResult> segmentValidationResult = new List <SegmentValidationResult>(); segmentValidationResult.Add(new SegmentValidationResult() { Description = "Invalid Segment XYZ", Name = "XYZ", SequenceNumber = 5, Type = ResultType.Error, StartIndex = 300, EndIndex = 305, }); bizRulesValidationResultDummy.EdiValidationResults.Add(new EDIValidationResult() { BeautifiedOriginalPayload = "EDI File Contents", FileName = "Delphi Corp - Spec Cert - 810 - Send.dat", SchemaName = "Delphi Corp - Spec Cert - 810 - Send", SegmentValidationResults = new List <SegmentValidationResult>(), // No validation failures TransactionNumbers = new List <string> { "1" }, DisplayName = "Delphi Corp - 810 - Send", Type = "X12_810" }); bizRulesValidationResultDummy.EdiValidationResults.Add(new EDIValidationResult() { BeautifiedOriginalPayload = "EDI File Contents", FileName = "Delphi Corporation - Spec Cert - 4010 - 850 - send - Comments.dat", SchemaName = "Delphi Corporation - Spec Cert - 4010 - 850 - send", SegmentValidationResults = segmentValidationResult, TransactionNumbers = new List <string> { "1" }, DisplayName = "Delphi Corporation - 850 - send", Type = "X12_850" }); bizRulesValidationResultDummy.EdiValidationResults.Add(new EDIValidationResult() { BeautifiedOriginalPayload = "EDI File Contents", FileName = "Delphi Corporation - Spec Cert - 4010 - 856 - receive - Comments.dat", SchemaName = "Delphi Corporation - Spec Cert - 4010 - 856 - receive", SegmentValidationResults = new List <SegmentValidationResult>(), // No validation failures TransactionNumbers = new List <string> { "1" }, DisplayName = "Delphi Corporation - 856 - receive", Type = "X12_856" }); return(bizRulesValidationResultDummy); } #endregion BizRulesValidationResult bizRulesValidationResult = null; string errorMessage = null; try { BizRuleSet bizRuleSet = SchemaCache.GetBizRuleSet(bizRuleCertMetadata, dalManager); List <ZipFileEntry> fileEntries = ZipFileUtil.GetFileEntries(zipArchive); List <DocumentPlugValidationInfo> documentPlugValidationInfoList = new List <DocumentPlugValidationInfo>(); foreach (ZipFileEntry fileEntry in fileEntries) { documentPlugValidationInfoList.Add(GetDocumentPlugValidationInfo(fileEntry, dalManager)); } bizRulesValidationResult = ValidateBizRules(userName, homeOrg, bizRuleCertMetadata.RuleCertFileName, bizRuleSet, documentPlugValidationInfoList, dalManager); } catch (GCEdiValidatorException gcException) { errorMessage = gcException.Message; } catch (Exception) { errorMessage = "Internal error occurred, please contact Maarg"; } if (errorMessage != null) { // TODO: Add generic error } return(bizRulesValidationResult); }