コード例 #1
0
        public SpriteBordersViewModel(SpriteInfoViewModel sprite, IObjectNode spriteNode)
            : base(sprite)
        {
            textureRegionNode = spriteNode[nameof(SpriteInfo.TextureRegion)];
            textureRegionNode.ValueChanged += OnTextureRegionValueChanged;

            var spriteBordersNode = spriteNode[nameof(SpriteInfo.Borders)];

            borderBinding = new MemberGraphNodeBinding <Vector4>(spriteBordersNode, nameof(Borders), OnPropertyChanging, OnPropertyChanged, UndoRedoService);

            DependentProperties.Add(nameof(Borders), new[] { nameof(ActualBorders) });
            DependentProperties.Add(nameof(ScaleFactor), new[] { nameof(ActualBorders) });
        }
コード例 #2
0
        public TextureRegionViewModel(SpriteInfoViewModel sprite, IMemberNode textureRegionNode)
            : base(sprite)
        {
            if (sprite.Editor.Cache != null)
            {
                RefreshImageSize();
            }
            else
            {
                sprite.Editor.Initialized += EditorInitialized;
            }
            textureRegionBinding = new MemberGraphNodeBinding <RectangleF, Rectangle>(textureRegionNode, nameof(Region), OnPropertyChanging, OnPropertyChanged, x => (Rectangle)x, UndoRedoService);

            DependentProperties.Add(nameof(Region), new[] { nameof(ActualLeft), nameof(ActualTop), nameof(ActualWidth), nameof(ActualHeight), nameof(ActualRightOffset), nameof(ActualBottomOffset) });
            DependentProperties.Add(nameof(ScaleFactor), new[] { nameof(ActualLeft), nameof(ActualTop), nameof(ActualWidth), nameof(ActualHeight), nameof(ActualRightOffset), nameof(ActualBottomOffset) });
            DependentProperties.Add(nameof(ImageWidth), new[] { nameof(ActualRightOffset), nameof(ActualBottomOffset) });
            DependentProperties.Add(nameof(ImageHeight), new[] { nameof(ActualRightOffset), nameof(ActualBottomOffset) });
        }
コード例 #3
0
        public SpriteCenterViewModel(SpriteInfoViewModel sprite, IObjectNode spriteNode)
            : base(sprite)
        {
            var spriteCenterNode = spriteNode[nameof(SpriteInfo.Center)];

            spriteCenterNodeBinding = new MemberGraphNodeBinding <Vector2>(spriteCenterNode, nameof(Center), OnPropertyChanging, OnPropertyChanged, UndoRedoService);
            var centerFromMiddleNode = spriteNode[nameof(SpriteInfo.CenterFromMiddle)];

            centerFromMiddleBinding = new MemberGraphNodeBinding <bool>(centerFromMiddleNode, nameof(CenterFromMiddle), OnPropertyChanging, OnPropertyChanged, UndoRedoService);

            var textureRegionNode = spriteNode[nameof(SpriteInfo.TextureRegion)];

            textureRegionBinding = new MemberGraphNodeBinding <Rectangle>(textureRegionNode, nameof(ActualCenter), OnPropertyChanging, OnPropertyChanged, UndoRedoService);

            DependentProperties.Add(nameof(Center), new[] { nameof(ActualCenter) });
            DependentProperties.Add(nameof(CenterFromMiddle), new[] { nameof(ActualCenter) });
            DependentProperties.Add(nameof(ScaleFactor), new[] { nameof(ActualCenter) });
        }
コード例 #4
0
 protected ResizableSpriteInfoPartViewModel(SpriteInfoViewModel sprite)
     : base(sprite)
 {
     Sprite.Editor.Viewport.PropertyChanged += ViewportPropertyChanged;
     scaleFactor = sprite.Editor.Viewport.ScaleFactor;
 }
コード例 #5
0
 public SpriteInfoPartViewModel(SpriteInfoViewModel sprite)
     : base(sprite.SafeArgument(nameof(sprite)).ServiceProvider)
 {
     Sprite = sprite;
 }