private NListBoxItem CreateDetailedListBoxItem(int index) { NDockPanel dock = new NDockPanel(); dock.HorizontalSpacing = 3; dock.Padding = new NMargins(0, 2, 0, 2); // Add the image string imageName = ImageNames[index % ImageNames.Length]; NImage icon = new NImage(new NEmbeddedResourceRef(NResources.Instance, "RIMG__24x24_" + imageName + "_png")); NImageBox imageBox = new NImageBox(icon); imageBox.HorizontalPlacement = ENHorizontalPlacement.Center; imageBox.VerticalPlacement = ENVerticalPlacement.Center; NDockLayout.SetDockArea(imageBox, ENDockArea.Left); dock.Add(imageBox); // Add the title NLabel titleLabel = new NLabel("Item " + index.ToString()); titleLabel.Font = new NFont(NFontDescriptor.DefaultSansFamilyName, 10, ENFontStyle.Bold); NDockLayout.SetDockArea(titleLabel, ENDockArea.Top); dock.AddChild(titleLabel); // Add the description NLabel descriptionLabel = new NLabel("This is item " + index.ToString() + "'s description."); NDockLayout.SetDockArea(descriptionLabel, ENDockArea.Center); dock.AddChild(descriptionLabel); return(new NListBoxItem(dock)); }
/// <summary> /// /// </summary> /// <returns></returns> protected override NWidget CreateExampleContent() { m_ChartView = new NChartView(); NDockPanel dockPanel = new NDockPanel(); m_ChartView.Surface.Content = dockPanel; NLabel label = new NLabel(); label.Margins = new NMargins(10); label.Font = new NFont(NFontDescriptor.DefaultSansFamilyName, 12); label.TextFill = new NColorFill(NColor.Black); label.TextAlignment = ENContentAlignment.MiddleCenter; label.Text = "Multiple Legends"; NDockLayout.SetDockArea(label, ENDockArea.Top); dockPanel.AddChild(label); // stack panel holding content NStackPanel stackPanel = new NStackPanel(); stackPanel.UniformHeights = ENUniformSize.Max; stackPanel.FillMode = ENStackFillMode.Equal; stackPanel.FitMode = ENStackFitMode.Equal; NDockLayout.SetDockArea(stackPanel, ENDockArea.Center); dockPanel.AddChild(stackPanel); // first group of pie + legend NDockPanel firstGroupPanel = new NDockPanel(); stackPanel.AddChild(firstGroupPanel); m_PieChart1 = CreatePieChart(); m_Legend1 = CreateLegend(); m_PieChart1.Legend = m_Legend1; firstGroupPanel.AddChild(m_Legend1); firstGroupPanel.AddChild(m_PieChart1); // second group of pie + legend NDockPanel secondGroupPanel = new NDockPanel(); stackPanel.AddChild(secondGroupPanel); // setup the volume chart m_PieChart2 = CreatePieChart(); m_Legend2 = CreateLegend(); m_PieChart2.Legend = m_Legend2; secondGroupPanel.AddChild(m_Legend2); secondGroupPanel.AddChild(m_PieChart2); m_ChartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, true)); return(m_ChartView); }
private NLegend CreateLegend() { NLegend legend = new NLegend(); NDockLayout.SetDockArea(legend, ENDockArea.Center); legend.HorizontalPlacement = ENHorizontalPlacement.Right; legend.VerticalPlacement = ENVerticalPlacement.Top; return(legend); }
protected override NWidget CreateExampleControls() { NStackPanel stack = new NStackPanel(); stack.VerticalSpacing = 10; // Create the predefined tests list box NListBox testListBox = new NListBox(); testListBox.Items.Add(CreateTestListBoxItem(new NRichTextBorders())); testListBox.Items.Add(CreateTestListBoxItem(new NRichTextLists())); testListBox.Items.Add(CreateTestListBoxItem(new NRichTextTables())); testListBox.Items.Add(CreateTestListBoxItem(new NRichTextTextStyles())); testListBox.Items.Add(CreateTestListBoxItem(new NRichTextElementPositioning())); testListBox.Selection.Selected += OnTestListBoxItemSelected; // Add the list box in a group box stack.Add(new NGroupBox("Predefined text documents", testListBox)); // Create the Load from file group box NDockPanel dockPanel = new NDockPanel(); dockPanel.HorizontalSpacing = 3; dockPanel.VerticalSpacing = 3; NButton loadButton = new NButton("Load"); loadButton.Click += OnLoadButtonClick; NDockLayout.SetDockArea(loadButton, ENDockArea.Bottom); dockPanel.Add(loadButton); m_FileNameTextBox = new NTextBox(); m_FileNameTextBox.VerticalPlacement = ENVerticalPlacement.Center; NDockLayout.SetDockArea(m_FileNameTextBox, ENDockArea.Center); dockPanel.Add(m_FileNameTextBox); NButton browseButton = new NButton("..."); browseButton.Click += OnBrowseButtonClick; NDockLayout.SetDockArea(browseButton, ENDockArea.Right); dockPanel.Add(browseButton); stack.Add(new NGroupBox("Load from file", dockPanel)); m_ElapsedTimeLabel = new NLabel(); stack.Add(m_ElapsedTimeLabel); // Select the initial test testListBox.Selection.SingleSelect(testListBox.Items[0]); return(stack); }
void OnLegendDockAreaComboBoxSelectedIndexChanged(NValueChangeEventArgs arg) { ENDockArea dockArea = (ENDockArea)((NComboBox)arg.TargetNode).SelectedIndex; NLegend legend = m_ChartView.Surface.Legends[0]; // adjust the legend layout / position accordingly to the dock area switch (dockArea) { case ENDockArea.Left: legend.ExpandMode = ENLegendExpandMode.RowsOnly; legend.VerticalPlacement = ENVerticalPlacement.Center; break; case ENDockArea.Top: legend.ExpandMode = ENLegendExpandMode.ColsOnly; legend.HorizontalPlacement = ENHorizontalPlacement.Center; break; case ENDockArea.Right: legend.ExpandMode = ENLegendExpandMode.RowsOnly; legend.VerticalPlacement = ENVerticalPlacement.Center; break; case ENDockArea.Bottom: legend.ExpandMode = ENLegendExpandMode.ColsOnly; legend.HorizontalPlacement = ENHorizontalPlacement.Center; break; case ENDockArea.Center: legend.ExpandMode = ENLegendExpandMode.RowsOnly; legend.HorizontalPlacement = ENHorizontalPlacement.Center; legend.VerticalPlacement = ENVerticalPlacement.Center; break; } NDockLayout.SetDockArea(legend, dockArea); }
/// <summary> /// /// </summary> /// <returns></returns> protected override NWidget CreateExampleContent() { m_ChartView = new NChartView(); NDockPanel dockPanel = new NDockPanel(); m_ChartView.Surface.Content = dockPanel; NLabel label = new NLabel(); label.Margins = new NMargins(10); label.Font = new NFont(NFontDescriptor.DefaultSansFamilyName, 12); label.TextFill = new NColorFill(NColor.Black); label.TextAlignment = ENContentAlignment.MiddleCenter; label.Text = "Aligning Chart Areas"; NDockLayout.SetDockArea(label, ENDockArea.Top); dockPanel.AddChild(label); // configure title NStackPanel stackPanel = new NStackPanel(); stackPanel.UniformHeights = ENUniformSize.Max; stackPanel.FillMode = ENStackFillMode.Equal; stackPanel.FitMode = ENStackFitMode.Equal; NDockLayout.SetDockArea(stackPanel, ENDockArea.Center); dockPanel.AddChild(stackPanel); NCartesianChart stockPriceChart = new NCartesianChart(); stockPriceChart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XValueTimelineYLinear); stockPriceChart.FitMode = ENCartesianChartFitMode.Stretch; stockPriceChart.Margins = new NMargins(10, 0, 10, 10); ConfigureInteractivity(stockPriceChart); stackPanel.AddChild(stockPriceChart); // setup the stock series m_StockPrice = new NStockSeries(); stockPriceChart.Series.Add(m_StockPrice); m_StockPrice.Name = "Price"; m_StockPrice.LegendView.Mode = ENSeriesLegendMode.None; m_StockPrice.DataLabelStyle = new NDataLabelStyle(false); m_StockPrice.CandleShape = ENCandleShape.Stick; m_StockPrice.UpStroke = new NStroke(1, NColor.RoyalBlue); m_StockPrice.CandleWidth = 10; m_StockPrice.UseXValues = true; m_StockPrice.InflateMargins = false; // setup the volume chart NCartesianChart stockVolumeChart = new NCartesianChart(); stockVolumeChart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XValueTimelineYLinear); stockVolumeChart.FitMode = ENCartesianChartFitMode.Stretch; stockVolumeChart.Margins = new NMargins(10, 0, 10, 10); ConfigureInteractivity(stockVolumeChart); stackPanel.AddChild(stockVolumeChart); // setup the stock volume series // setup the volume series m_StockVolume = new NAreaSeries(); stockVolumeChart.Series.Add(m_StockVolume); m_StockVolume.Name = "Volume"; m_StockVolume.DataLabelStyle = new NDataLabelStyle(false); m_StockVolume.LegendView.Mode = ENSeriesLegendMode.None; m_StockVolume.Fill = new NColorFill(NColor.YellowGreen); m_StockVolume.UseXValues = true; // make sure all axes are synchronized stockPriceChart.Axes[ENCartesianAxis.PrimaryX].SynchronizedAxes = new NDomArray <NNodeRef>(new NNodeRef(stockVolumeChart.Axes[ENCartesianAxis.PrimaryX])); stockVolumeChart.Axes[ENCartesianAxis.PrimaryX].SynchronizedAxes = new NDomArray <NNodeRef>(new NNodeRef(stockPriceChart.Axes[ENCartesianAxis.PrimaryX])); GenerateData(); // align the left parts of those charts NAlignmentGuidelineCollection guideLines = new NAlignmentGuidelineCollection(); NAlignmentGuideline guideLine = new NAlignmentGuideline(); guideLine.ContentSide = ENContentSide.Left; guideLine.Targets = new NDomArray <NNodeRef>(new NNodeRef[] { new NNodeRef(stockPriceChart), new NNodeRef(stockVolumeChart) }); guideLines.Add(guideLine); m_ChartView.Surface.AlignmentGuidelines = guideLines; m_ChartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, false)); return(m_ChartView); }
protected override NWidget CreateExampleContent() { NMemoryDataTable dataTable = new NMemoryDataTable( new NFieldInfo("Company", typeof(String)), new NFieldInfo("RegionSales", typeof(Double[]))); Random rnd = new Random(); for (int i = 0; i < 1000; i++) { Double[] arr = new Double[10]; for (int j = 0; j < 10; j++) { arr[j] = rnd.Next(100); } dataTable.AddRow(NDummyDataSource.RandomCompanyName(), arr); } // create a view and get its grid NTableGridView view = new NTableGridView(); NTableGrid grid = view.Grid; grid.AutoCreateColumn += delegate(NAutoCreateColumnEventArgs arg) { if (arg.DataColumn.FieldName == "RegionSales") { NCustomColumnFormat pieColumnFormat = new NCustomColumnFormat(); pieColumnFormat.FormatDefaultDataCellDelegate = delegate(NDataCell theDataCell) { NWidget widget = new NWidget(); widget.PreferredSize = new NSize(400, 300); }; pieColumnFormat.CreateValueDataCellViewDelegate = delegate(NDataCell theDataCell, object value) { double[] values = (double[])value; NChartView chartView = new NChartView(); chartView.PreferredSize = new NSize(300, 60); NCartesianChart cartesianChart = new NCartesianChart(); NDockLayout.SetDockArea(cartesianChart, ENDockArea.Center); chartView.Surface.Content = cartesianChart; cartesianChart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear); cartesianChart.Legend = null; cartesianChart.Axes[ENCartesianAxis.PrimaryX].Visible = false; NCartesianAxis yAxis = cartesianChart.Axes[ENCartesianAxis.PrimaryY]; NValueScaleLabelStyle labelStyle = new NValueScaleLabelStyle(); labelStyle.TextStyle.Font = new NFont("Arimo", 8); ((NLinearScale)yAxis.Scale).Labels.Style = labelStyle; NBarSeries barSeries = new NBarSeries(); barSeries.DataLabelStyle = new NDataLabelStyle(false); barSeries.InflateMargins = false; cartesianChart.Series.Add(barSeries); int count = values.Length; for (int i = 0; i < count; i++) { barSeries.DataPoints.Add(new NBarDataPoint(values[i])); } return(chartView); }; arg.DataColumn.Format = pieColumnFormat; } }; grid.DataSource = new NDataSource(dataTable); return(view); }