示例#1
0
        void OnItemDoubleClicked(DataTableRow row)
        {
            if (row == null)
            {
                return;
            }

            var file     = _pf.FindFile(row.FileName);
            var nameSize = row.TagName.Length + 2;

            using (var stream = new MemoryStream((file as PackFile).DataSource.ReadData()))
            {
                var editor = new WpfHexaEditor.HexEditor
                {
                    Stream       = stream,
                    ReadOnlyMode = true,

                    ByteGrouping               = WpfHexaEditor.Core.ByteSpacerGroup.FourByte,
                    ByteSpacerPositioning      = WpfHexaEditor.Core.ByteSpacerPosition.HexBytePanel,
                    ByteSpacerVisualStyle      = WpfHexaEditor.Core.ByteSpacerVisual.Dash,
                    ByteSpacerWidthTickness    = WpfHexaEditor.Core.ByteSpacerWidth.Normal,
                    DataStringVisual           = WpfHexaEditor.Core.DataVisualType.Decimal,
                    OffSetStringVisual         = WpfHexaEditor.Core.DataVisualType.Decimal,
                    CustomBackgroundBlockItems = new List <WpfHexaEditor.Core.CustomBackgroundBlock>()
                    {
                        new WpfHexaEditor.Core.CustomBackgroundBlock()
                        {
                            Color       = new SolidColorBrush(Colors.LightGreen),
                            StartOffset = row.DataItem.Start,
                            Length      = row.DataItem.Size
                        },
                        new WpfHexaEditor.Core.CustomBackgroundBlock()
                        {
                            Color       = new SolidColorBrush(Colors.LightBlue),
                            StartOffset = row.DataItem.Start - nameSize,
                            Length      = nameSize
                        }
                    }
                };

                var form = new Window
                {
                    Title   = _pf.GetFullPath(file as PackFile),
                    Content = editor
                };
                form.ShowDialog();
            }
        }
示例#2
0
        public void ConfigureAsDecoder()
        {
            using (new WaitCursor())
            {
                var allMetaFiles = _pf.FindAllWithExtention(".meta");
                //allMetaFiles = allMetaFiles.Where(f => f.Name.Contains("anm.meta")).ToList();
                List <MetaDataFile> allMetaData = new List <MetaDataFile>();


                MetaDataFile master = new MetaDataFile()
                {
                    FileName = "Master collection"
                };

                var errorList = new List <Tuple <string, string> >();

                foreach (var file in allMetaFiles)
                {
                    try
                    {
                        var res = MetaDataFileParser.ParseFile(file, _pf);
                        allMetaData.Add(res);

                        foreach (var resultDataItem in res.TagItems)
                        {
                            var masterDataItem = master.TagItems.FirstOrDefault(x => x.Name == resultDataItem.Name && x.Version == resultDataItem.Version);
                            if (masterDataItem == null)
                            {
                                master.TagItems.Add(new MetaDataTagItem()
                                {
                                    Name = resultDataItem.Name, Version = resultDataItem.Version
                                });
                                masterDataItem = master.TagItems.Last();
                            }

                            foreach (var tag in resultDataItem.DataItems)
                            {
                                masterDataItem.DataItems.Add(tag);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        errorList.Add(new Tuple <string, string>(_pf.GetFullPath(file), e.Message));
                    }
                }

                var outputFolder = @"C:\temp\MetaDataDecoded\";

                foreach (var propSetType in master.TagItems)
                {
                    var           filename      = $"{propSetType.DisplayName}_{propSetType.DataItems.Count}.csv";
                    StringBuilder stringBuilder = new StringBuilder();

                    var tableDef = _schemaManager.GetMetaDataDefinition(propSetType.Name, propSetType.Version);
                    if (tableDef != null)
                    {
                        var headers = new List <string>()
                        {
                            "FileName", "Error"
                        };

                        for (int outputRowIndex = 0; outputRowIndex < tableDef.ColumnDefinitions.Count; outputRowIndex++)
                        {
                            headers.Add(tableDef.ColumnDefinitions[outputRowIndex].Name + " - " + tableDef.ColumnDefinitions[outputRowIndex].Type.ToString());
                        }
                        WriteRow(stringBuilder, headers);

                        for (int i = 0; i < propSetType.DataItems.Count(); i++)
                        {
                            var outputRow = new List <string>();
                            for (int outputRowIndex = 0; outputRowIndex < tableDef.ColumnDefinitions.Count + 2; outputRowIndex++)
                            {
                                outputRow.Add("");
                            }

                            var dataRow = new DataTableRow(propSetType.DisplayName, i, tableDef.ColumnDefinitions, propSetType.DataItems[i]);
                            outputRow[0] = propSetType.DataItems[i].ParentFileName;
                            outputRow[1] = dataRow.GetError();
                            if (string.IsNullOrEmpty(outputRow[1]))
                            {
                                for (int valueIndex = 0; valueIndex < dataRow.Values.Count; valueIndex++)
                                {
                                    outputRow[valueIndex + 2] = dataRow.Values[valueIndex].Value;
                                }
                            }
                            WriteRow(stringBuilder, outputRow);
                        }
                    }
                    else
                    {
                        var headers = new List <string>()
                        {
                            "FileName", "Size"
                        };
                        WriteRow(stringBuilder, headers);
                        for (int i = 0; i < propSetType.DataItems.Count(); i++)
                        {
                            var outputRow = new List <string>()
                            {
                                propSetType.DataItems[i].ParentFileName, propSetType.DataItems[i].Size.ToString()
                            };
                            WriteRow(stringBuilder, outputRow);
                        }
                    }

                    DirectoryHelper.EnsureCreated(outputFolder);
                    File.WriteAllText(outputFolder + filename, stringBuilder.ToString());
                }


                master.TagItems             = master.TagItems.OrderBy(x => x.DisplayName).ToList();
                ActiveMentaDataContent.File = master;
            }
        }
示例#3
0
 public ItemWrapper(DataTableRow parent, string value, string error)
 {
     _parent = parent;
     _value  = value;
     Error   = error;
 }