예제 #1
0
        public Form1()
        {
            InitializeComponent();
            this.MetroColor = Color.White;
            this.BackColor  = Color.White;

            PopulationViewModel data = new PopulationViewModel();

            TreeMap1.ItemsSource                  = data.PopulationDetails;
            TreeMap1.WeightValuePath              = "Population";
            TreeMap1.ColorValuePath               = "Growth";
            TreeMap1.LegendSetting.LegendType     = LegendTypes.Ellipse;
            TreeMap1.LegendSetting.LegendGap      = 150;
            TreeMap1.LegendSetting.ShowLegend     = true;
            TreeMap1.LegendSetting.LegendPosition = LegendPositions.Top;
            TreeMap1.Dock = DockStyle.Fill;
            //TreeMap1.Margin = new System.Windows.Forms.Padding(10,10,10,10);
            TreeMap1.ItemsLayoutMode = Syncfusion.Windows.Forms.TreeMap.ItemsLayoutModes.SliceAndDiceAuto;
            ToolTipInfo itemInfoHead = new ToolTipInfo();

            itemInfoHead.ToolTipHeaderPattern  = "<b>{Label}</b>";
            itemInfoHead.ToolTipContentPattern = "Growth \t  :  {Growth} % ";
            TreeMap1.HeaderToolTipInfo         = itemInfoHead;
            ToolTipInfo itemInfo = new ToolTipInfo();

            itemInfo.ToolTipHeaderPattern  = "<b>{Country}</b>";
            itemInfo.ToolTipContentPattern = "Growth \t      :  {Growth} %  \nPopulation   :  {StrPopulation}  ";
            TreeMap1.ItemToolTipInfo       = itemInfo;

            #region ColorMapping

            #region Range ColorMapping

            //RangeBrushColorMapping
            RangeBrushColorMapping rangeBrushColorMapping = new RangeBrushColorMapping();
            rangeBrushColorMapping.Brushes.Add(new RangeBrush()
            {
                Color = System.Drawing.ColorTranslator.FromHtml("#77D8D8"), From = 0, To = 1, LegendLabel = "1% Growth"
            });
            rangeBrushColorMapping.Brushes.Add(new RangeBrush()
            {
                Color = System.Drawing.ColorTranslator.FromHtml("#AED960"), From = 0, To = 2, LegendLabel = "2% Growth"
            });
            rangeBrushColorMapping.Brushes.Add(new RangeBrush()
            {
                Color = System.Drawing.ColorTranslator.FromHtml("#FFAF51"), From = 0, To = 3, LegendLabel = "3% Growth"
            });
            rangeBrushColorMapping.Brushes.Add(new RangeBrush()
            {
                Color = System.Drawing.ColorTranslator.FromHtml("#F3D240"), From = 0, To = 4, LegendLabel = "4% Growth"
            });
            TreeMap1.LeafColorMapping = rangeBrushColorMapping;

            #endregion

            #endregion

            #region Level

            //Level

            TreeMapFlatLevel treeMapFlatLevel1 = new TreeMapFlatLevel();
            treeMapFlatLevel1.GroupPath = "Continent";
            TreeMap1.Levels.Add(treeMapFlatLevel1);

            TreeMap1.LeafItemSettings.LabelPath = "Country";
            TreeMap1.LeafItemDrawing           += TreeMap1_LeafItemDrawing;
            #endregion

            LegendPositionComboBox.Items.Add("Left");
            LegendPositionComboBox.Items.Add("Right");
            LegendPositionComboBox.Items.Add("Top");
            LegendPositionComboBox.Items.Add("Bottom");
            LegendPositionComboBox.SelectedIndex         = 2;
            LegendPositionComboBox.KeyDown              += LegendPositionComboBox_KeyDown;
            LegendPositionComboBox.Dock                  = DockStyle.Top;
            LegendPositionComboBox.Font                  = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            LegendPositionComboBox.SelectedValueChanged += comboBox1_SelectedValueChanged;
            userOptionsGroupBox.Controls.Add(LegendPositionComboBox);

            legendpositionLabel.Text   = "Legend Position :";
            legendpositionLabel.Height = (int)DpiAware.LogicalToDeviceUnits(legendpositionLabel.Height);
            legendpositionLabel.Dock   = DockStyle.Top;
            legendpositionLabel.Font   = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            userOptionsGroupBox.Controls.Add(legendpositionLabel);

            splitter.Dock   = DockStyle.Top;
            splitter.Height = 40;
            userOptionsGroupBox.Controls.Add(splitter);

            layoutModeComboBox.Items.Add("SliceAndDiceAuto");
            layoutModeComboBox.Items.Add("SliceAndDiceHorizontal");
            layoutModeComboBox.Items.Add("SliceAndDiceVertical");
            layoutModeComboBox.Items.Add("Squarified");
            layoutModeComboBox.SelectedIndex         = 0;
            layoutModeComboBox.KeyDown              += layoutModeComboBox_KeyDown;
            layoutModeComboBox.Dock                  = DockStyle.Top;
            layoutModeComboBox.Font                  = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            layoutModeComboBox.SelectedValueChanged += layoutModeComboBox_SelectedValueChanged;
            userOptionsGroupBox.Controls.Add(layoutModeComboBox);

            layoutModeLabel.Text   = "TreeMap Layout :";
            layoutModeLabel.Height = (int)DpiAware.LogicalToDeviceUnits(layoutModeLabel.Height);
            layoutModeLabel.Font   = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            layoutModeLabel.Dock   = DockStyle.Top;
            userOptionsGroupBox.Controls.Add(layoutModeLabel);
            userOptionsGroupBox.Dock  = DockStyle.Right;
            userOptionsGroupBox.Width = (int)DpiAware.LogicalToDeviceUnits(userOptionsGroupBox.Width);

            treeMapContainer.Name = "Population Growth FY2012";
            treeMapPanel.Dock     = DockStyle.Fill;
            treeMapPanel.Controls.Add(TreeMap1);
            treeMapPanel.Controls.Add(userOptionsGroupBox);
            this.Controls.Add(treeMapPanel);

            sampleHeader.Text      = "This sample represents various types of layout available in the TreeMap for arrangement of items";
            sampleHeader.Font      = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            sampleHeader.Location  = new Point(10, 10);
            sampleHeader.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(17)))), ((int)(((byte)(150)))), ((int)(((byte)(205)))));
            sampleHeader.ForeColor = System.Drawing.Color.White;
            sampleHeader.Location  = new System.Drawing.Point(0, 0);
            sampleHeader.Size      = new System.Drawing.Size(284, (int)DpiAware.LogicalToDeviceUnits(33));
            sampleHeader.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            sampleHeader.Dock      = DockStyle.Top;
            this.Controls.Add(sampleHeader);
        }
예제 #2
0
        public Form1()
        {
            InitializeComponent();
            this.BackColor = Color.White;

            PopulationViewModel data = new PopulationViewModel();

            TreeMap1.ItemsSource              = data.PopulationDetails;
            TreeMap1.WeightValuePath          = "Population";
            TreeMap1.ColorValuePath           = "Growth"; //"Population";
            TreeMap1.LegendSetting.LegendType = LegendTypes.Ellipse;
            TreeMap1.LegendSetting.LegendGap  = 130;
            TreeMap1.LegendSetting.ShowLegend = true;
            //TreeMap1.IsLegendVisible = false;
            TreeMap1.LegendSetting.LegendPosition = LegendPositions.Top;
            TreeMap1.Dock            = DockStyle.Fill;
            TreeMap1.ItemsLayoutMode = Syncfusion.Windows.Forms.TreeMap.ItemsLayoutModes.SliceAndDiceAuto;
            ToolTipInfo itemInfoHead = new ToolTipInfo();

            itemInfoHead.ToolTipHeaderPattern  = "<b>{Label}</b>";
            itemInfoHead.ToolTipContentPattern = "Growth \t  :  {Growth} % ";
            TreeMap1.HeaderToolTipInfo         = itemInfoHead;
            ToolTipInfo itemInfo = new ToolTipInfo();

            itemInfo.ToolTipHeaderPattern  = "<b>{Country}</b>";
            itemInfo.ToolTipContentPattern = "Growth \t      :  {Growth} %  \nPopulation   :  {StrPopulation}  ";
            TreeMap1.ItemToolTipInfo       = itemInfo;
            #region ColorMapping

            #region UniColorMapping

            uniColorMapping.Color = Color.MediumSlateBlue;

            #endregion


            #region RangeColorMapping

            rangeBrushColorMapping.Brushes.Add(new RangeBrush()
            {
                Color = System.Drawing.ColorTranslator.FromHtml("#77D8D8"), From = 0, To = 1, LegendLabel = "1% Growth"
            });
            rangeBrushColorMapping.Brushes.Add(new RangeBrush()
            {
                Color = System.Drawing.ColorTranslator.FromHtml("#AED960"), From = 0, To = 2, LegendLabel = "2% Growth"
            });
            rangeBrushColorMapping.Brushes.Add(new RangeBrush()
            {
                Color = System.Drawing.ColorTranslator.FromHtml("#FFAF51"), From = 0, To = 3, LegendLabel = "3% Growth"
            });
            rangeBrushColorMapping.Brushes.Add(new RangeBrush()
            {
                Color = System.Drawing.ColorTranslator.FromHtml("#F3D240"), From = 0, To = 4, LegendLabel = "4% Growth"
            });

            #endregion


            #region DesaturationColorMapping

            desaturationColorMapping.Color        = Color.OrangeRed;
            desaturationColorMapping.From         = 220;
            desaturationColorMapping.To           = 0;
            desaturationColorMapping.RangeMinimum = 0;
            desaturationColorMapping.RangeMaximum = 80000;
            this.TreeMap1.LeafColorMapping        = desaturationColorMapping;

            #endregion

            #region PaletteColorMapping

            paletteColorMapping.Colors = new List <Brush>()
            {
                new SolidBrush(Color.MediumSeaGreen),
                new SolidBrush(Color.PaleVioletRed),
                new SolidBrush(Color.MediumSlateBlue),
            };

            #endregion


            #endregion

            TreeMap1.LeafItemSettings.LabelPath = "Country";
            splitter.Dock   = DockStyle.Top;
            splitter.Height = 40;
            userOptionsGroupBox.Controls.Add(splitter);

            layoutModeComboBox.Items.Add("UniColorMapping");
            layoutModeComboBox.Items.Add("RangeColorMapping");
            layoutModeComboBox.Items.Add("DesaturationColorMapping");
            layoutModeComboBox.Items.Add("PaletteColorMapping");
            layoutModeComboBox.SelectedIndex         = 2;
            layoutModeComboBox.KeyDown              += layoutModeComboBox_KeyDown;
            layoutModeComboBox.Dock                  = DockStyle.Top;
            layoutModeComboBox.SelectedValueChanged += layoutModeComboBox_SelectedValueChanged;
            userOptionsGroupBox.Controls.Add(layoutModeComboBox);

            layoutModeLabel.Text    = "Color Mapping:";
            layoutModeLabel.Height  = (int)DpiAware.LogicalToDeviceUnits(layoutModeLabel.Height);
            layoutModeLabel.Dock    = DockStyle.Top;
            layoutModeLabel.Font    = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            layoutModeComboBox.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            userOptionsGroupBox.Controls.Add(layoutModeLabel);
            userOptionsGroupBox.Padding = new System.Windows.Forms.Padding(20, 20, 20, 30);
            userOptionsGroupBox.Dock    = DockStyle.Right;
            userOptionsGroupBox.Width   = (int)DpiAware.LogicalToDeviceUnits(userOptionsGroupBox.Width);

            treeMapPanel.Dock = DockStyle.Fill;
            treeMapPanel.Controls.Add(TreeMap1);
            treeMapPanel.Controls.Add(userOptionsGroupBox);
            this.Controls.Add(treeMapPanel);

            sampleHeader.Text      = "This sample demonstrates the various types of  Color Mapping available in TreeMap.";
            sampleHeader.Font      = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            sampleHeader.Location  = new Point(10, 10);
            sampleHeader.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(17)))), ((int)(((byte)(150)))), ((int)(((byte)(205)))));
            sampleHeader.ForeColor = System.Drawing.Color.White;
            sampleHeader.Location  = new System.Drawing.Point(0, 0);
            sampleHeader.Size      = new System.Drawing.Size(284, (int)DpiAware.LogicalToDeviceUnits(33));
            sampleHeader.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            sampleHeader.Dock      = DockStyle.Top;
            this.Controls.Add(sampleHeader);
        }