Example #1
0
        List <Beer> ConvertToBeer(List <CsvModel> CsvModelList)
        {
            List <Beer> _beerList = new List <Beer>();

            for (int i = 0; i < CsvModelList.Count; i++)
            {
                CsvModel csvModel = CsvModelList[i];
                if (csvModel.Quantity > 0)
                {
                    Brewery     brewery = new Brewery();
                    Models.Type type    = new Models.Type();
                    brewery.BreweryName = csvModel.Provider;
                    type.TypeName       = csvModel.Group;
                    type.FoodParing     = csvModel.Provider;//docelowo foodparing

                    Beer beer = new Beer(csvModel.Name, brewery, csvModel.NetPrice, csvModel.PurchasePrice, type, csvModel.UnitWeight, csvModel.Description);
                    beer.BrewerName = brewery.BreweryName;
                    beer.TypeName   = type.TypeName;

                    UpdateDataBases(ref brewery, ref type);
                    beer.BreweryID  = brewery.BreweryID;
                    beer.TypeID     = type.TypeID;
                    beer.PriceListA = CountGrossPrice(csvModel.NetPrice);
                    beer.Quantity   = csvModel.Quantity;
                    beer.EanCode    = csvModel.Code;
                    //beer.PhotoPath = csvModel.FilePickturePath;
                    beer.PhotoPath = ConvertPath(csvModel.FilePickturePath);
                    beer.Plato     = csvModel.PackageWeight;

                    _beerList.Add(beer);
                    KatalogPiw.App.Database.SaveBeer(beer);
                }
            }
            return(_beerList);
        }
Example #2
0
        private List <CsvModel> ConverteCsvParaListaDeCsvModel(TextReader csv)
        {
            var csvRowList = new List <CsvModel>();

            var parser = new CsvParser(csv);

            while (true)
            {
                var row = parser.Read();
                if (row == null)
                {
                    break;
                }

                var splitRow = row[0].Split(';');

                var linha = new CsvModel()
                {
                    NomeCampanha = splitRow[0],
                    Ping         = splitRow[1]
                };

                csvRowList.Add(linha);
            }

            return(csvRowList);
        }
Example #3
0
        private List <CsvModel> TratarNomeDaCampanha(List <CsvModel> csvRowList)
        {
            var listaCsvNomeTratado = new List <CsvModel>();

            foreach (var item in csvRowList)
            {
                var csv = new CsvModel();

                if (item.NomeCampanha.Contains("CAMPAIGN"))
                {
                    continue;
                }

                item.NomeCampanha = item.NomeCampanha.Split('_')[1];

                if (item.NomeCampanha.Contains("Retry"))
                {
                    csv.NomeCampanha = item.NomeCampanha.Remove(item.NomeCampanha.Length - 6);
                }
                else
                {
                    csv.NomeCampanha = item.NomeCampanha;
                }

                csv.Ping = item.Ping;

                listaCsvNomeTratado.Add(csv);
            }

            return(listaCsvNomeTratado);
        }
        /// <summary>
        /// Factory function for filtering a <see cref="CsvModel"/>.
        /// </summary>
        /// <param name="data">The data to be filtered</param>
        /// <param name="filterCollection">The filter collection to be applied</param>
        /// <param name="method">The filter method</param>
        /// <returns>The filtered data</returns>
        public static CsvModel filter(
            CsvModel data,
            Filter.FilterCollection filterCollection,
            Filter.FilterMethod method
            )
        {
            CsvModel model = new CsvModel(data.SupportedValues);

            // set limits of the activitylevel calculator of the new model
            model.ActivityLevelCalculator.MinVeryheavy = data.ActivityLevelCalculator.MinVeryheavy;
            model.ActivityLevelCalculator.MinHeavy = data.ActivityLevelCalculator.MinHeavy;
            model.ActivityLevelCalculator.MinModerate = data.ActivityLevelCalculator.MinModerate;
            model.ActivityLevelCalculator.MinLight = data.ActivityLevelCalculator.MinLight;
            model.ActivityLevelCalculator.MinSedantary = data.ActivityLevelCalculator.MinSedantary;

            // set filename and supported values
            model.AbsoluteFileName = data.AbsoluteFileName;
            model.SupportedValues = data.SupportedValues;

            // do the filtering
            //filterCollection.filter(data, model, method);

            // finish model
            model.finishParsing();

            return model;
        }
Example #5
0
 private void saveButton_Click(object sender, EventArgs e)
 {
     // Open file stream to PeopleModel.fileName
     // Will overwrite current file
     // For every loan in list loan, write info to line
     // Close file
     CsvModel.SaveToCsv(profile);
 }
Example #6
0
        public static PredictResult Convert(this CsvModel model)
        {
            var entity = new PredictResult();

            entity.WinTeam   = model.win;
            entity.LoseTeam  = model.lose;
            entity.Probility = Double.Parse(model.probability);
            return(entity);
        }
Example #7
0
        public IActionResult Index()
        {
            var model = new CsvModel {
                FilesFoundMessage = _csvLoader.FindFilesMessage()
            };

            if (_directoryFinder.Exists(_inputFilesPath))
            {
                model.Files = _csvLoader.GetFiles();
            }

            return(View(model));
        }
Example #8
0
        private static IList <CsvModel> Parse(string path)
        {
            char[]          splitChar = new[] { ',', '"', '“', '”', '\n', '\r', '\t' };
            List <CsvModel> csvModels = new List <CsvModel>();

            try
            {
                string[] lines = File.ReadAllLines(path, Encoding.Default);

                foreach (string line in lines)
                {
                    string[]      items     = line.Split(splitChar);
                    List <string> lineItems = new List <string>(items);
                    int           i         = 1;
                    string        amount    = lineItems[i];


                    lineItems.RemoveAll(string.IsNullOrWhiteSpace);

                    if (lineItems.Count > 5)
                    {
                        amount = string.Empty;
                        int amountLength = lineItems.Count - 5;

                        for (; i <= amountLength + 1; i++)
                        {
                            amount += lineItems[i];
                        }
                    }
                    else
                    {
                        i++;
                    }

                    var csvModel = new CsvModel
                    {
                        TransactionIdentificator = lineItems[0].Trim(),
                        Amount          = amount.Trim(),
                        CurrencyCode    = lineItems[i++].Trim(),
                        TransactionDate = lineItems[i++].Trim(),
                        Status          = lineItems[i].Trim()
                    };
                    csvModels.Add(csvModel);
                }
            }
            catch (Exception e)
            {
                Log.Information(LogMessageConstants.CsvParseError + e.Message + e.InnerException);
            }
            return(csvModels);
        }
Example #9
0
        public static string IsValid(this CsvModel csvModel, int index, string uploadedFileName)
        {
            List <string> invalidItems = new List <string>();

            if (string.IsNullOrWhiteSpace(csvModel.TransactionIdentificator))
            {
                invalidItems.Add(CommonConstants.TransactionId);
            }

            if (string.IsNullOrWhiteSpace(csvModel.Status))
            {
                invalidItems.Add(CommonConstants.Status);
            }

            if (string.IsNullOrWhiteSpace(csvModel.Amount) ||
                !decimal.TryParse(csvModel.Amount, out var amount))
            {
                invalidItems.Add(CommonConstants.Amount);
            }

            if (string.IsNullOrWhiteSpace(csvModel.CurrencyCode))
            {
                invalidItems.Add(CommonConstants.CurrencyCode);
            }

            if (!string.IsNullOrWhiteSpace(csvModel.TransactionDate))
            {
                try
                {
                    var dt = DateTime.ParseExact(csvModel.TransactionDate, CommonConstants.DateTimeFormatForCsv, CultureInfo.InvariantCulture);
                }
                catch (Exception)
                {
                    invalidItems.Add(CommonConstants.TransactionDate);
                }
            }
            else if (string.IsNullOrWhiteSpace(csvModel.TransactionDate))
            {
                invalidItems.Add(CommonConstants.TransactionDate);
            }

            if (!invalidItems.Any())
            {
                return(string.Empty);
            }

            var msg = $"In File: {uploadedFileName}, Transaction #{index}, {CommonConstants.InvalidItems}" + string.Join(", ", invalidItems);

            return(msg);
        }
Example #10
0
        private List <CsvModel> LinesToData(List <string> lines)
        {
            lines = GetRecords(lines);
            List <CsvModel> ModelsList = new List <CsvModel>();

            for (int i = 0; i < lines.Count; i++)
            {
                string[] tabToAddModel = new string[13];
                GenerateTab(lines[i], ref tabToAddModel);
                CsvModel cSVModel = new CsvModel(tabToAddModel);
                ModelsList.Add(cSVModel);
            }
            return(ModelsList);
        }
Example #11
0
        public static Transactions ToTransaction(this CsvModel csvModel)
        {
            var transactionHistory = new Transactions {
                TransactionId = csvModel.TransactionIdentificator
            };
            var dateTime = DateTime.ParseExact(csvModel.TransactionDate, CommonConstant.DateTimeFormatForCsv, CultureInfo.InvariantCulture);

            transactionHistory.TransactionDate = dateTime;
            decimal.TryParse(csvModel.Amount, out var amount);
            transactionHistory.Amount       = amount;
            transactionHistory.CurrencyCode = csvModel.CurrencyCode;
            transactionHistory.Status       = csvModel.Status;
            return(transactionHistory);
        }
Example #12
0
        public CsvModel buildModel(List <string> splitted)
        {
            CsvModel csvmodel = new CsvModel
            {
                Symbol = splitted[7],
                Date   = Convert.ToDateTime(splitted[8]),
                Time   = splitted[9],
                Open   = splitted[10],
                High   = splitted[11],
                Low    = splitted[12],
                Close  = splitted[13],
                Volume = splitted[14]
            };

            return(csvmodel);
        }
        private void AddNewCardFromCsv(IList newCsvItems)
        {
            if (newCsvItems != null)
            {
                CsvModel csvClient        = (CsvModel)(newCsvItems[0]);
                XmlModel matchedXmlClient = _xmlModels.FirstOrDefault(el => el.ClientId == csvClient.ClientId);

                if (matchedXmlClient.ClientId != null && _cardModels.All(el => el.ClientId != csvClient.ClientId))
                {
                    Card card = new Card(matchedXmlClient.ClientId, matchedXmlClient.Pan, csvClient.FName, csvClient.LName,
                                         csvClient.Telephone,
                                         matchedXmlClient.Date);
                    _cardModels.Add(card);
                }
            }
        }
        private void AddCardFromNewXml(IList xmlItems)
        {
            if (xmlItems != null)
            {
                XmlModel newXmlClient     = (XmlModel)(xmlItems[0]);
                CsvModel matchedCsvClient = _csvModels.FirstOrDefault(el => el.ClientId == newXmlClient.ClientId);

                bool alreadyExists = _cardModels.All(el => el.ClientId == newXmlClient.ClientId);
                if (matchedCsvClient.ClientId != null && !alreadyExists)
                {
                    Card card = new Card(newXmlClient.ClientId, newXmlClient.Pan, matchedCsvClient.FName
                                         , matchedCsvClient.LName, matchedCsvClient.Telephone, newXmlClient.Date);

                    _cardModels.Add(card);
                }
            }
        }
Example #15
0
        public List <CsvModel> GenerateVendorsAndProductsCSV(int QtyVendors, int QtyProductsForOneVendor, bool MatchingProducts = true)
        {
            if (MatchingProducts)
            {
                string          vendorName;
                List <CsvModel> VendorsAndProducts = new List <CsvModel>();
                for (int v = QtyVendors; v != 0; v--)
                {
                    vendorName = "Vendor" + v;

                    for (int p = QtyProductsForOneVendor; p != 0; p--)
                    {
                        CsvModel product = new CsvModel
                        {
                            VendorName  = vendorName,
                            ProductName = "V." + v + "_" + "Product" + p,
                            Price       = p
                        };
                        VendorsAndProducts.Add(product);
                    }
                }
                return(VendorsAndProducts);
            }
            else
            {
                string          vendorName;
                List <CsvModel> VendorsAndProducts = new List <CsvModel>();
                for (int v = QtyVendors; v != 0; v--)
                {
                    vendorName = "FakeVendor" + v;

                    for (int p = QtyProductsForOneVendor; p != 0; p--)
                    {
                        CsvModel product = new CsvModel
                        {
                            VendorName  = vendorName,
                            ProductName = "V." + v + "_" + "FakeProduct" + p,
                            Price       = p
                        };
                        VendorsAndProducts.Add(product);
                    }
                }
                return(VendorsAndProducts);
            }
        }
Example #16
0
        public static Transaction ToTransaction(this CsvModel csvModel)
        {
            Transaction transactionDto = new Transaction {
                TransactionId = csvModel.TransactionIdentificator
            };

            DateTime dateTime = DateTime.ParseExact(csvModel.TransactionDate, CommonConstants.DateTimeFormatForCsv, CultureInfo.InvariantCulture);

            transactionDto.TransactionDate = dateTime;

            decimal.TryParse(csvModel.Amount, out var amount);
            transactionDto.Amount = amount;

            transactionDto.CurrencyCode = csvModel.CurrencyCode;
            transactionDto.Status       = csvModel.Status;

            return(transactionDto);
        }
Example #17
0
        private void createButton_Click(object sender, EventArgs e)
        {
            string associatedFile = string.Format("{0}.csv", System.IO.Path.GetRandomFileName().Substring(0, 8));

            associatedFile = string.Concat("loans\\" + associatedFile);


            if (ValidateName())
            {
                if (CsvModel.AddNewProfileToIndex(
                        ConfigurationManager.AppSettings["filePath"],
                        nameValue.Text, associatedFile))
                {
                    CloseWindow();
                }
                // create empty file
            }
        }
Example #18
0
        public List <CsvModel> FromCsvToCSVModel(string[] CsvStrings)
        {
            List <CsvModel> Items = new List <CsvModel>();

            foreach (string item in CsvStrings)
            {
                string[] values = item.Split(',');

                CsvModel @object = new CsvModel
                {
                    VendorName  = values[0].Trim(new char[] { '"', '\\' }),
                    ProductName = values[1].Trim(new char[] { '"', '\\' }),
                    Price       = Convert.ToDouble(values[2])
                };
                Items.Add(@object);
            }
            return(Items);
        }
Example #19
0
        private void InitTestModel()
        {
            Model = new CsvModel();
            List <ItemMasterModel> Models;

            using (var entities = new ApplicationDbContext())
            {
                Models = entities.ItemMasters.Select(X => X).ToList();

                foreach (var model in Models)
                {
                    var cell = new Cell(Model.ColumnNames);
                    cell.SetCellInfo(Model.ColumnNames[0], model.PartNumber);
                    cell.SetCellInfo(Model.ColumnNames[1], model.Specification);
                    cell.SetCellInfo(Model.ColumnNames[2], model.Description);
                    cell.SetCellInfo(Model.ColumnNames[3], model.CreatedDate.ToString());
                    Model.AddCell(cell);
                }
            }
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="model">The model used for calculations</param>
        public ActivityLevelsCalculator(CsvModel model)
        {
            this.model = model;
            this.activityValueSupported = this.model.SupportedValues.Contains(SensorData.Activity);
            this.vmuValueSupported = this.model.SupportedValues.Contains(SensorData.Vmu);

            // set array of activity levels depending of the enum
            this.activityLevels = new ActivityLevel[Enum.GetNames(typeof(ActivityLevels)).Length];

            // set structures and set them to zero.
            int position = 0;
            foreach (ActivityLevels level in Enum.GetValues(typeof(ActivityLevels)))
            {
                ActivityLevel l = new ActivityLevel();
                l.Level = level;
                l.Count = 0;
                l.Percent = 0.0;

                this.activityLevels[position] = l;
                position++;
            }
        }
Example #21
0
        /// <summary>
        /// Imports list of names from index.csv to be used to select profile to load.
        /// Data is saved in nested List in order to expot profile id, name, and filePath
        /// </summary>
        private void importDataButton_Click(object sender, EventArgs e)
        {
            loadProfileSelector.Items.Clear();
            data = null;
            data = CsvModel.ImportProfileList(ConfigurationManager.AppSettings["filePath"]);

            if (data != null)
            {
                foreach (var line in data)
                {
                    string profileName = line[1];

                    loadProfileSelector.Items.Add(profileName);
                }

                try { loadProfileSelector.SelectedIndex = loadProfileSelector.Items.Count - 1; }
                catch { }
            }

            else
            {
                loadProfileSelector.SelectedItem = "";
            }
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="model">The model</param>
 public ActiveTimeCalculator(CsvModel model)
 {
     this.model = model;
 }
Example #23
0
        //Function addes shapes, vertices and meshes
        public void AddOjects(string FileName, ResFile resFileNX, ResU.ResFile resFileU, bool Replace = true)
        {
            int totalSkinCountLimiter = 0;

            bool IsWiiU = (resFileU != null);

            if (shapes.Count > 0)
            {
                totalSkinCountLimiter = shapes[0].VertexSkinCount;
            }

            int    MatStartIndex = materials.Count;
            string ext           = System.IO.Path.GetExtension(FileName);

            ext = ext.ToLower();

            switch (ext)
            {
            case ".bfobj":
                Cursor.Current = Cursors.WaitCursor;

                if (Replace)
                {
                    shapes.Clear();
                    Nodes["FshpFolder"].Nodes.Clear();
                }
                if (IsWiiU)
                {
                    var shpS          = new ResU.Shape();
                    var vertexBufferU = new ResU.VertexBuffer();
                    shpS.Import(FileName, vertexBufferU, resFileU);

                    FSHP shapeS = new FSHP();
                    shapeS.ShapeU = shpS;
                    BfresWiiU.ReadShapesVertices(shapeS, shpS, vertexBufferU, this);
                    shapes.Add(shapeS);
                    Nodes["FshpFolder"].Nodes.Add(shapeS);
                }
                else
                {
                    Shape        shpS         = new Shape();
                    VertexBuffer vertexBuffer = new VertexBuffer();
                    shpS.Import(FileName, vertexBuffer);

                    FSHP shapeS = new FSHP();
                    shapeS.Shape = shpS;
                    BfresSwitch.ReadShapesVertices(shapeS, shpS, vertexBuffer, this);
                    shapes.Add(shapeS);
                    Nodes["FshpFolder"].Nodes.Add(shapeS);
                }

                IsEdited = true;

                Cursor.Current = Cursors.Default;
                break;

            case ".bfmdl":
                Cursor.Current = Cursors.WaitCursor;

                if (Replace)
                {
                    shapes.Clear();
                    Nodes["FshpFolder"].Nodes.Clear();
                    materials.Clear();
                    Nodes["FmatFolder"].Nodes.Clear();
                }

                if (IsWiiU)
                {
                    var mdlU = new ResU.Model();
                    mdlU.Import(FileName, resFileU);
                    mdlU.Name = Text;
                    BfresWiiU.ReadModel(this, mdlU);
                }
                else
                {
                    Model mdl = new Model();
                    mdl.Import(FileName, resFileNX);
                    mdl.Name = Text;

                    Console.WriteLine(mdl.ShapeCount);
                    Console.WriteLine(mdl.MaterialCount);
                    Console.WriteLine(mdl.VertexBufferCount);
                    Console.WriteLine(mdl.Skeleton.Bones.Count);

                    BfresSwitch.ReadModel(this, mdl);
                }
                IsEdited = true;

                Cursor.Current = Cursors.Default;
                break;

            case ".csv":
                CsvModel csvModel = new CsvModel();
                csvModel.LoadFile(new System.IO.FileStream(FileName, System.IO.FileMode.Open), true);

                if (csvModel.objects.Count == 0)
                {
                    MessageBox.Show("No models found!");
                    return;
                }
                BfresModelImportSettings csvsettings = new BfresModelImportSettings();
                csvsettings.DisableMaterialEdits();
                csvsettings.SkinCountLimit = totalSkinCountLimiter;
                csvsettings.SetModelAttributes(csvModel.objects[0]);
                if (csvsettings.ShowDialog() == DialogResult.OK)
                {
                    if (Replace)
                    {
                        shapes.Clear();
                        Nodes["FshpFolder"].Nodes.Clear();
                    }

                    Cursor.Current = Cursors.WaitCursor;

                    foreach (STGenericObject obj in csvModel.objects)
                    {
                        FSHP shape = new FSHP();
                        Nodes["FshpFolder"].Nodes.Add(shape);
                        shapes.Add(shape);

                        shape.VertexBufferIndex = shapes.Count;
                        shape.vertices          = obj.vertices;
                        shape.MaterialIndex     = 0;
                        shape.vertexAttributes  = csvsettings.CreateNewAttributes();
                        shape.BoneIndex         = 0;
                        shape.Text      = obj.ObjectName;
                        shape.lodMeshes = obj.lodMeshes;
                        shape.CreateNewBoundingBoxes();
                        shape.CreateBoneList(obj, this);
                        shape.CreateIndexList(obj, this);
                        //Todo find better way. Currently uses import settings now
                        shape.ApplyImportSettings(csvsettings, GetMaterial(shape.MaterialIndex));
                        shape.VertexSkinCount = obj.GetMaxSkinInfluenceCount();
                        shape.BoneIndices     = shape.GetIndices(Skeleton);
                        shape.SaveShape(IsWiiU);
                        shape.SaveVertexBuffer();

                        if (IsWiiU)
                        {
                            shape.ShapeU.SubMeshBoundingIndices = new List <ushort>();
                            shape.ShapeU.SubMeshBoundingIndices.Add(0);
                            shape.ShapeU.SubMeshBoundingNodes = new List <ResU.BoundingNode>();
                            shape.ShapeU.SubMeshBoundingNodes.Add(new ResU.BoundingNode()
                            {
                                LeftChildIndex  = 0,
                                NextSibling     = 0,
                                SubMeshIndex    = 0,
                                RightChildIndex = 0,
                                Unknown         = 0,
                                SubMeshCount    = 1,
                            });
                        }

                        if (IsWiiU)
                        {
                            BfresWiiU.ReadShapesVertices(shape, shape.ShapeU, shape.VertexBufferU, this);
                        }
                        else
                        {
                            BfresSwitch.ReadShapesVertices(shape, shape.Shape, shape.VertexBuffer, this);
                        }
                    }
                    Cursor.Current = Cursors.Default;
                }
                IsEdited = true;

                break;

            default:
                AssimpData assimp = new AssimpData();
                assimp.LoadFile(FileName);

                if (assimp.objects.Count == 0)
                {
                    MessageBox.Show("No models found!");
                    return;
                }
                BfresModelImportSettings settings = new BfresModelImportSettings();
                settings.SetModelAttributes(assimp.objects[0]);
                if (settings.ShowDialog() == DialogResult.OK)
                {
                    bool UseMats = settings.ExternalMaterialPath != string.Empty;

                    if (Replace)
                    {
                        shapes.Clear();
                        Nodes["FshpFolder"].Nodes.Clear();
                    }

                    Cursor.Current = Cursors.WaitCursor;
                    if (Replace && UseMats)
                    {
                        materials.Clear();
                        Nodes["FmatFolder"].Nodes.Clear();
                        MatStartIndex = 0;
                    }
                    if (UseMats)
                    {
                        foreach (STGenericMaterial mat in assimp.materials)
                        {
                            FMAT fmat = new FMAT();

                            if (IsWiiU)
                            {
                                fmat.MaterialU = new ResU.Material();
                                fmat.MaterialU.Import(settings.ExternalMaterialPath, resFileU);
                                BfresWiiU.ReadMaterial(fmat, fmat.MaterialU);
                            }
                            else
                            {
                                fmat.Material = new Material();
                                fmat.Material.Import(settings.ExternalMaterialPath);
                                fmat.ReadMaterial(fmat.Material);
                            }

                            fmat.Text = mat.Text;
                            //Setup placeholder textures
                            //Note we can't add/remove samplers so we must fill these slots
                            foreach (var t in fmat.TextureMaps)
                            {
                                t.wrapModeS = 0;
                                t.wrapModeT = 0;

                                switch (t.Type)
                                {
                                case STGenericMatTexture.TextureType.Diffuse:
                                    t.Name = "Basic_Alb";
                                    break;

                                case STGenericMatTexture.TextureType.Emission:
                                    t.Name = "Basic_Emm";
                                    break;

                                case STGenericMatTexture.TextureType.Normal:
                                    t.Name = "Basic_Nrm";
                                    break;

                                case STGenericMatTexture.TextureType.Specular:
                                    t.Name = "Basic_Spm";
                                    break;

                                case STGenericMatTexture.TextureType.SphereMap:
                                    t.Name = "Basic_Sphere";
                                    break;

                                case STGenericMatTexture.TextureType.Metalness:
                                    t.Name = "Basic_Mtl";
                                    break;

                                case STGenericMatTexture.TextureType.Roughness:
                                    t.Name = "Basic_Rgh";
                                    break;

                                case STGenericMatTexture.TextureType.MRA:
                                    t.Name = "Basic_MRA";
                                    break;

                                case STGenericMatTexture.TextureType.Shadow:
                                    t.Name = "Basic_Bake_st0";
                                    break;

                                case STGenericMatTexture.TextureType.Light:
                                    t.Name = "Basic_Bake_st1";
                                    break;
                                }
                            }

                            if (PluginRuntime.bntxContainers.Count > 0 && Parent != null)
                            {
                                foreach (var node in Parent.Parent.Nodes)
                                {
                                    if (node is BNTX)
                                    {
                                        var bntx = (BNTX)node;

                                        bntx.ImportBasicTextures("Basic_Alb");
                                        bntx.ImportBasicTextures("Basic_Nrm");
                                        bntx.ImportBasicTextures("Basic_Spm");
                                        bntx.ImportBasicTextures("Basic_Sphere");
                                        bntx.ImportBasicTextures("Basic_Mtl");
                                        bntx.ImportBasicTextures("Basic_Rgh");
                                        bntx.ImportBasicTextures("Basic_MRA");
                                        bntx.ImportBasicTextures("Basic_Bake_st0");
                                        bntx.ImportBasicTextures("Basic_Bake_st1");
                                        bntx.ImportBasicTextures("Basic_Emm");
                                    }
                                }
                            }
                            if (PluginRuntime.ftexContainers.Count > 0 && Parent != null)
                            {
                                foreach (var node in Parent.Parent.Nodes)
                                {
                                    if (node is BFRESGroupNode)
                                    {
                                        if (((BFRESGroupNode)node).Type == BRESGroupType.Textures)
                                        {
                                            var ftexCont = (BFRESGroupNode)node;

                                            ftexCont.ImportBasicTextures("Basic_Alb");
                                            ftexCont.ImportBasicTextures("Basic_Nrm");
                                            ftexCont.ImportBasicTextures("Basic_Spm");
                                            ftexCont.ImportBasicTextures("Basic_Sphere");
                                            ftexCont.ImportBasicTextures("Basic_Mtl");
                                            ftexCont.ImportBasicTextures("Basic_Rgh");
                                            ftexCont.ImportBasicTextures("Basic_MRA");
                                            ftexCont.ImportBasicTextures("Basic_Bake_st0");
                                            ftexCont.ImportBasicTextures("Basic_Bake_st1");
                                            ftexCont.ImportBasicTextures("Basic_Emm");
                                        }
                                    }
                                }
                            }

                            foreach (var tex in mat.TextureMaps)
                            {
                                foreach (var t in fmat.TextureMaps)
                                {
                                    if (t.Type == tex.Type)
                                    {
                                        t.Name      = tex.Name;
                                        t.wrapModeS = tex.wrapModeS;
                                        t.wrapModeT = tex.wrapModeT;
                                        t.wrapModeW = tex.wrapModeW;
                                        t.Type      = tex.Type;
                                    }
                                }
                            }

                            List <string> keyList = new List <string>(materials.Keys);
                            fmat.Text = Utils.RenameDuplicateString(keyList, fmat.Text);

                            if (IsWiiU)
                            {
                                fmat.MaterialU.Name = Text;
                                fmat.SetMaterial(fmat.MaterialU, resFileU);
                            }
                            else
                            {
                                fmat.Material.Name = Text;
                                fmat.SetMaterial(fmat.Material);
                            }

                            materials.Add(fmat.Text, fmat);
                            Nodes["FmatFolder"].Nodes.Add(fmat);
                        }
                    }

                    if (settings.ImportBones)
                    {
                        if (assimp.skeleton.bones.Count > 0)
                        {
                            Skeleton.bones.Clear();
                            Skeleton.node.Nodes.Clear();

                            if (IsWiiU)
                            {
                                BfresWiiU.SaveSkeleton(Skeleton, assimp.skeleton.bones);
                            }
                            else
                            {
                                BfresSwitch.SaveSkeleton(Skeleton, assimp.skeleton.bones);
                            }
                        }
                    }

                    if (materials.Count <= 0)
                    {
                        //Force material creation if there is none present
                        FMAT fmat = new FMAT();
                        fmat.Text = "NewMaterial";
                        materials.Add(fmat.Text, fmat);
                        Nodes["FmatFolder"].Nodes.Add(fmat);

                        if (IsWiiU)
                        {
                            fmat.MaterialU      = new ResU.Material();
                            fmat.MaterialU.Name = "NewMaterial";
                            BfresWiiU.ReadMaterial(fmat, fmat.MaterialU);
                        }
                        else
                        {
                            fmat.Material      = new Material();
                            fmat.Material.Name = "NewMaterial";
                            fmat.ReadMaterial(fmat.Material);
                        }
                    }

                    foreach (STGenericObject obj in assimp.objects)
                    {
                        FSHP shape = new FSHP();
                        Nodes["FshpFolder"].Nodes.Add(shape);
                        shapes.Add(shape);

                        shape.VertexBufferIndex = shapes.Count;
                        shape.vertices          = obj.vertices;
                        shape.vertexAttributes  = settings.CreateNewAttributes();
                        shape.BoneIndex         = obj.BoneIndex;

                        STConsole.WriteLine(Text + " " + obj.MaterialIndex);

                        if (UseMats)
                        {
                            shape.MaterialIndex = obj.MaterialIndex + MatStartIndex;
                        }
                        else
                        {
                            shape.MaterialIndex = 0;
                        }

                        if (shape.MaterialIndex >= materials.Count)
                        {
                            shape.MaterialIndex = 0;
                        }

                        shape.Text      = obj.ObjectName;
                        shape.lodMeshes = obj.lodMeshes;
                        shape.CreateNewBoundingBoxes();
                        shape.CreateBoneList(obj, this);
                        shape.CreateIndexList(obj, this);
                        shape.ApplyImportSettings(settings, GetMaterial(shape.MaterialIndex));
                        shape.VertexSkinCount = obj.GetMaxSkinInfluenceCount();
                        shape.BoneIndices     = shape.GetIndices(Skeleton);

                        shape.SaveShape(IsWiiU);
                        shape.SaveVertexBuffer();

                        if (IsWiiU)
                        {
                            shape.ShapeU.SubMeshBoundingIndices = new List <ushort>();
                            shape.ShapeU.SubMeshBoundingIndices.Add(0);
                            shape.ShapeU.SubMeshBoundingNodes = new List <ResU.BoundingNode>();
                            shape.ShapeU.SubMeshBoundingNodes.Add(new ResU.BoundingNode()
                            {
                                LeftChildIndex  = 0,
                                NextSibling     = 0,
                                SubMeshIndex    = 0,
                                RightChildIndex = 0,
                                Unknown         = 0,
                                SubMeshCount    = 1,
                            });
                        }

                        List <string> keyList = shapes.Select(o => o.Text).ToList();
                        shape.Text = Utils.RenameDuplicateString(keyList, shape.Text);

                        if (IsWiiU)
                        {
                            BfresWiiU.ReadShapesVertices(shape, shape.ShapeU, shape.VertexBufferU, this);
                        }
                        else
                        {
                            BfresSwitch.ReadShapesVertices(shape, shape.Shape, shape.VertexBuffer, this);
                        }
                    }


                    IsEdited = true;

                    Cursor.Current = Cursors.Default;
                }
                break;
            }

            if (IsEdited)
            {
                UpdateVertexData();
            }
        }
Example #24
0
 private void InitializeLoans()
 {
     CsvModel.OpenFromCsv(profile);
     LoadLoans();
 }
Example #25
0
 public HomeController()
 {
     Model = new CsvModel();
 }
Example #26
0
        public async Task <ActionResult> Upload(HttpPostedFileBase upload)
        {
            if (ModelState.IsValid)
            {
                if (upload != null && upload.ContentLength > 0)
                {
                    if (upload.FileName.EndsWith(".csv"))
                    {
                        Stream    stream       = upload.InputStream;
                        DataTable csvDataTable = new DataTable();

                        var csvName = upload.FileName.Trim();

                        var userEmail = User.Identity.GetUserName();
                        if (userEmail != "")
                        {
                            var userEntity = await UserManager.FindByEmailAsync(userEmail);

                            List <string> userCSVs = new List <string>();

                            if (userEntity.CsvFileNames != null)
                            {
                                var csvString = userEntity.CsvFileNames.Trim();

                                userCSVs = csvString.Split(',').ToList();
                                if (!userCSVs.Contains(csvName))
                                {
                                    var newCsv = "," + csvName;
                                    csvString += newCsv;

                                    userEntity.CsvFileNames = csvString;
                                    UserManager.Update(userEntity);
                                }
                            }
                            else
                            {
                                // add the first CSV file name to user
                                userEntity.CsvFileNames = csvName;
                                UserManager.Update(userEntity);
                            }

                            // save CSV file
                            var path = Path.Combine(this.Request.PhysicalApplicationPath, csvName);
                            upload.SaveAs(path);
                        }


                        var csvDataModel = new CsvModel();    //CREATE MODEL
                        //var csvDataList = new List<string>();           // List for the model

                        using (CsvReader csvReader =
                                   new CsvReader(new StreamReader(stream), true))
                        {
                            csvDataTable.Load(csvReader);
                        }

                        // FOR SERVER SIDE SORTING etc

                        /*
                         * string[] csvColNames = csvDataTable.Columns.Cast<DataColumn>()
                         *   .Select(x => x.ColumnName.Trim())
                         *   .ToArray();
                         * csvDataModel.ColumnNames = csvColNames;
                         *
                         * int rowNo = 0;
                         * var columns = csvDataTable.Columns;
                         *
                         * foreach (var row in csvDataTable.Rows)
                         * {
                         *  var cell = new Cell(csvDataModel.ColumnNames);
                         *  int colNo = 0;
                         *  foreach (var colName in csvDataModel.ColumnNames)
                         *  {
                         *      var column = columns[colNo];
                         *      cell.SetCellInfo(colName, csvDataTable.Rows[rowNo][column].ToString());
                         *      colNo++;
                         *      //_model.SetProperty(colName, table.Rows[colNo][colName].ToString());
                         *  }
                         *  rowNo++;
                         *  csvDataModel.AddCell(cell);
                         * }
                         */

                        //var ddd = DataTableToDatabase(csvDataTable, csvDataModel, csvColNames);
                        //AddRowsToTable(ddd);

                        /*
                         * using (ApplicationDbContext entities = new ApplicationDbContext())
                         * {
                         *  entities.UserCSVDatabase.Add(csvDataModel);
                         *  entities.SaveChanges();
                         * }*/

                        /*
                         * Model.SetColumNames(csvDataModel.ColumnNames);
                         * Model.Data = csvDataModel.Data;
                         */

                        TempData["Model"] = csvDataTable;


                        return(RedirectToAction("Edit", new { csvName = csvName }));
                    }
                    else
                    {
                        ModelState.AddModelError("File", "This file format is not supported");
                        return(View());
                    }
                }
                else
                {
                    ModelState.AddModelError("File", "Please Upload Your file");
                }
            }
            return(View());
        }
Example #27
0
        public void Export(object sender, EventArgs args)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "Supported Formats|*.bfmdl;*.fbx;*.dae; *.obj;*.csv;|" +
                         "Bfres Model|*.bfmdl|" +
                         "FBX |*.fbx|" +
                         "DAE |*.dae|" +
                         "OBJ |*.obj|" +
                         "CSV |*.csv|" +
                         "All files(*.*)|*.*";
            sfd.DefaultExt = ".bfobj";
            sfd.FileName   = Text;

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                string ext = System.IO.Path.GetExtension(sfd.FileName);
                ext = ext.ToLower();

                switch (ext)
                {
                case ".bfmdl":
                    Model.Export(sfd.FileName, GetResFile());
                    break;

                case ".csv":
                    CsvModel csv = new CsvModel();
                    foreach (FSHP shape in shapes)
                    {
                        STGenericObject obj = new STGenericObject();
                        obj.ObjectName = shape.Text;
                        obj.vertices   = shape.vertices;
                        obj.faces      = shape.lodMeshes[shape.DisplayLODIndex].faces;
                        csv.objects.Add(obj);

                        int CurVtx = 0;
                        foreach (Vertex v in shape.vertices)
                        {
                            if (v.boneIds[0] != 0)
                            {
                                obj.vertices[CurVtx].boneNames.Add(shape.GetBoneNameFromIndex(this, v.boneIds[0]));
                            }
                            if (v.boneIds[1] != 0)
                            {
                                obj.vertices[CurVtx].boneNames.Add(shape.GetBoneNameFromIndex(this, v.boneIds[1]));
                            }
                            if (v.boneIds[2] != 0)
                            {
                                obj.vertices[CurVtx].boneNames.Add(shape.GetBoneNameFromIndex(this, v.boneIds[2]));
                            }
                            if (v.boneIds[3] != 0)
                            {
                                obj.vertices[CurVtx].boneNames.Add(shape.GetBoneNameFromIndex(this, v.boneIds[3]));
                            }

                            CurVtx++;
                        }
                    }
                    System.IO.File.WriteAllBytes(sfd.FileName, csv.Save());
                    break;

                default:
                    AssimpData assimp = new AssimpData();
                    assimp.SaveFromModel(this, sfd.FileName);
                    break;
                }
            }
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="model">The model for calculations</param>
 public DayStartEndCalculator(CsvModel model)
 {
     this.model = model;
     this.activityValueSupported = this.model.SupportedValues.Contains(SensorData.Activity);
     this.vmuValueSupported = this.model.SupportedValues.Contains(SensorData.Vmu);
 }
Example #29
0
        public void Export(object sender, EventArgs args)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "Supported Formats|*.bfmdl;*.fbx;*.dae; *.obj;*.csv;|" +
                         "Bfres Model|*.bfmdl|" +
                         "FBX |*.fbx|" +
                         "DAE |*.dae|" +
                         "OBJ |*.obj|" +
                         "CSV |*.csv|" +
                         "All files(*.*)|*.*";
            sfd.DefaultExt = ".bfobj";
            sfd.FileName   = Text;

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                string ext = System.IO.Path.GetExtension(sfd.FileName);
                ext = ext.ToLower();

                switch (ext)
                {
                case ".bfmdl":
                    if (GetResFileU() != null)
                    {
                    }
                    else
                    {
                        Model.Export(sfd.FileName, GetResFile());
                    }
                    break;

                case ".csv":
                    CsvModel csv = new CsvModel();
                    foreach (FSHP shape in shapes)
                    {
                        STGenericObject obj = new STGenericObject();
                        obj.ObjectName = shape.Text;
                        obj.vertices   = shape.vertices;
                        obj.faces      = shape.lodMeshes[shape.DisplayLODIndex].faces;
                        csv.objects.Add(obj);

                        int CurVtx = 0;
                        foreach (Vertex v in shape.vertices)
                        {
                            if (v.boneIds[0] != 0)
                            {
                                obj.vertices[CurVtx].boneNames.Add(shape.GetBoneNameFromIndex(this, v.boneIds[0]));
                            }
                            if (v.boneIds[1] != 0)
                            {
                                obj.vertices[CurVtx].boneNames.Add(shape.GetBoneNameFromIndex(this, v.boneIds[1]));
                            }
                            if (v.boneIds[2] != 0)
                            {
                                obj.vertices[CurVtx].boneNames.Add(shape.GetBoneNameFromIndex(this, v.boneIds[2]));
                            }
                            if (v.boneIds[3] != 0)
                            {
                                obj.vertices[CurVtx].boneNames.Add(shape.GetBoneNameFromIndex(this, v.boneIds[3]));
                            }

                            CurVtx++;
                        }
                    }
                    System.IO.File.WriteAllBytes(sfd.FileName, csv.Save());
                    break;

                default:
                    List <STGenericTexture> Surfaces = new List <STGenericTexture>();
                    foreach (FSHP fshp in shapes)
                    {
                        foreach (var bntx in PluginRuntime.bntxContainers)
                        {
                            foreach (var tex in fshp.GetMaterial().TextureMaps)
                            {
                                if (bntx.Textures.ContainsKey(tex.Name))
                                {
                                    Surfaces.Add(bntx.Textures[tex.Name]);
                                }
                            }
                        }
                        foreach (var ftex in PluginRuntime.ftexContainers)
                        {
                            foreach (var tex in fshp.GetMaterial().TextureMaps)
                            {
                                if (ftex.Textures.ContainsKey(tex.Name))
                                {
                                    Surfaces.Add(ftex.Textures[tex.Name]);
                                }
                            }
                        }
                    }
                    Console.WriteLine("tex count " + Surfaces.Count);

                    AssimpData assimp = new AssimpData();
                    assimp.SaveFromModel(this, sfd.FileName, Surfaces);
                    break;
                }
            }
        }
        /// <summary>
        /// Imports a csv-file into <see cref="CsvModel"/> with the given
        /// lower limits for the activitylevel calculator
        /// </summary>
        /// <param name="file">The absolute filepath to the file to import</param>
        /// <param name="minSedantary">Lower limit for sedantary activity</param>
        /// <param name="minLight">Lower limit for light activity</param>
        /// <param name="minModerate">Lower limit for moderate activity</param>
        /// <param name="minHeavy">Lower limit for heavy activity</param>
        /// <param name="minVeryheavy">Lower limit for very heavy activity</param>
        /// <returns>The imported CsvModel</returns>
        public static CsvModel parse(
            String file,
            int minSedantary,
            int minLight,
            int minModerate,
            int minHeavy,
            int minVeryheavy
            )
        {
            // all available line parsers, ascending priority
            AbstractLineParser[] lineParsers = {
               new SingleEntryLineParser(),
               new DateTimeActivityStepsLineParser(),
               new ActivityUnknownLineParser(),
               new DateTimeActivity3dVMUStepsInclLineParser(),
               new DateTimeActivity2dVMUStepsInclLineParser(),
               new Activity3dVMULineParser(),
               new Activity2dVMULineParser(),
               new NoDate3dActivityStepsLineParser(),
               new DateTime3dActivityStepsLineParser(),
               new DateTimeActivityLineParser(),
               new RExportedLineParser(),
               new RT3LineParser(),
               new RT3SemicolomSepLineParser()
            };

            // the active line parser
            AbstractLineParser activeLineParser = null;

            // prevent locking the file when an exception occures
            using (StreamReader reader = new StreamReader(file))
            {
                String line;

                // we need a buffer to parse the line that is overwritten after testing
                String bufferline = "";

                // as long as we have lines to read but haven't found a valid format
                while ((line = reader.ReadLine()) != null && activeLineParser == null)
                {
                    // iterate over all available line parsers
                    foreach (AbstractLineParser parser in lineParsers)
                    {
                        // this line parser does match the given line
                        if (parser.test(line) == true)
                        {
                            activeLineParser = parser;
                            bufferline = line;
                            break;
                        }
                    }
                }

                // reached eof with no line parser matching
                if(activeLineParser == null)
                {
                    throw new LineparserException("No valid line format found for file " + file);
                }

                Console.WriteLine("Detected lineparser: " + activeLineParser.ToString());

                // construct model with supported values
                CsvModel model = new CsvModel(activeLineParser.SupportedValues);
                // set limits for the activitylevel calculator

                model.ActivityLevelCalculator.MinSedantary = minSedantary;
                model.ActivityLevelCalculator.MinLight = minLight;
                model.ActivityLevelCalculator.MinModerate = minModerate;
                model.ActivityLevelCalculator.MinHeavy = minHeavy;
                model.ActivityLevelCalculator.MinVeryheavy = minVeryheavy;

                // Set filename
                model.AbsoluteFileName = file;
                // Add the two lines consumed by lineparser testing
                model.Add(activeLineParser.parseLine(bufferline));
                model.Add(activeLineParser.parseLine(line));

                //iterate over all remaining lines with
                while((line = reader.ReadLine()) != null)
                {
                    if (line.Trim().Length > 0)
                    {
                        model.Add(activeLineParser.parseLine(line));
                    }
                }

                // finish model
                model.finishParsing();

                return model;
            }
        }
Example #31
0
        //Function addes shapes, vertices and meshes
        public void AddOjects(string FileName, bool Replace = true)
        {
            bool IsWiiU = (GetResFileU() != null);

            int    MatStartIndex = materials.Count;
            string ext           = System.IO.Path.GetExtension(FileName);

            ext = ext.ToLower();

            switch (ext)
            {
            case ".bfobj":
                Cursor.Current = Cursors.WaitCursor;

                if (Replace)
                {
                    shapes.Clear();
                    Nodes["FshpFolder"].Nodes.Clear();
                }

                Shape        shpS         = new Shape();
                VertexBuffer vertexBuffer = new VertexBuffer();
                shpS.Import(FileName, vertexBuffer);

                FSHP shapeS = new FSHP();
                shapeS.Shape = shpS;
                BfresSwitch.ReadShapesVertices(shapeS, shpS, vertexBuffer, this);
                shapes.Add(shapeS);
                Nodes["FshpFolder"].Nodes.Add(shapeS);
                Cursor.Current = Cursors.Default;
                break;

            case ".bfmdl":
                Cursor.Current = Cursors.WaitCursor;

                if (Replace)
                {
                    shapes.Clear();
                    Nodes["FshpFolder"].Nodes.Clear();
                }

                Model mdl = new Model();
                mdl.Import(FileName, GetResFile());
                mdl.Name = Text;
                shapes.Clear();
                foreach (Shape shp in mdl.Shapes)
                {
                    FSHP shape = new FSHP();
                    shape.Shape = shp;
                    BfresSwitch.ReadShapesVertices(shape, shp, mdl.VertexBuffers[shp.VertexBufferIndex], this);
                    shapes.Add(shape);
                    Nodes["FshpFolder"].Nodes.Add(shape);
                }
                Cursor.Current = Cursors.Default;
                break;

            case ".csv":
                CsvModel csvModel = new CsvModel();
                csvModel.LoadFile(FileName, true);

                if (csvModel.objects.Count == 0)
                {
                    MessageBox.Show("No models found!");
                    return;
                }
                BfresModelImportSettings csvsettings = new BfresModelImportSettings();
                csvsettings.DisableMaterialEdits();
                csvsettings.SetModelAttributes(csvModel.objects[0]);
                if (csvsettings.ShowDialog() == DialogResult.OK)
                {
                    if (Replace)
                    {
                        shapes.Clear();
                        Nodes["FshpFolder"].Nodes.Clear();
                    }

                    Cursor.Current = Cursors.WaitCursor;

                    foreach (STGenericObject obj in csvModel.objects)
                    {
                        FSHP shape = new FSHP();
                        shape.VertexBufferIndex = shapes.Count;
                        shape.vertices          = obj.vertices;
                        shape.MaterialIndex     = 0;
                        shape.vertexAttributes  = csvsettings.CreateNewAttributes();
                        shape.boneIndx          = 0;
                        shape.Text      = obj.ObjectName;
                        shape.lodMeshes = obj.lodMeshes;
                        shape.CreateNewBoundingBoxes();
                        shape.CreateBoneList(obj, this);
                        shape.CreateIndexList(obj, this);
                        shape.VertexSkinCount = obj.GetMaxSkinInfluenceCount();
                        shape.ApplyImportSettings(csvsettings, GetMaterial(shape.MaterialIndex));
                        shape.SaveShape(IsWiiU);
                        shape.SaveVertexBuffer(IsWiiU);
                        shape.BoneIndices = new List <ushort>();

                        Nodes["FshpFolder"].Nodes.Add(shape);
                        shapes.Add(shape);
                    }
                    Cursor.Current = Cursors.Default;
                }
                break;

            default:
                AssimpData assimp = new AssimpData();
                assimp.LoadFile(FileName);

                if (assimp.objects.Count == 0)
                {
                    MessageBox.Show("No models found!");
                    return;
                }
                BfresModelImportSettings settings = new BfresModelImportSettings();
                settings.SetModelAttributes(assimp.objects[0]);
                if (settings.ShowDialog() == DialogResult.OK)
                {
                    if (Replace)
                    {
                        shapes.Clear();
                        Nodes["FshpFolder"].Nodes.Clear();
                    }

                    Cursor.Current = Cursors.WaitCursor;
                    if (Replace)
                    {
                        materials.Clear();
                        Nodes["FmatFolder"].Nodes.Clear();
                        MatStartIndex = 0;
                    }
                    foreach (STGenericMaterial mat in assimp.materials)
                    {
                        FMAT fmat = new FMAT();
                        if (settings.ExternalMaterialPath != string.Empty)
                        {
                            if (GetResFileU() != null)
                            {
                                fmat.MaterialU = new ResU.Material();
                                fmat.MaterialU.Import(settings.ExternalMaterialPath, GetResFileU());
                                BfresWiiU.ReadMaterial(fmat, fmat.MaterialU);
                            }
                            else
                            {
                                fmat.Material = new Material();
                                fmat.Material.Import(settings.ExternalMaterialPath);
                                fmat.ReadMaterial(fmat.Material);
                            }
                        }

                        fmat.Text = mat.Text;
                        //Setup placeholder textures
                        //Note we can't add/remove samplers so we must fill these slots
                        foreach (var t in fmat.TextureMaps)
                        {
                            t.wrapModeS = 0;
                            t.wrapModeT = 0;

                            switch (t.Type)
                            {
                            case STGenericMatTexture.TextureType.Diffuse:
                                t.Name = "Basic_Alb";
                                break;

                            case STGenericMatTexture.TextureType.Emission:
                                t.Name = "Basic_Emm";
                                break;

                            case STGenericMatTexture.TextureType.Normal:
                                t.Name = "Basic_Nrm";
                                break;

                            case STGenericMatTexture.TextureType.Specular:
                                t.Name = "Basic_Spm";
                                break;

                            case STGenericMatTexture.TextureType.SphereMap:
                                t.Name = "Basic_Sphere";
                                break;

                            case STGenericMatTexture.TextureType.Metalness:
                                t.Name = "Basic_Mtl";
                                break;

                            case STGenericMatTexture.TextureType.Roughness:
                                t.Name = "Basic_Rgh";
                                break;

                            case STGenericMatTexture.TextureType.MRA:
                                t.Name = "Basic_MRA";
                                break;

                            case STGenericMatTexture.TextureType.Shadow:
                                t.Name = "Basic_Bake_st0";
                                break;

                            case STGenericMatTexture.TextureType.Light:
                                t.Name = "Basic_Bake_st1";
                                break;
                            }
                        }

                        if (PluginRuntime.bntxContainers.Count > 0)
                        {
                            foreach (var node in Parent.Parent.Nodes["EXT"].Nodes)
                            {
                                if (node is BNTX)
                                {
                                    var bntx = (BNTX)node;

                                    bntx.ImportBasicTextures("Basic_Alb");
                                    bntx.ImportBasicTextures("Basic_Nrm");
                                    bntx.ImportBasicTextures("Basic_Spm");
                                    bntx.ImportBasicTextures("Basic_Sphere");
                                    bntx.ImportBasicTextures("Basic_Mtl");
                                    bntx.ImportBasicTextures("Basic_Rgh");
                                    bntx.ImportBasicTextures("Basic_MRA");
                                    bntx.ImportBasicTextures("Basic_Bake_st0");
                                    bntx.ImportBasicTextures("Basic_Bake_st1");
                                    bntx.ImportBasicTextures("Basic_Emm");
                                }
                            }
                        }

                        foreach (var tex in mat.TextureMaps)
                        {
                            foreach (var t in fmat.TextureMaps)
                            {
                                if (t.Type == tex.Type)
                                {
                                    t.Name      = tex.Name;
                                    t.wrapModeS = tex.wrapModeS;
                                    t.wrapModeT = tex.wrapModeT;
                                    t.wrapModeW = tex.wrapModeW;
                                    t.Type      = tex.Type;
                                }
                            }
                        }

                        List <string> keyList = new List <string>(materials.Keys);
                        fmat.Text = Utils.RenameDuplicateString(keyList, fmat.Text);

                        materials.Add(fmat.Text, fmat);
                        Nodes["FmatFolder"].Nodes.Add(fmat);

                        if (GetResFileU() != null)
                        {
                            fmat.MaterialU.Name = Text;
                            fmat.SetMaterial(fmat.MaterialU);
                        }
                        else
                        {
                            fmat.Material.Name = Text;
                            fmat.SetMaterial(fmat.Material);
                        }
                    }


                    foreach (STGenericObject obj in assimp.objects)
                    {
                        FSHP shape = new FSHP();
                        shape.VertexBufferIndex = shapes.Count;
                        shape.vertices          = obj.vertices;
                        shape.VertexSkinCount   = obj.MaxSkinInfluenceCount;
                        shape.vertexAttributes  = settings.CreateNewAttributes();
                        shape.boneIndx          = obj.BoneIndex;
                        shape.MaterialIndex     = obj.MaterialIndex + MatStartIndex;

                        shape.Text      = obj.ObjectName;
                        shape.lodMeshes = obj.lodMeshes;
                        shape.CreateNewBoundingBoxes();
                        shape.CreateBoneList(obj, this);
                        shape.CreateIndexList(obj, this);
                        shape.ApplyImportSettings(settings, GetMaterial(shape.MaterialIndex));
                        shape.SaveShape(IsWiiU);
                        shape.SaveVertexBuffer(IsWiiU);
                        shape.BoneIndices = new List <ushort>();

                        List <string> keyList = shapes.Select(o => o.Text).ToList();

                        shape.Text = Utils.RenameDuplicateString(keyList, shape.Text);

                        Nodes["FshpFolder"].Nodes.Add(shape);
                        shapes.Add(shape);
                    }
                    Console.WriteLine("Finshed Importing Model");

                    Cursor.Current = Cursors.Default;
                }
                break;
            }
            UpdateVertexData();
        }