void HandleRegionChanged(object sender, EventArgs e) { AnimationFrameSave frame = SelectedState.Self.SelectedFrame; if (frame != null) { Texture2D texture = mControl.CurrentTexture; frame.LeftCoordinate = mControl.RectangleSelector.Left / (float)texture.Width; frame.RightCoordinate = mControl.RectangleSelector.Right / (float)texture.Width; frame.TopCoordinate = mControl.RectangleSelector.Top / (float)texture.Height; frame.BottomCoordinate = mControl.RectangleSelector.Bottom / (float)texture.Height; TreeViewManager.Self.RefreshTreeNode(frame); } else if (SelectedState.Self.SelectedChain != null) { if (mPushedRegion != null) { Texture2D texture = mControl.CurrentTexture; int changedLeft = FlatRedBall.Math.MathFunctions.RoundToInt(mPushedRegion.Left - mPushedRegion.OldLeft); int changedTop = FlatRedBall.Math.MathFunctions.RoundToInt(mPushedRegion.Top - mPushedRegion.OldTop); int changedBottom = FlatRedBall.Math.MathFunctions.RoundToInt(mPushedRegion.Bottom - mPushedRegion.OldBottom); int changedRight = FlatRedBall.Math.MathFunctions.RoundToInt(mPushedRegion.Right - mPushedRegion.OldRight); if (changedLeft != 0 || changedTop != 0 || changedRight != 0 || changedBottom != 0) { // only move the regions that are shown foreach (var region in mControl.RectangleSelectors) { var frameForRegion = region.Tag as AnimationFrameSave; frameForRegion.LeftCoordinate += changedLeft / (float)texture.Width; frameForRegion.RightCoordinate += changedRight / (float)texture.Width; frameForRegion.TopCoordinate += changedTop / (float)texture.Height; frameForRegion.BottomCoordinate += changedBottom / (float)texture.Height; } UpdateSelectorsToAnimation(skipUpdatingRectangleSelector: true, texture: texture); PreviewManager.Self.ReactToAnimationChainSelected(); } } } // This is causing spamming of the save - we only want to do this on a mouse click //if (AnimationChainChange != null) //{ // AnimationChainChange(this, null); b //} AnimationFrameChange?.Invoke(this, null); }
private void HandleWireframePropertyChanged(object sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { case nameof(WireframeEditControlsViewModel.SelectedTextureFilePath): RecordCameraPosition(); // update the texture before updating the frame (and calling refresh) UpdateToSelectedAnimationTextureFile(WireframeEditControlsViewModel.SelectedTextureFilePath); UpdateToSavedCameraPosition(); if (SelectedState.Self.SelectedFrame != null && WireframeEditControlsViewModel.SelectedTextureFilePath != null) { var achxFolder = FileManager.GetDirectory(SelectedState.Self.SelectedChain.Name); achxFolder = FileManager.GetDirectory(ProjectManager.Self.FileName); string relativeFileName = FileManager.MakeRelative(WireframeEditControlsViewModel.SelectedTextureFilePath.FullPath, achxFolder); SelectedState.Self.SelectedFrame.TextureName = relativeFileName; AnimationFrameChange?.Invoke(this, null); PropertyGridManager.Self.Refresh(); RefreshAll(); } break; case nameof(WireframeEditControlsViewModel.IsMagicWandSelected): ReactToMagicWandChange(this, null); break; case nameof(WireframeEditControlsViewModel.IsSnapToGridChecked): ReactToSnapToGridChecedChange(); break; } }