Download RadialDiagramDemoPart1.zip, last updated 05/11/2017 (11.38 KB)

Download
  • md5: 980240e651a010b143b573f01f46ab02
  • sha1: c26f00aaec5f56e9a27fcab7e796b8abe0b33e29
  • sha256: c209600f7368ebe7a0b63de229b0a5bde7efbe547f2387a6b61a34e35c034c66
// Arranging items radially around a central point using C#
// http://www.cyotek.com/blog/arranging-items-radially-around-a-central-point-using-csharp
// Copyright © 2017 Cyotek Ltd. All Rights Reserved.

// This work is licensed under the Creative Commons Attribution 4.0 International License.
// To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/.

using System.Collections.Generic;
using System.Drawing;

namespace Cyotek.Demo.RadialDiagram
{
  internal sealed class DiagramNode
  {
    #region Fields

    private Rectangle _bounds;

    private List<DiagramNode> _childNodes;

    private string _text;

    #endregion

    #region Constructors

    public DiagramNode()
    {
      _childNodes = new List<DiagramNode>();
    }

    public DiagramNode(string text)
      : this(text, Size.Empty)
    { }

    public DiagramNode(string text, Size size)
      : this()
    {
      _text = text;
      _bounds = new Rectangle(Point.Empty, size);
    }

    #endregion

    #region Properties

    public Rectangle Bounds
    {
      get { return _bounds; }
      set { _bounds = value; }
    }

    public Point Center
    {
      get { return new Point(_bounds.Left + _bounds.Width / 2, _bounds.Top + _bounds.Height / 2); }
    }

    public List<DiagramNode> ChildNodes
    {
      get { return _childNodes; }
      set { _childNodes = value; }
    }

    public int Height
    {
      get { return _bounds.Height; }
    }

    public int Left
    {
      get { return _bounds.Left; }
    }

    public Point Location
    {
      get { return _bounds.Location; }
      set { _bounds.Location = value; }
    }

    public Size Size
    {
      get { return _bounds.Size; }
      set { _bounds.Size = value; }
    }

    public string Text
    {
      get { return _text; }
      set { _text = value; }
    }

    public int Top
    {
      get { return _bounds.Top; }
    }

    public int Width
    {
      get { return _bounds.Width; }
    }

    #endregion
  }
}

Donate

Donate