Back to Devexpress

TreeMapLayoutAlgorithmBase.Direction Property

windowsforms-devexpress-dot-xtratreemap-dot-treemaplayoutalgorithmbase.md

latest7.4 KB
Original Source

TreeMapLayoutAlgorithmBase.Direction Property

Gets or sets the layout fill direction used by the algorithm.

Namespace : DevExpress.XtraTreeMap

Assembly : DevExpress.XtraTreeMap.v25.2.dll

NuGet Package : DevExpress.TreeMap

Declaration

csharp
[DefaultValue(TreeMapLayoutDirection.TopLeftToBottomRight)]
[XtraSerializableProperty]
public TreeMapLayoutDirection Direction { get; set; }
vb
<XtraSerializableProperty>
<DefaultValue(TreeMapLayoutDirection.TopLeftToBottomRight)>
Public Property Direction As TreeMapLayoutDirection

Property Value

TypeDefaultDescription
TreeMapLayoutDirectionTopLeftToBottomRight

A LayoutDirection enumeration value.

|

Available values:

NameDescription
TopLeftToBottomRight

Items are arranged from the top-left angle to the bottom-right corner.

| | BottomLeftToTopRight |

Items are arranged from the bottom-left angle to the top-right corner.

| | TopRightToBottomLeft |

Items are arranged from the top-right angle to the bottom-left corner.

| | BottomRightToTopLeft |

Items are arranged from the bottom-right angle to the top-left corner.

|

Remarks

For instance, for the LayoutDirection.TopLeftToBottomRight value, the largest tree map item will be arranged at the top left corner and the smallest item will be placed at the bottom right corner.

Example

To change the layout algorithm used by TreeMapControl, specify the TreeMapControl.LayoutAlgorithm property. For all default algorithms, you can configure the fill direction using the TreeMapLayoutAlgorithmBase.Direction.

csharp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LayoutAlgorithmCustomization {
    static class Program {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main() {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}
csharp
using DevExpress.XtraTreeMap;
using System;
using System.Windows.Forms;

namespace LayoutAlgorithmCustomization {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e) {
            InitializeLayoutAlgorithmListBox();
            InitializeLayoutDirectionListBox();
        }

        private void InitializeLayoutAlgorithmListBox() {
            lbLayoutAlgorithm.DataSource = new ITreeMapLayoutAlgorithm[] {
                new TreeMapSliceAndDiceLayoutAlgorithm(),
                new TreeMapSquarifiedLayoutAlgorithm(),
                new TreeMapStripedLayoutAlgorithm()
            };
        }

        private void InitializeLayoutDirectionListBox() {
            lbLayoutDirection.DataSource = Enum.GetValues(typeof(TreeMapLayoutDirection));
        }

        private void SetLayoutAlgorithm() {
            if(lbLayoutAlgorithm.SelectedValue == null) return;
            treeMap.LayoutAlgorithm = lbLayoutAlgorithm.SelectedValue as ITreeMapLayoutAlgorithm;
        }

        private void SetLayoutDirection() {
            if(lbLayoutDirection.SelectedValue == null) return;
            TreeMapLayoutAlgorithmBase layoutAlgorithm = treeMap.LayoutAlgorithm as TreeMapLayoutAlgorithmBase;
            layoutAlgorithm.Direction = (TreeMapLayoutDirection)lbLayoutDirection.SelectedValue;
        }

        private void lbLayoutAlgorithm_SelectedIndexChanged(object sender, EventArgs e) {
            SetLayoutAlgorithm();
            SetLayoutDirection();
        }

        private void lbLayoutDirection_SelectedIndexChanged(object sender, EventArgs e) {
            SetLayoutDirection();
        }
    }
}
vb
Imports DevExpress.XtraTreeMap
Imports System
Imports System.Windows.Forms

Namespace LayoutAlgorithmCustomization
    Partial Public Class Form1
        Inherits Form

        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
            InitializeLayoutAlgorithmListBox()
            InitializeLayoutDirectionListBox()
        End Sub

        Private Sub InitializeLayoutAlgorithmListBox()
            lbLayoutAlgorithm.DataSource = New ITreeMapLayoutAlgorithm() { _
                New TreeMapSliceAndDiceLayoutAlgorithm(), _
                New TreeMapSquarifiedLayoutAlgorithm(), _
                New TreeMapStripedLayoutAlgorithm() _
            }
        End Sub

        Private Sub InitializeLayoutDirectionListBox()
            lbLayoutDirection.DataSource = System.Enum.GetValues(GetType(TreeMapLayoutDirection))
        End Sub

        Private Sub SetLayoutAlgorithm()
            If lbLayoutAlgorithm.SelectedValue Is Nothing Then
                Return
            End If
            treeMap.LayoutAlgorithm = TryCast(lbLayoutAlgorithm.SelectedValue, ITreeMapLayoutAlgorithm)
        End Sub

        Private Sub SetLayoutDirection()
            If lbLayoutDirection.SelectedValue Is Nothing Then
                Return
            End If
            Dim layoutAlgorithm As TreeMapLayoutAlgorithmBase = TryCast(treeMap.LayoutAlgorithm, TreeMapLayoutAlgorithmBase)
            layoutAlgorithm.Direction = CType(lbLayoutDirection.SelectedValue, TreeMapLayoutDirection)
        End Sub

        Private Sub lbLayoutAlgorithm_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles lbLayoutAlgorithm.SelectedIndexChanged
            SetLayoutAlgorithm()
            SetLayoutDirection()
        End Sub

        Private Sub lbLayoutDirection_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles lbLayoutDirection.SelectedIndexChanged
            SetLayoutDirection()
        End Sub
    End Class
End Namespace
vb
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Threading.Tasks
Imports System.Windows.Forms

Namespace LayoutAlgorithmCustomization
    Friend NotInheritable Class Program

        Private Sub New()
        End Sub

        ''' <summary>
        ''' The main entry point for the application.
        ''' </summary>
        <STAThread> _
        Shared Sub Main()
            Application.EnableVisualStyles()
            Application.SetCompatibleTextRenderingDefault(False)
            Application.Run(New Form1())
        End Sub
    End Class
End Namespace

See Also

TreeMapLayoutAlgorithmBase Class

TreeMapLayoutAlgorithmBase Members

DevExpress.XtraTreeMap Namespace