private void Window_Loaded(object sender, RoutedEventArgs e) { if (objectToEdit != null && objectToEdit is BoxLight) { BoxLight obj = objectToEdit as BoxLight; txtBaseObjectId.Text = obj.BaseObjectId; txtBaseObjectName.Text = obj.BaseObjectName; isEditingObj = true; txtBaseObjectId.IsEnabled = false; //custom code haloToLoad.Content = obj.HaloTextureName; maskToLoad.Content = obj.LightMaskTextureName; mapToLoad.Content = obj.LightMapTextureName; cancelRevert = (BoxLight)Utils.DeepClone(obj); //custom code end } }
private void btnOk_Click(object sender, RoutedEventArgs e) { if (objectToEdit == null) { objectToEdit = new BoxLight(); } BoxLight obj = objectToEdit as BoxLight; obj.BaseObjectId = txtBaseObjectId.Text; obj.BaseObjectName = txtBaseObjectName.Text; //custom code String haloTexName = haloToLoad.Content != null?haloToLoad.Content.ToString() : ""; if (string.IsNullOrEmpty(haloTexName)) { obj.HaloSRV = null; obj.HaloTextureName = null; } else { obj.HaloSRV = TextureLoader.LoadTexture("flares/" + haloTexName); obj.HaloTextureName = haloTexName; } String maskTexName = maskToLoad.Content != null?maskToLoad.Content.ToString() : ""; if (string.IsNullOrEmpty(maskTexName)) { obj.LightMaskSRV = null; obj.LightMaskTextureName = null; } else { obj.LightMaskSRV = TextureLoader.LoadCubeTexture("fx/" + maskTexName); obj.LightMaskTextureName = maskTexName; } String mapTexName = mapToLoad.Content != null?mapToLoad.Content.ToString() : ""; if (string.IsNullOrEmpty(mapTexName)) { obj.LightMapSRV = null; obj.LightMapTextureName = null; } else { obj.LightMapSRV = TextureLoader.LoadCubeTexture("fx/" + mapTexName); obj.LightMapTextureName = mapTexName; } //custom code end obj.Category = objCategory; bool success = isEditingObj ? WorldData.UpdateObject(obj) : WorldData.AddObject(obj); if (!success) { MessageBox.Show(Application.Current.MainWindow, "ID already exists", "AddObject Failure", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.Cancel); } else { this.Close(); if (parentWindow != null) { parentWindow.Refresh(); } } }