public void Delete(ModelImageViewModel viewModel) { ModelImage toRemove = EntityStore.ModelImages.Find(viewModel.Id); EntityStore.ModelImages.Remove(toRemove); EntityStore.SaveChanges(); }
public ShipSerializable Serialize() { var serializable = new ShipSerializable(); serializable.Id = ItemId.Id; serializable.FileName = ItemId.Name; serializable.ItemType = (int)ItemType.Ship; serializable.ShipCategory = ShipCategory; serializable.Name = Name; serializable.Faction = Faction.Id; serializable.SizeClass = SizeClass; serializable.IconImage = IconImage.ToString(); serializable.IconScale = IconScale.Value; serializable.ModelImage = ModelImage.ToString(); serializable.ModelScale = ModelScale.Value; serializable.EnginePosition = EnginePosition; serializable.EngineColor = Utils.ColorUtils.ColorToString(EngineColor); serializable.EngineSize = EngineSize.Value; serializable.EnergyResistance = EnergyResistance.Value; serializable.KineticResistance = KineticResistance.Value; serializable.HeatResistance = HeatResistance.Value; serializable.Regeneration = Regeneration; serializable.BaseWeightModifier = BaseWeightModifier.Value; serializable.BuiltinDevices = BuiltinDevices?.Select(item => item.Item.Id).ToArray(); serializable.Layout = Layout.Data; serializable.Barrels = Barrels?.Select(item => item.Serialize()).ToArray(); return(serializable); }
public Form1() { InitializeComponent(); //model = new Model.Model(); modelImage = new ModelImage(); modelSound = new ModelSound(); Controller.Controller controller = new Controller.Controller(/*model,*/ modelImage, modelSound, this); }
/// <summary> /// Associate a ModelImage object with a MongoDBRecord. /// </summary> /// <param name="img">The ModelImage object.</param> private void SetModelInfo(ModelImage img) { Record record = records.records.First(r => r.name == models[img]); // Display info. textModelInfo.text = record.name + "\n" + record.wnid + "\n" + record.wcategory; }
public static ModelImageViewModel FromModel(ModelImage model) { return(new ModelImageViewModel { Id = model.Id, HighResolutionUrl = model.HighResolutionUrl, LowResolutionUrl = model.LowResolutionUrl, Order = model.Order, ShortDescription = model.ShortDescription }); }
public static void DestroyAllByteImages() { if (runTimeImageDict != null) { foreach (int key in runTimeImageDict.Keys) { ModelImage obj = runTimeImageDict[key]; obj.DestroyImage(); } } runTimeImageDict.Clear(); generateId = -1; Resources.UnloadUnusedAssets(); }
public SatelliteSerializable Serialize() { var serializable = new SatelliteSerializable(); serializable.Id = ItemId.Id; serializable.FileName = ItemId.Name; serializable.ItemType = (int)ItemType.Satellite; serializable.Name = Name; serializable.ModelImage = ModelImage.ToString(); serializable.ModelScale = ModelScale.Value; serializable.SizeClass = SizeClass; serializable.Layout = Layout.Data; serializable.Barrels = Barrels?.Select(item => item.Serialize()).ToArray(); return(serializable); }
public static int LoadByteImage(string imageName, Vector3 imagePosition, TextureFormat textFormat = TextureFormat.RGB24, GameObject gObj = null, bool isSprite = true, float width = -1, float height = -1) { generateId++; if (runTimeImageDict == null) { runTimeImageDict = new Dictionary <int, ModelImage>(); } ModelImage runTime = new ModelImage(); runTime.LoadImage(imageName, imagePosition, textFormat, width, height, gObj, isSprite); runTimeImageDict.Add(generateId, runTime); return(generateId); }
private void HandleImages(ModelDetailsViewModel model, Model m) { IList <ModelImage> toAdd = new List <ModelImage>(); foreach (ModelImageViewModel image in model.Images) { if (image.Id != 0) { ModelImage o = m.Images.Find(x => x.Id == image.Id); o.Order = image.Order; o.HighResolutionUrl = image.HighResolutionUrl; o.LowResolutionUrl = image.LowResolutionUrl; o.ShortDescription = image.ShortDescription; o.LongDescription = image.ShortDescription; o.ModelId = image.ModelId; } else { image.ModelId = model.Id; toAdd.Add(ModelImageViewModel.ToModel(image)); } } if (toAdd.Count != 0) { foreach (ModelImage mi in toAdd) { EntityStore.ModelImages.Add(mi); } } IList <ModelImage> toDelete = (from modelImage in m.Images let mivw = model.Images.FirstOrDefault(x => x.Id == modelImage.Id) where mivw == null select modelImage).ToList(); if (toDelete.Count != 0) { foreach (ModelImage mi in toDelete) { EntityStore.ModelImages.Remove(mi); } } }
private void Start() { records = JsonConvert.DeserializeObject <Records>( File.ReadAllText(Path.Combine(ImageDirectory, "records.json"))); foreach (Record record in records.records) { string filepath = Path.Combine(ImageDirectory, record.name + ".png"); if (!File.Exists(filepath)) { continue; } // Instantiate the image. ModelImage img = Instantiate(imagePrefab.gameObject).GetComponent <ModelImage>(); // Parent this image to the scroll view. img.GetComponent <RectTransform>().SetParent(content); // Set the image. Texture2D tex = GetMaterialImage(filepath); img.image.sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f)); img.text.text = record.name; // Store the image and model name. images.Add(img, record); } loading.gameObject.SetActive(false); buttonQuit.onClick.AddListener(() => Application.Quit()); PopulateDropdownSearch(); dropdownSearch.onValueChanged.AddListener(SelectSearchType); inputSearch.onValueChanged.AddListener(FilterByName); // Set a defaul value. dropdownSearch.value = 0; // Listen to events. ModelImage.OnSelect += Select; ModelImage.OnDeselect += Deselect; }
/// <summary> /// Get all model images. Only do this at start! /// </summary> private void PopulateModelImages() { DirectoryInfo d = new DirectoryInfo(ImageDirectory); foreach (FileInfo f in d.GetFiles()) { string modelName = f.Name.Replace("\r", "").Replace(".jpg", "").Replace(".png", ""); // Ignore blanks. if (modelName == "") { continue; } // Set the image. Texture2D tex = GetModelImage(f.FullName); if (tex == null) { continue; } // Instantiate the image. ModelImage img = Instantiate(modelImagePrefab.gameObject).GetComponent <ModelImage>(); // Parent this image to the scroll view. img.GetComponent <RectTransform>().SetParent(imageScrollView); img.image.sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f)); img.text.text = modelName; // Store the image and model name. models.Add(img, modelName); } // Apply filter. dropdownWnids.value = DEFAULT_WNID_FILTER; // Listen to events. ModelImage.OnSelect += Select; ModelImage.OnDeselect += Deselect; searchBar.onValueChanged.AddListener(Search); }
/// <summary> /// Select an image. /// </summary> /// <param name="image">The image.</param> private void Select(ModelImage image) { textMaterialInfo.text = images[image].name + "\tType: " + images[image].type; }
/// <summary> /// Event for when a model image is selected. /// </summary> /// <param name="img">The selected model image.</param> private void Select(ModelImage img) { SetModelInfo(img); }