public void Apply(IShapeObject target) { if (target is T selection) { ApplyParam(selection); } }
public void MouseMove(Point newPosition) { switch (currentState) { case State.Free: { IShapeObject hit = GetHit(newPosition); if (shapeStrategy.Target != hit) { shapeStrategy.Target?.MouseLeave(); shapeStrategy.Target = hit; } shapeStrategy.MouseMove(newPosition); } break; case State.HostCapture: { var movePoint = newPosition - mouseOffset; scene.Host.Position = movePoint; } break; case State.ShapeCapture: { shapeStrategy.MouseMove(newPosition); } break; default: break; } }
public void SelectShape(IShapeObject selection, bool canProcess) { canProcessSelection = canProcess; this.selection = selection; IsShow = Param.CanApply(selection); RaisePropertyChanged(nameof(IsShow)); }
public void AddShape(IShapeObject shapeObject, ShapeTool tool) { var visual = shapeObject.Shape; ShapeTool.SetShapeObject(visual, shapeObject); ShapeTool.SetShapeCreate(visual, tool); scene.Host.Paint(visual); }
public Dictionary <string, object> Serialize(IShapeObject shape) { shape = shape ?? throw new ArgumentNullException(nameof(shape)); var shapeType = shape.GetType(); var shapeProperty = propertyCache.GetProperties(shapeType); var result = shapeProperty.Values.ToDictionary(k => k.PropName, v => v.Getter.DynamicInvoke(shape)); return(result); }
public void Deserialize(IShapeObject shape, Dictionary <string, object> shapeState) { shape = shape ?? throw new ArgumentNullException(nameof(shape)); var shapeType = shape.GetType(); var props = propertyCache.GetProperties(shapeType); foreach ((string propName, object value) in shapeState) { props[propName].Setter.DynamicInvoke(shape, value); } }
public bool CanApply(IShapeObject target) { return(target is T); }
public Dictionary <string, object> Serialize(IShapeObject shape) { return(creator.Serialize(shape)); }
public static void SetShapeObject(DependencyObject obj, IShapeObject value) { obj.SetValue(ShapeObjectProperty, value); }