コード例 #1
0
 private void execute()
 {
     Property.Value = Value;
     if (Property.Component != null)
     {
         List <IProperty> propertyChain = Property.Parent == null ? null : getPropertyChain(Property);
         _undoModel = ModelAction.Execute(_model, (Property.Component, Property.Name, Value, propertyChain));
     }
     else if (Property.Name == nameof(IEntity.DisplayName) && Property.Object is IEntity entity)
     {
         var entityModel = ModelAction.GetEntity(entity, _model);
         Trace.Assert(entityModel != null);
         var oldDisplayName = entityModel.DisplayName;
         entityModel.DisplayName = Value?.Value as string;
         _undoModel = () => entity.DisplayName = oldDisplayName;
     }
     else if (Property.Object is IGameSettings settings)
     {
         PropertyInfo modelProperty = _model.Settings.GetType().GetProperty(Property.Name);
         Trace.Assert(modelProperty != null);
         var oldValue = modelProperty.GetValue(_model.Settings);
         modelProperty.SetValue(_model.Settings, Property.Value.Value);
         _undoModel = () => modelProperty.SetValue(_model.Settings, oldValue);
     }
     else
     {
         Debug.WriteLine($"No component associated with property {Property.DisplayName} of {Property.Object?.ToString() ?? "null"}, can't update model.");
     }
 }
コード例 #2
0
 private void execute()
 {
     Property.SetValue(Value);
     if (Property.Object is API.IComponent component)
     {
         _undoModel = ModelAction.Execute(_model, (component, Property.Name, Value));
     }
 }
コード例 #3
0
        private void execute()
        {
            var pivot    = new PointF(_toPivotX, _toPivotY);
            var position = new Position(_toX, _toY);

            _image.Pivot        = pivot;
            _translate.Position = position;
            _undoModel          = ModelAction.Execute(_model,
                                                      (_image, nameof(IImageComponent.Pivot), new ValueModel(pivot), null),
                                                      (_translate, nameof(ITranslateComponent.Position), new ValueModel(position), null));
        }