public void QueueRotate(ObjectInstance inst, Point oldLocation, Point newLocation, float oldRotation, float newRotation) { _objects.Add(new ObjectRecord() { Instance = inst, OldLocation = oldLocation, NewLocation = newLocation, OldRotation = oldRotation, NewRotation = newRotation, }); }
public void QueueMove(ObjectInstance inst, int diffX, int diffY) { _objects.Add(new ObjectRecord() { Instance = inst, OldLocation = new Point(inst.X, inst.Y), NewLocation = new Point(inst.X + diffX, inst.Y + diffY), OldRotation = inst.Rotation, NewRotation = inst.Rotation, }); }
public ObjectInstance(ObjectInstance inst) : this(inst._class, inst._posX, inst._posY) { _rotation = inst._rotation; _scaleX = inst._scaleX; _scaleY = inst._scaleY; foreach (Property prop in inst.PropertyManager.CustomProperties) { PropertyManager.CustomProperties.Add(prop.Clone() as Property); } UpdateBounds(); }
public ObjectAddCommand(ObjectLayer source, ObjectInstance inst, ObjectSelectionManager selectionManager) : this(source, selectionManager) { _objects.Add(inst); }
private bool TestOrigin(Rectangle region, ObjectInstance instance) { return instance.X >= region.Left && instance.X <= region.Right && instance.Y >= region.Top && instance.Y <= region.Bottom; }
private bool TestMaskBounds(Rectangle region, ObjectInstance instance) { Rectangle bounds = instance.MaskBounds; return bounds.Left >= region.Left && bounds.Right <= region.Right && bounds.Top >= region.Top && bounds.Bottom <= region.Bottom; }
public ObjectInstanceEventArgs(ObjectInstance inst) { Instance = inst; }
public int ObjectIndex(ObjectInstance inst) { return _objects.IndexOf(inst); }
public void MoveObjectToFront(ObjectInstance instance) { if (_objects.MoveItem(instance, _objects.Count - 1)) OnObjectReordered(new ObjectInstanceEventArgs(instance)); }
private ToolState StartClickNew(PointerEventInfo info, ILevelGeometry viewport, ObjectInstance obj) { Tool._selectionManager.ClearSelection(); return StartClickAdd(info, viewport, obj); }
private ToolState StartClickAdd(PointerEventInfo info, ILevelGeometry viewport, ObjectInstance obj) { Tool._selectionManager.AddObjectToSelection(obj); Tool.StartAutoScroll(info, viewport); Tool.UpdatePropertyProvider(); return new SelectionMovingToolState(Tool) { InitialLocation = new Point((int)info.X, (int)info.Y), InitialSnapLocation = new Point(obj.X, obj.Y), SnapManager = Tool.GetSnappingManager(obj.ObjectClass), }.StartPointerSequence(info, viewport); }
public SelectionRotatingToolState(ObjectSelectTool tool, ObjectInstance hitObject) : base(tool) { HitObject = hitObject; InitialPosition = hitObject.Position; InitialCenter = hitObject.ImageBounds.Center; InitialAngle = hitObject.Rotation; float radius = Tool.MaxBoundingDiagonal(HitObject) / 2 + 5; Annot = new CircleAnnot(HitObject.ImageBounds.Center, radius); Annot.Outline = Outline; Annot.OutlineGlow = OutlineGlow; Tool._annots.Add(Annot); }
private float MaxBoundingDiagonal(ObjectInstance inst) { int maxDim = Math.Max(inst.ObjectClass.ImageBounds.Width, inst.ObjectClass.ImageBounds.Height); float diag1 = (float)Math.Sqrt(maxDim * maxDim * 2); float diag2 = (float)Math.Sqrt(diag1 * diag1 * 2); return diag2; }
public static LevelX.ObjectInstanceX ToXProxy(ObjectInstance inst) { if (inst == null) return null; List<CommonX.PropertyX> props = new List<CommonX.PropertyX>(); foreach (Property prop in inst.PropertyManager.CustomProperties) props.Add(Property.ToXmlProxyX(prop)); return new LevelX.ObjectInstanceX() { Uid = inst.Uid, Class = inst.ObjectClass.Uid, X = inst.X, Y = inst.Y, Rotation = MathEx.RadToDeg(inst.Rotation), Properties = (props.Count > 0) ? props : null, }; }
public void QueueAdd(ObjectInstance inst) { _objects.Add(inst); }
public void MoveObjectForward(ObjectInstance instance) { if (_objects.IndexOf(instance) < _objects.Count - 1) { _objects.MoveItemBy(instance, 1); OnObjectReordered(new ObjectInstanceEventArgs(instance)); } }
public void MoveObjectToBack(ObjectInstance instance) { if (_objects.MoveItem(instance, 0)) OnObjectReordered(new ObjectInstanceEventArgs(instance)); }
private ToolState StartClickRemove(PointerEventInfo info, ILevelGeometry viewport, ObjectInstance obj) { Tool._selectionManager.RemoveObjectFromSelection(obj); Tool.StartAutoScroll(info, viewport); Tool.UpdatePropertyProvider(); return new SelectionStandbyToolState(Tool).StartPointerSequence(info, viewport); }
public void MoveToIndex(ObjectInstance inst, int index) { _objects.MoveItem(inst, index); }
private ToolState StartTimeoutSequence(PointerEventInfo info, ILevelGeometry viewport, ObjectInstance obj) { return new SelectionTimeoutToolState(Tool) { HitObject = obj }.StartPointerSequence(info, viewport); }
public void RemoveObject(ObjectInstance instance) { if (_objects.Remove(instance)) { instance.Modified -= ObjectInst_Modified; OnObjectRemoved(new ObjectInstanceEventArgs(instance)); } }
public bool IsObjectSelected(ObjectInstance obj) { foreach (SelectedObjectRecord record in _selectedObjects) { if (record.Instance == obj) return true; } return false; }
private bool TestMaskAtPoint(Point point, ObjectInstance instance) { Rectangle bounds = instance.MaskBounds; return bounds.Left <= point.X && bounds.Right > point.X && bounds.Top <= point.Y && bounds.Bottom > point.Y; }
public void RemoveObjectFromSelection(ObjectInstance obj) { foreach (SelectedObjectRecord record in _selectedObjects) { if (record.Instance == obj) { RemoveAnnotation(record.Annot); RemoveAnnotation(record.OriginAnnot); _selectedObjects.Remove(record); obj.PositionChanged -= InstancePositionChanged; obj.RotationChanged -= InstanceRotationChanged; break; } } OnSelectionChanged(EventArgs.Empty); //if (_selectedObjects.Count == 0) { // CommandManager.Invalidate(CommandKey.Delete); // CommandManager.Invalidate(CommandKey.SelectNone); //} }
private bool TestMaskBoundsPartial(Rectangle region, ObjectInstance instance) { Rectangle bounds = instance.MaskBounds; return bounds.Right > region.Left && bounds.Left < region.Right && bounds.Bottom > region.Top && bounds.Top < region.Bottom; }
public void AddObjectToSelection(ObjectInstance obj) { foreach (SelectedObjectRecord instRecord in _selectedObjects) if (instRecord.Instance == obj) return; SelectedObjectRecord record = new SelectedObjectRecord() { Instance = obj, Annot = new SelectionAnnot(obj.ImageBounds.Location) { End = new Point(obj.ImageBounds.Right, obj.ImageBounds.Bottom), Fill = SelectedAnnotFill, Outline = SelectedAnnotOutline, OutlineGlow = SelectedAnnotOutlineGlow, }, OriginAnnot = new GripAnnot(obj.Position, 3) { Fill = SelectedAnnotOriginFill, FillGlow = SelectedAnnotOriginFillGlow, }, InitialLocation = new Point(obj.X, obj.Y), }; obj.PositionChanged += InstancePositionChanged; obj.RotationChanged += InstanceRotationChanged; _selectedObjects.Add(record); AddAnnotation(record.Annot); AddAnnotation(record.OriginAnnot); OnSelectionChanged(EventArgs.Empty); }
public ObjectMoveCommand(ObjectInstance inst, int diffX, int diffY) : this() { QueueMove(inst, diffX, diffY); }
public void AddObject(ObjectInstance instance) { if (!_objects.Contains(instance)) { _objects.Add(instance); instance.Modified += ObjectInst_Modified; OnObjectAdded(new ObjectInstanceEventArgs(instance)); } }
public void MoveObjectBackward(ObjectInstance instance) { if (_objects.IndexOf(instance) > 1) { _objects.MoveItemBy(instance, -1); OnObjectReordered(new ObjectInstanceEventArgs(instance)); } }
public ObjectAddCommand(ObjectLayer source, ObjectInstance inst) : this(source) { _objects.Add(inst); }