private void initValues(SkySetting mObj) { cloudCover.Value = mObj.CloudCover; cloudTitle1.Value = mObj.CloudTile.X; cloudTitle2.Value = mObj.CloudTile.Y; cloudScroll1.Value = mObj.Scroll.X; cloudScroll2.Value = mObj.Scroll.Y; numSamples.Value = mObj.NumSamples; exposure.Value = mObj.Exposure; waveLenX.Value = mObj.WaveLengths.X; waveLenY.Value = mObj.WaveLengths.Y; waveLenZ.Value = mObj.WaveLengths.Z; fogDensity.Value = mObj.FogDensity; }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (objectToEdit != null && objectToEdit is SkySetting) { SkySetting obj = objectToEdit as SkySetting; txtBaseObjectId.Text = obj.BaseObjectId; txtBaseObjectName.Text = obj.BaseObjectName; isEditingObj = true; txtBaseObjectId.IsEnabled = false; initValues(obj); cancelRevert = (SkySetting)Utils.DeepClone(obj); } else { SkySetting ss = new SkySetting(); initValues(ss); } }
private void btnOk_Click(object sender, RoutedEventArgs e) { if (objectToEdit == null) { objectToEdit = new SkySetting(); } SkySetting obj = objectToEdit as SkySetting; obj.BaseObjectId = txtBaseObjectId.Text; obj.BaseObjectName = txtBaseObjectName.Text; //custom code obj.CloudCover = (float)cloudCover.Value; obj.CloudTile = new Vector2((float)cloudTitle1.Value, (float)cloudTitle2.Value); obj.Scroll = new Vector2((float)cloudScroll1.Value, (float)cloudScroll2.Value); obj.NumSamples = (int)numSamples.Value; obj.Exposure = (float)exposure.Value; Vector3 wl = new Vector3((float)waveLenX.Value, (float)waveLenY.Value, (float)waveLenZ.Value); obj.WaveLengths = wl; obj.FogDensity = (float)fogDensity.Value; //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(); } } }