/// <summary> /// Sets scroll and zoom so that the largest axis of the given rectangle almost /// fills the client area</summary> /// <param name="adapter">Adapter managing transform</param> /// <param name="itemBounds">Rectangle to frame, in client coordinates</param> /// <param name="clientBounds">Client area</param> public static void Frame(this ITransformAdapter adapter, Rect itemBounds, Rect clientBounds) { if (adapter == null || itemBounds.IsEmpty || !adapter.Transform.HasInverse) { return; } Rect worldBounds = MathUtil.InverseTransform(adapter.Transform, itemBounds); // calculate scale so bounding rectangle (in world coordinates) fills client // rectangle with some margin around the edges const double MarginScale = 0.86; Point scale = new Point( Math.Abs(clientBounds.Width / worldBounds.Width) * MarginScale, Math.Abs(clientBounds.Height / worldBounds.Height) * MarginScale); if (adapter.UniformScale) { scale.X = scale.Y = Math.Min(scale.X, scale.Y); } scale = TransformAdapters.ConstrainScale(adapter, scale); // calculate translation needed to put bounds center at center of view Point worldBoundsCenter = new Point( worldBounds.X + worldBounds.Width / 2, worldBounds.Y + worldBounds.Height / 2); Point translation = new Point( clientBounds.Width / 2 - worldBoundsCenter.X * scale.X, clientBounds.Height / 2 - worldBoundsCenter.Y * scale.Y); adapter.SetTransform(scale.X, scale.Y, translation.X, translation.Y); }
/// <summary> /// Sets scroll and zoom to center the given rectangle in the client area with a given scale</summary> /// <param name="adapter">Adapter managing transform</param> /// <param name="scale">Scale</param> /// <param name="itemBounds">Rectangle to frame, in client coordinates</param> /// <param name="clientBounds">Client area</param> public static void ZoomAboutCenter(this ITransformAdapter adapter, Point scale, Rect itemBounds, Rect clientBounds) { if (adapter == null || !adapter.Transform.HasInverse) { return; } Rect worldBounds = MathUtil.InverseTransform(adapter.Transform, itemBounds); if (adapter.UniformScale) { scale.X = scale.Y = Math.Min(scale.X, scale.Y); } scale = TransformAdapters.ConstrainScale(adapter, scale); // calculate translation needed to put bounds center at center of view Point worldBoundsCenter = new Point( worldBounds.X + worldBounds.Width / 2, worldBounds.Y + worldBounds.Height / 2); Point translation = new Point( clientBounds.Width / 2 - worldBoundsCenter.X * scale.X, clientBounds.Height / 2 - worldBoundsCenter.Y * scale.Y); adapter.SetTransform(scale.X, scale.Y, translation.X, translation.Y); }
/// <summary> /// Constructor</summary> /// <param name="renderer">Graph renderer to draw and hit-test graph</param> /// <param name="transformAdapter">Transform adapter</param> public D2dGraphAdapter(D2dGraphRenderer <TNode, TEdge, TEdgeRoute> renderer, ITransformAdapter transformAdapter) { m_renderer = renderer; m_renderer.Redraw += renderer_Redraw; EdgeRenderPolicy = DrawEdgePolicy.AllFirst; }
/// <summary> /// Constructor</summary> /// <param name="renderer">Graph renderer to draw and hit-test graph</param> /// <param name="transformAdapter">Transform adapter</param> public D2dGraphAdapter(D2dGraphRenderer <TNode, TEdge, TEdgeRoute> renderer, ITransformAdapter transformAdapter) { m_renderer = renderer; m_renderer.Redraw += renderer_Redraw; m_renderer.GetStyle = GetStyle; }
/// <summary> /// Constructor</summary> /// <param name="transformAdapter">Transform adapter</param> public AutoTranslateAdapter(ITransformAdapter transformAdapter) { m_transformAdapter = transformAdapter; m_timer = new Timer(); m_timer.Interval = 10; m_timer.Tick += timer_Tick; }
/// <summary> /// Constructor</summary> /// <param name="transformAdapter">Transform adapter</param> public AutoTranslateAdapter(ITransformAdapter transformAdapter) { m_transformAdapter = transformAdapter; m_timer = new Timer(); m_timer.Interval = 10; m_timer.Tick += timer_Tick; }
/// <summary> /// Constructor</summary> /// <param name="renderer">Graph renderer, to draw and hit-test graph</param> /// <param name="transformAdapter">Transform adapter</param> public GraphAdapter( GraphRenderer <TNode, TEdge, TEdgeRoute> renderer, ITransformAdapter transformAdapter) { m_renderer = renderer; m_renderer.Redraw += new EventHandler(renderer_Redraw); m_transformAdapter = transformAdapter; }
/// <summary> /// Called to prepare the Direct2D graphics device for drawing, including clearing the back buffer /// render target and initializing the Transform property of the D2dGraphics instance.</summary> protected virtual void OnBeginDrawD2d() { D2dGraphics.BeginDraw(); ITransformAdapter xform = this.As <ITransformAdapter>(); D2dGraphics.Transform = xform == null ? Matrix3x2F.Identity : xform.Transform; D2dGraphics.Clear(BackColor); D2dGraphics.AntialiasMode = D2dAntialiasMode.Aliased; }
/// <summary> /// Constructor</summary> /// <param name="renderer">Graph renderer</param> /// <param name="graphAdapter">Graph adapter</param> /// <param name="transformAdapter">Transform adapter</param> public D2dGraphEdgeEditAdapter( D2dGraphRenderer <TNode, TEdge, TEdgeRoute> renderer, D2dGraphAdapter <TNode, TEdge, TEdgeRoute> graphAdapter, ITransformAdapter transformAdapter) { m_renderer = renderer; m_graphAdapter = graphAdapter; m_draggingContext = new EdgeDraggingContext(this); }
/// <summary> /// Constructor</summary> /// <param name="renderer">Graph renderer</param> /// <param name="graphAdapter">Graph adapter</param> /// <param name="transformAdapter">Transform adapter</param> public D2dGraphNodeEditAdapter( D2dGraphRenderer <TNode, TEdge, TEdgeRoute> renderer, D2dGraphAdapter <TNode, TEdge, TEdgeRoute> graphAdapter, ITransformAdapter transformAdapter) { m_renderer = renderer; m_graphAdapter = graphAdapter; m_transformAdapter = transformAdapter; }
/// <summary> /// Constrains translation to the adapter's MinTranslation and MaxTranslation property /// constraints</summary> /// <param name="adapter">Transform adapter</param> /// <param name="translation">Desired translation</param> /// <returns>Translation constrained to the adapter's limits</returns> public static Point ConstrainTranslation(this ITransformAdapter adapter, Point translation) { Point minTranslation = adapter.MinTranslation; Point maxTranslation = adapter.MaxTranslation; return(new Point( Math.Max(minTranslation.X, Math.Min(maxTranslation.X, translation.X)), Math.Max(minTranslation.Y, Math.Min(maxTranslation.Y, translation.Y)))); }
public void transform(ITransformAdapter newForm) { var newNumber = newForm.newNumber(tipo1, tipo2); this.hp = (hp + newNumber) * 10.0; this.attack = (attack + newNumber) * 3.0; this.defese = (defese + newNumber) * 2.0; this.specialAttack = (specialAttack + newNumber) * 2.0; this.specialDefese = (specialDefese + newNumber) * 3.0; this.speed = (speed + newNumber) * 1.0; }
public void baseform(ITransformAdapter newForm) { var newNumber = newForm.newNumber(tipo1, tipo2); this.hp = (hp / 10.0) - newNumber; this.attack = (attack / 3.0) - newNumber; this.defese = (defese / 2.0) - newNumber; this.specialAttack = (specialAttack / 2.0) - newNumber; this.specialDefese = (specialDefese / 3.0) - newNumber; this.speed = (speed / 1.0) - newNumber; }
/// <summary> /// If the given rectangle isn't visible, sets scroll and scale so that the largest axis /// of the rectangle almost fills the client area</summary> /// <param name="adapter">Adapter managing transform</param> /// <param name="itemBounds">Rectangle to ensure visible</param> /// <param name="clientBounds">Client area</param> public static void EnsureVisible(this ITransformAdapter adapter, Rect itemBounds, Rect clientBounds) { // check rectangle is already in the visible rect if (clientBounds.Contains(itemBounds)) { // already visible return; } TransformAdapters.Frame(adapter, itemBounds, clientBounds); }
/// <summary> /// If the given rectangle isn't visible, sets scroll and scale so that the largest axis /// of the rectangle almost fills the client area</summary> /// <param name="adapter">Adapter managing transform</param> /// <param name="bounds">Rectangle to make visible, in Windows client coordinates</param> public static void EnsureVisible(this ITransformAdapter adapter, RectangleF bounds) { // check rectangle is already in the visible rect RectangleF clientRect = adapter.AdaptedControl.ClientRectangle; if (clientRect.Contains(bounds)) { // already visible return; } adapter.Frame(bounds); }
/// <summary> /// Constructor</summary> /// <param name="renderer">Graph renderer</param> /// <param name="graphAdapter">Graph adapter</param> /// <param name="transformAdapter">Transform adapter</param> public D2dGraphEdgeEditAdapter( D2dGraphRenderer <TNode, TEdge, TEdgeRoute> renderer, D2dGraphAdapter <TNode, TEdge, TEdgeRoute> graphAdapter, ITransformAdapter transformAdapter) { m_renderer = renderer; m_graphAdapter = graphAdapter; m_draggingContext = new EdgeDraggingContext(this); OverRouteCursor = Cursors.Cross; FromPlaceCursor = Cursors.PanWest; ToPlaceCursor = Cursors.PanEast; InadmissibleCursor = Cursors.Cross; }
/// <summary> /// Constrains scale to the adapter's MinScale, MaxScale, and UniformScale property /// constraints</summary> /// <param name="adapter">Transform adapter</param> /// <param name="scale">Desired scale</param> /// <returns>Scale, constrained to the adapter's limits</returns> public static Point ConstrainScale(this ITransformAdapter adapter, Point scale) { Point minScale = adapter.MinScale; Point maxScale = adapter.MaxScale; if (adapter.UniformScale) { scale.X = scale.Y = Math.Max(scale.X, scale.Y); } return(new Point( Math.Max(minScale.X, Math.Min(maxScale.X, scale.X)), Math.Max(minScale.Y, Math.Min(maxScale.Y, scale.Y)))); }
/// <summary> /// Pans the view the minimum necessary so that the given rectangle is visible</summary> /// <param name="adapter">Adapter managing transform</param> /// <param name="bounds">Rectangle to make visible, in Windows client coordinates</param> public static void PanToRect(this ITransformAdapter adapter, RectangleF bounds) { RectangleF clientRect = adapter.AdaptedControl.ClientRectangle; if (clientRect.IsEmpty) { return; } float dx; if (bounds.Right > clientRect.Right) { dx = bounds.Right - clientRect.Right; } else if (bounds.Left < clientRect.Left) { dx = bounds.Left - clientRect.Left; } else { dx = 0; } float dy; if (bounds.Bottom > clientRect.Bottom) { dy = bounds.Bottom - clientRect.Bottom; } else if (bounds.Top < clientRect.Top) { dy = bounds.Top - clientRect.Top; } else { dy = 0; } if (dx == 0 && dy == 0) { return; // already visible } PointF currentTranslation = adapter.Translation; adapter.Translation = new PointF( currentTranslation.X - dx, currentTranslation.Y - dy); }
/// <summary> /// Constructor</summary> /// <param name="transformAdapter">Transform adapter</param> /// <param name="canvasAdapter">Canvas adapter</param> public ScrollbarAdapter(ITransformAdapter transformAdapter, ICanvasAdapter canvasAdapter) { m_transformAdapter = transformAdapter; m_transformAdapter.TransformChanged += transformAdapter_TransformChanged; m_canvasAdapter = canvasAdapter; m_canvasAdapter.BoundsChanged += canvasAdapter_BoundsChanged; m_canvasAdapter.WindowBoundsChanged += canvasAdapter_WindowBoundsChanged; m_vScrollBar = new VScrollBar(); m_vScrollBar.Dock = DockStyle.Right; m_vScrollBar.ValueChanged += vScrollBar_ValueChanged; m_hScrollBar = new HScrollBar(); m_hScrollBar.Dock = DockStyle.Bottom; m_hScrollBar.ValueChanged += hScrollBar_ValueChanged; }
/// <summary> /// Constructor</summary> /// <param name="transformAdapter">Transform adapter</param> /// <param name="canvasAdapter">Canvas adapter</param> public ScrollbarAdapter(ITransformAdapter transformAdapter, ICanvasAdapter canvasAdapter) { m_transformAdapter = transformAdapter; m_transformAdapter.TransformChanged += transformAdapter_TransformChanged; m_canvasAdapter = canvasAdapter; m_canvasAdapter.BoundsChanged += canvasAdapter_BoundsChanged; m_canvasAdapter.WindowBoundsChanged += canvasAdapter_WindowBoundsChanged; m_vScrollBar = new VScrollBar(); m_vScrollBar.Dock = DockStyle.Right; m_vScrollBar.ValueChanged += vScrollBar_ValueChanged; m_hScrollBar = new HScrollBar(); m_hScrollBar.Dock = DockStyle.Bottom; m_hScrollBar.ValueChanged += hScrollBar_ValueChanged; }
/// <summary> /// Pans the view the minimum necessary so that the given rectangle is visible</summary> /// <param name="adapter">Adapter managing transform</param> /// <param name="bounds">Rectangle to make visible, in Windows client coordinates</param> /// <param name="clientRect">Rectangle to make visible, in Windows client coordinates</param> public static void PanToRect(this ITransformAdapter adapter, Rect bounds, Rect clientRect) { if (clientRect.IsEmpty) { return; } double dx; if (bounds.Right > clientRect.Right) { dx = bounds.Right - clientRect.Right; } else if (bounds.Left < clientRect.Left) { dx = bounds.Left - clientRect.Left; } else { dx = 0; } double dy; if (bounds.Bottom > clientRect.Bottom) { dy = bounds.Bottom - clientRect.Bottom; } else if (bounds.Top < clientRect.Top) { dy = bounds.Top - clientRect.Top; } else { dy = 0; } if (dx == 0 && dy == 0) { return; // already visible } var currentTranslation = adapter.Translation; adapter.Translation = new Point(currentTranslation.X - dx, currentTranslation.Y - dy); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Font font = m_columnHeadersAdapter.AdaptedControl.Font; Graphics g = e.Graphics; int x = 0; ITransformAdapter transformAdapter = m_columnHeadersAdapter.m_transformAdapter; if (transformAdapter != null) { x = (int)transformAdapter.Transform.OffsetX; } int rowHeight = m_columnHeadersAdapter.AdaptedControl.Font.Height; int xPadding = Margin.Left; int yPadding = Margin.Top; // draw column headers int left = x; foreach (ColumnInfo info in m_columnHeadersAdapter.m_columns) { int width = info.Width; int right = left + width; ControlPaint.DrawBorder3D(g, left, 0, width, rowHeight, Border3DStyle.Etched, Border3DSide.Bottom | Border3DSide.Right); Rectangle textRect = new Rectangle(left, 0, width, rowHeight); textRect.Width -= SortDirectionIndicatorWidth + xPadding; Sce.Atf.GdiUtil.DrawSortDirectionIndicator( textRect.Right + xPadding, rowHeight / 2 - 1 - Sce.Atf.GdiUtil.SortDirectionIndicatorHeight / 2, info.SortDirection == ListSortDirection.Descending, g); string text = "foo"; g.DrawString(text, m_columnHeadersAdapter.AdaptedControl.Font, SystemBrushes.ControlText, textRect, LeftStringFormat); left += width; } }
private void SetCanvasBounds() { // update the control CanvasAdapter's bounds if (m_control != null && m_control.Visible) { Rectangle bounds = GetBounds(); ITransformAdapter transformAdapter = m_control.As <ITransformAdapter>(); bounds = GdiUtil.InverseTransform(transformAdapter.Transform, bounds); // make canvas twice as large as it needs to be to give the user some room, // or at least as large as the control's client area. Rectangle clientRect = m_control.ClientRectangle; bounds.Width = Math.Max(bounds.Width * 2, clientRect.Width); bounds.Height = Math.Max(bounds.Height * 2, clientRect.Height); ICanvasAdapter canvasAdapter = m_control.As <ICanvasAdapter>(); canvasAdapter.Bounds = new Rectangle(0, 0, bounds.Right, bounds.Bottom); } }
/// <summary> /// Sets scroll and zoom so that the largest axis of the given rectangle almost /// fills the client area</summary> /// <param name="adapter">Adapter managing transform</param> /// <param name="bounds">Rectangle to frame, in Windows client coordinates</param> public static void Frame(this ITransformAdapter adapter, RectangleF bounds) { if (bounds.IsEmpty) { return; } RectangleF worldBounds = GdiUtil.InverseTransform(adapter.Transform, bounds); // calculate scale so bounding rectangle (in world coordinates) fills client // rectangle with some margin around the edges RectangleF clientRect = adapter.AdaptedControl.ClientRectangle; const float MarginScale = 0.86f; PointF scale = new PointF( Math.Abs(clientRect.Width / worldBounds.Width) * MarginScale, Math.Abs(clientRect.Height / worldBounds.Height) * MarginScale); if (adapter.UniformScale) { scale.X = scale.Y = Math.Min(scale.X, scale.Y); } scale = adapter.ConstrainScale(scale); // calculate translation needed to put bounds center at center of view PointF worldBoundsCenter = new PointF( worldBounds.X + worldBounds.Width / 2, worldBounds.Y + worldBounds.Height / 2); PointF translation = new PointF( clientRect.Width / 2 - worldBoundsCenter.X * scale.X, clientRect.Height / 2 - worldBoundsCenter.Y * scale.Y); adapter.SetTransform( scale.X, scale.Y, translation.X, translation.Y); }
/// <summary> /// Constructor</summary> /// <param name="transformAdapter">Transform adapter</param> public MouseWheelManipulator(ITransformAdapter transformAdapter) { m_transformAdapter = transformAdapter; }
/// <summary> /// Sets the transform to the given matrix; rotation and skew are ignored</summary> /// <param name="transformAdapter">Adapter managing transform</param> /// <param name="transform">Transformation matrix</param> public static void SetTransform(this ITransformAdapter transformAdapter, Matrix transform) { transformAdapter.SetTransform(transform.M11, transform.M22, transform.OffsetX, transform.OffsetY); }
public Func<ICircuitElement, int, bool, int> GetPinOffset; // callback to compute group pin y offset /// <summary> /// Constructor</summary> /// <param name="transformAdapter">Transform adapter</param> public GroupPinEditor(ITransformAdapter transformAdapter) { m_transformAdapter = transformAdapter; }
/// <summary> /// Sets the transform to the given matrix; rotation and skew are /// ignored</summary> /// <param name="transformAdapter">Adapter managing transform</param> /// <param name="transform">Transformation matrix, from world to Window client coordinates</param> public static void SetTransform(this ITransformAdapter transformAdapter, Matrix transform) { float[] m = transform.Elements; transformAdapter.SetTransform(m[0], m[3], m[4], m[5]); }
/// <summary> /// Constructor</summary> /// <param name="renderer">Graph renderer to draw and hit-test graph</param> /// <param name="transformAdapter">Transform adapter</param> public D2dSubgraphAdapter(D2dSubCircuitRenderer <TNode, TEdge, TEdgeRoute> renderer, ITransformAdapter transformAdapter) : base(renderer, transformAdapter) { m_renderer = renderer; m_transformAdapter = transformAdapter; }
/// <summary> /// Constructor</summary> /// <param name="transformAdapter">ITransformAdapter</param> public MouseLayoutManipulator(ITransformAdapter transformAdapter) { m_transformAdapter = transformAdapter; }
/// <summary> /// Transforms transform point to client coordinates</summary> /// <param name="adapter">Adapter managing transform</param> /// <param name="x">Point in transform coordinates</param> /// <returns>Point in client coordinates</returns> public static Point TransformToClient(this ITransformAdapter adapter, Point x) { return(MathUtil.Transform(adapter.Transform, x)); }
/// <summary> /// Transforms client point to transform coordinates</summary> /// <param name="adapter">Adapter managing transform</param> /// <param name="x">Point, in client coordinates</param> /// <returns>Point in transform coordinates</returns> public static Point ClientToTransform(this ITransformAdapter adapter, Point x) { return(MathUtil.InverseTransform(adapter.Transform, x)); }
/// <summary> /// Constructor</summary> /// <param name="transformAdapter">Transform adapter</param> public MouseWheelManipulator(ITransformAdapter transformAdapter) { m_transformAdapter = transformAdapter; }
/// <summary> /// Constructor</summary> /// <param name="transformAdapter">Transform adapter</param> public ViewingAdapter(ITransformAdapter transformAdapter) { m_transformAdapter = transformAdapter; }
/// <summary> /// Constructor</summary> /// <param name="transformAdapter">ITransformAdapter</param> public MouseLayoutManipulator(ITransformAdapter transformAdapter) { m_transformAdapter = transformAdapter; }
/// <summary> /// Constructor</summary> /// <param name="transformAdapter">Transform adapter</param> public ViewingAdapter(ITransformAdapter transformAdapter) { m_transformAdapter = transformAdapter; }