public void AddStyleSelector(StyleSelectorUserControl styleSelector) { this.StyleSelectors.Add(styleSelector); styleSelector.StyleUpdated += StyleSelectorUserControl_StyleUpdated; styleSelector.Location = new Point(styleSelector.Margin.Left, styleSelector.Margin.Top + CompleteHeight); CompleteHeight += styleSelector.Height; Panel.Controls.Add(styleSelector); }
private void AddStyleSelectors(ShapeFileFeatureLayer featureLayer) { for (int i = Panel.Controls.Count - 1; i >= 0; i--) { StyleSelectorUserControl styleSelectorUserControl = Panel.Controls[i] as StyleSelectorUserControl; if (styleSelectorUserControl != null) { Panel.Controls.Remove(styleSelectorUserControl); } } int panelHeight = customDataSelector.Height + customDataSelector.Top; List <DbfColumn> numericDbfColumns = GetNumericDbfColumns(featureLayer.QueryTools.GetColumns().OfType <DbfColumn>()); StyleSelectors.Clear(); foreach (DbfColumn column in numericDbfColumns) { StyleSelectorUserControl styleSelectorUserControl = new StyleSelectorUserControl(); styleSelectorUserControl.StyleUpdated += StyleSelectorUserControl_StyleUpdated; panelHeight += styleSelectorUserControl.Height + styleSelectorUserControl.Top; styleSelectorUserControl.Alias = column.ColumnName; styleSelectorUserControl.ColumnName = column.ColumnName; styleSelectorUserControl.LegendTitle = column.ColumnName; styleSelectorUserControl.WithinPieChart = true; StyleSelectors.Add(styleSelectorUserControl); CompleteHeight += styleSelectorUserControl.Height; Panel.Controls.Add(styleSelectorUserControl); } int height = 0; foreach (Control control in Panel.Controls.OfType <Control>()) { control.Location = new Point(control.Margin.Left, control.Margin.Top + height); height = control.Location.Y + control.Height; } if (Panel.Controls.Count >= 2) { PieChartEnabled = true; } Panel.Height = panelHeight; Height = HeaderHeight + panelHeight; }
// Here we load all the nodes on the left from xml file. private void LoadDataSelectorUserControls() { XDocument xDocument = XDocument.Load(@"../../App_Data/CategoryList.xml"); IEnumerable <XElement> elements = from category in xDocument.Element("DemographicMap").Elements("Category") select category; Collection <DataSelectorUserControl> userControls = new Collection <DataSelectorUserControl>(); foreach (var element in elements) { DataSelectorUserControl dataSelector = null; if (element.Attribute("name").Value != "Custom Data") { dataSelector = new DataSelectorUserControl(); } else { dataSelector = new CustomDataSelectorUserControl(); ((CustomDataSelectorUserControl)dataSelector).DataSelected += MainForm_CustomDataSelected; } dataSelector.Title = element.Attribute("name").Value; dataSelector.Image = new Bitmap(string.Format("{0}{1}", "../../", element.Attribute("icon").Value)); foreach (var item in element.Elements("item")) { StyleSelectorUserControl styleSelector = new StyleSelectorUserControl(); styleSelector.ColumnName = item.Element("columnName").Value; styleSelector.Alias = item.Element("alias").Value; styleSelector.LegendTitle = item.Element("legendTitle").Value; dataSelector.AddStyleSelector(styleSelector); } if (dataSelector.GetStyleSelectorCount() >= 2) { dataSelector.PieChartEnabled = true; } dataSelector.StyleUpdated += dataSelectorUserControl_StyleUpdated; dataSelector.Click += dataSelector_Click; flowLayoutPanel1.Controls.Add(dataSelector); } ((DataSelectorUserControl)(flowLayoutPanel1.Controls[0])).SetActiveStatus(true); }