public static void SetSettings(SnowSetting s) { if (s == null) { s = new SnowSetting(); } settings = s; }
private void initValues(SnowSetting mObj) { snowValue.Value = mObj.SnowValue; snowWallValue.Value = mObj.WallSnowValue; snowSpeed.Value = mObj.SnowSpeed; percentDrawParticlesSnow.Value = mObj.PercentDrawParticles; turbulenceValue.Value = mObj.Turbulence; spriteSizeSnow.Value = mObj.SpriteSize; }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (objectToEdit != null && objectToEdit is SnowSetting) { SnowSetting obj = objectToEdit as SnowSetting; txtBaseObjectId.Text = obj.BaseObjectId; txtBaseObjectName.Text = obj.BaseObjectName; isEditingObj = true; txtBaseObjectId.IsEnabled = false; initValues(obj); cancelRevert = (SnowSetting)Utils.DeepClone(obj); } else { SnowSetting ss = new SnowSetting(); initValues(ss); } }
private void btnOk_Click(object sender, RoutedEventArgs e) { if (objectToEdit == null) { objectToEdit = new SnowSetting(); } SnowSetting obj = objectToEdit as SnowSetting; obj.BaseObjectId = txtBaseObjectId.Text; obj.BaseObjectName = txtBaseObjectName.Text; //custom code obj.SnowValue = (float)snowValue.Value; obj.WallSnowValue = (float)snowWallValue.Value; obj.SnowSpeed = (float)snowSpeed.Value; obj.PercentDrawParticles = (float)percentDrawParticlesSnow.Value; obj.Turbulence = (float)turbulenceValue.Value; obj.SpriteSize = (float)spriteSizeSnow.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(); } } }