private static void BoxItemOnChangeValue(DependencyObject source, DependencyPropertyChangedEventArgs e) { if (e != null) { CharacterView instance = source as CharacterView; String boxItem = (string)e.NewValue; instance._selectedRectItem = new BoundingBox(); if (instance._actor != null && String.IsNullOrEmpty(boxItem) == false && String.IsNullOrEmpty(instance.Animation) == false && String.IsNullOrEmpty(instance.Frame) == false && String.IsNullOrEmpty(instance.SelectedBoxType) == false) { instance._selectedBoundingBox = instance._actor.GetCurrentBoxes(instance._selectedBoxType)[Convert.ToInt32(boxItem) - 1]; instance._selectedRectItem.X = (int)Math.Round(instance._selectedBoundingBox.GetBaseOffset().X); instance._selectedRectItem.Y = (int)Math.Round(instance._selectedBoundingBox.GetBaseOffset().Y); instance._selectedRectItem.Width = instance._selectedBoundingBox.GetBaseRect().Width; instance._selectedRectItem.Height = instance._selectedBoundingBox.GetBaseRect().Height; instance._selectedBoundingBox.SetVisibility(1.0f); instance._actor.GetBodyBox().SetVisibility(0.4f); instance._actor.GetBoundsBox().SetVisibility(0.4f); instance._actor.GetDepthBox().SetVisibility(0.4f); for (int i = 0; i < instance._actor.GetAllFrameBoxes().Count; i++) { CLNS.BoundingBox box = instance._actor.GetAllFrameBoxes()[i]; if (box != instance._selectedBoundingBox) { box.SetVisibility(0.4f); } } } else { if (instance._actor != null) { instance._actor.GetBodyBox().SetVisibility(1.0f); instance._actor.GetBoundsBox().SetVisibility(1.0f); instance._actor.GetDepthBox().SetVisibility(1.0f); for (int i = 0; i < instance._actor.GetAllFrameBoxes().Count; i++) { CLNS.BoundingBox box = instance._actor.GetAllFrameBoxes()[i]; box.SetVisibility(1.0f); } } } instance.SelectedRectItem = instance._selectedRectItem; } }
private void RemoveBox() { if (_actor != null && string.IsNullOrEmpty(SelectedBoxType) == false && string.IsNullOrEmpty(SelectedBoxItem) == false && _selectedBoundingBox != null) { List <CLNS.BoundingBox> boxes = _actor.GetCurrentSprite().GetBaseBoxes()[_actor.GetCurrentSpriteFrame()]; boxes.Remove(_selectedBoundingBox); _selectedBoundingBox = null; DependencyPropertyChangedEventArgs args = new DependencyPropertyChangedEventArgs(BoxItemsProperty, null, SelectedBoxType); BoxTypeOnChangeValue(this, args); } }