public void AddModels(ModelFromFile fromFile, bool isNew)//(string fileName,byte[] data) { if (!availableModel) { availableGCode = false; gCode = ""; GCodeChange(gCode); InitSlicerView(); } availableModel = true; IsChanged = true; PrintModel model = new PrintModel(control, fromFile); model.Load(fromFile.Name, fromFile.Data); model.update(); if (isNew) { model.Center(SettingsProvider.Instance.Printer_Settings.PrintAreaWidth / 2, SettingsProvider.Instance.Printer_Settings.PrintAreaDepth / 2); model.Land(); } ModelList.Add(model); if (model.ActiveModel.triangles.Count > 0) { PreView.models.AddLast(model); if (isNew) { Allocate(model); model.addAnimation(new DropAnimation("drop")); } updateSTLState(model); } }
public void AddFileModels(string[] files) { foreach (string file in files) { FileInfo info; byte[] data = null; string modelName = ""; try { info = new FileInfo(file); data = File.ReadAllBytes(file); modelName = info.Name; int exist = Models.Count(x => x.Key == info.Name); int point = modelName.IndexOf("."); if (exist > 0) { string ext = ""; if (point != -1) { ext = modelName.Substring(point); modelName = modelName.Substring(0, point - 1); } int i = 0; do { i++; // modelName = info.Name + i; } while (Models.Count(x => x.Key == modelName + i + ext) > 0); modelName = modelName + i + ext; } ModelFromFile fromFile = new ModelFromFile() { Name = modelName, ExtruderNumber = 0, Data = data }; Models.Add(modelName, fromFile); AddModels(fromFile, true); // BinaryDataList.Add(modelName, data); } catch (Exception exp) { } } }