protected void HandleMemberSet(object sender, MemberChangeArgs args) { string name = args.Member; object value = args.Value; (this.Instance as IElement).Properties.SetValue(name, value); }
void HandleOrthogonalMemberChange(object sender, MemberChangeArgs args) { // We need to lose focus so we can update the UI immediately this.PropertyGrid.Enabled = false; UpdateDisplayedProperties(mInstance as Camera); UpdateSets(); this.PropertyGrid.Enabled = true; }
private void AfterTimeSet(object sender, MemberChangeArgs args) { if (AppState.Self.CurrentSpline != null) { AppState.Self.CurrentSpline.Sort(); } // Refresh the entire spline because time and ordering may have changed AppCommands.Self.Gui.RefreshTreeView(AppState.Self.CurrentSpline); }
void AfterChangeValueThatConflictsWithPixelSize(object sender, MemberChangeArgs e) { float textureScale = GetTextureScale(); if (textureScale != 0) { string memberChanged = e.Member; MessageBox.Show("Setting " + memberChanged + " when TextureScale is not 0 may result in the " + memberChanged + " value not applying"); } }
public void ReactToMemberChange(object sender, MemberChangeArgs args) { if (MemberChange != null) { MemberChange(sender, args); } else { LateBinder.GetInstance(args.Owner.GetType()).SetValue(args.Owner, args.Member, args.Value); } if (AfterMemberChange != null) { AfterMemberChange(sender, args); } }
void HandleAfteruseGlobalContentChanged(object sender, MemberChangeArgs args) { IElement element = Instance as IElement; List<IElement> elementsToMakeGlobal = new List<IElement>(); if (element.UseGlobalContent) { GetAllElementsReferencedThroughObjectsRecursively(element, elementsToMakeGlobal); if (elementsToMakeGlobal.Count != 0) { string message = "Setting " + FileManager.RemovePath(element.Name) + " to use a global content manager will result in the following Entities being " + " loaded with a global content manager. What would you like to do?"; ListBoxWindow lbw = new ListBoxWindow(); lbw.Message = message; foreach (var item in elementsToMakeGlobal) { lbw.AddItem(item); } lbw.ClearButtons(); lbw.AddButton("Set all to use global content", System.Windows.Forms.DialogResult.Yes); lbw.AddButton("Nothing - this may result in runtime errors", System.Windows.Forms.DialogResult.No); var result = lbw.ShowDialog(); if (result == System.Windows.Forms.DialogResult.Yes) { foreach (IElement toMakeGlobal in elementsToMakeGlobal) { toMakeGlobal.UseGlobalContent = true; GlueCommands.Self.GenerateCodeCommands.GenerateElementCode(toMakeGlobal); } } } } }
public void SetNumberOfTilesWide(object sender, MemberChangeArgs args) { string asString = (string)args.Value; int valueToSet; if (asString.Contains("cells") && SelectedState.Self.SelectedTexture != null) { asString = asString.Replace(" cells", ""); int cellsWide = int.Parse(asString); valueToSet = SelectedState.Self.SelectedTexture.Width / cellsWide; } else { int.TryParse((string)args.Value, out valueToSet); //valueToSet = int.Parse((string)args.Value); } if (TileMapInformation != null) { TileMapInformation.TileWidth = valueToSet; } }
void CoordinateChange(object sender, MemberChangeArgs args) { AnimationFrameSave frame = Instance as AnimationFrameSave; if (mTexture == null) { // We can't do anything. } else { if (args.Member == "X") { int oldValue = MathFunctions.RoundToInt( frame.LeftCoordinate * mTexture.Width ); int newValue = ((int)args.Value); int increaseAsInt = newValue - oldValue; float increaseAsTextureCoord = increaseAsInt / (float) mTexture.Width; // Users expect the entire frame to shift, so we want to shift the right coordinates too. frame.LeftCoordinate += increaseAsTextureCoord; frame.RightCoordinate += increaseAsTextureCoord; SetForPixelCoordinates(ref frame.LeftCoordinate, mTexture.Width); SetForPixelCoordinates(ref frame.RightCoordinate, mTexture.Width); } else if (args.Member == "Y") { int oldValue = MathFunctions.RoundToInt(frame.TopCoordinate * mTexture.Height); int newValue = ((int)args.Value); int increaseAsInt = newValue - oldValue; float increaseAsTextureCoord = increaseAsInt / (float) mTexture.Height; frame.TopCoordinate += increaseAsTextureCoord; frame.BottomCoordinate += increaseAsTextureCoord; SetForPixelCoordinates(ref frame.TopCoordinate, mTexture.Height); SetForPixelCoordinates(ref frame.BottomCoordinate, mTexture.Height); } else if (args.Member == "Width") { float widthInCoords = ((int)args.Value) / (float)mTexture.Width; frame.RightCoordinate = frame.LeftCoordinate + widthInCoords; } else if (args.Member == "Height") { float heightInCoords = ((int)args.Value) / (float)mTexture.Height; frame.BottomCoordinate = frame.TopCoordinate + heightInCoords; } else if (args.Member == "TileX") { int valueAsInt = (int)args.Value; SetTileX(frame, valueAsInt); } else if (args.Member == "TileY") { int valueAsInt = (int)args.Value; SetTileY(frame, valueAsInt); } } }
protected void SetClassName(object sender, MemberChangeArgs args) { ((IElement)Instance).RenameElement((string)args.Value); }
public static void OnMemberChanged(object sender, MemberChangeArgs args) { CustomVariable variable = args.Owner as CustomVariable; object value = args.Value; if (GetShouldCustomVariableBeConvertedToType(args, variable)) { var variableRuntimeType = variable.GetRuntimeType(); value = PropertyValuePair.ConvertStringToType((string)args.Value, variableRuntimeType); } if (EditorLogic.CurrentEntitySave != null) { EditorLogic.CurrentEntitySave.SetCustomVariable(EditorLogic.CurrentCustomVariable.Name, value); } else { EditorLogic.CurrentScreenSave.SetCustomVariable(EditorLogic.CurrentCustomVariable.Name, value); } }
public static bool GetShouldCustomVariableBeConvertedToType(MemberChangeArgs args, CustomVariable variable) { var runtimeType = variable.GetRuntimeType(); return runtimeType != null && args.Value is string && !variable.GetIsFile() && variable.Type != "Color"; }
void HandleTextureChanged(object sender, MemberChangeArgs memberChangeArgs) { // Justin has reported a bug here. I don't know what is going on, so I'm going to spit out the error to a message box try { string fullFileName = memberChangeArgs.Value as string; string emitterDirectory = FileManager.GetDirectory(ProjectManager.Self.FileName); if (FileManager.IsRelative(fullFileName)) { // This file is relative. // This means that the user // typed in a value rather than // using the file window. We should // assume that the file is relative to // the emitter. fullFileName = emitterDirectory + fullFileName; } if (!FileManager.IsRelativeTo(fullFileName, emitterDirectory)) { MultiButtonMessageBox mbmb = new MultiButtonMessageBox(); mbmb.MessageText = "The selected file:\n\n" + fullFileName + "\n\nis not relative to the Emitter file. What would you like to do?"; mbmb.AddButton("Copy the file to the same folder as the Emitter file", System.Windows.Forms.DialogResult.Yes); mbmb.AddButton("Keep the file where it is (this may limit the portability of the Emitter file)", System.Windows.Forms.DialogResult.No); DialogResult result = mbmb.ShowDialog(); if (result == DialogResult.Yes) { string destination = emitterDirectory + FileManager.RemovePath(fullFileName); try { System.IO.File.Copy(fullFileName, destination, true); fullFileName = destination; } catch (Exception e) { MessageBox.Show("Could not copy the file:\n" + e); } } } string relativeFileName = FileManager.MakeRelative(fullFileName, emitterDirectory); SettingsSaveInstance.Texture = relativeFileName; } catch (Exception e) { MessageBox.Show(e.ToString()); } }
private void AfterUseNewSyntaxChanged(object sender, MemberChangeArgs args) { CallOnUpdate(); }
public void SetNumberOfTilesTall(object sender, MemberChangeArgs args) { string asString = (string)args.Value; int valueToSet; if (asString.Contains("cells") && SelectedState.Self.SelectedTexture != null) { asString = asString.Replace(" cells", ""); int cellsTall = int.Parse(asString); valueToSet = SelectedState.Self.SelectedTexture.Height / cellsTall; } else { // If it fails that's okay...I think. int.TryParse((string)args.Value, out valueToSet); } if (TileMapInformation != null) { TileMapInformation.TileHeight = valueToSet; } }
private void SetRelativeY(object sender, MemberChangeArgs args) { AnimationFrameInstance.RelativeY = (float)args.Value / PreviewManager.Self.OffsetMultiplier; }
public void ReactToMemberChange (object sender, MemberChangeArgs args) { if (MemberChange != null) { MemberChange(sender, args); } else { LateBinder.GetInstance(args.Owner.GetType()).SetValue( args.Owner, args.Member, args.Value); } if(AfterMemberChange != null) { AfterMemberChange(sender, args); } }
void OnFilteringChange(object sender, MemberChangeArgs args) { bool newValue = (bool)args.Value; if (newValue) { FlatRedBallServices.GraphicsOptions.TextureFilter = Microsoft.Xna.Framework.Graphics.TextureFilter.Linear; } else { FlatRedBallServices.GraphicsOptions.TextureFilter = Microsoft.Xna.Framework.Graphics.TextureFilter.Point; } }
void SetProjectSpecificFiles(object sender, MemberChangeArgs args) { // do nothing }
void HandleAniimationPathChanged(object sender, MemberChangeArgs memberChangeArgs) { string fullFileName = memberChangeArgs.Value as string; string emitterDirectory = FileManager.GetDirectory(ProjectManager.Self.FileName); if (FileManager.IsRelative(fullFileName)) { // This file is relative. // This means that the user // typed in a value rather than // using the file window. We should // assume that the file is relative to // the emitter. fullFileName = emitterDirectory + fullFileName; } string relativeFileName = FileManager.MakeRelative(fullFileName, emitterDirectory); SettingsSaveInstance.AnimationChains = relativeFileName; }
void TextureNameChange(object sender, MemberChangeArgs args) { string absoluteFileName = (string)args.Value; string achxFolder; if (!System.IO.File.Exists(absoluteFileName)) { MessageBox.Show("The file\n" + absoluteFileName + "\ndoesn't exist"); } else { bool shouldProceed = TryAskToMoveFileRelativeToAnimationChainFile(ref absoluteFileName, out achxFolder); if (shouldProceed) { ShowWarningsForTooBigTextures(absoluteFileName); string relativeFileName = FileManager.MakeRelative(absoluteFileName, achxFolder); AnimationFrameInstance.TextureName = relativeFileName; } } }
void AfterNameSet(object sender, MemberChangeArgs args) { AppCommands.Self.Gui.RefreshTreeView(); }
private void ChangeType(object sender, MemberChangeArgs args) { ((CustomVariable)args.Owner).Type = args.Value as string; }